aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-04-01 11:40:08 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-04-01 11:40:08 +0000
commit3695f55c493a485a838b3defff6b15a63fddd987 (patch)
tree4f02c4c685fad95491bf70b5e98a869645147852
parent2c803aa73957a91e8d523b072134dff7b6c5ca73 (diff)
downloadgnunet-3695f55c493a485a838b3defff6b15a63fddd987.tar.gz
gnunet-3695f55c493a485a838b3defff6b15a63fddd987.zip
changes
-rw-r--r--src/transport/gnunet-service-transport.c38
-rw-r--r--src/transport/test_transport_ats.c74
-rw-r--r--src/transport/transport.h4
3 files changed, 92 insertions, 24 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 927e18d61..996720d56 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -5603,7 +5603,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5603 return GNUNET_SYSERR; 5603 return GNUNET_SYSERR;
5604#else 5604#else
5605 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "glpk installed\n"); 5605 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "glpk installed\n");
5606 5606#endif
5607 5607
5608 glp_prob *prob; 5608 glp_prob *prob;
5609 5609
@@ -5676,6 +5676,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
5676 mechanisms[c_mechs].col_index = c_mechs; 5676 mechanisms[c_mechs].col_index = c_mechs;
5677 mechanisms[c_mechs].peer = &peers[c_peers]; 5677 mechanisms[c_mechs].peer = &peers[c_peers];
5678 mechanisms[c_mechs].next = NULL; 5678 mechanisms[c_mechs].next = NULL;
5679 mechanisms[c_mechs].plugin = r_next->plugin;
5679 5680
5680 GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]); 5681 GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]);
5681 c_mechs++; 5682 c_mechs++;
@@ -6058,22 +6059,27 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6058 default: 6059 default:
6059 break; 6060 break;
6060 } 6061 }
6061 6062#endif
6062 char * debug_solution = NULL; 6063 int check;
6063 char * old = NULL; 6064 double bw;
6064 for (c=1; c<= (2*c_mechs) +3; c++ ) 6065 struct ATS_mechanism *t = NULL;
6066 for (c=1; c<= (c_peers); c++ )
6065 { 6067 {
6066 old = debug_solution; 6068 check = GNUNET_NO;
6067 GNUNET_asprintf(&debug_solution, "%s %s = %g;", (debug_solution!=NULL) ? debug_solution : "", glp_get_col_name(prob,c), glp_get_col_prim(prob, c)); 6069 t = peers[c].m_head;
6068 if (old!=NULL) GNUNET_free(old); 6070 while (t!=NULL)
6071 {
6072 bw = glp_get_col_prim(prob, t->col_index);
6073 GNUNET_assert (1);
6074 if (bw != 0)
6075 {
6076 GNUNET_assert (check != GNUNET_YES);
6077 check = GNUNET_YES;
6078 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);
6079 }
6080 t = t->next;
6081 }
6069 } 6082 }
6070 old = debug_solution;
6071 GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(prob));
6072 if (old!=NULL) GNUNET_free(old);
6073 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s \n",debug_solution);
6074 GNUNET_free(debug_solution);
6075#endif
6076
6077 res->c_mechs = c_mechs; 6083 res->c_mechs = c_mechs;
6078 res->c_peers = c_peers; 6084 res->c_peers = c_peers;
6079 res->solution = solution; 6085 res->solution = solution;
@@ -6091,7 +6097,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub
6091 GNUNET_free(peers); 6097 GNUNET_free(peers);
6092 6098
6093 return c_mechs; 6099 return c_mechs;
6094#endif 6100
6095} 6101}
6096 6102
6097void ats_calculate_bandwidth_distribution () 6103void ats_calculate_bandwidth_distribution ()
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c
index d4189d063..fca54ed52 100644
--- a/src/transport/test_transport_ats.c
+++ b/src/transport/test_transport_ats.c
@@ -46,7 +46,6 @@ static struct GNUNET_TESTING_PeerGroup *pg;
46 46
47static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; 47static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
48static GNUNET_SCHEDULER_TaskIdentifier stats_task; 48static GNUNET_SCHEDULER_TaskIdentifier stats_task;
49
50struct GNUNET_TESTING_Daemon * master_deamon; 49struct GNUNET_TESTING_Daemon * master_deamon;
51 50
52struct GNUNET_STATISTICS_Handle * stats; 51struct GNUNET_STATISTICS_Handle * stats;
@@ -65,6 +64,11 @@ static int r_index;
65static int peers; 64static int peers;
66static struct TEST_result results[MEASUREMENTS]; 65static struct TEST_result results[MEASUREMENTS];
67 66
67struct GNUNET_STATISTICS_GetHandle * s_solution;
68struct GNUNET_STATISTICS_GetHandle * s_time;
69struct GNUNET_STATISTICS_GetHandle * s_peers;
70struct GNUNET_STATISTICS_GetHandle * s_mechs;
71struct GNUNET_STATISTICS_GetHandle * s_duration;
68 72
69/** 73/**
70 * Check whether peers successfully shut down. 74 * Check whether peers successfully shut down.
@@ -105,6 +109,33 @@ static void shutdown_peers()
105 stats_task = GNUNET_SCHEDULER_NO_TASK; 109 stats_task = GNUNET_SCHEDULER_NO_TASK;
106 } 110 }
107 111
112 if (s_time != NULL)
113 {
114 GNUNET_STATISTICS_get_cancel(s_time);
115 s_time = NULL;
116 }
117 if (s_peers != NULL)
118 {
119 GNUNET_STATISTICS_get_cancel(s_peers);
120 s_peers = NULL;
121 }
122 if (s_mechs != NULL)
123 {
124 GNUNET_STATISTICS_get_cancel(s_mechs);
125 s_mechs = NULL;
126 }
127 if (s_solution != NULL)
128 {
129 GNUNET_STATISTICS_get_cancel(s_solution);
130 s_solution = NULL;
131 }
132 if (s_duration != NULL)
133 {
134 GNUNET_STATISTICS_get_cancel(s_duration);
135 s_duration = NULL;
136 }
137
138
108 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 139 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
109} 140}
110 141
@@ -120,6 +151,8 @@ static void evaluate_measurements()
120 output = temp; 151 output = temp;
121 } 152 }
122 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"%s\n",output); 153 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"%s\n",output);
154
155
123 shutdown_peers(); 156 shutdown_peers();
124} 157}
125 158
@@ -129,6 +162,30 @@ int stats_cb (void *cls,
129 uint64_t value, 162 uint64_t value,
130 int is_persistent) 163 int is_persistent)
131{ 164{
165 if (0 == strcmp (name,"ATS solution"))
166 {
167 s_solution = NULL;
168 }
169
170 if (0 == strcmp (name,"ATS peers"))
171 {
172 s_peers = NULL;
173 }
174
175 if (0 == strcmp (name,"ATS mechanisms"))
176 {
177 s_mechs = NULL;
178 }
179
180 if (0 == strcmp (name,"ATS duration"))
181 {
182 s_duration = NULL;
183 }
184 if (0 == strcmp (name,"ATS timestamp"))
185 {
186 s_time = NULL;
187 }
188
132 if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1)) 189 if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1))
133 { 190 {
134 measurement_started = GNUNET_YES; 191 measurement_started = GNUNET_YES;
@@ -147,6 +204,11 @@ int stats_cb (void *cls,
147 r_index++; 204 r_index++;
148 if (r_index >= MEASUREMENTS) 205 if (r_index >= MEASUREMENTS)
149 { 206 {
207 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
208 {
209 GNUNET_SCHEDULER_cancel(stats_task);
210 stats_task = GNUNET_SCHEDULER_NO_TASK;
211 }
150 evaluate_measurements(); 212 evaluate_measurements();
151 return GNUNET_NO; 213 return GNUNET_NO;
152 } 214 }
@@ -195,11 +257,11 @@ stats_get_task (void *cls,
195 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 257 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
196 return; 258 return;
197 259
198 GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); 260 s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL);
199 GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); 261 s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL);
200 GNUNET_assert (NULL != GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL)); 262 s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL);
201 GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); 263 s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL);
202 GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); 264 s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL);
203 265
204 stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); 266 stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL);
205} 267}
diff --git a/src/transport/transport.h b/src/transport/transport.h
index e00b8d92a..f3e3b1c2c 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -31,8 +31,8 @@
31#include "gnunet_transport_service.h" 31#include "gnunet_transport_service.h"
32 32
33/* Minimum time between to calculations*/ 33/* Minimum time between to calculations*/
34#define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 200) 34#define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1)
35#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250) 35#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2)
36#define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100) 36#define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
37#define ATS_MAX_ITERATIONS INT_MAX 37#define ATS_MAX_ITERATIONS INT_MAX
38 38