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