summaryrefslogtreecommitdiff
path: root/src/ats-tests/ats-testing-log.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/ats-tests/ats-testing-log.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/ats-tests/ats-testing-log.c')
-rw-r--r--src/ats-tests/ats-testing-log.c1023
1 files changed, 543 insertions, 480 deletions
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c
index a362955d2..12a08ffda 100644
--- a/src/ats-tests/ats-testing-log.c
+++ b/src/ats-tests/ats-testing-log.c
@@ -72,7 +72,8 @@
72/** 72/**
73 * A single logging time step for a partner 73 * A single logging time step for a partner
74 */ 74 */
75struct PartnerLoggingTimestep { 75struct PartnerLoggingTimestep
76{
76 /** 77 /**
77 * Peer 78 * Peer
78 */ 79 */
@@ -142,7 +143,8 @@ struct PartnerLoggingTimestep {
142/** 143/**
143 * A single logging time step for a peer 144 * A single logging time step for a peer
144 */ 145 */
145struct PeerLoggingTimestep { 146struct PeerLoggingTimestep
147{
146 /** 148 /**
147 * Next in DLL 149 * Next in DLL
148 */ 150 */
@@ -197,7 +199,8 @@ struct PeerLoggingTimestep {
197/** 199/**
198 * Entry for a benchmark peer 200 * Entry for a benchmark peer
199 */ 201 */
200struct LoggingPeer { 202struct LoggingPeer
203{
201 /** 204 /**
202 * Peer 205 * Peer
203 */ 206 */
@@ -219,7 +222,8 @@ struct LoggingPeer {
219 struct PeerLoggingTimestep *tail; 222 struct PeerLoggingTimestep *tail;
220}; 223};
221 224
222struct LoggingHandle { 225struct LoggingHandle
226{
223 /** 227 /**
224 * Logging task 228 * Logging task
225 */ 229 */
@@ -244,179 +248,205 @@ struct LoggingHandle {
244 248
245 249
246static void 250static void
247write_throughput_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves) 251write_throughput_gnuplot_script (char *fn, struct LoggingPeer *lp, char **fs,
252 int slaves)
248{ 253{
249 struct GNUNET_DISK_FileHandle *f; 254 struct GNUNET_DISK_FileHandle *f;
250 char * gfn; 255 char *gfn;
251 char *data; 256 char *data;
252 int c_s; 257 int c_s;
253 258
254 GNUNET_asprintf(&gfn, "gnuplot_throughput_%s", fn); 259 GNUNET_asprintf (&gfn, "gnuplot_throughput_%s", fn);
255 fprintf(stderr, "Writing throughput plot for master %u and %u slaves to `%s'\n", 260 fprintf (stderr,
256 lp->peer->no, slaves, gfn); 261 "Writing throughput plot for master %u and %u slaves to `%s'\n",
262 lp->peer->no, slaves, gfn);
257 263
258 f = GNUNET_DISK_file_open(gfn, 264 f = GNUNET_DISK_file_open (gfn,
259 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 265 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
260 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | 266 GNUNET_DISK_PERM_USER_EXEC
261 GNUNET_DISK_PERM_USER_WRITE); 267 | GNUNET_DISK_PERM_USER_READ
268 | GNUNET_DISK_PERM_USER_WRITE);
262 if (NULL == f) 269 if (NULL == f)
263 { 270 {
264 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 271 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n",
265 GNUNET_free(gfn); 272 gfn);
266 return; 273 GNUNET_free (gfn);
267 } 274 return;
275 }
268 276
269 /* Write header */ 277 /* Write header */
270 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, 278 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, THROUGHPUT_TEMPLATE,
271 strlen(THROUGHPUT_TEMPLATE))) 279 strlen (THROUGHPUT_TEMPLATE)))
272 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 280 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
273 "Cannot write data to plot file `%s'\n", gfn); 281 "Cannot write data to plot file `%s'\n", gfn);
274 282
275 /* Write master data */ 283 /* Write master data */
276 GNUNET_asprintf(&data, 284 GNUNET_asprintf (&data,
277 "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ 285 "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \
278 "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", 286 "'%s' using 2:%u with lines title 'Master %u receive total', \\\n",
279 fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, 287 fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no,
280 fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); 288 fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no);
281 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 289 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
282 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 290 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
283 GNUNET_free(data); 291 "Cannot write data to plot file `%s'\n", gfn);
292 GNUNET_free (data);
284 293
285 for (c_s = 0; c_s < slaves; c_s++) 294 for (c_s = 0; c_s < slaves; c_s++)
286 { 295 {
287 GNUNET_asprintf(&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ 296 GNUNET_asprintf (&data,
288 "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", 297 "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \
289 fs[c_s], 298 "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n",
290 LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, 299 fs[c_s],
291 lp->peer->no, 300 LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT,
292 lp->peer->partners[c_s].dest->no, 301 lp->peer->no,
293 fs[c_s], 302 lp->peer->partners[c_s].dest->no,
294 LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, 303 fs[c_s],
295 lp->peer->no, 304 LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV,
296 lp->peer->partners[c_s].dest->no, 305 lp->peer->no,
297 (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); 306 lp->peer->partners[c_s].dest->no,
298 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 307 (c_s < lp->peer->num_partners - 1) ? ", \\" :
299 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 308 "\n pause -1");
300 GNUNET_free(data); 309 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
301 } 310 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
302 311 "Cannot write data to plot file `%s'\n", gfn);
303 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 312 GNUNET_free (data);
304 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 313 }
305 "Cannot close gnuplot file `%s'\n", gfn); 314
315 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f))
316 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
317 "Cannot close gnuplot file `%s'\n", gfn);
306 else 318 else
307 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 319 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
308 "Data successfully written to plot file `%s'\n", gfn); 320 "Data successfully written to plot file `%s'\n", gfn);
309 GNUNET_free(gfn); 321 GNUNET_free (gfn);
310} 322}
311 323
312 324
313static void 325static void
314write_rtt_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves) 326write_rtt_gnuplot_script (char *fn, struct LoggingPeer *lp, char **fs, int
327 slaves)
315{ 328{
316 struct GNUNET_DISK_FileHandle *f; 329 struct GNUNET_DISK_FileHandle *f;
317 char * gfn; 330 char *gfn;
318 char *data; 331 char *data;
319 int c_s; 332 int c_s;
320 333
321 GNUNET_asprintf(&gfn, "gnuplot_rtt_%s", fn); 334 GNUNET_asprintf (&gfn, "gnuplot_rtt_%s", fn);
322 fprintf(stderr, "Writing rtt plot for master %u to `%s'\n", 335 fprintf (stderr, "Writing rtt plot for master %u to `%s'\n",
323 lp->peer->no, gfn); 336 lp->peer->no, gfn);
324 337
325 f = GNUNET_DISK_file_open(gfn, 338 f = GNUNET_DISK_file_open (gfn,
326 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 339 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
327 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | 340 GNUNET_DISK_PERM_USER_EXEC
328 GNUNET_DISK_PERM_USER_WRITE); 341 | GNUNET_DISK_PERM_USER_READ
342 | GNUNET_DISK_PERM_USER_WRITE);
329 if (NULL == f) 343 if (NULL == f)
330 { 344 {
331 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 345 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n",
332 GNUNET_free(gfn); 346 gfn);
333 return; 347 GNUNET_free (gfn);
334 } 348 return;
349 }
335 350
336 /* Write header */ 351 /* Write header */
337 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, RTT_TEMPLATE, strlen(RTT_TEMPLATE))) 352 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, RTT_TEMPLATE, strlen (
338 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 353 RTT_TEMPLATE)))
354 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
355 "Cannot write data to plot file `%s'\n", gfn);
339 356
340 for (c_s = 0; c_s < slaves; c_s++) 357 for (c_s = 0; c_s < slaves; c_s++)
341 { 358 {
342 GNUNET_asprintf(&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", 359 GNUNET_asprintf (&data,
343 (0 == c_s) ? "plot " : "", 360 "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n",
344 fs[c_s], 361 (0 == c_s) ? "plot " : "",
345 LOG_ITEMS_TIME + LOG_ITEM_APP_RTT, 362 fs[c_s],
346 lp->peer->no, 363 LOG_ITEMS_TIME + LOG_ITEM_APP_RTT,
347 lp->peer->partners[c_s].dest->no, 364 lp->peer->no,
348 (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); 365 lp->peer->partners[c_s].dest->no,
349 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 366 (c_s < lp->peer->num_partners - 1) ? ", \\" :
350 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 367 "\n pause -1");
351 GNUNET_free(data); 368 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
352 } 369 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
353 370 "Cannot write data to plot file `%s'\n", gfn);
354 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 371 GNUNET_free (data);
355 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); 372 }
373
374 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f))
375 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n",
376 gfn);
356 else 377 else
357 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); 378 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
358 GNUNET_free(gfn); 379 "Data successfully written to plot file `%s'\n", gfn);
380 GNUNET_free (gfn);
359} 381}
360 382
361static void 383static void
362write_bw_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves) 384write_bw_gnuplot_script (char *fn, struct LoggingPeer *lp, char **fs, int
385 slaves)
363{ 386{
364 struct GNUNET_DISK_FileHandle *f; 387 struct GNUNET_DISK_FileHandle *f;
365 char * gfn; 388 char *gfn;
366 char *data; 389 char *data;
367 int c_s; 390 int c_s;
368 391
369 GNUNET_asprintf(&gfn, "gnuplot_bw_%s", fn); 392 GNUNET_asprintf (&gfn, "gnuplot_bw_%s", fn);
370 fprintf(stderr, "Writing bandwidth plot for master %u to `%s'\n", 393 fprintf (stderr, "Writing bandwidth plot for master %u to `%s'\n",
371 lp->peer->no, gfn); 394 lp->peer->no, gfn);
372 395
373 f = GNUNET_DISK_file_open(gfn, 396 f = GNUNET_DISK_file_open (gfn,
374 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 397 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
375 GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | 398 GNUNET_DISK_PERM_USER_EXEC
376 GNUNET_DISK_PERM_USER_WRITE); 399 | GNUNET_DISK_PERM_USER_READ
400 | GNUNET_DISK_PERM_USER_WRITE);
377 if (NULL == f) 401 if (NULL == f)
378 { 402 {
379 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); 403 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n",
380 GNUNET_free(gfn); 404 gfn);
381 return; 405 GNUNET_free (gfn);
382 } 406 return;
407 }
383 408
384 /* Write header */ 409 /* Write header */
385 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE))) 410 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, BW_TEMPLATE, strlen (
386 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 411 BW_TEMPLATE)))
387 "Cannot write data to plot file `%s'\n", gfn); 412 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
413 "Cannot write data to plot file `%s'\n", gfn);
388 414
389 for (c_s = 0; c_s < slaves; c_s++) 415 for (c_s = 0; c_s < slaves; c_s++)
390 { 416 {
391 GNUNET_asprintf(&data, "%s" \ 417 GNUNET_asprintf (&data, "%s" \
392 "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ 418 "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \
393 "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \ 419 "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \
394 "%s\n", 420 "%s\n",
395 (0 == c_s) ? "plot " : "", 421 (0 == c_s) ? "plot " : "",
396 fs[c_s], 422 fs[c_s],
397 LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_OUT, 423 LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_OUT,
398 lp->peer->no, c_s, 424 lp->peer->no, c_s,
399 fs[c_s], 425 fs[c_s],
400 LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_IN, 426 LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_IN,
401 lp->peer->no, c_s, 427 lp->peer->no, c_s,
402 (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); 428 (c_s < lp->peer->num_partners - 1) ? ", \\" :
403 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) 429 "\n pause -1");
404 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); 430 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data)))
405 GNUNET_free(data); 431 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
406 } 432 "Cannot write data to plot file `%s'\n", gfn);
407 433 GNUNET_free (data);
408 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) 434 }
409 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); 435
436 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f))
437 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n",
438 gfn);
410 else 439 else
411 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); 440 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
412 GNUNET_free(gfn); 441 "Data successfully written to plot file `%s'\n", gfn);
442 GNUNET_free (gfn);
413} 443}
414 444
415 445
416void 446void
417GNUNET_ATS_TEST_logging_write_to_file(struct LoggingHandle *l, 447GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
418 const char *experiment_name, 448 const char *experiment_name,
419 int plots) 449 int plots)
420{ 450{
421 struct GNUNET_DISK_FileHandle *f[l->num_slaves]; 451 struct GNUNET_DISK_FileHandle *f[l->num_slaves];
422 struct GNUNET_DISK_FileHandle *f_m; 452 struct GNUNET_DISK_FileHandle *f_m;
@@ -431,182 +461,207 @@ GNUNET_ATS_TEST_logging_write_to_file(struct LoggingHandle *l,
431 int c_s; 461 int c_s;
432 462
433 463
434 timestamp = GNUNET_TIME_absolute_get(); 464 timestamp = GNUNET_TIME_absolute_get ();
435 465
436 tmp_exp_name = experiment_name; 466 tmp_exp_name = experiment_name;
437 for (c_m = 0; c_m < l->num_masters; c_m++) 467 for (c_m = 0; c_m < l->num_masters; c_m++)
468 {
469 GNUNET_asprintf (&filename_master, "%s_%llu_master%u_%s",
470 experiment_name, timestamp.abs_value_us, c_m, l->name);
471 fprintf (stderr, "Writing data for master %u to file `%s'\n",
472 c_m, filename_master);
473
474 f_m = GNUNET_DISK_file_open (filename_master,
475 GNUNET_DISK_OPEN_WRITE
476 | GNUNET_DISK_OPEN_CREATE,
477 GNUNET_DISK_PERM_USER_READ
478 | GNUNET_DISK_PERM_USER_WRITE);
479 if (NULL == f_m)
438 { 480 {
439 GNUNET_asprintf(&filename_master, "%s_%llu_master%u_%s", 481 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n",
440 experiment_name, timestamp.abs_value_us, c_m, l->name); 482 filename_master);
441 fprintf(stderr, "Writing data for master %u to file `%s'\n", 483 GNUNET_free (filename_master);
442 c_m, filename_master); 484 return;
443 485 }
444 f_m = GNUNET_DISK_file_open(filename_master,
445 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE,
446 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE);
447 if (NULL == f_m)
448 {
449 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_master);
450 GNUNET_free(filename_master);
451 return;
452 }
453 486
454 GNUNET_asprintf(&data, "# master %u; experiment : %s\n" 487 GNUNET_asprintf (&data, "# master %u; experiment : %s\n"
455 "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; \n", 488 "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; \n",
456 c_m, experiment_name); 489 c_m, experiment_name);
457 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data))) 490 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_m, data, strlen (data)))
458 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 491 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
459 "Cannot write data to log file `%s'\n", filename_master); 492 "Cannot write data to log file `%s'\n", filename_master);
460 GNUNET_free(data); 493 GNUNET_free (data);
461 494
462 for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) 495 for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
463 { 496 {
464 GNUNET_asprintf(&filename_slaves[c_s], "%s_%llu_master%u_slave_%u_%s", 497 GNUNET_asprintf (&filename_slaves[c_s], "%s_%llu_master%u_slave_%u_%s",
465 tmp_exp_name, timestamp.abs_value_us, c_m, c_s, l->name); 498 tmp_exp_name, timestamp.abs_value_us, c_m, c_s, l->name);
466 499
467 fprintf(stderr, "Writing data for master %u slave %u to file `%s'\n", 500 fprintf (stderr, "Writing data for master %u slave %u to file `%s'\n",
468 c_m, c_s, filename_slaves[c_s]); 501 c_m, c_s, filename_slaves[c_s]);
469 502
470 f[c_s] = GNUNET_DISK_file_open(filename_slaves[c_s], 503 f[c_s] = GNUNET_DISK_file_open (filename_slaves[c_s],
471 GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, 504 GNUNET_DISK_OPEN_WRITE
472 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); 505 | GNUNET_DISK_OPEN_CREATE,
473 if (NULL == f[c_s]) 506 GNUNET_DISK_PERM_USER_READ
474 { 507 | GNUNET_DISK_PERM_USER_WRITE);
475 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_slaves[c_s]); 508 if (NULL == f[c_s])
476 GNUNET_free(filename_slaves[c_s]); 509 {
477 GNUNET_break(GNUNET_OK == GNUNET_DISK_file_close(f_m)); 510 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n",
478 GNUNET_free(filename_master); 511 filename_slaves[c_s]);
479 return; 512 GNUNET_free (filename_slaves[c_s]);
480 } 513 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (f_m));
481 514 GNUNET_free (filename_master);
482 /* Header */ 515 return;
483 GNUNET_asprintf(&data, "# master %u; slave %u ; experiment : %s\n" 516 }
484 "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \ 517
485 "rtt; bw in; bw out; ats_cost_lan; ats_cost_wlan; ats_delay; ats_distance; ats_network_type; ats_utilization_up ;ats_utilization_down;" \ 518 /* Header */
486 "pref bandwidth; pref delay\n", 519 GNUNET_asprintf (&data, "# master %u; slave %u ; experiment : %s\n"
487 c_m, c_s, experiment_name); 520 "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \
488 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data))) 521 "rtt; bw in; bw out; ats_cost_lan; ats_cost_wlan; ats_delay; ats_distance; ats_network_type; ats_utilization_up ;ats_utilization_down;" \
489 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 522 "pref bandwidth; pref delay\n",
490 "Cannot write data to log file `%s'\n", filename_slaves[c_s]); 523 c_m, c_s, experiment_name);
491 GNUNET_free(data); 524 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f[c_s], data, strlen (data)))
492 } 525 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
526 "Cannot write data to log file `%s'\n",
527 filename_slaves[c_s]);
528 GNUNET_free (data);
529 }
530
531 for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next)
532 {
533 if (l->verbose)
534 fprintf (stderr,
535 "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n",
536 l->lp[c_m].peer->no,
537 (long long unsigned int) cur_lt->timestamp.abs_value_us,
538 (long long unsigned int) GNUNET_TIME_absolute_get_difference (
539 l->lp[c_m].start,
540 cur_lt
541 ->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
549 /* Assembling master string */
550 GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;\n",
551 (long long unsigned int) cur_lt->timestamp.abs_value_us,
552 (long long unsigned
553 int) GNUNET_TIME_absolute_get_difference (
554 l->lp[c_m].start,
555 cur_lt
556 ->timestamp).
557 rel_value_us / 1000,
558 cur_lt->total_messages_sent,
559 cur_lt->total_bytes_sent,
560 cur_lt->total_throughput_send,
561 cur_lt->total_messages_received,
562 cur_lt->total_bytes_received,
563 cur_lt->total_throughput_recv);
564
565 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_m, data, strlen (data)))
566 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
567 "Cannot write data to master file %u\n", c_m);
568 GNUNET_free (data);
493 569
494 for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next)
495 {
496 if (l->verbose)
497 fprintf(stderr,
498 "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n",
499 l->lp[c_m].peer->no,
500 (long long unsigned int)cur_lt->timestamp.abs_value_us,
501 (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
502 cur_lt->timestamp).rel_value_us / 1000,
503 cur_lt->total_messages_sent,
504 cur_lt->total_bytes_sent,
505 cur_lt->total_throughput_send,
506 cur_lt->total_messages_received,
507 cur_lt->total_bytes_received,
508 cur_lt->total_throughput_recv);
509
510 /* Assembling master string */
511 GNUNET_asprintf(&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;\n",
512 (long long unsigned int)cur_lt->timestamp.abs_value_us,
513 (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
514 cur_lt->timestamp).rel_value_us / 1000,
515 cur_lt->total_messages_sent,
516 cur_lt->total_bytes_sent,
517 cur_lt->total_throughput_send,
518 cur_lt->total_messages_received,
519 cur_lt->total_bytes_received,
520 cur_lt->total_throughput_recv);
521
522 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data)))
523 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
524 "Cannot write data to master file %u\n", c_m);
525 GNUNET_free(data);
526
527
528 for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
529 {
530 plt = &cur_lt->slaves_log[c_s];
531 /* Log partners */
532
533 /* Assembling slave string */
534 GNUNET_asprintf(&data,
535 "%llu;%llu;%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%.3f;%.3f\n",
536 (long long unsigned int)cur_lt->timestamp.abs_value_us,
537 (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start,
538 cur_lt->timestamp).rel_value_us / 1000,
539 plt->total_messages_sent,
540 plt->total_bytes_sent,
541 plt->throughput_sent,
542 plt->total_messages_received,
543 plt->total_bytes_received,
544 plt->throughput_recv,
545 (double)plt->app_rtt / 1000,
546 plt->bandwidth_in,
547 plt->bandwidth_out,
548 plt->ats_delay,
549 plt->ats_distance,
550 plt->ats_network_type,
551 plt->ats_utilization_out,
552 plt->ats_utilization_in,
553 plt->pref_bandwidth,
554 plt->pref_delay);
555
556 if (l->verbose)
557 fprintf(stderr,
558 "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %llu bw_in %u bw_out %u \n",
559 plt->slave->no,
560 plt->total_messages_sent,
561 plt->total_bytes_sent,
562 plt->throughput_sent,
563 plt->total_messages_received,
564 plt->total_bytes_received,
565 plt->throughput_recv,
566 plt->app_rtt,
567 (long long unsigned int)plt->ats_delay.rel_value_us,
568 plt->bandwidth_in,
569 plt->bandwidth_out);
570
571 if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data)))
572 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
573 "Cannot write data to log file `%s'\n", filename_slaves[c_s]);
574 GNUNET_free(data);
575 }
576 }
577 570
578 for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) 571 for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
579 { 572 {
580 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f[c_s])) 573 plt = &cur_lt->slaves_log[c_s];
581 { 574 /* Log partners */
582 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 575
583 "Cannot close log file for master[%u] slave[%u]\n", c_m, c_s); 576 /* Assembling slave string */
584 continue; 577 GNUNET_asprintf (&data,
585 } 578 "%llu;%llu;%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%.3f;%.3f\n",
586 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 579 (long long unsigned
587 "Data file successfully written to log file for `%s'\n", 580 int) cur_lt->timestamp.abs_value_us,
588 filename_slaves[c_s]); 581 (long long unsigned
589 } 582 int) GNUNET_TIME_absolute_get_difference (
583 l->lp[c_m].start,
584 cur_lt
585 ->timestamp)
586 .rel_value_us / 1000,
587 plt->total_messages_sent,
588 plt->total_bytes_sent,
589 plt->throughput_sent,
590 plt->total_messages_received,
591 plt->total_bytes_received,
592 plt->throughput_recv,
593 (double) plt->app_rtt / 1000,
594 plt->bandwidth_in,
595 plt->bandwidth_out,
596 plt->ats_delay,
597 plt->ats_distance,
598 plt->ats_network_type,
599 plt->ats_utilization_out,
600 plt->ats_utilization_in,
601 plt->pref_bandwidth,
602 plt->pref_delay);
603
604 if (l->verbose)
605 fprintf (stderr,
606 "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %llu bw_in %u bw_out %u \n",
607 plt->slave->no,
608 plt->total_messages_sent,
609 plt->total_bytes_sent,
610 plt->throughput_sent,
611 plt->total_messages_received,
612 plt->total_bytes_received,
613 plt->throughput_recv,
614 plt->app_rtt,
615 (long long unsigned int) plt->ats_delay.rel_value_us,
616 plt->bandwidth_in,
617 plt->bandwidth_out);
618
619 if (GNUNET_SYSERR == GNUNET_DISK_file_write (f[c_s], data, strlen (
620 data)))
621 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
622 "Cannot write data to log file `%s'\n",
623 filename_slaves[c_s]);
624 GNUNET_free (data);
625 }
626 }
590 627
591 if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_m)) 628 for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
592 { 629 {
593 GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, 630 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f[c_s]))
594 "close", 631 {
595 filename_master); 632 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
596 GNUNET_free(filename_master); 633 "Cannot close log file for master[%u] slave[%u]\n", c_m,
597 return; 634 c_s);
598 } 635 continue;
599 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 636 }
600 "Data file successfully written to log file for master `%s'\n", filename_master); 637 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
638 "Data file successfully written to log file for `%s'\n",
639 filename_slaves[c_s]);
640 }
601 641
602 if (GNUNET_YES == plots) 642 if (GNUNET_SYSERR == GNUNET_DISK_file_close (f_m))
603 { 643 {
604 write_throughput_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); 644 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
605 write_rtt_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); 645 "close",
606 write_bw_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); 646 filename_master);
607 } 647 GNUNET_free (filename_master);
648 return;
608 } 649 }
609 GNUNET_free(filename_master); 650 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
651 "Data file successfully written to log file for master `%s'\n",
652 filename_master);
653
654 if (GNUNET_YES == plots)
655 {
656 write_throughput_gnuplot_script (filename_master, &l->lp[c_m],
657 filename_slaves, l->num_slaves);
658 write_rtt_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves,
659 l->num_slaves);
660 write_bw_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves,
661 l->num_slaves);
662 }
663 }
664 GNUNET_free (filename_master);
610} 665}
611 666
612/** 667/**
@@ -615,7 +670,7 @@ GNUNET_ATS_TEST_logging_write_to_file(struct LoggingHandle *l,
615 * @param l logging handle to use 670 * @param l logging handle to use
616 */ 671 */
617void 672void
618GNUNET_ATS_TEST_logging_now(struct LoggingHandle *l) 673GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l)
619{ 674{
620 struct LoggingPeer *bp; 675 struct LoggingPeer *bp;
621 struct PeerLoggingTimestep *mlt; 676 struct PeerLoggingTimestep *mlt;
@@ -633,180 +688,188 @@ GNUNET_ATS_TEST_logging_now(struct LoggingHandle *l)
633 return; 688 return;
634 689
635 for (c_m = 0; c_m < l->num_masters; c_m++) 690 for (c_m = 0; c_m < l->num_masters; c_m++)
691 {
692 bp = &l->lp[c_m];
693 mlt = GNUNET_new (struct PeerLoggingTimestep);
694 GNUNET_CONTAINER_DLL_insert_tail (l->lp[c_m].head, l->lp[c_m].tail, mlt);
695 prev_log_mlt = mlt->prev;
696
697 /* Collect data */
698 /* Current master state */
699 mlt->timestamp = GNUNET_TIME_absolute_get ();
700 mlt->total_bytes_sent = bp->peer->total_bytes_sent;
701 mlt->total_messages_sent = bp->peer->total_messages_sent;
702 mlt->total_bytes_received = bp->peer->total_bytes_received;
703 mlt->total_messages_received = bp->peer->total_messages_received;
704
705 /* Throughput */
706 if (NULL == prev_log_mlt)
707 {
708 /* Get difference to start */
709 delta = GNUNET_TIME_absolute_get_difference (l->lp[c_m].start,
710 mlt->timestamp);
711 }
712 else
713 {
714 /* Get difference to last timestep */
715 delta = GNUNET_TIME_absolute_get_difference (mlt->prev->timestamp,
716 mlt->timestamp);
717 }
718
719 /* Multiplication factor for throughput calculation */
720 mult = (double) GNUNET_TIME_UNIT_SECONDS.rel_value_us
721 / (delta.rel_value_us);
722
723 /* Total throughput */
724 if (NULL != prev_log_mlt)
725 {
726 if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0)
727 {
728 mlt->total_throughput_send = mult * (mlt->total_bytes_sent
729 - mlt->prev->total_bytes_sent);
730 }
731 else
732 {
733 mlt->total_throughput_send = 0;
734 // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */
735 }
736
737 if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0)
738 {
739 mlt->total_throughput_recv = mult * (mlt->total_bytes_received
740 - mlt->prev->total_bytes_received);
741 }
742 else
743 {
744 mlt->total_throughput_recv = 0;
745 // mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */
746 }
747 }
748 else
749 {
750 mlt->total_throughput_send = mult * mlt->total_bytes_sent;
751 mlt->total_throughput_recv = mult * mlt->total_bytes_received;
752 }
753
754 if (GNUNET_YES == l->verbose)
755 {
756 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
757 "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n",
758 c_m,
759 (unsigned long long) delta.rel_value_us,
760 mlt->total_bytes_sent,
761 mlt->total_bytes_received,
762 mlt->total_throughput_send,
763 mlt->total_throughput_recv);
764 }
765
766 mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners
767 * sizeof(struct PartnerLoggingTimestep));
768
769 for (c_s = 0; c_s < bp->peer->num_partners; c_s++)
636 { 770 {
637 bp = &l->lp[c_m]; 771 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
638 mlt = GNUNET_new(struct PeerLoggingTimestep); 772 "Collect logging data master[%u] slave [%u]\n", c_m, c_s);
639 GNUNET_CONTAINER_DLL_insert_tail(l->lp[c_m].head, l->lp[c_m].tail, mlt); 773
640 prev_log_mlt = mlt->prev; 774 p = &bp->peer->partners[c_s];
641 775 slt = &mlt->slaves_log[c_s];
642 /* Collect data */ 776
643 /* Current master state */ 777 slt->slave = p->dest;
644 mlt->timestamp = GNUNET_TIME_absolute_get(); 778 /* Bytes sent from master to this slave */
645 mlt->total_bytes_sent = bp->peer->total_bytes_sent; 779 slt->total_bytes_sent = p->bytes_sent;
646 mlt->total_messages_sent = bp->peer->total_messages_sent; 780 /* Messages sent from master to this slave */
647 mlt->total_bytes_received = bp->peer->total_bytes_received; 781 slt->total_messages_sent = p->messages_sent;
648 mlt->total_messages_received = bp->peer->total_messages_received; 782 /* Bytes master received from this slave */
649 783 slt->total_bytes_received = p->bytes_received;
650 /* Throughput */ 784 /* Messages master received from this slave */
785 slt->total_messages_received = p->messages_received;
786 slt->total_app_rtt = p->total_app_rtt;
787 /* ats performance information */
788 slt->ats_delay = p->props.delay;
789 slt->ats_distance = p->props.distance;
790 slt->ats_network_type = p->props.scope;
791 slt->ats_utilization_in = p->props.utilization_out;
792 slt->ats_utilization_out = p->props.utilization_out;
793 slt->bandwidth_in = p->bandwidth_in;
794 slt->bandwidth_out = p->bandwidth_out;
795 slt->pref_bandwidth = p->pref_bandwidth;
796 slt->pref_delay = p->pref_delay;
797
798 /* Total application level rtt */
651 if (NULL == prev_log_mlt) 799 if (NULL == prev_log_mlt)
652 { 800 {
653 /* Get difference to start */ 801 if (0 != slt->total_messages_sent)
654 delta = GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, mlt->timestamp); 802 app_rtt = slt->total_app_rtt / slt->total_messages_sent;
655 } 803 else
804 app_rtt = 0;
805 }
656 else 806 else
807 {
808 prev_log_slt = &prev_log_mlt->slaves_log[c_s];
809 if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0)
810 app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt)
811 / (slt->total_messages_sent
812 - prev_log_slt->total_messages_sent);
813 else
657 { 814 {
658 /* Get difference to last timestep */ 815 app_rtt = prev_log_slt->app_rtt; /* No messages were */
659 delta = GNUNET_TIME_absolute_get_difference(mlt->prev->timestamp, mlt->timestamp);
660 } 816 }
817 }
818 slt->app_rtt = app_rtt;
661 819
662 /* Multiplication factor for throughput calculation */ 820 /* Partner throughput */
663 mult = (double)GNUNET_TIME_UNIT_SECONDS.rel_value_us / (delta.rel_value_us);
664
665 /* Total throughput */
666 if (NULL != prev_log_mlt) 821 if (NULL != prev_log_mlt)
667 { 822 {
668 if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) 823 prev_log_slt = &prev_log_mlt->slaves_log[c_s];
669 { 824 if (slt->total_bytes_sent > prev_log_slt->total_bytes_sent)
670 mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent); 825 slt->throughput_sent = mult * (slt->total_bytes_sent
671 } 826 - prev_log_slt->total_bytes_sent);
672 else 827 else
673 { 828 slt->throughput_sent = 0;
674 mlt->total_throughput_send = 0; 829
675 // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ 830 if (slt->total_bytes_received > prev_log_slt->total_bytes_received)
676 } 831 slt->throughput_recv = mult
677 832 * (slt->total_bytes_received
678 if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) 833 - prev_log_slt->total_bytes_received);
679 { 834 else
680 mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received); 835 slt->throughput_recv = 0;
681 } 836 }
682 else
683 {
684 mlt->total_throughput_recv = 0;
685 //mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */
686 }
687 }
688 else 837 else
689 { 838 {
690 mlt->total_throughput_send = mult * mlt->total_bytes_sent; 839 slt->throughput_sent = mult * slt->total_bytes_sent;
691 mlt->total_throughput_recv = mult * mlt->total_bytes_received; 840 slt->throughput_recv = mult * slt->total_bytes_received;
692 } 841 }
693 842
694 if (GNUNET_YES == l->verbose) 843 if (GNUNET_YES == l->verbose)
695 { 844 {
696 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 845 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
697 "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", 846 "Master [%u] -> Slave [%u]: delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n",
698 c_m, 847 c_m, c_s,
699 (unsigned long long)delta.rel_value_us, 848 (unsigned long long) delta.rel_value_us,
700 mlt->total_bytes_sent, 849 mlt->total_bytes_sent,
701 mlt->total_bytes_received, 850 mlt->total_bytes_received,
702 mlt->total_throughput_send, 851 slt->throughput_sent,
703 mlt->total_throughput_recv); 852 slt->throughput_recv);
704 } 853 }
705 854 else
706 mlt->slaves_log = GNUNET_malloc(bp->peer->num_partners * 855 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
707 sizeof(struct PartnerLoggingTimestep)); 856 "Master [%u]: slave [%u]\n",
708 857 bp->peer->no, p->dest->no);
709 for (c_s = 0; c_s < bp->peer->num_partners; c_s++)
710 {
711 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
712 "Collect logging data master[%u] slave [%u]\n", c_m, c_s);
713
714 p = &bp->peer->partners[c_s];
715 slt = &mlt->slaves_log[c_s];
716
717 slt->slave = p->dest;
718 /* Bytes sent from master to this slave */
719 slt->total_bytes_sent = p->bytes_sent;
720 /* Messages sent from master to this slave */
721 slt->total_messages_sent = p->messages_sent;
722 /* Bytes master received from this slave */
723 slt->total_bytes_received = p->bytes_received;
724 /* Messages master received from this slave */
725 slt->total_messages_received = p->messages_received;
726 slt->total_app_rtt = p->total_app_rtt;
727 /* ats performance information */
728 slt->ats_delay = p->props.delay;
729 slt->ats_distance = p->props.distance;
730 slt->ats_network_type = p->props.scope;
731 slt->ats_utilization_in = p->props.utilization_out;
732 slt->ats_utilization_out = p->props.utilization_out;
733 slt->bandwidth_in = p->bandwidth_in;
734 slt->bandwidth_out = p->bandwidth_out;
735 slt->pref_bandwidth = p->pref_bandwidth;
736 slt->pref_delay = p->pref_delay;
737
738 /* Total application level rtt */
739 if (NULL == prev_log_mlt)
740 {
741 if (0 != slt->total_messages_sent)
742 app_rtt = slt->total_app_rtt / slt->total_messages_sent;
743 else
744 app_rtt = 0;
745 }
746 else
747 {
748 prev_log_slt = &prev_log_mlt->slaves_log[c_s];
749 if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0)
750 app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) /
751 (slt->total_messages_sent - prev_log_slt->total_messages_sent);
752 else
753 {
754 app_rtt = prev_log_slt->app_rtt; /* No messages were */
755 }
756 }
757 slt->app_rtt = app_rtt;
758
759 /* Partner throughput */
760 if (NULL != prev_log_mlt)
761 {
762 prev_log_slt = &prev_log_mlt->slaves_log[c_s];
763 if (slt->total_bytes_sent > prev_log_slt->total_bytes_sent)
764 slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent);
765 else
766 slt->throughput_sent = 0;
767
768 if (slt->total_bytes_received > prev_log_slt->total_bytes_received)
769 slt->throughput_recv = mult *
770 (slt->total_bytes_received - prev_log_slt->total_bytes_received);
771 else
772 slt->throughput_recv = 0;
773 }
774 else
775 {
776 slt->throughput_sent = mult * slt->total_bytes_sent;
777 slt->throughput_recv = mult * slt->total_bytes_received;
778 }
779
780 if (GNUNET_YES == l->verbose)
781 {
782 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
783 "Master [%u] -> Slave [%u]: delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n",
784 c_m, c_s,
785 (unsigned long long)delta.rel_value_us,
786 mlt->total_bytes_sent,
787 mlt->total_bytes_received,
788 slt->throughput_sent,
789 slt->throughput_recv);
790 }
791 else
792 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
793 "Master [%u]: slave [%u]\n",
794 bp->peer->no, p->dest->no);
795 }
796 } 858 }
859 }
797} 860}
798 861
799 862
800static void 863static void
801collect_log_task(void *cls) 864collect_log_task (void *cls)
802{ 865{
803 struct LoggingHandle *l = cls; 866 struct LoggingHandle *l = cls;
804 867
805 l->log_task = NULL; 868 l->log_task = NULL;
806 GNUNET_ATS_TEST_logging_now(l); 869 GNUNET_ATS_TEST_logging_now (l);
807 l->log_task = GNUNET_SCHEDULER_add_delayed(l->frequency, 870 l->log_task = GNUNET_SCHEDULER_add_delayed (l->frequency,
808 &collect_log_task, 871 &collect_log_task,
809 l); 872 l);
810} 873}
811 874
812 875
@@ -816,20 +879,20 @@ collect_log_task(void *cls)
816 * @param l the logging handle 879 * @param l the logging handle
817 */ 880 */
818void 881void
819GNUNET_ATS_TEST_logging_stop(struct LoggingHandle *l) 882GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l)
820{ 883{
821 if (GNUNET_YES != l->running) 884 if (GNUNET_YES != l->running)
822 return; 885 return;
823 886
824 if (NULL != l->log_task) 887 if (NULL != l->log_task)
825 { 888 {
826 GNUNET_SCHEDULER_cancel(l->log_task); 889 GNUNET_SCHEDULER_cancel (l->log_task);
827 l->log_task = NULL; 890 l->log_task = NULL;
828 } 891 }
829 l->running = GNUNET_NO; 892 l->running = GNUNET_NO;
830 893
831 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 894 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
832 _("Stop logging\n")); 895 _ ("Stop logging\n"));
833} 896}
834 897
835/** 898/**
@@ -838,26 +901,26 @@ GNUNET_ATS_TEST_logging_stop(struct LoggingHandle *l)
838 * @param l the logging handle 901 * @param l the logging handle
839 */ 902 */
840void 903void
841GNUNET_ATS_TEST_logging_clean_up(struct LoggingHandle *l) 904GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l)
842{ 905{
843 int c_m; 906 int c_m;
844 struct PeerLoggingTimestep *cur; 907 struct PeerLoggingTimestep *cur;
845 908
846 if (GNUNET_YES == l->running) 909 if (GNUNET_YES == l->running)
847 GNUNET_ATS_TEST_logging_stop(l); 910 GNUNET_ATS_TEST_logging_stop (l);
848 911
849 for (c_m = 0; c_m < l->num_masters; c_m++) 912 for (c_m = 0; c_m < l->num_masters; c_m++)
913 {
914 while (NULL != (cur = l->lp[c_m].head))
850 { 915 {
851 while (NULL != (cur = l->lp[c_m].head)) 916 GNUNET_CONTAINER_DLL_remove (l->lp[c_m].head, l->lp[c_m].tail, cur);
852 { 917 GNUNET_free (cur->slaves_log);
853 GNUNET_CONTAINER_DLL_remove(l->lp[c_m].head, l->lp[c_m].tail, cur); 918 GNUNET_free (cur);
854 GNUNET_free(cur->slaves_log);
855 GNUNET_free(cur);
856 }
857 } 919 }
920 }
858 921
859 GNUNET_free(l->lp); 922 GNUNET_free (l->lp);
860 GNUNET_free(l); 923 GNUNET_free (l);
861} 924}
862 925
863 926
@@ -873,35 +936,35 @@ GNUNET_ATS_TEST_logging_clean_up(struct LoggingHandle *l)
873 * @return the logging handle or NULL on error 936 * @return the logging handle or NULL on error
874 */ 937 */
875struct LoggingHandle * 938struct LoggingHandle *
876GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, 939GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
877 const char *testname, 940 const char *testname,
878 struct BenchmarkPeer *masters, 941 struct BenchmarkPeer *masters,
879 int num_masters, 942 int num_masters,
880 int num_slaves, 943 int num_slaves,
881 int verbose) 944 int verbose)
882{ 945{
883 struct LoggingHandle *l; 946 struct LoggingHandle *l;
884 int c_m; 947 int c_m;
885 948
886 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 949 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
887 _("Start logging `%s'\n"), testname); 950 _ ("Start logging `%s'\n"), testname);
888 951
889 l = GNUNET_new(struct LoggingHandle); 952 l = GNUNET_new (struct LoggingHandle);
890 l->num_masters = num_masters; 953 l->num_masters = num_masters;
891 l->num_slaves = num_slaves; 954 l->num_slaves = num_slaves;
892 l->name = testname; 955 l->name = testname;
893 l->frequency = log_frequency; 956 l->frequency = log_frequency;
894 l->verbose = verbose; 957 l->verbose = verbose;
895 l->lp = GNUNET_malloc(num_masters * sizeof(struct LoggingPeer)); 958 l->lp = GNUNET_malloc (num_masters * sizeof(struct LoggingPeer));
896 959
897 for (c_m = 0; c_m < num_masters; c_m++) 960 for (c_m = 0; c_m < num_masters; c_m++)
898 { 961 {
899 l->lp[c_m].peer = &masters[c_m]; 962 l->lp[c_m].peer = &masters[c_m];
900 l->lp[c_m].start = GNUNET_TIME_absolute_get(); 963 l->lp[c_m].start = GNUNET_TIME_absolute_get ();
901 } 964 }
902 965
903 /* Schedule logging task */ 966 /* Schedule logging task */
904 l->log_task = GNUNET_SCHEDULER_add_now(&collect_log_task, l); 967 l->log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, l);
905 l->running = GNUNET_YES; 968 l->running = GNUNET_YES;
906 969
907 return l; 970 return l;