diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 17:49:18 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 17:49:18 +0000 |
commit | b26ee701eb12e7664fc0f158e5f38bfbd4149b10 (patch) | |
tree | fdd6a4cab56ea4c1f23fd662e621d782477817b7 /src/ats-tests/ats-testing-log.c | |
parent | f52d267bb4d1ec781cf051b9a8d5beaa2b2ceb03 (diff) | |
download | gnunet-b26ee701eb12e7664fc0f158e5f38bfbd4149b10.tar.gz gnunet-b26ee701eb12e7664fc0f158e5f38bfbd4149b10.zip |
logging all nodes in a single file
Diffstat (limited to 'src/ats-tests/ats-testing-log.c')
-rw-r--r-- | src/ats-tests/ats-testing-log.c | 316 |
1 files changed, 198 insertions, 118 deletions
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c index 968ecc6cd..f41af3573 100644 --- a/src/ats-tests/ats-testing-log.c +++ b/src/ats-tests/ats-testing-log.c | |||
@@ -235,8 +235,10 @@ struct LoggingHandle | |||
235 | /** | 235 | /** |
236 | * Reference to perf_ats' masters | 236 | * Reference to perf_ats' masters |
237 | */ | 237 | */ |
238 | int num_peers; | 238 | int num_masters; |
239 | int num_slaves; | ||
239 | int running; | 240 | int running; |
241 | int verbose; | ||
240 | char *name; | 242 | char *name; |
241 | struct GNUNET_TIME_Relative frequency; | 243 | struct GNUNET_TIME_Relative frequency; |
242 | 244 | ||
@@ -249,17 +251,16 @@ struct LoggingHandle | |||
249 | 251 | ||
250 | 252 | ||
251 | static void | 253 | static void |
252 | write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp) | 254 | write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves) |
253 | { | 255 | { |
254 | struct GNUNET_DISK_FileHandle *f; | 256 | struct GNUNET_DISK_FileHandle *f; |
255 | char * gfn; | 257 | char * gfn; |
256 | char *data; | 258 | char *data; |
257 | int c_s; | 259 | int c_s; |
258 | int peer_index; | ||
259 | 260 | ||
260 | GNUNET_asprintf (&gfn, "gnuplot_throughput_%s",fn); | 261 | GNUNET_asprintf (&gfn, "gnuplot_throughput_%s",fn); |
261 | fprintf (stderr, "Writing throughput plot for master %u to `%s'\n", | 262 | fprintf (stderr, "Writing throughput plot for master %u and %u slaves to `%s'\n", |
262 | lp->peer->no, gfn); | 263 | lp->peer->no, slaves, gfn); |
263 | 264 | ||
264 | f = GNUNET_DISK_file_open (gfn, | 265 | f = GNUNET_DISK_file_open (gfn, |
265 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 266 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
@@ -273,41 +274,37 @@ write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
273 | } | 274 | } |
274 | 275 | ||
275 | /* Write header */ | 276 | /* Write header */ |
276 | |||
277 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, | 277 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, |
278 | strlen(THROUGHPUT_TEMPLATE))) | 278 | strlen(THROUGHPUT_TEMPLATE))) |
279 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 279 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
280 | "Cannot write data to plot file `%s'\n", gfn); | 280 | "Cannot write data to plot file `%s'\n", gfn); |
281 | 281 | ||
282 | /* Write master data */ | 282 | /* Write master data */ |
283 | peer_index = LOG_ITEMS_TIME; | ||
284 | GNUNET_asprintf (&data, | 283 | GNUNET_asprintf (&data, |
285 | "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ | 284 | "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ |
286 | "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", | 285 | "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", |
287 | fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, | 286 | fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, |
288 | fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); | 287 | fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); |
289 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 288 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
290 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 289 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
291 | GNUNET_free (data); | 290 | GNUNET_free (data); |
292 | 291 | ||
293 | peer_index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER ; | 292 | for (c_s = 0; c_s < slaves; c_s++) |
294 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | ||
295 | { | 293 | { |
296 | GNUNET_asprintf (&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ | 294 | GNUNET_asprintf (&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ |
297 | "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", | 295 | "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", |
298 | fn, | 296 | fs[c_s], |
299 | peer_index + LOG_ITEM_THROUGHPUT_SENT, | 297 | LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, |
300 | lp->peer->no, | 298 | lp->peer->no, |
301 | lp->peer->partners[c_s].dest->no, | 299 | lp->peer->partners[c_s].dest->no, |
302 | fn, | 300 | fs[c_s], |
303 | peer_index + LOG_ITEM_THROUGHPUT_RECV, | 301 | LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, |
304 | lp->peer->no, | 302 | lp->peer->no, |
305 | lp->peer->partners[c_s].dest->no, | 303 | lp->peer->partners[c_s].dest->no, |
306 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 304 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); |
307 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 305 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
308 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 306 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
309 | GNUNET_free (data); | 307 | GNUNET_free (data); |
310 | peer_index += LOG_ITEMS_PER_PEER; | ||
311 | } | 308 | } |
312 | 309 | ||
313 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 310 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
@@ -316,19 +313,17 @@ write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
316 | else | 313 | else |
317 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 314 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
318 | "Data successfully written to plot file `%s'\n", gfn); | 315 | "Data successfully written to plot file `%s'\n", gfn); |
319 | |||
320 | GNUNET_free (gfn); | 316 | GNUNET_free (gfn); |
321 | } | 317 | } |
322 | 318 | ||
323 | 319 | ||
324 | static void | 320 | static void |
325 | write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp) | 321 | write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves) |
326 | { | 322 | { |
327 | struct GNUNET_DISK_FileHandle *f; | 323 | struct GNUNET_DISK_FileHandle *f; |
328 | char * gfn; | 324 | char * gfn; |
329 | char *data; | 325 | char *data; |
330 | int c_s; | 326 | int c_s; |
331 | int index; | ||
332 | 327 | ||
333 | GNUNET_asprintf (&gfn, "gnuplot_rtt_%s",fn); | 328 | GNUNET_asprintf (&gfn, "gnuplot_rtt_%s",fn); |
334 | fprintf (stderr, "Writing rtt plot for master %u to `%s'\n", | 329 | fprintf (stderr, "Writing rtt plot for master %u to `%s'\n", |
@@ -346,21 +341,21 @@ write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
346 | } | 341 | } |
347 | 342 | ||
348 | /* Write header */ | 343 | /* Write header */ |
349 | |||
350 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, RTT_TEMPLATE, strlen(RTT_TEMPLATE))) | 344 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, RTT_TEMPLATE, strlen(RTT_TEMPLATE))) |
351 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 345 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
352 | 346 | ||
353 | index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; | 347 | for (c_s = 0; c_s < slaves; c_s++) |
354 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | ||
355 | { | 348 | { |
356 | GNUNET_asprintf (&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", | 349 | GNUNET_asprintf (&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", |
357 | (0 == c_s) ? "plot " :"", | 350 | (0 == c_s) ? "plot " :"", |
358 | fn, index + LOG_ITEM_APP_RTT, lp->peer->no, lp->peer->partners[c_s].dest->no, | 351 | fs[c_s], |
352 | LOG_ITEMS_TIME + LOG_ITEM_APP_RTT, | ||
353 | lp->peer->no, | ||
354 | lp->peer->partners[c_s].dest->no, | ||
359 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 355 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); |
360 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 356 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
361 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 357 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
362 | GNUNET_free (data); | 358 | GNUNET_free (data); |
363 | index += LOG_ITEMS_PER_PEER; | ||
364 | } | 359 | } |
365 | 360 | ||
366 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 361 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
@@ -371,13 +366,12 @@ write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
371 | } | 366 | } |
372 | 367 | ||
373 | static void | 368 | static void |
374 | write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp) | 369 | write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves) |
375 | { | 370 | { |
376 | struct GNUNET_DISK_FileHandle *f; | 371 | struct GNUNET_DISK_FileHandle *f; |
377 | char * gfn; | 372 | char * gfn; |
378 | char *data; | 373 | char *data; |
379 | int c_s; | 374 | int c_s; |
380 | int index; | ||
381 | 375 | ||
382 | GNUNET_asprintf (&gfn, "gnuplot_bw_%s",fn); | 376 | GNUNET_asprintf (&gfn, "gnuplot_bw_%s",fn); |
383 | fprintf (stderr, "Writing bandwidth plot for master %u to `%s'\n", | 377 | fprintf (stderr, "Writing bandwidth plot for master %u to `%s'\n", |
@@ -399,21 +393,23 @@ write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
399 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 393 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
400 | "Cannot write data to plot file `%s'\n", gfn); | 394 | "Cannot write data to plot file `%s'\n", gfn); |
401 | 395 | ||
402 | index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; | 396 | for (c_s = 0; c_s < slaves; c_s++) |
403 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | ||
404 | { | 397 | { |
405 | GNUNET_asprintf (&data, "%s"\ | 398 | GNUNET_asprintf (&data, "%s"\ |
406 | "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ | 399 | "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ |
407 | "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '"\ | 400 | "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '"\ |
408 | "%s\n", | 401 | "%s\n", |
409 | (0 == c_s) ? "plot " :"", | 402 | (0 == c_s) ? "plot " :"", |
410 | fn, index + LOG_ITEM_ATS_BW_OUT, lp->peer->no, lp->peer->partners[c_s].dest->no, | 403 | fs[c_s], |
411 | fn, index + LOG_ITEM_ATS_BW_IN, lp->peer->no, lp->peer->partners[c_s].dest->no, | 404 | LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_OUT, |
405 | lp->peer->no, c_s, | ||
406 | fs[c_s], | ||
407 | LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_IN, | ||
408 | lp->peer->no, c_s, | ||
412 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 409 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); |
413 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 410 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
414 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 411 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
415 | GNUNET_free (data); | 412 | GNUNET_free (data); |
416 | index += LOG_ITEMS_PER_PEER; | ||
417 | } | 413 | } |
418 | 414 | ||
419 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 415 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
@@ -428,12 +424,12 @@ void | |||
428 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | 424 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, |
429 | char *experiment_name, int plots) | 425 | char *experiment_name, int plots) |
430 | { | 426 | { |
431 | struct GNUNET_DISK_FileHandle *f; | 427 | struct GNUNET_DISK_FileHandle *f[l->num_slaves]; |
428 | struct GNUNET_DISK_FileHandle *f_m; | ||
432 | char *tmp_exp_name; | 429 | char *tmp_exp_name; |
433 | char *filename_data; | 430 | char *filename_master; |
431 | char *filename_slaves[l->num_slaves]; | ||
434 | char *data; | 432 | char *data; |
435 | char *slave_string; | ||
436 | char *slave_string_tmp; | ||
437 | struct PeerLoggingTimestep *cur_lt; | 433 | struct PeerLoggingTimestep *cur_lt; |
438 | struct PartnerLoggingTimestep *plt; | 434 | struct PartnerLoggingTimestep *plt; |
439 | struct GNUNET_TIME_Absolute timestamp; | 435 | struct GNUNET_TIME_Absolute timestamp; |
@@ -450,38 +446,80 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | |||
450 | tmp_exp_name++; | 446 | tmp_exp_name++; |
451 | } | 447 | } |
452 | 448 | ||
453 | for (c_m = 0; c_m < l->num_peers; c_m++) | 449 | for (c_m = 0; c_m < l->num_masters; c_m++) |
454 | { | 450 | { |
455 | GNUNET_asprintf (&filename_data, "%s_%llu_master_%u_%s_%s", tmp_exp_name, | 451 | GNUNET_asprintf (&filename_master, "%s_%llu_master%u_%s", |
456 | timestamp.abs_value_us, | 452 | tmp_exp_name, timestamp.abs_value_us, c_m, l->name); |
457 | l->lp[c_m].peer->no, GNUNET_i2s(&l->lp[c_m].peer->id), l->name); | 453 | fprintf (stderr, "Writing data for master %u to file `%s'\n", |
458 | 454 | c_m,filename_master); | |
459 | fprintf (stderr, "Writing master %u to file `%s'\n", c_m, filename_data); | ||
460 | 455 | ||
461 | f = GNUNET_DISK_file_open (filename_data, | 456 | f_m = GNUNET_DISK_file_open (filename_master, |
462 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 457 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
463 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 458 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
464 | if (NULL == f) | 459 | if (NULL == f_m) |
465 | { | 460 | { |
466 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_data); | 461 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_master); |
467 | GNUNET_free (filename_data); | 462 | GNUNET_free (filename_master); |
468 | return; | 463 | return; |
469 | } | 464 | } |
470 | 465 | ||
471 | GNUNET_asprintf (&data, "# master peers: %u ; slave peers: %u ; experiment : %s\n", | 466 | GNUNET_asprintf (&data, "# master %u; experiment : %s\n" |
472 | l->num_peers, l->lp[c_m].peer->num_partners, experiment_name); | 467 | "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; \n" , |
473 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 468 | c_m, experiment_name); |
469 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data))) | ||
474 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 470 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
475 | "Cannot write data to log file `%s'\n", filename_data); | 471 | "Cannot write data to log file `%s'\n",filename_master); |
476 | GNUNET_free (data); | 472 | GNUNET_free (data); |
477 | 473 | ||
474 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | ||
475 | { | ||
476 | GNUNET_asprintf (&filename_slaves[c_s], "%s_%llu_master%u_slave_%u_%s", | ||
477 | tmp_exp_name, timestamp.abs_value_us, c_m, c_s, l->name); | ||
478 | |||
479 | fprintf (stderr, "Writing data for master %u slave %u to file `%s'\n", | ||
480 | c_m, c_s, filename_slaves[c_s]); | ||
481 | |||
482 | f[c_s] = GNUNET_DISK_file_open (filename_slaves[c_s], | ||
483 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
484 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
485 | if (NULL == f[c_s]) | ||
486 | { | ||
487 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_slaves[c_s]); | ||
488 | GNUNET_free (filename_slaves[c_s]); | ||
489 | return; | ||
490 | } | ||
491 | |||
492 | /* Header */ | ||
493 | GNUNET_asprintf (&data, "# master %u; slave %u ; experiment : %s\n" | ||
494 | "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \ | ||
495 | "rtt; bw in; bw out; ats_cost_lan; ats_cost_wlan; ats_delay; ats_distance; ats_network_type; ats_utilization_up ;ats_utilization_down\n" , | ||
496 | c_m, c_s, experiment_name); | ||
497 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data))) | ||
498 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
499 | "Cannot write data to log file `%s'\n",filename_slaves[c_s]); | ||
500 | GNUNET_free (data); | ||
501 | } | ||
502 | |||
478 | for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) | 503 | for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) |
479 | { | 504 | { |
480 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 505 | if (l->verbose) |
481 | "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", | 506 | fprintf (stderr, |
482 | l->lp[c_m].peer->no, | 507 | "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", |
483 | cur_lt->timestamp, | 508 | l->lp[c_m].peer->no, |
484 | GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | 509 | (long long unsigned int) cur_lt->timestamp.abs_value_us, |
510 | (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | ||
511 | cur_lt->timestamp).rel_value_us / 1000, | ||
512 | cur_lt->total_messages_sent, | ||
513 | cur_lt->total_bytes_sent, | ||
514 | cur_lt->total_throughput_send, | ||
515 | cur_lt->total_messages_received, | ||
516 | cur_lt->total_bytes_received, | ||
517 | cur_lt->total_throughput_recv); | ||
518 | |||
519 | /* Assembling master string */ | ||
520 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;\n", | ||
521 | (long long unsigned int) cur_lt->timestamp.abs_value_us, | ||
522 | (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | ||
485 | cur_lt->timestamp).rel_value_us / 1000, | 523 | cur_lt->timestamp).rel_value_us / 1000, |
486 | cur_lt->total_messages_sent, | 524 | cur_lt->total_messages_sent, |
487 | cur_lt->total_bytes_sent, | 525 | cur_lt->total_bytes_sent, |
@@ -490,36 +528,29 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | |||
490 | cur_lt->total_bytes_received, | 528 | cur_lt->total_bytes_received, |
491 | cur_lt->total_throughput_recv); | 529 | cur_lt->total_throughput_recv); |
492 | 530 | ||
493 | slave_string = GNUNET_strdup (";"); | 531 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data))) |
532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
533 | "Cannot write data to master file %u\n", c_m); | ||
534 | GNUNET_free (data); | ||
535 | |||
536 | |||
494 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | 537 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) |
495 | { | 538 | { |
496 | plt = &cur_lt->slaves_log[c_s]; | 539 | plt = &cur_lt->slaves_log[c_s]; |
497 | /* Log partners */ | 540 | /* Log partners */ |
498 | 541 | ||
499 | /* Assembling slave string */ | 542 | /* Assembling slave string */ |
500 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 543 | GNUNET_asprintf(&data, |
501 | "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n", | 544 | "%llu;%llu;%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%u;%u;%u;\n", |
502 | plt->slave->no, | 545 | (long long unsigned int) cur_lt->timestamp.abs_value_us, |
546 | (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | ||
547 | cur_lt->timestamp).rel_value_us / 1000, | ||
503 | plt->total_messages_sent, | 548 | plt->total_messages_sent, |
504 | plt->total_bytes_sent, | 549 | plt->total_bytes_sent, |
505 | plt->throughput_sent, | 550 | plt->throughput_sent, |
506 | plt->total_messages_received, | 551 | plt->total_messages_received, |
507 | plt->total_bytes_received, | 552 | plt->total_bytes_received, |
508 | plt->throughput_recv, | 553 | plt->throughput_recv, |
509 | plt->app_rtt, | ||
510 | plt->ats_delay, | ||
511 | plt->bandwidth_in, | ||
512 | plt->bandwidth_out); | ||
513 | |||
514 | GNUNET_asprintf(&slave_string_tmp, | ||
515 | "%s%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%u;%u;%u;", | ||
516 | slave_string, | ||
517 | plt->total_messages_sent, | ||
518 | plt->total_bytes_sent, | ||
519 | plt->throughput_sent, | ||
520 | plt->total_messages_received, | ||
521 | plt->total_bytes_received, | ||
522 | plt->throughput_sent, | ||
523 | (double) plt->app_rtt / 1000, | 554 | (double) plt->app_rtt / 1000, |
524 | plt->bandwidth_in, | 555 | plt->bandwidth_in, |
525 | plt->bandwidth_out, | 556 | plt->bandwidth_out, |
@@ -531,47 +562,60 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | |||
531 | plt->ats_network_type, | 562 | plt->ats_network_type, |
532 | plt->ats_utilization_up, | 563 | plt->ats_utilization_up, |
533 | plt->ats_utilization_down); | 564 | plt->ats_utilization_down); |
534 | GNUNET_free (slave_string); | 565 | |
535 | slave_string = slave_string_tmp; | 566 | if (l->verbose) |
567 | fprintf (stderr, | ||
568 | "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n", | ||
569 | plt->slave->no, | ||
570 | plt->total_messages_sent, | ||
571 | plt->total_bytes_sent, | ||
572 | plt->throughput_sent, | ||
573 | plt->total_messages_received, | ||
574 | plt->total_bytes_received, | ||
575 | plt->throughput_recv, | ||
576 | plt->app_rtt, | ||
577 | plt->ats_delay, | ||
578 | plt->bandwidth_in, | ||
579 | plt->bandwidth_out); | ||
580 | |||
581 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data))) | ||
582 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
583 | "Cannot write data to log file `%s'\n", filename_slaves[c_s]); | ||
584 | GNUNET_free (data); | ||
585 | |||
536 | } | 586 | } |
537 | /* Assembling master string */ | 587 | } |
538 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;;;;;;;;;;;%s\n", | ||
539 | cur_lt->timestamp, | ||
540 | GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | ||
541 | cur_lt->timestamp).rel_value_us / 1000, | ||
542 | cur_lt->total_messages_sent, | ||
543 | cur_lt->total_bytes_sent, | ||
544 | cur_lt->total_throughput_send, | ||
545 | cur_lt->total_messages_received, | ||
546 | cur_lt->total_bytes_received, | ||
547 | cur_lt->total_throughput_recv, | ||
548 | slave_string); | ||
549 | GNUNET_free (slave_string); | ||
550 | 588 | ||
551 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 589 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) |
590 | { | ||
591 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f[c_s])) | ||
592 | { | ||
552 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 593 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
553 | "Cannot write data to log file `%s'\n", filename_data); | 594 | "Cannot close log file for master[%u] slave[%u]\n", c_m, c_s); |
554 | GNUNET_free (data); | 595 | return; |
596 | } | ||
597 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
598 | "Data file successfully written to log file for `%s'\n", | ||
599 | filename_slaves[c_s]); | ||
555 | } | 600 | } |
556 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 601 | |
602 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_m)) | ||
557 | { | 603 | { |
558 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 604 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
559 | "Cannot close log file `%s'\n", filename_data); | 605 | "Cannot close log file `%s'\n", filename_master); |
560 | GNUNET_free (filename_data); | ||
561 | return; | 606 | return; |
562 | } | 607 | } |
608 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
609 | "Data file successfully written to log file for master `%s'\n", filename_master); | ||
563 | 610 | ||
564 | if (GNUNET_YES == plots) | 611 | if (GNUNET_YES == plots) |
565 | { | 612 | { |
566 | write_throughput_gnuplot_script (filename_data, &l->lp[c_m]); | 613 | write_throughput_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); |
567 | write_rtt_gnuplot_script (filename_data, &l->lp[c_m]); | 614 | write_rtt_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); |
568 | write_bw_gnuplot_script (filename_data, &l->lp[c_m]); | 615 | write_bw_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); |
569 | } | 616 | } |
570 | |||
571 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
572 | "Data file successfully written to log file `%s'\n", filename_data); | ||
573 | GNUNET_free (filename_data); | ||
574 | } | 617 | } |
618 | |||
575 | } | 619 | } |
576 | 620 | ||
577 | /** | 621 | /** |
@@ -597,7 +641,7 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | |||
597 | if (GNUNET_YES != l->running) | 641 | if (GNUNET_YES != l->running) |
598 | return; | 642 | return; |
599 | 643 | ||
600 | for (c_m = 0; c_m < l->num_peers; c_m++) | 644 | for (c_m = 0; c_m < l->num_masters; c_m++) |
601 | { | 645 | { |
602 | bp = &l->lp[c_m]; | 646 | bp = &l->lp[c_m]; |
603 | mlt = GNUNET_new (struct PeerLoggingTimestep); | 647 | mlt = GNUNET_new (struct PeerLoggingTimestep); |
@@ -625,20 +669,30 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | |||
625 | } | 669 | } |
626 | 670 | ||
627 | /* Multiplication factor for throughput calculation */ | 671 | /* Multiplication factor for throughput calculation */ |
628 | mult = (1.0 * 1000 * 1000) / (delta.rel_value_us); | 672 | mult = (double) GNUNET_TIME_UNIT_SECONDS.rel_value_us / (delta.rel_value_us); |
629 | 673 | ||
630 | /* Total throughput */ | 674 | /* Total throughput */ |
631 | if (NULL != prev_log_mlt) | 675 | if (NULL != prev_log_mlt) |
632 | { | 676 | { |
633 | if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) | 677 | if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) |
678 | { | ||
634 | mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent); | 679 | mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent); |
680 | } | ||
635 | else | 681 | else |
636 | mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ | 682 | { |
683 | mlt->total_throughput_send = 0; | ||
684 | // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ | ||
685 | } | ||
637 | 686 | ||
638 | if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) | 687 | if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) |
688 | { | ||
639 | mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received); | 689 | mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received); |
690 | } | ||
640 | else | 691 | else |
641 | mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ | 692 | { |
693 | mlt->total_throughput_send = 0; | ||
694 | //mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ | ||
695 | } | ||
642 | } | 696 | } |
643 | else | 697 | else |
644 | { | 698 | { |
@@ -646,13 +700,23 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | |||
646 | mlt->total_throughput_send = mult * mlt->total_bytes_received; | 700 | mlt->total_throughput_send = mult * mlt->total_bytes_received; |
647 | } | 701 | } |
648 | 702 | ||
703 | if (GNUNET_YES == l->verbose) | ||
704 | { | ||
705 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
706 | "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", c_m, | ||
707 | delta.rel_value_us, | ||
708 | mlt->total_bytes_sent, | ||
709 | mlt->total_bytes_received, | ||
710 | mlt->total_throughput_send, | ||
711 | mlt->total_throughput_recv); | ||
712 | } | ||
713 | |||
649 | mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners * | 714 | mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners * |
650 | sizeof (struct PartnerLoggingTimestep)); | 715 | sizeof (struct PartnerLoggingTimestep)); |
651 | 716 | ||
652 | for (c_s = 0; c_s < bp->peer->num_partners; c_s++) | 717 | for (c_s = 0; c_s < bp->peer->num_partners; c_s++) |
653 | { | 718 | { |
654 | 719 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | |
655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
656 | "Collect logging data master[%u] slave [%u]\n", c_m, c_s); | 720 | "Collect logging data master[%u] slave [%u]\n", c_m, c_s); |
657 | 721 | ||
658 | p = &bp->peer->partners[c_s]; | 722 | p = &bp->peer->partners[c_s]; |
@@ -695,7 +759,9 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | |||
695 | app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) / | 759 | app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) / |
696 | (slt->total_messages_sent - prev_log_slt->total_messages_sent); | 760 | (slt->total_messages_sent - prev_log_slt->total_messages_sent); |
697 | else | 761 | else |
762 | { | ||
698 | app_rtt = prev_log_slt->app_rtt; /* No messages were */ | 763 | app_rtt = prev_log_slt->app_rtt; /* No messages were */ |
764 | } | ||
699 | } | 765 | } |
700 | slt->app_rtt = app_rtt; | 766 | slt->app_rtt = app_rtt; |
701 | 767 | ||
@@ -703,23 +769,36 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | |||
703 | if (NULL != prev_log_mlt) | 769 | if (NULL != prev_log_mlt) |
704 | { | 770 | { |
705 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | 771 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; |
706 | if (slt->total_bytes_sent - prev_log_slt->total_bytes_sent > 0) | 772 | if (slt->total_bytes_sent > prev_log_slt->total_bytes_sent) |
707 | slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent); | 773 | slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent); |
708 | else | 774 | else |
709 | slt->throughput_sent = prev_log_slt->throughput_sent; /* no msgs send */ | 775 | slt->throughput_sent = 0; |
710 | 776 | ||
711 | if (slt->total_bytes_received - prev_log_slt->total_bytes_received > 0) | 777 | if (slt->total_bytes_received > prev_log_slt->total_bytes_received) |
712 | slt->throughput_recv = mult * (slt->total_bytes_received - prev_log_slt->total_bytes_received); | 778 | slt->throughput_recv = mult * |
779 | (slt->total_bytes_received - prev_log_slt->total_bytes_received); | ||
713 | else | 780 | else |
714 | slt->throughput_recv = prev_log_slt->throughput_recv; /* no msgs received */ | 781 | slt->throughput_recv = 0; |
715 | } | 782 | } |
716 | else | 783 | else |
717 | { | 784 | { |
718 | slt->throughput_sent = mult * slt->total_bytes_sent; | 785 | slt->throughput_sent = mult * slt->total_bytes_sent; |
719 | slt->throughput_sent = mult * slt->total_bytes_received; | 786 | slt->throughput_recv = mult * slt->total_bytes_received; |
720 | } | 787 | } |
721 | 788 | ||
722 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 789 | if (GNUNET_YES == l->verbose) |
790 | { | ||
791 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
792 | "Master [%u] -> Slave [%u]: delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", | ||
793 | c_m, c_s, | ||
794 | delta.rel_value_us, | ||
795 | mlt->total_bytes_sent, | ||
796 | mlt->total_bytes_received, | ||
797 | slt->throughput_sent, | ||
798 | slt->throughput_recv); | ||
799 | } | ||
800 | else | ||
801 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
723 | "Master [%u]: slave [%u]\n", | 802 | "Master [%u]: slave [%u]\n", |
724 | bp->peer->no, p->dest->no); | 803 | bp->peer->no, p->dest->no); |
725 | } | 804 | } |
@@ -749,14 +828,12 @@ collect_log_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
749 | void | 828 | void |
750 | GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l) | 829 | GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l) |
751 | { | 830 | { |
752 | struct GNUNET_SCHEDULER_TaskContext tc; | ||
753 | if (GNUNET_YES!= l->running) | 831 | if (GNUNET_YES!= l->running) |
754 | return; | 832 | return; |
755 | 833 | ||
756 | if (GNUNET_SCHEDULER_NO_TASK != l->log_task) | 834 | if (GNUNET_SCHEDULER_NO_TASK != l->log_task) |
757 | GNUNET_SCHEDULER_cancel (l->log_task); | 835 | GNUNET_SCHEDULER_cancel (l->log_task); |
758 | l->log_task = GNUNET_SCHEDULER_NO_TASK; | 836 | l->log_task = GNUNET_SCHEDULER_NO_TASK; |
759 | tc.reason = GNUNET_SCHEDULER_REASON_SHUTDOWN; | ||
760 | l->running = GNUNET_NO; | 837 | l->running = GNUNET_NO; |
761 | 838 | ||
762 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 839 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
@@ -777,7 +854,7 @@ GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l) | |||
777 | if (GNUNET_YES == l->running) | 854 | if (GNUNET_YES == l->running) |
778 | GNUNET_ATS_TEST_logging_stop (l); | 855 | GNUNET_ATS_TEST_logging_stop (l); |
779 | 856 | ||
780 | for (c_m = 0; c_m < l->num_peers; c_m++) | 857 | for (c_m = 0; c_m < l->num_masters; c_m++) |
781 | { | 858 | { |
782 | while (NULL != (cur = l->lp[c_m].head)) | 859 | while (NULL != (cur = l->lp[c_m].head)) |
783 | { | 860 | { |
@@ -803,7 +880,8 @@ GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l) | |||
803 | */ | 880 | */ |
804 | struct LoggingHandle * | 881 | struct LoggingHandle * |
805 | GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, | 882 | GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, |
806 | char *testname, struct BenchmarkPeer *masters, int num_masters) | 883 | char *testname, struct BenchmarkPeer *masters, int num_masters, int num_slaves, |
884 | int verbose) | ||
807 | { | 885 | { |
808 | struct LoggingHandle *l; | 886 | struct LoggingHandle *l; |
809 | int c_m; | 887 | int c_m; |
@@ -811,9 +889,11 @@ GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, | |||
811 | _("Start logging `%s'\n"), testname); | 889 | _("Start logging `%s'\n"), testname); |
812 | 890 | ||
813 | l = GNUNET_new (struct LoggingHandle); | 891 | l = GNUNET_new (struct LoggingHandle); |
814 | l->num_peers = num_masters; | 892 | l->num_masters = num_masters; |
893 | l->num_slaves = num_slaves; | ||
815 | l->name = testname; | 894 | l->name = testname; |
816 | l->frequency = log_frequency; | 895 | l->frequency = log_frequency; |
896 | l->verbose = verbose; | ||
817 | l->lp = GNUNET_malloc (num_masters * sizeof (struct LoggingPeer)); | 897 | l->lp = GNUNET_malloc (num_masters * sizeof (struct LoggingPeer)); |
818 | 898 | ||
819 | for (c_m = 0; c_m < num_masters; c_m ++) | 899 | for (c_m = 0; c_m < num_masters; c_m ++) |