aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests/perf_ats_logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats-tests/perf_ats_logging.c')
-rw-r--r--src/ats-tests/perf_ats_logging.c713
1 files changed, 392 insertions, 321 deletions
diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c
index e0f192ae4..41c50ea6e 100644
--- a/src/ats-tests/perf_ats_logging.c
+++ b/src/ats-tests/perf_ats_logging.c
@@ -72,7 +72,7 @@
72/** 72/**
73 * Logging task 73 * Logging task
74 */ 74 */
75static struct GNUNET_SCHEDULER_Task * log_task; 75static struct GNUNET_SCHEDULER_Task *log_task;
76 76
77/** 77/**
78 * Reference to perf_ats' masters 78 * Reference to perf_ats' masters
@@ -85,7 +85,8 @@ static struct GNUNET_TIME_Relative frequency;
85/** 85/**
86 * A single logging time step for a partner 86 * A single logging time step for a partner
87 */ 87 */
88struct PartnerLoggingTimestep { 88struct PartnerLoggingTimestep
89{
89 /** 90 /**
90 * Peer 91 * Peer
91 */ 92 */
@@ -158,7 +159,8 @@ struct PartnerLoggingTimestep {
158/** 159/**
159 * A single logging time step for a peer 160 * A single logging time step for a peer
160 */ 161 */
161struct PeerLoggingTimestep { 162struct PeerLoggingTimestep
163{
162 /** 164 /**
163 * Next in DLL 165 * Next in DLL
164 */ 166 */
@@ -213,7 +215,8 @@ struct PeerLoggingTimestep {
213/** 215/**
214 * Entry for a benchmark peer 216 * Entry for a benchmark peer
215 */ 217 */
216struct LoggingPeer { 218struct LoggingPeer
219{
217 /** 220 /**
218 * Peer 221 * Peer
219 */ 222 */
@@ -242,164 +245,200 @@ static struct LoggingPeer *lp;
242 245
243 246
244static void 247static void
245write_throughput_gnuplot_script(char * fn, struct LoggingPeer *lp) 248write_throughput_gnuplot_script (char *fn, struct LoggingPeer *lp)
246{ 249{
247 struct GNUNET_DISK_FileHandle *f; 250 struct GNUNET_DISK_FileHandle *f;
248 char * gfn; 251 char *gfn;
249 char *data; 252 char *data;
250 int c_s; 253 int c_s;
251 int peer_index; 254 int peer_index;
252 255
253 GNUNET_asprintf(&gfn, "gnuplot_throughput_%s", fn); 256 GNUNET_asprintf (&gfn, "gnuplot_throughput_%s", fn);
254 f = GNUNET_DISK_file_open(gfn, 257 f = GNUNET_DISK_file_open (gfn,
255 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 258 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
256 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 259 GNUNET_DISK_PERM_USER_EXEC
260 | GNUNET_DISK_PERM_USER_READ
261 | GNUNET_DISK_PERM_USER_WRITE);
257 if (NULL == f) 262 if (NULL == f)
258 { 263 {
259 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 264 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n",
260 GNUNET_free(gfn); 265 gfn);
261 return; 266 GNUNET_free (gfn);
262 } 267 return;
268 }
263 269
264 /* Write header */ 270 /* Write header */
265 271
266 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, strlen(THROUGHPUT_TEMPLATE))) 272 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, THROUGHPUT_TEMPLATE, strlen (
267 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 273 THROUGHPUT_TEMPLATE)))
274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
275 "Cannot write data to plot file `%s'\n", gfn);
268 276
269 /* Write master data */ 277 /* Write master data */
270 peer_index = LOG_ITEMS_TIME; 278 peer_index = LOG_ITEMS_TIME;
271 GNUNET_asprintf(&data, "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ 279 GNUNET_asprintf (&data,
272 "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", 280 "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \
273 fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, 281 "'%s' using 2:%u with lines title 'Master %u receive total', \\\n",
274 fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); 282 fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no,
275 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 283 fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no);
276 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 284 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
277 GNUNET_free(data); 285 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
286 "Cannot write data to plot file `%s'\n", gfn);
287 GNUNET_free (data);
278 288
279 peer_index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; 289 peer_index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER;
280 for (c_s = 0; c_s < lp->peer->num_partners; c_s++) 290 for (c_s = 0; c_s < lp->peer->num_partners; c_s++)
281 { 291 {
282 GNUNET_asprintf(&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ 292 GNUNET_asprintf (&data,
283 "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", 293 "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \
284 fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, lp->peer->partners[c_s].dest->no, 294 "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n",
285 fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no, lp->peer->partners[c_s].dest->no, 295 fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no,
286 (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); 296 lp->peer->partners[c_s].dest->no,
287 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 297 fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no,
288 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 298 lp->peer->partners[c_s].dest->no,
289 GNUNET_free(data); 299 (c_s < lp->peer->num_partners - 1) ? ", \\" :
290 peer_index += LOG_ITEMS_PER_PEER; 300 "\n pause -1");
291 } 301 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
292 302 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
293 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 303 "Cannot write data to plot file `%s'\n", gfn);
294 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); 304 GNUNET_free (data);
305 peer_index += LOG_ITEMS_PER_PEER;
306 }
307
308 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f))
309 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n",
310 gfn);
295 else 311 else
296 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); 312 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
313 "Data successfully written to plot file `%s'\n", gfn);
297 314
298 GNUNET_free(gfn); 315 GNUNET_free (gfn);
299} 316}
300 317
301 318
302static void 319static void
303write_rtt_gnuplot_script(char * fn, struct LoggingPeer *lp) 320write_rtt_gnuplot_script (char *fn, struct LoggingPeer *lp)
304{ 321{
305 struct GNUNET_DISK_FileHandle *f; 322 struct GNUNET_DISK_FileHandle *f;
306 char * gfn; 323 char *gfn;
307 char *data; 324 char *data;
308 int c_s; 325 int c_s;
309 int index; 326 int index;
310 327
311 GNUNET_asprintf(&gfn, "gnuplot_rtt_%s", fn); 328 GNUNET_asprintf (&gfn, "gnuplot_rtt_%s", fn);
312 f = GNUNET_DISK_file_open(gfn, 329 f = GNUNET_DISK_file_open (gfn,
313 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 330 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
314 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 331 GNUNET_DISK_PERM_USER_EXEC
332 | GNUNET_DISK_PERM_USER_READ
333 | GNUNET_DISK_PERM_USER_WRITE);
315 if (NULL == f) 334 if (NULL == f)
316 { 335 {
317 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 336 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n",
318 GNUNET_free(gfn); 337 gfn);
319 return; 338 GNUNET_free (gfn);
320 } 339 return;
340 }
321 341
322 /* Write header */ 342 /* Write header */
323 343
324 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 (
325 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 345 RTT_TEMPLATE)))
346 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
347 "Cannot write data to plot file `%s'\n", gfn);
326 348
327 index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; 349 index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER;
328 for (c_s = 0; c_s < lp->peer->num_partners; c_s++) 350 for (c_s = 0; c_s < lp->peer->num_partners; c_s++)
329 { 351 {
330 GNUNET_asprintf(&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", 352 GNUNET_asprintf (&data,
331 (0 == c_s) ? "plot " : "", 353 "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n",
332 fn, index + LOG_ITEM_APP_RTT, lp->peer->no, lp->peer->partners[c_s].dest->no, 354 (0 == c_s) ? "plot " : "",
333 (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); 355 fn, index + LOG_ITEM_APP_RTT, lp->peer->no,
334 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 356 lp->peer->partners[c_s].dest->no,
335 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 357 (c_s < lp->peer->num_partners - 1) ? ", \\" :
336 GNUNET_free(data); 358 "\n pause -1");
337 index += LOG_ITEMS_PER_PEER; 359 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
338 } 360 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
339 361 "Cannot write data to plot file `%s'\n", gfn);
340 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 362 GNUNET_free (data);
341 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); 363 index += LOG_ITEMS_PER_PEER;
364 }
365
366 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f))
367 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n",
368 gfn);
342 else 369 else
343 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); 370 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
344 GNUNET_free(gfn); 371 "Data successfully written to plot file `%s'\n", gfn);
372 GNUNET_free (gfn);
345} 373}
346 374
347static void 375static void
348write_bw_gnuplot_script(char * fn, struct LoggingPeer *lp) 376write_bw_gnuplot_script (char *fn, struct LoggingPeer *lp)
349{ 377{
350 struct GNUNET_DISK_FileHandle *f; 378 struct GNUNET_DISK_FileHandle *f;
351 char * gfn; 379 char *gfn;
352 char *data; 380 char *data;
353 int c_s; 381 int c_s;
354 int index; 382 int index;
355 383
356 GNUNET_asprintf(&gfn, "gnuplot_bw_%s", fn); 384 GNUNET_asprintf (&gfn, "gnuplot_bw_%s", fn);
357 f = GNUNET_DISK_file_open(gfn, 385 f = GNUNET_DISK_file_open (gfn,
358 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 386 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
359 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 387 GNUNET_DISK_PERM_USER_EXEC
388 | GNUNET_DISK_PERM_USER_READ
389 | GNUNET_DISK_PERM_USER_WRITE);
360 if (NULL == f) 390 if (NULL == f)
361 { 391 {
362 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 392 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n",
363 GNUNET_free(gfn); 393 gfn);
364 return; 394 GNUNET_free (gfn);
365 } 395 return;
396 }
366 397
367 /* Write header */ 398 /* Write header */
368 399
369 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE))) 400 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, BW_TEMPLATE, strlen (
370 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 401 BW_TEMPLATE)))
402 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
403 "Cannot write data to plot file `%s'\n", gfn);
371 404
372 index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; 405 index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER;
373 for (c_s = 0; c_s < lp->peer->num_partners; c_s++) 406 for (c_s = 0; c_s < lp->peer->num_partners; c_s++)
374 { 407 {
375 GNUNET_asprintf(&data, "%s" \ 408 GNUNET_asprintf (&data, "%s" \
376 "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ 409 "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \
377 "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \ 410 "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \
378 "%s\n", 411 "%s\n",
379 (0 == c_s) ? "plot " : "", 412 (0 == c_s) ? "plot " : "",
380 fn, index + LOG_ITEM_ATS_BW_OUT, lp->peer->no, lp->peer->partners[c_s].dest->no, 413 fn, index + LOG_ITEM_ATS_BW_OUT, lp->peer->no,
381 fn, index + LOG_ITEM_ATS_BW_IN, lp->peer->no, lp->peer->partners[c_s].dest->no, 414 lp->peer->partners[c_s].dest->no,
382 (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); 415 fn, index + LOG_ITEM_ATS_BW_IN, lp->peer->no,
383 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 416 lp->peer->partners[c_s].dest->no,
384 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 417 (c_s < lp->peer->num_partners - 1) ? ", \\" :
385 GNUNET_free(data); 418 "\n pause -1");
386 index += LOG_ITEMS_PER_PEER; 419 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
387 } 420 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
388 421 "Cannot write data to plot file `%s'\n", gfn);
389 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 422 GNUNET_free (data);
390 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); 423 index += LOG_ITEMS_PER_PEER;
424 }
425
426 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f))
427 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n",
428 gfn);
391 else 429 else
392 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); 430 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
393 GNUNET_free(gfn); 431 "Data successfully written to plot file `%s'\n", gfn);
432 GNUNET_free (gfn);
394} 433}
395 434
396 435
397static void 436static void
398write_to_file() 437write_to_file ()
399{ 438{
400 struct GNUNET_DISK_FileHandle *f; 439 struct GNUNET_DISK_FileHandle *f;
401 440
402 char * filename; 441 char *filename;
403 char *data; 442 char *data;
404 char *slave_string; 443 char *slave_string;
405 char *slave_string_tmp; 444 char *slave_string_tmp;
@@ -409,88 +448,112 @@ write_to_file()
409 int c_s; 448 int c_s;
410 449
411 for (c_m = 0; c_m < num_peers; c_m++) 450 for (c_m = 0; c_m < num_peers; c_m++)
451 {
452 GNUNET_asprintf (&filename, "%llu_master_%u_%s_%s.data",
453 GNUNET_TIME_absolute_get ().abs_value_us,
454 lp[c_m].peer->no, GNUNET_i2s (&lp[c_m].peer->id), name);
455
456 f = GNUNET_DISK_file_open (filename,
457 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
458 GNUNET_DISK_PERM_USER_READ
459 | GNUNET_DISK_PERM_USER_WRITE);
460 if (NULL == f)
412 { 461 {
413 GNUNET_asprintf(&filename, "%llu_master_%u_%s_%s.data", GNUNET_TIME_absolute_get().abs_value_us, 462 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n",
414 lp[c_m].peer->no, GNUNET_i2s(&lp[c_m].peer->id), name); 463 filename);
415 464 GNUNET_free (filename);
416 f = GNUNET_DISK_file_open(filename, 465 return;
417 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
418 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
419 if (NULL == f)
420 {
421 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename);
422 GNUNET_free(filename);
423 return;
424 }
425
426 for (cur_lt = lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next)
427 {
428 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
429 "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", lp[c_m].peer->no,
430 cur_lt->timestamp, GNUNET_TIME_absolute_get_difference(lp[c_m].start, cur_lt->timestamp).rel_value_us / 1000,
431 cur_lt->total_messages_sent, cur_lt->total_bytes_sent, cur_lt->total_throughput_send,
432 cur_lt->total_messages_received, cur_lt->total_bytes_received, cur_lt->total_throughput_recv);
433
434 slave_string = GNUNET_strdup(";");
435 for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++)
436 {
437 plt = &cur_lt->slaves_log[c_s];
438 /* Log partners */
439
440 /* Assembling slave string */
441 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
442 "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n", plt->slave->no,
443 plt->total_messages_sent, plt->total_bytes_sent, plt->throughput_sent,
444 plt->total_messages_received, plt->total_bytes_received, plt->throughput_recv,
445 plt->app_rtt, plt->ats_delay,
446 plt->bandwidth_in, plt->bandwidth_out);
447
448 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,
449 plt->total_messages_sent, plt->total_bytes_sent, plt->throughput_sent,
450 plt->total_messages_received, plt->total_bytes_received, plt->throughput_sent,
451 (double)plt->app_rtt / 1000,
452 plt->bandwidth_in, plt->bandwidth_out,
453 plt->ats_cost_lan, plt->ats_cost_wan, plt->ats_cost_wlan,
454 plt->ats_delay, plt->ats_distance, plt->ats_network_type,
455 plt->ats_utilization_up, plt->ats_utilization_down);
456 GNUNET_free(slave_string);
457 slave_string = slave_string_tmp;
458 }
459 /* Assembling master string */
460
461
462
463 GNUNET_asprintf(&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;;;;;;;;;;;%s\n",
464 cur_lt->timestamp,
465 GNUNET_TIME_absolute_get_difference(lp[c_m].start, cur_lt->timestamp).rel_value_us / 1000,
466 cur_lt->total_messages_sent, cur_lt->total_bytes_sent, cur_lt->total_throughput_send,
467 cur_lt->total_messages_received, cur_lt->total_bytes_received, cur_lt->total_throughput_recv,
468 slave_string);
469 GNUNET_free(slave_string);
470
471 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
472 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", filename);
473 GNUNET_free(data);
474 }
475 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f))
476 {
477 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", filename);
478 GNUNET_free(filename);
479 return;
480 }
481
482 write_throughput_gnuplot_script(filename, lp);
483 write_rtt_gnuplot_script(filename, lp);
484 write_bw_gnuplot_script(filename, lp);
485
486 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data file successfully written to log file `%s'\n", filename);
487 GNUNET_free(filename);
488 } 466 }
467
468 for (cur_lt = lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next)
469 {
470 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
471 "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n",
472 lp[c_m].peer->no,
473 cur_lt->timestamp, GNUNET_TIME_absolute_get_difference (
474 lp[c_m].start, cur_lt->timestamp).rel_value_us / 1000,
475 cur_lt->total_messages_sent, cur_lt->total_bytes_sent,
476 cur_lt->total_throughput_send,
477 cur_lt->total_messages_received, cur_lt->total_bytes_received,
478 cur_lt->total_throughput_recv);
479
480 slave_string = GNUNET_strdup (";");
481 for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++)
482 {
483 plt = &cur_lt->slaves_log[c_s];
484 /* Log partners */
485
486 /* Assembling slave string */
487 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
488 "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n",
489 plt->slave->no,
490 plt->total_messages_sent, plt->total_bytes_sent,
491 plt->throughput_sent,
492 plt->total_messages_received, plt->total_bytes_received,
493 plt->throughput_recv,
494 plt->app_rtt, plt->ats_delay,
495 plt->bandwidth_in, plt->bandwidth_out);
496
497 GNUNET_asprintf (&slave_string_tmp,
498 "%s%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%u;%u;%u;",
499 slave_string,
500 plt->total_messages_sent, plt->total_bytes_sent,
501 plt->throughput_sent,
502 plt->total_messages_received,
503 plt->total_bytes_received, plt->throughput_sent,
504 (double) plt->app_rtt / 1000,
505 plt->bandwidth_in, plt->bandwidth_out,
506 plt->ats_cost_lan, plt->ats_cost_wan,
507 plt->ats_cost_wlan,
508 plt->ats_delay, plt->ats_distance,
509 plt->ats_network_type,
510 plt->ats_utilization_up, plt->ats_utilization_down);
511 GNUNET_free (slave_string);
512 slave_string = slave_string_tmp;
513 }
514 /* Assembling master string */
515
516
517
518 GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;;;;;;;;;;;%s\n",
519 cur_lt->timestamp,
520 GNUNET_TIME_absolute_get_difference (lp[c_m].start,
521 cur_lt->timestamp).
522 rel_value_us / 1000,
523 cur_lt->total_messages_sent, cur_lt->total_bytes_sent,
524 cur_lt->total_throughput_send,
525 cur_lt->total_messages_received,
526 cur_lt->total_bytes_received,
527 cur_lt->total_throughput_recv,
528 slave_string);
529 GNUNET_free (slave_string);
530
531 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
532 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
533 "Cannot write data to log file `%s'\n", filename);
534 GNUNET_free (data);
535 }
536 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f))
537 {
538 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n",
539 filename);
540 GNUNET_free (filename);
541 return;
542 }
543
544 write_throughput_gnuplot_script (filename, lp);
545 write_rtt_gnuplot_script (filename, lp);
546 write_bw_gnuplot_script (filename, lp);
547
548 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
549 "Data file successfully written to log file `%s'\n", filename);
550 GNUNET_free (filename);
551 }
489} 552}
490 553
491 554
492void 555void
493collect_log_now(void) 556collect_log_now (void)
494{ 557{
495 struct LoggingPeer *bp; 558 struct LoggingPeer *bp;
496 struct PeerLoggingTimestep *mlt; 559 struct PeerLoggingTimestep *mlt;
@@ -508,143 +571,150 @@ collect_log_now(void)
508 return; 571 return;
509 572
510 for (c_m = 0; c_m < num_peers; c_m++) 573 for (c_m = 0; c_m < num_peers; c_m++)
574 {
575 bp = &lp[c_m];
576 mlt = GNUNET_new (struct PeerLoggingTimestep);
577 GNUNET_CONTAINER_DLL_insert_tail (bp->head, bp->tail, mlt);
578 prev_log_mlt = mlt->prev;
579
580 /* Collect data */
581
582 /* Current master state */
583 mlt->timestamp = GNUNET_TIME_absolute_get ();
584 mlt->total_bytes_sent = bp->peer->total_bytes_sent;
585 mlt->total_messages_sent = bp->peer->total_messages_sent;
586 mlt->total_bytes_received = bp->peer->total_bytes_received;
587 mlt->total_messages_received = bp->peer->total_messages_received;
588
589 /* Throughput */
590 if (NULL == prev_log_mlt)
591 {
592 /* Get difference to start */
593 delta = GNUNET_TIME_absolute_get_difference (lp[c_m].start,
594 mlt->timestamp);
595 }
596 else
511 { 597 {
512 bp = &lp[c_m]; 598 /* Get difference to last timestep */
513 mlt = GNUNET_new(struct PeerLoggingTimestep); 599 delta = GNUNET_TIME_absolute_get_difference (mlt->prev->timestamp,
514 GNUNET_CONTAINER_DLL_insert_tail(bp->head, bp->tail, mlt); 600 mlt->timestamp);
515 prev_log_mlt = mlt->prev; 601 }
516 602
517 /* Collect data */ 603 /* Multiplication factor for throughput calculation */
604 mult = (1.0 * 1000 * 1000) / (delta.rel_value_us);
518 605
519 /* Current master state */ 606 /* Total throughput */
520 mlt->timestamp = GNUNET_TIME_absolute_get(); 607 if (NULL != prev_log_mlt)
521 mlt->total_bytes_sent = bp->peer->total_bytes_sent; 608 {
522 mlt->total_messages_sent = bp->peer->total_messages_sent; 609 if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0)
523 mlt->total_bytes_received = bp->peer->total_bytes_received; 610 mlt->total_throughput_send = mult * (mlt->total_bytes_sent
524 mlt->total_messages_received = bp->peer->total_messages_received; 611 - mlt->prev->total_bytes_sent);
612 else
613 mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */
525 614
526 /* Throughput */ 615 if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0)
527 if (NULL == prev_log_mlt) 616 mlt->total_throughput_recv = mult * (mlt->total_bytes_received
528 { 617 - mlt->prev->total_bytes_received);
529 /* Get difference to start */
530 delta = GNUNET_TIME_absolute_get_difference(lp[c_m].start, mlt->timestamp);
531 }
532 else 618 else
533 { 619 mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */
534 /* Get difference to last timestep */ 620 }
535 delta = GNUNET_TIME_absolute_get_difference(mlt->prev->timestamp, mlt->timestamp); 621 else
536 } 622 {
623 mlt->total_throughput_send = mult * mlt->total_bytes_sent;
624 mlt->total_throughput_send = mult * mlt->total_bytes_received;
625 }
537 626
538 /* Multiplication factor for throughput calculation */ 627 mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners
539 mult = (1.0 * 1000 * 1000) / (delta.rel_value_us); 628 * sizeof(struct PartnerLoggingTimestep));
540 629
541 /* Total throughput */ 630 for (c_s = 0; c_s < bp->peer->num_partners; c_s++)
631 {
632 p = &bp->peer->partners[c_s];
633 slt = &mlt->slaves_log[c_s];
634
635 slt->slave = p->dest;
636 /* Bytes sent from master to this slave */
637 slt->total_bytes_sent = p->bytes_sent;
638 /* Messages sent from master to this slave */
639 slt->total_messages_sent = p->messages_sent;
640 /* Bytes master received from this slave */
641 slt->total_bytes_received = p->bytes_received;
642 /* Messages master received from this slave */
643 slt->total_messages_received = p->messages_received;
644 slt->total_app_rtt = p->total_app_rtt;
645 /* ats performance information */
646 slt->ats_cost_lan = p->ats_cost_lan;
647 slt->ats_cost_wan = p->ats_cost_wan;
648 slt->ats_cost_wlan = p->ats_cost_wlan;
649 slt->ats_delay = p->ats_delay;
650 slt->ats_distance = p->ats_distance;
651 slt->ats_network_type = p->ats_network_type;
652 slt->ats_utilization_down = p->ats_utilization_down;
653 slt->ats_utilization_up = p->ats_utilization_up;
654 slt->bandwidth_in = p->bandwidth_in;
655 slt->bandwidth_out = p->bandwidth_out;
656
657 /* Total application level rtt */
658 if (NULL == prev_log_mlt)
659 {
660 if (0 != slt->total_messages_sent)
661 app_rtt = slt->total_app_rtt / slt->total_messages_sent;
662 else
663 app_rtt = 0;
664 }
665 else
666 {
667 prev_log_slt = &prev_log_mlt->slaves_log[c_s];
668 if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0)
669 app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt)
670 / (slt->total_messages_sent
671 - prev_log_slt->total_messages_sent);
672 else
673 app_rtt = prev_log_slt->app_rtt; /* No messages were */
674 }
675 slt->app_rtt = app_rtt;
676
677 /* Partner throughput */
542 if (NULL != prev_log_mlt) 678 if (NULL != prev_log_mlt)
543 { 679 {
544 if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) 680 prev_log_slt = &prev_log_mlt->slaves_log[c_s];
545 mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent); 681 if (slt->total_bytes_sent - prev_log_slt->total_bytes_sent > 0)
546 else 682 slt->throughput_sent = mult * (slt->total_bytes_sent
547 mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ 683 - prev_log_slt->total_bytes_sent);
548 684 else
549 if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) 685 slt->throughput_sent = prev_log_slt->throughput_sent; /* no msgs send */
550 mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received); 686
551 else 687 if (slt->total_bytes_received - prev_log_slt->total_bytes_received > 0)
552 mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ 688 slt->throughput_recv = mult * (slt->total_bytes_received
553 } 689 - prev_log_slt->total_bytes_received);
690 else
691 slt->throughput_recv = prev_log_slt->throughput_recv; /* no msgs received */
692 }
554 else 693 else
555 { 694 {
556 mlt->total_throughput_send = mult * mlt->total_bytes_sent; 695 slt->throughput_sent = mult * slt->total_bytes_sent;
557 mlt->total_throughput_send = mult * mlt->total_bytes_received; 696 slt->throughput_sent = mult * slt->total_bytes_received;
558 } 697 }
559 698
560 mlt->slaves_log = GNUNET_malloc(bp->peer->num_partners * 699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
561 sizeof(struct PartnerLoggingTimestep)); 700 "Master [%u]: slave [%u]\n",
562 701 bp->peer->no, p->dest->no);
563 for (c_s = 0; c_s < bp->peer->num_partners; c_s++)
564 {
565 p = &bp->peer->partners[c_s];
566 slt = &mlt->slaves_log[c_s];
567
568 slt->slave = p->dest;
569 /* Bytes sent from master to this slave */
570 slt->total_bytes_sent = p->bytes_sent;
571 /* Messages sent from master to this slave */
572 slt->total_messages_sent = p->messages_sent;
573 /* Bytes master received from this slave */
574 slt->total_bytes_received = p->bytes_received;
575 /* Messages master received from this slave */
576 slt->total_messages_received = p->messages_received;
577 slt->total_app_rtt = p->total_app_rtt;
578 /* ats performance information */
579 slt->ats_cost_lan = p->ats_cost_lan;
580 slt->ats_cost_wan = p->ats_cost_wan;
581 slt->ats_cost_wlan = p->ats_cost_wlan;
582 slt->ats_delay = p->ats_delay;
583 slt->ats_distance = p->ats_distance;
584 slt->ats_network_type = p->ats_network_type;
585 slt->ats_utilization_down = p->ats_utilization_down;
586 slt->ats_utilization_up = p->ats_utilization_up;
587 slt->bandwidth_in = p->bandwidth_in;
588 slt->bandwidth_out = p->bandwidth_out;
589
590 /* Total application level rtt */
591 if (NULL == prev_log_mlt)
592 {
593 if (0 != slt->total_messages_sent)
594 app_rtt = slt->total_app_rtt / slt->total_messages_sent;
595 else
596 app_rtt = 0;
597 }
598 else
599 {
600 prev_log_slt = &prev_log_mlt->slaves_log[c_s];
601 if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0)
602 app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) /
603 (slt->total_messages_sent - prev_log_slt->total_messages_sent);
604 else
605 app_rtt = prev_log_slt->app_rtt; /* No messages were */
606 }
607 slt->app_rtt = app_rtt;
608
609 /* Partner throughput */
610 if (NULL != prev_log_mlt)
611 {
612 prev_log_slt = &prev_log_mlt->slaves_log[c_s];
613 if (slt->total_bytes_sent - prev_log_slt->total_bytes_sent > 0)
614 slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent);
615 else
616 slt->throughput_sent = prev_log_slt->throughput_sent; /* no msgs send */
617
618 if (slt->total_bytes_received - prev_log_slt->total_bytes_received > 0)
619 slt->throughput_recv = mult * (slt->total_bytes_received - prev_log_slt->total_bytes_received);
620 else
621 slt->throughput_recv = prev_log_slt->throughput_recv; /* no msgs received */
622 }
623 else
624 {
625 slt->throughput_sent = mult * slt->total_bytes_sent;
626 slt->throughput_sent = mult * slt->total_bytes_received;
627 }
628
629 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
630 "Master [%u]: slave [%u]\n",
631 bp->peer->no, p->dest->no);
632 }
633 } 702 }
703 }
634} 704}
635 705
636static void 706static void
637collect_log_task(void *cls) 707collect_log_task (void *cls)
638{ 708{
639 log_task = NULL; 709 log_task = NULL;
640 collect_log_now(); 710 collect_log_now ();
641 log_task = GNUNET_SCHEDULER_add_delayed(frequency, 711 log_task = GNUNET_SCHEDULER_add_delayed (frequency,
642 &collect_log_task, NULL); 712 &collect_log_task, NULL);
643} 713}
644 714
645 715
646void 716void
647perf_logging_stop() 717perf_logging_stop ()
648{ 718{
649 int c_m; 719 int c_m;
650 struct PeerLoggingTimestep *cur; 720 struct PeerLoggingTimestep *cur;
@@ -653,54 +723,55 @@ perf_logging_stop()
653 return; 723 return;
654 724
655 if (NULL != log_task) 725 if (NULL != log_task)
656 { 726 {
657 GNUNET_SCHEDULER_cancel(log_task); 727 GNUNET_SCHEDULER_cancel (log_task);
658 log_task = NULL; 728 log_task = NULL;
659 } 729 }
660 collect_log_task(NULL); 730 collect_log_task (NULL);
661 731
662 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 732 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
663 _("Stop logging\n")); 733 _ ("Stop logging\n"));
664 734
665 write_to_file(); 735 write_to_file ();
666 736
667 for (c_m = 0; c_m < num_peers; c_m++) 737 for (c_m = 0; c_m < num_peers; c_m++)
738 {
739 while (NULL != (cur = lp[c_m].head))
668 { 740 {
669 while (NULL != (cur = lp[c_m].head)) 741 GNUNET_CONTAINER_DLL_remove (lp[c_m].head, lp[c_m].tail, cur);
670 { 742 GNUNET_free (cur->slaves_log);
671 GNUNET_CONTAINER_DLL_remove(lp[c_m].head, lp[c_m].tail, cur); 743 GNUNET_free (cur);
672 GNUNET_free(cur->slaves_log);
673 GNUNET_free(cur);
674 }
675 } 744 }
745 }
676 746
677 GNUNET_free(lp); 747 GNUNET_free (lp);
678} 748}
679 749
680 750
681void 751void
682perf_logging_start(struct GNUNET_TIME_Relative log_frequency, 752perf_logging_start (struct GNUNET_TIME_Relative log_frequency,
683 char * testname, struct BenchmarkPeer *masters, int num_masters) 753 char *testname, struct BenchmarkPeer *masters, int
754 num_masters)
684{ 755{
685 int c_m; 756 int c_m;
686 757
687 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 758 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
688 _("Start logging `%s'\n"), testname); 759 _ ("Start logging `%s'\n"), testname);
689 760
690 num_peers = num_masters; 761 num_peers = num_masters;
691 name = testname; 762 name = testname;
692 frequency = log_frequency; 763 frequency = log_frequency;
693 764
694 lp = GNUNET_malloc(num_masters * sizeof(struct LoggingPeer)); 765 lp = GNUNET_malloc (num_masters * sizeof(struct LoggingPeer));
695 766
696 for (c_m = 0; c_m < num_masters; c_m++) 767 for (c_m = 0; c_m < num_masters; c_m++)
697 { 768 {
698 lp[c_m].peer = &masters[c_m]; 769 lp[c_m].peer = &masters[c_m];
699 lp[c_m].start = GNUNET_TIME_absolute_get(); 770 lp[c_m].start = GNUNET_TIME_absolute_get ();
700 } 771 }
701 772
702 /* Schedule logging task */ 773 /* Schedule logging task */
703 log_task = GNUNET_SCHEDULER_add_now(&collect_log_task, NULL); 774 log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, NULL);
704 running = GNUNET_YES; 775 running = GNUNET_YES;
705} 776}
706/* end of file perf_ats_logging.c */ 777/* end of file perf_ats_logging.c */