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