gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r25762 - gnunet/src/ats
Date: Fri, 11 Jan 2013 17:32:10 +0100

Author: wachs
Date: 2013-01-11 17:32:10 +0100 (Fri, 11 Jan 2013)
New Revision: 25762

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
   gnunet/src/ats/test_ats_simplistic_change_preference.c
Log:
changes


Modified: gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2013-01-11 
15:32:02 UTC (rev 25761)
+++ gnunet/src/ats/gnunet-service-ats_addresses_simplistic.c    2013-01-11 
16:32:10 UTC (rev 25762)
@@ -447,29 +447,40 @@
   total_prefs = 0.0;
   for (cur = net->head; NULL != cur; cur = cur->next)
   {
-     t = GNUNET_CONTAINER_multihashmap_get (s->prefs, 
&cur->addr->peer.hashPubKey);
-     if (NULL == t)
-       total_prefs += DEFAULT_PREFERENCE;
-     else
-       total_prefs += (*t);
+      if (GNUNET_YES == cur->addr->active)
+      {
+        t = GNUNET_CONTAINER_multihashmap_get (s->prefs, 
&cur->addr->peer.hashPubKey);
+        if (NULL == t)
+          total_prefs += DEFAULT_PREFERENCE;
+        else
+          total_prefs += (*t);
+      }
   }
   for (cur = net->head; NULL != cur; cur = cur->next)
   {
-     cur_pref = 0.0;
-     t = GNUNET_CONTAINER_multihashmap_get (s->prefs, 
&cur->addr->peer.hashPubKey);
-     if (NULL == t)
-       cur_pref = DEFAULT_PREFERENCE;
+     if (GNUNET_YES == cur->addr->active)
+     {
+       cur_pref = 0.0;
+       t = GNUNET_CONTAINER_multihashmap_get (s->prefs, 
&cur->addr->peer.hashPubKey);
+       if (NULL == t)
+         cur_pref = DEFAULT_PREFERENCE;
+       else
+         cur_pref = (*t);
+       quota_in = min_bw + (cur_pref / total_prefs) * (float) 
remaining_quota_in;
+       quota_out = min_bw + (cur_pref / total_prefs) * (float) 
remaining_quota_out;
+
+       LOG (GNUNET_ERROR_TYPE_DEBUG,
+                   "New quota for peer `%s' with preference (cur/total) 
%.3f/%.3f (in/out): %llu /%llu\n",
+                   GNUNET_i2s (&cur->addr->peer),
+                   cur_pref, total_prefs,
+                   quota_in, quota_out);
+     }
      else
-       cur_pref = (*t);
-     quota_in = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_in;
-     quota_out = min_bw + (cur_pref / total_prefs) * (float) 
remaining_quota_out;
-     LOG (GNUNET_ERROR_TYPE_DEBUG,
-                 "New quota for peer `%s' with preference (cur/total) 
%.3f/%.3f (in/out): %llu /%llu\n",
-                 GNUNET_i2s (&cur->addr->peer),
-                 cur_pref,
-                 total_prefs,
-                 quota_in,
-                 quota_out);
+     {
+       quota_in = 0;
+       quota_out = 0;
+     }
+
      quota_in_used += quota_in;
      quota_out_used += quota_out;
      /* Prevent overflow due to rounding errors */
@@ -496,12 +507,12 @@
                           quota_out_used);
   if (quota_out_used > quota_out)
     LOG (GNUNET_ERROR_TYPE_WARNING,
-                            "DEBUG! Total inbount bandwidth assigned is larget 
than allowed  %llu /%llu\n",
+                            "DEBUG! Total inbound bandwidth assigned is larget 
than allowed  %llu /%llu\n",
                             quota_out_used,
                             quota_out); /* FIXME: Can happen atm, we have some 
rounding error */
   if (quota_in_used > quota_in)
     LOG (GNUNET_ERROR_TYPE_WARNING,
-                            "DEBUG! Total inbount bandwidth assigned is larget 
than allowed  %llu /%llu\n",
+                            "DEBUG! Total inbound bandwidth assigned is larget 
than allowed  %llu /%llu\n",
                             quota_in_used,
                             quota_in); /* FIXME: Can happen atm, we have some 
rounding error */
 }

Modified: gnunet/src/ats/test_ats_simplistic_change_preference.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_change_preference.c      2013-01-11 
15:32:02 UTC (rev 25761)
+++ gnunet/src/ats/test_ats_simplistic_change_preference.c      2013-01-11 
16:32:10 UTC (rev 25762)
@@ -146,20 +146,23 @@
   {
     if (GNUNET_OK == compare_addresses (address, session, 
&test_hello_address[0], test_session[0]))
     {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct 
address `%s'\n",
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct 
address `%s'\n",
+                    stage,
                     GNUNET_i2s (&address->peer));
         ret = 0;
     }
     else
     {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid 
address `%s'\n",
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid 
address `%s'\n",
+            stage,
                     GNUNET_i2s (&address->peer));
         ret = 1;
     }
 
     if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, 
test_ats_count))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect 
ats info \n");
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect 
ats info \n",
+          stage);
       ret = 1;
     }
 
@@ -193,7 +196,67 @@
     stage ++;
 
     GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
+    GNUNET_ATS_suggest_address (sched_ats, &p[1].id);
+    return;
+  }
+  if (1 == stage)
+  {
+    if (GNUNET_OK == compare_addresses (address, session, 
&test_hello_address[1], test_session[1]))
+    {
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct 
address `%s'\n",
+                    stage,
+                    GNUNET_i2s (&address->peer));
+        ret = 0;
+    }
+    else
+    {
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid 
address `%s'\n",
+                    stage,
+                    GNUNET_i2s (&address->peer));
+        ret = 1;
+    }
+
+    if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, 
test_ats_count))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect 
ats info \n",
+          stage);
+      ret = 1;
+    }
+
+    if (bw_in > wan_quota_in)
+    {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u 
bigger than allowed quota %llu \n",
+            bw_in, wan_quota_in);
+        ret = 1;
+    }
+    else
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, 
allowed quota %llu \n",
+          bw_in, wan_quota_in);
+
+    if (bw_out > wan_quota_out)
+    {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u 
bigger than allowed quota %llu \n",
+            bw_out, wan_quota_out);
+        ret = 1;
+    }
+    else
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, 
allowed quota %llu \n",
+          bw_out, wan_quota_out);
+
+    if (1 == ret)
+    {
+      GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
+      GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
+      GNUNET_SCHEDULER_add_now (&end, NULL);
+      return;
+    }
+
+    stage ++;
+
+    GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
+    GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id);
     GNUNET_SCHEDULER_add_now (&end, NULL);
+
     return;
   }
 }




reply via email to

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