changes
authorMatthias Wachs <wachs@net.in.tum.de>
Fri, 1 Apr 2011 11:40:08 +0000 (11:40 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Fri, 1 Apr 2011 11:40:08 +0000 (11:40 +0000)
src/transport/gnunet-service-transport.c
src/transport/test_transport_ats.c
src/transport/transport.h

index 927e18d61a82615894aec13a618d90e8c1926994..996720d5678094b401bfd908ad33f6b15bbe54b0 100644 (file)
@@ -5603,7 +5603,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
        return GNUNET_SYSERR;
 #else
        if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "glpk installed\n");
-
+#endif
 
        glp_prob *prob;
 
@@ -5676,6 +5676,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
                                mechanisms[c_mechs].col_index = c_mechs;
                                mechanisms[c_mechs].peer = &peers[c_peers];
                                mechanisms[c_mechs].next = NULL;
+                               mechanisms[c_mechs].plugin = r_next->plugin;
 
                                GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]);
                                c_mechs++;
@@ -6058,22 +6059,27 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
                default:
                        break;
        }
-
-       char * debug_solution = NULL;
-       char * old = NULL;
-       for (c=1; c<= (2*c_mechs) +3; c++ )
+#endif
+       int check;
+       double bw;
+       struct ATS_mechanism *t = NULL;
+       for (c=1; c<= (c_peers); c++ )
        {
-               old = debug_solution;
-               GNUNET_asprintf(&debug_solution, "%s %s = %g;", (debug_solution!=NULL) ? debug_solution : "", glp_get_col_name(prob,c), glp_get_col_prim(prob, c));
-               if (old!=NULL) GNUNET_free(old);
+               check = GNUNET_NO;
+               t = peers[c].m_head;
+               while (t!=NULL)
+               {
+                       bw = glp_get_col_prim(prob, t->col_index);
+                       GNUNET_assert (1);
+                       if (bw != 0)
+                       {
+                               GNUNET_assert (check != GNUNET_YES);
+                               check = GNUNET_YES;
+                               if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[%i][%i] `%s' %s %s %f\n", c, t->col_index, GNUNET_h2s(&peers[c].peer.hashPubKey), t->plugin->short_name, glp_get_col_name(prob,t->col_index), bw);
+                       }
+                       t = t->next;
+               }
        }
-       old = debug_solution;
-       GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution,  glp_get_obj_val(prob));
-       if (old!=NULL) GNUNET_free(old);
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s \n",debug_solution);
-       GNUNET_free(debug_solution);
-#endif
-
        res->c_mechs = c_mechs;
        res->c_peers = c_peers;
        res->solution = solution;
@@ -6091,7 +6097,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
        GNUNET_free(peers);
 
        return c_mechs;
-#endif
+
 }
 
 void ats_calculate_bandwidth_distribution ()
index d4189d063aaa131d8a931d90eb05691d7fbafc72..fca54ed5265eb0882a8b7ad9ce67bacadeb80021 100644 (file)
@@ -46,7 +46,6 @@ static struct GNUNET_TESTING_PeerGroup *pg;
 
 static  GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
 static  GNUNET_SCHEDULER_TaskIdentifier stats_task;
-
 struct GNUNET_TESTING_Daemon * master_deamon;
 
 struct GNUNET_STATISTICS_Handle * stats;
@@ -65,6 +64,11 @@ static int r_index;
 static int peers;
 static struct TEST_result results[MEASUREMENTS];
 
+struct GNUNET_STATISTICS_GetHandle * s_solution;
+struct GNUNET_STATISTICS_GetHandle * s_time;
+struct GNUNET_STATISTICS_GetHandle * s_peers;
+struct GNUNET_STATISTICS_GetHandle * s_mechs;
+struct GNUNET_STATISTICS_GetHandle * s_duration;
 
 /**
  * Check whether peers successfully shut down.
@@ -105,6 +109,33 @@ static void shutdown_peers()
                stats_task = GNUNET_SCHEDULER_NO_TASK;
        }
 
+       if (s_time != NULL)
+       {
+               GNUNET_STATISTICS_get_cancel(s_time);
+               s_time = NULL;
+       }
+       if (s_peers != NULL)
+       {
+               GNUNET_STATISTICS_get_cancel(s_peers);
+               s_peers = NULL;
+       }
+       if (s_mechs != NULL)
+       {
+               GNUNET_STATISTICS_get_cancel(s_mechs);
+               s_mechs = NULL;
+       }
+       if (s_solution != NULL)
+       {
+               GNUNET_STATISTICS_get_cancel(s_solution);
+               s_solution = NULL;
+       }
+       if (s_duration != NULL)
+       {
+               GNUNET_STATISTICS_get_cancel(s_duration);
+               s_duration = NULL;
+       }
+
+
     GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
 }
 
@@ -120,6 +151,8 @@ static void evaluate_measurements()
                output = temp;
        }
        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"%s\n",output);
+
+
        shutdown_peers();
 }
 
@@ -129,6 +162,30 @@ int stats_cb (void *cls,
                           uint64_t value,
                           int is_persistent)
 {
+       if (0 == strcmp (name,"ATS solution"))
+       {
+               s_solution = NULL;
+       }
+
+       if (0 == strcmp (name,"ATS peers"))
+       {
+               s_peers = NULL;
+       }
+
+       if (0 == strcmp (name,"ATS mechanisms"))
+       {
+               s_mechs = NULL;
+       }
+
+       if (0 == strcmp (name,"ATS duration"))
+       {
+               s_duration = NULL;
+       }
+       if (0 == strcmp (name,"ATS timestamp"))
+       {
+               s_time = NULL;
+       }
+
     if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1))
     {
                measurement_started = GNUNET_YES;
@@ -147,6 +204,11 @@ int stats_cb (void *cls,
                                r_index++;
                                if (r_index >= MEASUREMENTS)
                                {
+                                       if (stats_task != GNUNET_SCHEDULER_NO_TASK)
+                                       {
+                                               GNUNET_SCHEDULER_cancel(stats_task);
+                                               stats_task = GNUNET_SCHEDULER_NO_TASK;
+                                       }
                                        evaluate_measurements();
                                        return GNUNET_NO;
                                }
@@ -195,11 +257,11 @@ stats_get_task (void *cls,
        if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
            return;
 
-       GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL);
-       GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL);
-       GNUNET_assert (NULL != GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL));
-       GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL);
-       GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL);
+       s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL);
+       s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL);
+       s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL);
+       s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL);
+       s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL);
 
        stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL);
 }
index e00b8d92aba579e501083474b52a59bc146b1840..f3e3b1c2c793eefec249a757c0743f3d9223b0d8 100644 (file)
@@ -31,8 +31,8 @@
 #include "gnunet_transport_service.h"
 
 /* Minimum time between to calculations*/
-#define ATS_MIN_INTERVAL  GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200)
-#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250)
+#define ATS_MIN_INTERVAL  GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1)
+#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2)
 #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
 #define ATS_MAX_ITERATIONS INT_MAX