aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-30 10:14:27 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-30 10:14:27 +0000
commitdaf74c08914b5dbec07848207262eff933a5f180 (patch)
tree9711ab4917f17078fcc2f66cefe131fb4a54fcba /src
parent61a0bd5180cb6aaae0effd9e67abf3ba83a270ff (diff)
downloadgnunet-daf74c08914b5dbec07848207262eff933a5f180.tar.gz
gnunet-daf74c08914b5dbec07848207262eff933a5f180.zip
improved logging
Diffstat (limited to 'src')
-rw-r--r--src/ats-tests/ats-testing-log.c154
1 files changed, 108 insertions, 46 deletions
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c
index a5c1d0bc0..17b3ab450 100644
--- a/src/ats-tests/ats-testing-log.c
+++ b/src/ats-tests/ats-testing-log.c
@@ -244,7 +244,6 @@ struct LoggingHandle
244 * Log structure of length num_peers 244 * Log structure of length num_peers
245 */ 245 */
246 struct LoggingPeer *lp; 246 struct LoggingPeer *lp;
247
248}; 247};
249 248
250 249
@@ -261,7 +260,8 @@ write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp)
261 GNUNET_asprintf (&gfn, "gnuplot_throughput_%s",fn); 260 GNUNET_asprintf (&gfn, "gnuplot_throughput_%s",fn);
262 f = GNUNET_DISK_file_open (gfn, 261 f = GNUNET_DISK_file_open (gfn,
263 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 262 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
264 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 263 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
264 GNUNET_DISK_PERM_USER_WRITE);
265 if (NULL == f) 265 if (NULL == f)
266 { 266 {
267 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 267 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
@@ -271,15 +271,18 @@ write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp)
271 271
272 /* Write header */ 272 /* Write header */
273 273
274 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, strlen(THROUGHPUT_TEMPLATE))) 274 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE,
275 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 275 strlen(THROUGHPUT_TEMPLATE)))
276 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
277 "Cannot write data to plot file `%s'\n", gfn);
276 278
277 /* Write master data */ 279 /* Write master data */
278 peer_index = LOG_ITEMS_TIME; 280 peer_index = LOG_ITEMS_TIME;
279 GNUNET_asprintf (&data, "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ 281 GNUNET_asprintf (&data,
280 "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", 282 "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \
281 fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, 283 "'%s' using 2:%u with lines title 'Master %u receive total', \\\n",
282 fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); 284 fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no,
285 fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no);
283 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 286 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
284 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 287 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
285 GNUNET_free (data); 288 GNUNET_free (data);
@@ -288,10 +291,16 @@ write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp)
288 for (c_s = 0; c_s < lp->peer->num_partners; c_s++) 291 for (c_s = 0; c_s < lp->peer->num_partners; c_s++)
289 { 292 {
290 GNUNET_asprintf (&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ 293 GNUNET_asprintf (&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \
291 "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", 294 "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n",
292 fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, lp->peer->partners[c_s].dest->no, 295 fn,
293 fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no, lp->peer->partners[c_s].dest->no, 296 peer_index + LOG_ITEM_THROUGHPUT_SENT,
294 (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); 297 lp->peer->no,
298 lp->peer->partners[c_s].dest->no,
299 fn,
300 peer_index + LOG_ITEM_THROUGHPUT_RECV,
301 lp->peer->no,
302 lp->peer->partners[c_s].dest->no,
303 (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1");
295 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 304 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
296 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 305 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
297 GNUNET_free (data); 306 GNUNET_free (data);
@@ -299,9 +308,11 @@ write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp)
299 } 308 }
300 309
301 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 310 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); 311 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
312 "Cannot close gnuplot file `%s'\n", gfn);
303 else 313 else
304 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); 314 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
315 "Data successfully written to plot file `%s'\n", gfn);
305 316
306 GNUNET_free (gfn); 317 GNUNET_free (gfn);
307} 318}
@@ -319,7 +330,8 @@ write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp)
319 GNUNET_asprintf (&gfn, "gnuplot_rtt_%s",fn); 330 GNUNET_asprintf (&gfn, "gnuplot_rtt_%s",fn);
320 f = GNUNET_DISK_file_open (gfn, 331 f = GNUNET_DISK_file_open (gfn,
321 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 332 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
322 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 333 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
334 GNUNET_DISK_PERM_USER_WRITE);
323 if (NULL == f) 335 if (NULL == f)
324 { 336 {
325 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 337 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
@@ -364,7 +376,8 @@ write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp)
364 GNUNET_asprintf (&gfn, "gnuplot_bw_%s",fn); 376 GNUNET_asprintf (&gfn, "gnuplot_bw_%s",fn);
365 f = GNUNET_DISK_file_open (gfn, 377 f = GNUNET_DISK_file_open (gfn,
366 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 378 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
367 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 379 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ |
380 GNUNET_DISK_PERM_USER_WRITE);
368 if (NULL == f) 381 if (NULL == f)
369 { 382 {
370 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 383 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
@@ -375,7 +388,8 @@ write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp)
375 /* Write header */ 388 /* Write header */
376 389
377 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE))) 390 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE)))
378 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 391 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
392 "Cannot write data to plot file `%s'\n", gfn);
379 393
380 index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; 394 index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER;
381 for (c_s = 0; c_s < lp->peer->num_partners; c_s++) 395 for (c_s = 0; c_s < lp->peer->num_partners; c_s++)
@@ -413,14 +427,21 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, char *test_name)
413 char *slave_string_tmp; 427 char *slave_string_tmp;
414 struct PeerLoggingTimestep *cur_lt; 428 struct PeerLoggingTimestep *cur_lt;
415 struct PartnerLoggingTimestep *plt; 429 struct PartnerLoggingTimestep *plt;
430 struct GNUNET_TIME_Absolute timestamp;
416 int c_m; 431 int c_m;
417 int c_s; 432 int c_s;
418 433
434 timestamp = GNUNET_TIME_absolute_get();
435
419 for (c_m = 0; c_m < l->num_peers; c_m++) 436 for (c_m = 0; c_m < l->num_peers; c_m++)
420 { 437 {
421 GNUNET_asprintf (&filename, "%s_%llu_master_%u_%s_%s.data", test_name, GNUNET_TIME_absolute_get().abs_value_us, 438 GNUNET_asprintf (&filename, "%s_%llu_master_%u_%s_%s.data", test_name,
439 timestamp.abs_value_us,
422 l->lp[c_m].peer->no, GNUNET_i2s(&l->lp[c_m].peer->id), l->name); 440 l->lp[c_m].peer->no, GNUNET_i2s(&l->lp[c_m].peer->id), l->name);
423 441
442 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Writing master %u to file `%s'\n",
443 c_m, filename);
444
424 f = GNUNET_DISK_file_open (filename, 445 f = GNUNET_DISK_file_open (filename,
425 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 446 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
426 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 447 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
@@ -431,13 +452,27 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, char *test_name)
431 return; 452 return;
432 } 453 }
433 454
455 GNUNET_asprintf (&data, "# master peers: %u ; slave peers: %u ; experiment : %s\n",
456 l->num_peers, l->lp[c_m].peer->num_partners, test_name);
457 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
458 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
459 "Cannot write data to log file `%s'\n", filename);
460 GNUNET_free (data);
461
434 for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) 462 for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next)
435 { 463 {
436 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 464 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
437 "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", l->lp[c_m].peer->no, 465 "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n",
438 cur_lt->timestamp, GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,cur_lt->timestamp).rel_value_us / 1000, 466 l->lp[c_m].peer->no,
439 cur_lt->total_messages_sent, cur_lt->total_bytes_sent, cur_lt->total_throughput_send, 467 cur_lt->timestamp,
440 cur_lt->total_messages_received, cur_lt->total_bytes_received, cur_lt->total_throughput_recv); 468 GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
469 cur_lt->timestamp).rel_value_us / 1000,
470 cur_lt->total_messages_sent,
471 cur_lt->total_bytes_sent,
472 cur_lt->total_throughput_send,
473 cur_lt->total_messages_received,
474 cur_lt->total_bytes_received,
475 cur_lt->total_throughput_recv);
441 476
442 slave_string = GNUNET_strdup (";"); 477 slave_string = GNUNET_strdup (";");
443 for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) 478 for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
@@ -447,42 +482,65 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, char *test_name)
447 482
448 /* Assembling slave string */ 483 /* Assembling slave string */
449 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 484 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
450 "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n", plt->slave->no, 485 "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n",
451 plt->total_messages_sent, plt->total_bytes_sent, plt->throughput_sent, 486 plt->slave->no,
452 plt->total_messages_received, plt->total_bytes_received, plt->throughput_recv, 487 plt->total_messages_sent,
453 plt->app_rtt, plt->ats_delay, 488 plt->total_bytes_sent,
454 plt->bandwidth_in, plt->bandwidth_out); 489 plt->throughput_sent,
455 490 plt->total_messages_received,
456 GNUNET_asprintf(&slave_string_tmp, "%s%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%u;%u;%u;",slave_string, 491 plt->total_bytes_received,
457 plt->total_messages_sent, plt->total_bytes_sent, plt->throughput_sent, 492 plt->throughput_recv,
458 plt->total_messages_received, plt->total_bytes_received, plt->throughput_sent, 493 plt->app_rtt,
494 plt->ats_delay,
495 plt->bandwidth_in,
496 plt->bandwidth_out);
497
498 GNUNET_asprintf(&slave_string_tmp,
499 "%s%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%u;%u;%u;",
500 slave_string,
501 plt->total_messages_sent,
502 plt->total_bytes_sent,
503 plt->throughput_sent,
504 plt->total_messages_received,
505 plt->total_bytes_received,
506 plt->throughput_sent,
459 (double) plt->app_rtt / 1000, 507 (double) plt->app_rtt / 1000,
460 plt->bandwidth_in,plt->bandwidth_out, 508 plt->bandwidth_in,
461 plt->ats_cost_lan, plt->ats_cost_wan, plt->ats_cost_wlan, 509 plt->bandwidth_out,
462 plt->ats_delay, plt->ats_distance, plt->ats_network_type, 510 plt->ats_cost_lan,
463 plt->ats_utilization_up, plt->ats_utilization_down); 511 plt->ats_cost_wan,
512 plt->ats_cost_wlan,
513 plt->ats_delay,
514 plt->ats_distance,
515 plt->ats_network_type,
516 plt->ats_utilization_up,
517 plt->ats_utilization_down);
464 GNUNET_free (slave_string); 518 GNUNET_free (slave_string);
465 slave_string = slave_string_tmp; 519 slave_string = slave_string_tmp;
466 } 520 }
467 /* Assembling master string */ 521 /* Assembling master string */
468
469
470
471 GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;;;;;;;;;;;%s\n", 522 GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;;;;;;;;;;;%s\n",
472 cur_lt->timestamp, 523 cur_lt->timestamp,
473 GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,cur_lt->timestamp).rel_value_us / 1000, 524 GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
474 cur_lt->total_messages_sent, cur_lt->total_bytes_sent, cur_lt->total_throughput_send, 525 cur_lt->timestamp).rel_value_us / 1000,
475 cur_lt->total_messages_received, cur_lt->total_bytes_received, cur_lt->total_throughput_recv, 526 cur_lt->total_messages_sent,
527 cur_lt->total_bytes_sent,
528 cur_lt->total_throughput_send,
529 cur_lt->total_messages_received,
530 cur_lt->total_bytes_received,
531 cur_lt->total_throughput_recv,
476 slave_string); 532 slave_string);
477 GNUNET_free (slave_string); 533 GNUNET_free (slave_string);
478 534
479 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 535 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
480 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", filename); 536 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
537 "Cannot write data to log file `%s'\n", filename);
481 GNUNET_free (data); 538 GNUNET_free (data);
482 } 539 }
483 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 540 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
484 { 541 {
485 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", filename); 542 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
543 "Cannot close log file `%s'\n", filename);
486 GNUNET_free (filename); 544 GNUNET_free (filename);
487 return; 545 return;
488 } 546 }
@@ -491,7 +549,8 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, char *test_name)
491 write_rtt_gnuplot_script (filename, l->lp); 549 write_rtt_gnuplot_script (filename, l->lp);
492 write_bw_gnuplot_script (filename, l->lp); 550 write_bw_gnuplot_script (filename, l->lp);
493 551
494 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data file successfully written to log file `%s'\n", filename); 552 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
553 "Data file successfully written to log file `%s'\n", filename);
495 GNUNET_free (filename); 554 GNUNET_free (filename);
496 } 555 }
497} 556}
@@ -523,11 +582,10 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l)
523 { 582 {
524 bp = &l->lp[c_m]; 583 bp = &l->lp[c_m];
525 mlt = GNUNET_new (struct PeerLoggingTimestep); 584 mlt = GNUNET_new (struct PeerLoggingTimestep);
526 GNUNET_CONTAINER_DLL_insert_tail(bp->head, bp->tail, mlt); 585 GNUNET_CONTAINER_DLL_insert_tail(l->lp[c_m].head, l->lp[c_m].tail, mlt);
527 prev_log_mlt = mlt->prev; 586 prev_log_mlt = mlt->prev;
528 587
529 /* Collect data */ 588 /* Collect data */
530
531 /* Current master state */ 589 /* Current master state */
532 mlt->timestamp = GNUNET_TIME_absolute_get(); 590 mlt->timestamp = GNUNET_TIME_absolute_get();
533 mlt->total_bytes_sent = bp->peer->total_bytes_sent; 591 mlt->total_bytes_sent = bp->peer->total_bytes_sent;
@@ -574,6 +632,10 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l)
574 632
575 for (c_s = 0; c_s < bp->peer->num_partners; c_s++) 633 for (c_s = 0; c_s < bp->peer->num_partners; c_s++)
576 { 634 {
635
636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
637 "Collect logging data master[%u] slave [%u]\n", c_m, c_s);
638
577 p = &bp->peer->partners[c_s]; 639 p = &bp->peer->partners[c_s];
578 slt = &mlt->slaves_log[c_s]; 640 slt = &mlt->slaves_log[c_s];
579 641