GNUnet  0.10.x
ats-testing-log.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010-2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "ats-testing.h"
29 
30 #define THROUGHPUT_TEMPLATE "#!/usr/bin/gnuplot \n" \
31  "set datafile separator ';' \n" \
32  "set title \"Throughput between Master and Slaves\" \n" \
33  "set xlabel \"Time in ms\" \n" \
34  "set ylabel \"Bytes/s\" \n" \
35  "set grid \n"
36 
37 #define RTT_TEMPLATE "#!/usr/bin/gnuplot \n" \
38  "set datafile separator ';' \n" \
39  "set title \"Application level roundtrip time between Master and Slaves\" \n" \
40  "set xlabel \"Time in ms\" \n" \
41  "set ylabel \"ms\" \n" \
42  "set grid \n"
43 
44 #define BW_TEMPLATE "#!/usr/bin/gnuplot \n" \
45  "set datafile separator ';' \n" \
46  "set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \
47  "set xlabel \"Time in ms\" \n" \
48  "set ylabel \"Bytes / s \" \n" \
49  "set grid \n"
50 
51 #define LOG_ITEMS_TIME 2
52 #define LOG_ITEMS_PER_PEER 17
53 
54 #define LOG_ITEM_BYTES_SENT 1
55 #define LOG_ITEM_MSGS_SENT 2
56 #define LOG_ITEM_THROUGHPUT_SENT 3
57 #define LOG_ITEM_BYTES_RECV 4
58 #define LOG_ITEM_MSGS_RECV 5
59 #define LOG_ITEM_THROUGHPUT_RECV 6
60 #define LOG_ITEM_APP_RTT 7
61 #define LOG_ITEM_ATS_BW_IN 8
62 #define LOG_ITEM_ATS_BW_OUT 9
63 #define LOG_ITEM_ATS_COSTS_LAN 10
64 #define LOG_ITEM_ATS_WAN 11
65 #define LOG_ITEM_ATS_WLAN 12
66 #define LOG_ITEM_ATS_DELAY 13
67 #define LOG_ITEM_ATS_DISTANCE 14
68 #define LOG_ITEM_ATS_NETWORKTYPE 15
69 #define LOG_ITEM_ATS_UTIL_UP 16
70 #define LOG_ITEM_ATS_UTIL_DOWN 17
71 
80 
84  unsigned int total_messages_sent;
85 
89  unsigned int total_bytes_sent;
90 
95 
99  unsigned int total_bytes_received;
100 
104  unsigned int throughput_sent;
105 
109  unsigned int throughput_recv;
110 
114  unsigned int total_app_rtt;
115 
119  unsigned int app_rtt;
120 
121  /* Current ATS properties */
122 
123  unsigned int ats_distance;
124 
126 
127  uint32_t bandwidth_in;
128 
129  uint32_t bandwidth_out;
130 
132 
134 
136 
138  double pref_delay;
139 };
140 
141 
150 
155 
159  struct GNUNET_TIME_Absolute timestamp;
160 
164  unsigned int total_messages_sent;
165 
169  unsigned int total_bytes_sent;
170 
175 
179  unsigned int total_bytes_received;
180 
184  unsigned int total_throughput_send;
185 
189  unsigned int total_throughput_recv;
190 
195 };
196 
200 struct LoggingPeer {
205 
210 
215 
220 };
221 
222 struct LoggingHandle {
227 
233  int running;
234  int verbose;
235  const char *name;
236  struct GNUNET_TIME_Relative frequency;
237 
241  struct LoggingPeer *lp;
242 };
243 
244 
245 
246 static void
247 write_throughput_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves)
248 {
249  struct GNUNET_DISK_FileHandle *f;
250  char * gfn;
251  char *data;
252  int c_s;
253 
254  GNUNET_asprintf(&gfn, "gnuplot_throughput_%s", fn);
255  fprintf(stderr, "Writing throughput plot for master %u and %u slaves to `%s'\n",
256  lp->peer->no, slaves, gfn);
257 
258  f = GNUNET_DISK_file_open(gfn,
262  if (NULL == f)
263  {
264  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
265  GNUNET_free(gfn);
266  return;
267  }
268 
269  /* Write header */
271  strlen(THROUGHPUT_TEMPLATE)))
273  "Cannot write data to plot file `%s'\n", gfn);
274 
275  /* Write master data */
276  GNUNET_asprintf(&data,
277  "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",
281  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);
283  GNUNET_free(data);
284 
285  for (c_s = 0; c_s < slaves; c_s++)
286  {
287  GNUNET_asprintf(&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \
288  "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n",
289  fs[c_s],
291  lp->peer->no,
292  lp->peer->partners[c_s].dest->no,
293  fs[c_s],
295  lp->peer->no,
296  lp->peer->partners[c_s].dest->no,
297  (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1");
298  if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
299  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
300  GNUNET_free(data);
301  }
302 
305  "Cannot close gnuplot file `%s'\n", gfn);
306  else
308  "Data successfully written to plot file `%s'\n", gfn);
309  GNUNET_free(gfn);
310 }
311 
312 
313 static void
314 write_rtt_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves)
315 {
316  struct GNUNET_DISK_FileHandle *f;
317  char * gfn;
318  char *data;
319  int c_s;
320 
321  GNUNET_asprintf(&gfn, "gnuplot_rtt_%s", fn);
322  fprintf(stderr, "Writing rtt plot for master %u to `%s'\n",
323  lp->peer->no, gfn);
324 
325  f = GNUNET_DISK_file_open(gfn,
329  if (NULL == f)
330  {
331  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
332  GNUNET_free(gfn);
333  return;
334  }
335 
336  /* Write header */
338  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
339 
340  for (c_s = 0; c_s < slaves; c_s++)
341  {
342  GNUNET_asprintf(&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n",
343  (0 == c_s) ? "plot " : "",
344  fs[c_s],
346  lp->peer->no,
347  lp->peer->partners[c_s].dest->no,
348  (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1");
349  if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
350  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
351  GNUNET_free(data);
352  }
353 
355  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn);
356  else
357  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn);
358  GNUNET_free(gfn);
359 }
360 
361 static void
362 write_bw_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves)
363 {
364  struct GNUNET_DISK_FileHandle *f;
365  char * gfn;
366  char *data;
367  int c_s;
368 
369  GNUNET_asprintf(&gfn, "gnuplot_bw_%s", fn);
370  fprintf(stderr, "Writing bandwidth plot for master %u to `%s'\n",
371  lp->peer->no, gfn);
372 
373  f = GNUNET_DISK_file_open(gfn,
377  if (NULL == f)
378  {
379  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn);
380  GNUNET_free(gfn);
381  return;
382  }
383 
384  /* Write header */
387  "Cannot write data to plot file `%s'\n", gfn);
388 
389  for (c_s = 0; c_s < slaves; c_s++)
390  {
391  GNUNET_asprintf(&data, "%s" \
392  "'%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 '" \
394  "%s\n",
395  (0 == c_s) ? "plot " : "",
396  fs[c_s],
398  lp->peer->no, c_s,
399  fs[c_s],
401  lp->peer->no, c_s,
402  (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1");
403  if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data)))
404  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn);
405  GNUNET_free(data);
406  }
407 
409  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn);
410  else
411  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn);
412  GNUNET_free(gfn);
413 }
414 
415 
416 void
418  const char *experiment_name,
419  int plots)
420 {
421  struct GNUNET_DISK_FileHandle *f[l->num_slaves];
422  struct GNUNET_DISK_FileHandle *f_m;
423  const char *tmp_exp_name;
424  char *filename_master;
425  char *filename_slaves[l->num_slaves];
426  char *data;
427  struct PeerLoggingTimestep *cur_lt;
428  struct PartnerLoggingTimestep *plt;
429  struct GNUNET_TIME_Absolute timestamp;
430  int c_m;
431  int c_s;
432 
433 
434  timestamp = GNUNET_TIME_absolute_get();
435 
436  tmp_exp_name = experiment_name;
437  for (c_m = 0; c_m < l->num_masters; c_m++)
438  {
439  GNUNET_asprintf(&filename_master, "%s_%llu_master%u_%s",
440  experiment_name, timestamp.abs_value_us, c_m, l->name);
441  fprintf(stderr, "Writing data for master %u to file `%s'\n",
442  c_m, filename_master);
443 
444  f_m = GNUNET_DISK_file_open(filename_master,
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 
454  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",
456  c_m, experiment_name);
457  if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data)))
459  "Cannot write data to log file `%s'\n", filename_master);
460  GNUNET_free(data);
461 
462  for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
463  {
464  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);
466 
467  fprintf(stderr, "Writing data for master %u slave %u to file `%s'\n",
468  c_m, c_s, filename_slaves[c_s]);
469 
470  f[c_s] = GNUNET_DISK_file_open(filename_slaves[c_s],
473  if (NULL == f[c_s])
474  {
475  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_slaves[c_s]);
476  GNUNET_free(filename_slaves[c_s]);
478  GNUNET_free(filename_master);
479  return;
480  }
481 
482  /* Header */
483  GNUNET_asprintf(&data, "# master %u; slave %u ; experiment : %s\n"
484  "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \
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;" \
486  "pref bandwidth; pref delay\n",
487  c_m, c_s, experiment_name);
488  if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data)))
490  "Cannot write data to log file `%s'\n", filename_slaves[c_s]);
491  GNUNET_free(data);
492  }
493 
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)))
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,
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,
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)))
573  "Cannot write data to log file `%s'\n", filename_slaves[c_s]);
574  GNUNET_free(data);
575  }
576  }
577 
578  for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++)
579  {
580  if (GNUNET_SYSERR == GNUNET_DISK_file_close(f[c_s]))
581  {
583  "Cannot close log file for master[%u] slave[%u]\n", c_m, c_s);
584  continue;
585  }
587  "Data file successfully written to log file for `%s'\n",
588  filename_slaves[c_s]);
589  }
590 
592  {
594  "close",
595  filename_master);
596  GNUNET_free(filename_master);
597  return;
598  }
600  "Data file successfully written to log file for master `%s'\n", filename_master);
601 
602  if (GNUNET_YES == plots)
603  {
604  write_throughput_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
605  write_rtt_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
606  write_bw_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves);
607  }
608  }
609  GNUNET_free(filename_master);
610 }
611 
617 void
619 {
620  struct LoggingPeer *bp;
621  struct PeerLoggingTimestep *mlt;
622  struct PeerLoggingTimestep *prev_log_mlt;
623  struct PartnerLoggingTimestep *slt;
624  struct PartnerLoggingTimestep *prev_log_slt;
625  struct BenchmarkPartner *p;
626  struct GNUNET_TIME_Relative delta;
627  int c_s;
628  int c_m;
629  unsigned int app_rtt;
630  double mult;
631 
632  if (GNUNET_YES != l->running)
633  return;
634 
635  for (c_m = 0; c_m < l->num_masters; c_m++)
636  {
637  bp = &l->lp[c_m];
638  mlt = GNUNET_new(struct PeerLoggingTimestep);
639  GNUNET_CONTAINER_DLL_insert_tail(l->lp[c_m].head, l->lp[c_m].tail, mlt);
640  prev_log_mlt = mlt->prev;
641 
642  /* Collect data */
643  /* Current master state */
649 
650  /* Throughput */
651  if (NULL == prev_log_mlt)
652  {
653  /* Get difference to start */
654  delta = GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, mlt->timestamp);
655  }
656  else
657  {
658  /* Get difference to last timestep */
660  }
661 
662  /* Multiplication factor for throughput calculation */
663  mult = (double)GNUNET_TIME_UNIT_SECONDS.rel_value_us / (delta.rel_value_us);
664 
665  /* Total throughput */
666  if (NULL != prev_log_mlt)
667  {
668  if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0)
669  {
670  mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent);
671  }
672  else
673  {
674  mlt->total_throughput_send = 0;
675  // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */
676  }
677 
678  if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0)
679  {
681  }
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
689  {
690  mlt->total_throughput_send = mult * mlt->total_bytes_sent;
691  mlt->total_throughput_recv = mult * mlt->total_bytes_received;
692  }
693 
694  if (GNUNET_YES == l->verbose)
695  {
697  "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n",
698  c_m,
699  (unsigned long long)delta.rel_value_us,
700  mlt->total_bytes_sent,
703  mlt->total_throughput_recv);
704  }
705 
707  sizeof(struct PartnerLoggingTimestep));
708 
709  for (c_s = 0; c_s < bp->peer->num_partners; c_s++)
710  {
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 */
722  /* Bytes master received from this slave */
724  /* Messages master received from this slave */
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;
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  {
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,
788  slt->throughput_sent,
789  slt->throughput_recv);
790  }
791  else
793  "Master [%u]: slave [%u]\n",
794  bp->peer->no, p->dest->no);
795  }
796  }
797 }
798 
799 
800 static void
802 {
803  struct LoggingHandle *l = cls;
804 
805  l->log_task = NULL;
809  l);
810 }
811 
812 
818 void
820 {
821  if (GNUNET_YES != l->running)
822  return;
823 
824  if (NULL != l->log_task)
825  {
827  l->log_task = NULL;
828  }
829  l->running = GNUNET_NO;
830 
832  _("Stop logging\n"));
833 }
834 
840 void
842 {
843  int c_m;
844  struct PeerLoggingTimestep *cur;
845 
846  if (GNUNET_YES == l->running)
848 
849  for (c_m = 0; c_m < l->num_masters; c_m++)
850  {
851  while (NULL != (cur = l->lp[c_m].head))
852  {
853  GNUNET_CONTAINER_DLL_remove(l->lp[c_m].head, l->lp[c_m].tail, cur);
854  GNUNET_free(cur->slaves_log);
855  GNUNET_free(cur);
856  }
857  }
858 
859  GNUNET_free(l->lp);
860  GNUNET_free(l);
861 }
862 
863 
875 struct LoggingHandle *
877  const char *testname,
878  struct BenchmarkPeer *masters,
879  int num_masters,
880  int num_slaves,
881  int verbose)
882 {
883  struct LoggingHandle *l;
884  int c_m;
885 
887  _("Start logging `%s'\n"), testname);
888 
889  l = GNUNET_new(struct LoggingHandle);
891  l->num_slaves = num_slaves;
892  l->name = testname;
893  l->frequency = log_frequency;
894  l->verbose = verbose;
895  l->lp = GNUNET_malloc(num_masters * sizeof(struct LoggingPeer));
896 
897  for (c_m = 0; c_m < num_masters; c_m++)
898  {
899  l->lp[c_m].peer = &masters[c_m];
900  l->lp[c_m].start = GNUNET_TIME_absolute_get();
901  }
902 
903  /* Schedule logging task */
905  l->running = GNUNET_YES;
906 
907  return l;
908 }
909 /* end of file ats-testing-log.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
unsigned int total_bytes_sent
Total number of bytes this peer has sent.
unsigned int total_bytes_sent
Total number of bytes this peer has sent.
Definition: ats-testing.h:214
unsigned int messages_sent
Number of messages sent to this partner.
Definition: ats-testing.h:309
#define LOG_ITEM_APP_RTT
#define RTT_TEMPLATE
static void write_rtt_gnuplot_script(char *fn, struct LoggingPeer *lp, char **fs, int slaves)
unsigned int total_bytes_received
Total number of bytes this peer has received.
Definition: ats-testing.h:224
Create file if it doesn&#39;t exist.
A single logging time step for a partner.
const char * name
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1339
uint64_t rel_value_us
The actual value.
struct PeerLoggingTimestep * head
DLL for logging entries: head.
static void collect_log_task(void *cls)
unsigned int throughput_recv
Total inbound throughput for master in Bytes / s.
unsigned int total_messages_received
Total number of messages this peer has received.
void GNUNET_ATS_TEST_logging_write_to_file(struct LoggingHandle *l, const char *experiment_name, int plots)
Write logging data to file.
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
#define GNUNET_TIME_UNIT_SECONDS
One second.
#define LOG_ITEM_ATS_BW_IN
double pref_bandwidth
Current preference values for bandwidth.
Definition: ats-testing.h:344
struct BenchmarkPartner * partners
Array of partners with num_slaves entries (if master) or num_master entries (if slave) ...
Definition: ats-testing.h:188
unsigned int total_messages_received
Total number of messages this peer has received.
Definition: ats-testing.h:219
static void write_bw_gnuplot_script(char *fn, struct LoggingPeer *lp, char **fs, int slaves)
struct PartnerLoggingTimestep * slaves_log
Logs for slaves.
enum GNUNET_NetworkType ats_network_type
struct BenchmarkPeer * slave
Peer.
unsigned int bytes_received
Number of bytes received from this partner.
Definition: ats-testing.h:324
struct BenchmarkPeer * peer
Peer.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct PeerLoggingTimestep * prev
Prev in DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct LoggingPeer * lp
Log structure of length num_peers.
uint64_t abs_value_us
The actual value.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
unsigned int total_messages_sent
Total number of messages this peer has sent.
Definition: ats-testing.h:209
struct GNUNET_CADET_Port * lp
Data structure for ongoing reception of incoming virtual circuits.
Definition: gnunet-cadet.c:127
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
unsigned int total_bytes_sent
Total number of bytes this peer has sent.
A single logging time step for a peer.
static struct LoggingHandle * l
#define BW_TEMPLATE
struct LoggingHandle * GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, const char *testname, struct BenchmarkPeer *masters, int num_masters, int num_slaves, int verbose)
Start logging.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
unsigned int total_messages_sent
Total number of messages this peer has sent.
int num_partners
Number of partners.
Definition: ats-testing.h:193
int no
Unique identifier.
Definition: ats-testing.h:118
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
unsigned int total_app_rtt
Accumulated RTT for all messages.
Definition: ats-testing.h:304
void GNUNET_ATS_TEST_logging_stop(struct LoggingHandle *l)
Stop logging.
static int verbose
uint32_t bandwidth_in
Bandwidth assigned inbound.
Definition: ats-testing.h:334
Information we track for a peer in the testbed.
Definition: ats-testing.h:109
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:817
double pref_delay
Current preference values for delay.
Definition: ats-testing.h:349
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
unsigned int total_app_rtt
Accumulated RTT for all messages.
void GNUNET_ATS_TEST_logging_clean_up(struct LoggingHandle *l)
Clean up logging data.
Information about a benchmarking partner.
Definition: ats-testing.h:270
struct GNUNET_TIME_Relative delay
Delay.
unsigned int messages_received
Number of messages received from this partner.
Definition: ats-testing.h:319
uint32_t bandwidth_out
Bandwidth assigned outbound.
Definition: ats-testing.h:339
ats testing library: setup topology and provide logging to test ats
struct GNUNET_TIME_Absolute start
Start time.
struct GNUNET_TIME_Relative frequency
unsigned int app_rtt
Current application level delay.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Entry for a benchmark peer.
unsigned int total_messages_received
Total number of messages this peer has received.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
unsigned int throughput_sent
Total outbound throughput for master in Bytes / s.
Open the file for writing.
unsigned int total_throughput_send
Total outbound throughput for master in Bytes / s.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_TIME_Relative ats_delay
static struct GNUNET_FS_Handle * fs
Handle to FS service.
Definition: gnunet-fs.c:36
#define LOG_ITEMS_TIME
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_TIME_Absolute timestamp
Logging timestamp.
unsigned int bytes_sent
Number of bytes sent to this partner.
Definition: ats-testing.h:314
unsigned int total_messages_sent
Total number of messages this peer has sent.
struct GNUNET_SCHEDULER_Task * log_task
Logging task.
struct PeerLoggingTimestep * tail
DLL for logging entries: tail.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
#define LOG_ITEM_THROUGHPUT_SENT
unsigned int total_throughput_recv
Total inbound throughput for master in Bytes / s.
#define LOG_ITEM_ATS_BW_OUT
struct PeerLoggingTimestep * next
Next in DLL.
int num_masters
Reference to perf_ats&#39; masters.
#define LOG_ITEM_THROUGHPUT_RECV
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:353
struct GNUNET_ATS_Properties props
Current ATS properties.
Definition: ats-testing.h:329
void GNUNET_ATS_TEST_logging_now(struct LoggingHandle *l)
Log all data now.
unsigned int total_bytes_received
Total number of bytes this peer has received.
uint32_t data
The data value.
static void write_throughput_gnuplot_script(char *fn, struct LoggingPeer *lp, char **fs, int slaves)
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1262
unsigned int distance
Distance on network layer (required for distance-vector routing) in hops.
Handle used to access files (and pipes).
struct BenchmarkPeer * dest
The partner peer.
Definition: ats-testing.h:279
#define GNUNET_malloc(size)
Wrapper around malloc.
unsigned int total_bytes_received
Total number of bytes this peer has received.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
#define THROUGHPUT_TEMPLATE
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956