aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-03-26 10:50:06 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-03-26 10:50:06 +0000
commitfcd8cd22ee2c843b86cc945062ebbeb49f6030a2 (patch)
tree21e575a8a6e02ff7edb11c187a42d7b8c5b4f7a9 /src/ats
parentf22d1f58fde071d607853f50e9c0a7a2a3166e4e (diff)
downloadgnunet-fcd8cd22ee2c843b86cc945062ebbeb49f6030a2.tar.gz
gnunet-fcd8cd22ee2c843b86cc945062ebbeb49f6030a2.zip
changes
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses.c4
-rw-r--r--src/ats/gnunet-service-ats_performance.c16
-rw-r--r--src/ats/gnunet-service-ats_performance.h12
-rw-r--r--src/ats/test_ats_api_performance_monitor.c127
4 files changed, 97 insertions, 62 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 8ff9b2a5e..3dcb6aad2 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -465,7 +465,9 @@ disassemble_ats_information (const struct GNUNET_ATS_Information *src,
465 struct GNUNET_ATS_Information *destats; 465 struct GNUNET_ATS_Information *destats;
466 int ats_count; 466 int ats_count;
467 ats_count = assemble_ats_information (dest, &destats); 467 ats_count = assemble_ats_information (dest, &destats);
468 GAS_handle_performance_update (&dest->peer, destats, ats_count); 468 GAS_handle_performance_update (&dest->peer, dest->plugin,
469 dest->addr, dest->addr_len, dest->active,
470 destats, ats_count, dest->assigned_bw_out, dest->assigned_bw_in);
469 GNUNET_free (destats); 471 GNUNET_free (destats);
470 } 472 }
471 return res; 473 return res;
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index 585de6669..3739ad638 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -505,10 +505,24 @@ GAS_handle_request_address_list (void *cls, struct GNUNET_SERVER_Client *client,
505 505
506void 506void
507GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, 507GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer,
508 const char *plugin_name,
509 const void *plugin_addr,
510 size_t plugin_addr_len,
511 const int active,
508 struct GNUNET_ATS_Information *ats, 512 struct GNUNET_ATS_Information *ats,
509 uint32_t ats_count) 513 uint32_t ats_count,
514 struct GNUNET_BANDWIDTH_Value32NBO
515 bandwidth_out,
516 struct GNUNET_BANDWIDTH_Value32NBO
517 bandwidth_in)
510{ 518{
511/* Notify here */ 519/* Notify here */
520 GAS_performance_notify_all_clients (peer,
521 plugin_name,
522 plugin_addr, plugin_addr_len,
523 active,
524 ats, ats_count,
525 bandwidth_out, bandwidth_in);
512 526
513#if 0 527#if 0
514 struct PerformanceClient *cur; 528 struct PerformanceClient *cur;
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h
index cf7a5f9ca..790e1cc4a 100644
--- a/src/ats/gnunet-service-ats_performance.h
+++ b/src/ats/gnunet-service-ats_performance.h
@@ -54,8 +54,18 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client);
54 54
55void 55void
56GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer, 56GAS_handle_performance_update (struct GNUNET_PeerIdentity *peer,
57 const char *plugin_name,
58 const void *plugin_addr,
59 size_t plugin_addr_len,
60 const int active,
57 struct GNUNET_ATS_Information *ats, 61 struct GNUNET_ATS_Information *ats,
58 uint32_t ats_count); 62 uint32_t ats_count,
63 struct GNUNET_BANDWIDTH_Value32NBO
64 bandwidth_out,
65 struct GNUNET_BANDWIDTH_Value32NBO
66 bandwidth_in);
67
68
59 69
60/** 70/**
61 * Transmit the given performance information to all performance 71 * Transmit the given performance information to all performance
diff --git a/src/ats/test_ats_api_performance_monitor.c b/src/ats/test_ats_api_performance_monitor.c
index 86a957fcc..95c65c68f 100644
--- a/src/ats/test_ats_api_performance_monitor.c
+++ b/src/ats/test_ats_api_performance_monitor.c
@@ -77,14 +77,12 @@ static void setup_addresses ()
77 addr[0].transport_name = "test0"; 77 addr[0].transport_name = "test0";
78 addr[0].address = "test_addr0"; 78 addr[0].address = "test_addr0";
79 addr[0].address_length = strlen ("test_addr0") + 1; 79 addr[0].address_length = strlen ("test_addr0") + 1;
80 atsi[0].type = htonl(GNUNET_ATS_NETWORK_TYPE);
81 atsi[0].value = htonl(GNUNET_ATS_NET_LAN);
82 80
83 atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY); 81 atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
84 atsi[1].value = htonl(100); 82 atsi[0].value = htonl(100);
85 83
86 atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE); 84 atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
87 atsi[2].value = htonl(5); 85 atsi[1].value = htonl(5);
88 86
89 GNUNET_ATS_address_add (sh, &addr[0], NULL, atsi, ATS_COUNT); 87 GNUNET_ATS_address_add (sh, &addr[0], NULL, atsi, ATS_COUNT);
90 88
@@ -132,7 +130,15 @@ static void
132end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 130end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
133{ 131{
134 die_task = GNUNET_SCHEDULER_NO_TASK; 132 die_task = GNUNET_SCHEDULER_NO_TASK;
135 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout\n"); 133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error!\n");
134 if (GNUNET_NO == res_perf_cb_p0)
135 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get performance information for requested peer!\n");
136 if (GNUNET_YES == res_perf_cb_p1)
137 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested peer!\n");
138 if (GNUNET_NO == res_suggest_cb_p0)
139 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get suggestion for not peer!\n");
140 if (GNUNET_YES == res_suggest_cb_p1)
141 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested peer!\n");
136 end_now (1); 142 end_now (1);
137} 143}
138 144
@@ -179,10 +185,10 @@ perf_mon_cb (void *cls,
179 int c2; 185 int c2;
180 int c3; 186 int c3;
181 187
182 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 188 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
183 "ATS notifies about perfomance change for peer `%s'\n", GNUNET_i2s (peer)); 189 "ATS notifies about perfomance change for peer `%s'\n", GNUNET_i2s (peer));
184 190
185 if ((1 != stage) || (2 == stage)) 191 if ((1 != stage) && (2 != stage))
186 { 192 {
187 GNUNET_break (0); 193 GNUNET_break (0);
188 end_now(1); 194 end_now(1);
@@ -193,8 +199,17 @@ perf_mon_cb (void *cls,
193 { 199 {
194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 1st callback for peer `%s' with %u information\n", 200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 1st callback for peer `%s' with %u information\n",
195 GNUNET_i2s (&addr[0].peer), ats_count); 201 GNUNET_i2s (&addr[0].peer), ats_count);
196 if ((0 != memcmp (peer, &addr[0].peer, sizeof (addr[0].peer))) || 202 if (0 != memcmp (peer, &addr[0].peer, sizeof (addr[0].peer)))
197 (ats_count < ATS_COUNT)) 203 {
204 res_perf_cb_p1 = GNUNET_YES;
205 GNUNET_break (0);
206 if (GNUNET_SCHEDULER_NO_TASK != die_task)
207 GNUNET_SCHEDULER_cancel (die_task);
208 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
209 return;
210 }
211
212 if (ats_count < ATS_COUNT)
198 { 213 {
199 GNUNET_break (0); 214 GNUNET_break (0);
200 if (GNUNET_SCHEDULER_NO_TASK != die_task) 215 if (GNUNET_SCHEDULER_NO_TASK != die_task)
@@ -232,80 +247,74 @@ perf_mon_cb (void *cls,
232 stage ++; 247 stage ++;
233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u correct ATS information \n", c3); 248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u correct ATS information \n", c3);
234 249
235 atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY); 250 atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
236 atsi[1].value = htonl(1000); 251 atsi[0].value = htonl(1000);
237 252
238 atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE); 253 atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
239 atsi[2].value = htonl(50); 254 atsi[1].value = htonl(50);
240 255
241 GNUNET_ATS_address_update (sh, &addr[0], NULL, atsi, ATS_COUNT); 256 GNUNET_ATS_address_update (sh, &addr[0], NULL, atsi, ATS_COUNT);
257 return;
242 } 258 }
243 if (1 == stage) 259 if (2 == stage)
244 { 260 {
245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 2nd callback for peer `%s' with %u information\n", 261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received 2nd callback for peer `%s' with %u information\n",
246 GNUNET_i2s (&addr[0].peer), ats_count); 262 GNUNET_i2s (&addr[0].peer), ats_count);
247 } 263 if (0 != memcmp (peer, &addr[0].peer, sizeof (addr[0].peer)))
248 264 {
249 265 res_perf_cb_p1 = GNUNET_YES;
250#if 0 266 GNUNET_break (0);
251 static int stage_counter = 0; 267 if (GNUNET_SCHEDULER_NO_TASK != die_task)
252 268 GNUNET_SCHEDULER_cancel (die_task);
253 269 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
254 270 return;
255 if (0 == stage_counter) 271 }
256 {
257
258 c3 = 0;
259
260
261 stage_counter ++;
262
263 }
264 else if (1 == stage_counter)
265 {
266 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received updated callback for peer `%s' with %u information\n",
267 GNUNET_i2s (&addr.peer), ats_count);
268 272
269 if ((0 != memcmp (peer, &addr.peer, sizeof (addr.peer))) || 273 if (ats_count < ATS_COUNT)
270 (ats_count < ATS_COUNT))
271 { 274 {
272 GNUNET_break (0); 275 GNUNET_break (0);
273 GNUNET_SCHEDULER_add_now (&end_badly, NULL); 276 if (GNUNET_SCHEDULER_NO_TASK != die_task)
277 GNUNET_SCHEDULER_cancel (die_task);
278 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
274 return; 279 return;
275 } 280 }
281
282
276 c3 = 0; 283 c3 = 0;
277 for (c1 = 0; c1 < ats_count; c1++) 284 for (c1 = 0; c1 < ats_count; c1++)
278 { 285 {
279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS information [%u] %u : %u \n", c1, ntohl (ats[c1].type), ntohl (ats[c1].value)); 286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS information [%u] %u : %u \n",
280 for (c2 = 0; c2 < ATS_COUNT; c2++) 287 c1, ntohl (ats[c1].type), ntohl (ats[c1].value));
288 for (c2 = 0; c2 < ATS_COUNT; c2++)
289 {
290 if (ats[c1].type == atsi[c2].type)
281 { 291 {
282 if (ats[c1].type == atsi[c2].type) 292 if (ats[c1].value == atsi[c2].value)
293 c3++;
294 else
283 { 295 {
284 if (ats[c1].value == atsi[c2].value) 296 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS information [%u] should be %u, but is %u \n",
285 { 297 ntohl (ats[c1].type), ntohl(atsi[c2].value), ntohl (ats[c1].value));
286 c3++; 298 GNUNET_break (0);
287 }
288 else
289 {
290 GNUNET_break (0);
291 }
292 } 299 }
293 } 300 }
301 }
294 } 302 }
295
296 if (ATS_COUNT != c3) 303 if (ATS_COUNT != c3)
297 { 304 {
298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received only %u correct ATS information \n", c3); 305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received only %u correct ATS information \n", c3);
299 GNUNET_break (0); 306 if (GNUNET_SCHEDULER_NO_TASK != die_task)
300 GNUNET_SCHEDULER_add_now (&end_badly, NULL); 307 GNUNET_SCHEDULER_cancel (die_task);
308 die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
301 return; 309 return;
302 } 310 }
303 stage_counter ++; 311
304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u correct ATS information, shutdown... \n", c3); 312 /* Everything OK */
313 stage ++;
314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u correct ATS information \n", c3);
305 GNUNET_SCHEDULER_add_now (&end, NULL); 315 GNUNET_SCHEDULER_add_now (&end, NULL);
306 return; 316 return;
307 } 317 }
308#endif
309} 318}
310 319
311void ats_suggest_cb (void *cls, 320void ats_suggest_cb (void *cls,
@@ -316,7 +325,7 @@ void ats_suggest_cb (void *cls,
316 const struct GNUNET_ATS_Information *ats, 325 const struct GNUNET_ATS_Information *ats,
317 uint32_t ats_count) 326 uint32_t ats_count)
318{ 327{
319 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 328 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
320 "ATS is suggesting address for peer `%s'\n", GNUNET_i2s (&address->peer)); 329 "ATS is suggesting address for peer `%s'\n", GNUNET_i2s (&address->peer));
321 330
322 if (0 != stage) 331 if (0 != stage)