gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25847 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r25847 - gnunet/src/ats
Date: Mon, 21 Jan 2013 17:15:23 +0100

Author: wachs
Date: 2013-01-21 17:15:23 +0100 (Mon, 21 Jan 2013)
New Revision: 25847

Modified:
   gnunet/src/ats/test_ats_simplistic_pref_aging.c
Log:
improving test


Modified: gnunet/src/ats/test_ats_simplistic_pref_aging.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_pref_aging.c     2013-01-21 15:50:39 UTC 
(rev 25846)
+++ gnunet/src/ats/test_ats_simplistic_pref_aging.c     2013-01-21 16:15:23 UTC 
(rev 25847)
@@ -144,16 +144,105 @@
                     uint32_t ats_count)
 {
   static int stage = 0;
+  static int sug_p0 = GNUNET_NO;
+  static int sug_p1 = GNUNET_NO;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Callback for peer `%s': (in/out) 
%llu/%llu\n",
-               GNUNET_i2s (&address->peer),
-               ntohl (bandwidth_in.value__),
-               ntohl (bandwidth_out.value__));
+  if (0 == stage)
+  {
+               /* Callback for initial suggestion */
+               if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
+               {
+                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: 
Callback for peer `%s': (in/out) %llu/%llu\n",
+                                               stage,
+                                               GNUNET_i2s (&address->peer),
+                                               ntohl (bandwidth_in.value__),
+                                               ntohl (bandwidth_out.value__));
+                               sug_p0 = GNUNET_YES;
+               }
+               if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
+               {
+                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: 
Callback for peer `%s': (in/out) %llu/%llu\n",
+                                               stage,
+                                               GNUNET_i2s (&address->peer),
+                                               ntohl (bandwidth_in.value__),
+                                               ntohl (bandwidth_out.value__));
+                               sug_p1 = GNUNET_YES;
+               }
+               if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
+               {
+                 /* Changing preference for peer 0 */
+                       stage ++;
+                       GNUNET_ATS_change_preference (perf_ats, &p[0].id, 
GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
+                               sug_p0 = GNUNET_NO;
+                               sug_p1 = GNUNET_NO;
+                       return;
+               }
 
+  }
+  if (1 == stage)
+  {
+               /* Callback due to preference change */
+               if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
+               {
+                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: 
Callback for peer `%s': (in/out) %llu/%llu\n",
+                                               stage,
+                                               GNUNET_i2s (&address->peer),
+                                               ntohl (bandwidth_in.value__),
+                                               ntohl (bandwidth_out.value__));
+                               sug_p0 = GNUNET_YES;
+               }
+               if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
+               {
+                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: 
Callback for peer `%s': (in/out) %llu/%llu\n",
+                                               stage,
+                                               GNUNET_i2s (&address->peer),
+                                               ntohl (bandwidth_in.value__),
+                                               ntohl (bandwidth_out.value__));
+                               sug_p1 = GNUNET_YES;
+               }
+               if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
+               {
+                 /* Changing preference for peer 0 */
+                       stage ++;
+                               sug_p0 = GNUNET_NO;
+                               sug_p1 = GNUNET_NO;
+                       return;
+               }
+  }
+  if (2 == stage)
+  {
+               /* Callback due to preference aging */
+               if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
+               {
+                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: 
Callback for peer `%s': (in/out) %llu/%llu\n",
+                                               stage,
+                                               GNUNET_i2s (&address->peer),
+                                               ntohl (bandwidth_in.value__),
+                                               ntohl (bandwidth_out.value__));
+                               sug_p0 = GNUNET_YES;
+               }
+               if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
+               {
+                               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: 
Callback for peer `%s': (in/out) %llu/%llu\n",
+                                               stage,
+                                               GNUNET_i2s (&address->peer),
+                                               ntohl (bandwidth_in.value__),
+                                               ntohl (bandwidth_out.value__));
+                               sug_p1 = GNUNET_YES;
+               }
+  }
+
+
+
+
+/*
   stage ++;
   if (3 == stage)
     GNUNET_SCHEDULER_add_now (&end, NULL);
+*/
 
+
+
 }
 
 static void
@@ -274,9 +363,6 @@
   test_hello_address[1].address_length = test_addr[1].addr_len;
   GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], 
test_ats_info, test_ats_count);
 
-  GNUNET_ATS_change_preference (perf_ats, &p[1].id, 
GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
-  GNUNET_ATS_change_preference (perf_ats, &p[1].id, 
GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
-
   GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
   GNUNET_ATS_suggest_address (sched_ats, &p[1].id);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]