diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-30 08:29:58 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-30 08:29:58 +0000 |
commit | 5fcfc5b84691d1abb216ba5d5ab4b6b8a1f807f4 (patch) | |
tree | b76f2ba3dbe5c4495e16b401d92b177bcbd71f0c | |
parent | 1c45def2ce88a925031cf6fcc24fa3cfce6a7075 (diff) | |
download | gnunet-5fcfc5b84691d1abb216ba5d5ab4b6b8a1f807f4.tar.gz gnunet-5fcfc5b84691d1abb216ba5d5ab4b6b8a1f807f4.zip |
documentation
-rw-r--r-- | src/ats-tests/ats-testing-log.c | 10 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.c | 16 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.h | 125 |
3 files changed, 136 insertions, 15 deletions
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c index ffd55c88e..29408d1f8 100644 --- a/src/ats-tests/ats-testing-log.c +++ b/src/ats-tests/ats-testing-log.c | |||
@@ -403,7 +403,7 @@ write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
403 | 403 | ||
404 | 404 | ||
405 | void | 405 | void |
406 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, char *test) | 406 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, char *test_name) |
407 | { | 407 | { |
408 | struct GNUNET_DISK_FileHandle *f; | 408 | struct GNUNET_DISK_FileHandle *f; |
409 | 409 | ||
@@ -418,7 +418,7 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, char *test) | |||
418 | 418 | ||
419 | for (c_m = 0; c_m < l->num_peers; c_m++) | 419 | for (c_m = 0; c_m < l->num_peers; c_m++) |
420 | { | 420 | { |
421 | GNUNET_asprintf (&filename, "%s_%llu_master_%u_%s_%s.data", test, GNUNET_TIME_absolute_get().abs_value_us, | 421 | GNUNET_asprintf (&filename, "%s_%llu_master_%u_%s_%s.data", test_name, GNUNET_TIME_absolute_get().abs_value_us, |
422 | l->lp[c_m].peer->no, GNUNET_i2s(&l->lp[c_m].peer->id), l->name); | 422 | l->lp[c_m].peer->no, GNUNET_i2s(&l->lp[c_m].peer->id), l->name); |
423 | 423 | ||
424 | f = GNUNET_DISK_file_open (filename, | 424 | f = GNUNET_DISK_file_open (filename, |
@@ -496,7 +496,11 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, char *test) | |||
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | /** | |
500 | * Log all data now | ||
501 | * | ||
502 | * @param llogging handle to use | ||
503 | */ | ||
500 | void | 504 | void |
501 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | 505 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) |
502 | { | 506 | { |
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index fea04f41b..381dd7bb6 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c | |||
@@ -837,6 +837,19 @@ controller_event_cb (void *cls, | |||
837 | } | 837 | } |
838 | 838 | ||
839 | 839 | ||
840 | /** | ||
841 | * Create a topology for ats testing | ||
842 | * | ||
843 | * @param name test name | ||
844 | * @param cfg_file configuration file to use for the peers | ||
845 | * @param num_slaves number of slaves | ||
846 | * @param num_masters number of masters | ||
847 | * @param test_core connect to CORE service (GNUNET_YES) or transport (GNUNET_NO) | ||
848 | * @param done_cb function to call when topology is setup | ||
849 | * @param done_cb_cls cls for callback | ||
850 | * @param recv_cb callback to call when data are received | ||
851 | * @param perf_cb callback to call when performance info are received | ||
852 | */ | ||
840 | void | 853 | void |
841 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | 854 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, |
842 | unsigned int num_slaves, | 855 | unsigned int num_slaves, |
@@ -876,6 +889,9 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
876 | &main_run, NULL); | 889 | &main_run, NULL); |
877 | } | 890 | } |
878 | 891 | ||
892 | /** | ||
893 | * Shutdown topology | ||
894 | */ | ||
879 | void | 895 | void |
880 | GNUNET_ATS_TEST_shutdown_topology (void) | 896 | GNUNET_ATS_TEST_shutdown_topology (void) |
881 | { | 897 | { |
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index 8a59fb3f8..91c15d6d1 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h | |||
@@ -31,26 +31,62 @@ | |||
31 | 31 | ||
32 | #define TEST_ATS_PREFERENCE_DEFAULT 1.0 | 32 | #define TEST_ATS_PREFERENCE_DEFAULT 1.0 |
33 | 33 | ||
34 | /** | ||
35 | * Message type sent for traffic generation | ||
36 | */ | ||
34 | #define TEST_MESSAGE_TYPE_PING 12345 | 37 | #define TEST_MESSAGE_TYPE_PING 12345 |
38 | |||
39 | /** | ||
40 | * Message type sent as response during traffic generation | ||
41 | */ | ||
35 | #define TEST_MESSAGE_TYPE_PONG 12346 | 42 | #define TEST_MESSAGE_TYPE_PONG 12346 |
43 | |||
44 | /** | ||
45 | * Size of test messages | ||
46 | */ | ||
36 | #define TEST_MESSAGE_SIZE 100 | 47 | #define TEST_MESSAGE_SIZE 100 |
37 | 48 | ||
38 | struct BenchmarkPartner; | 49 | struct BenchmarkPartner; |
50 | |||
39 | struct BenchmarkPeer; | 51 | struct BenchmarkPeer; |
52 | |||
40 | struct GNUNET_ATS_TEST_Topology; | 53 | struct GNUNET_ATS_TEST_Topology; |
54 | |||
41 | struct TrafficGenerator; | 55 | struct TrafficGenerator; |
56 | |||
42 | struct LoggingHandle; | 57 | struct LoggingHandle; |
43 | 58 | ||
59 | |||
60 | /** | ||
61 | * Callback to call when topology setup is completed | ||
62 | * | ||
63 | * @param cls the closure | ||
64 | * @param masters array of master peers | ||
65 | * @param slaves array of master peers | ||
66 | */ | ||
44 | typedef void (*GNUNET_ATS_TEST_TopologySetupDoneCallback) (void *cls, | 67 | typedef void (*GNUNET_ATS_TEST_TopologySetupDoneCallback) (void *cls, |
45 | struct BenchmarkPeer *masters, | 68 | struct BenchmarkPeer *masters, |
46 | struct BenchmarkPeer *slaves); | 69 | struct BenchmarkPeer *slaves); |
47 | 70 | ||
71 | /** | ||
72 | * Callback called when logging is required for the data contained | ||
73 | * | ||
74 | * @param cls the closure | ||
75 | * @param address an address | ||
76 | * @param address_active is address active | ||
77 | * @param bandwidth_out bandwidth outbound | ||
78 | * @param bandwidth_in bandwidth inbound | ||
79 | * @param ats ats information | ||
80 | * @param ats_count number of ats inforation | ||
81 | */ | ||
48 | typedef void | 82 | typedef void |
49 | (*GNUNET_ATS_TEST_LogRequest) (void *cls, | 83 | (*GNUNET_ATS_TEST_LogRequest) (void *cls, |
50 | const struct GNUNET_HELLO_Address *address, int address_active, | 84 | const struct GNUNET_HELLO_Address *address, |
85 | int address_active, | ||
51 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 86 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
52 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 87 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
53 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count); | 88 | const struct GNUNET_ATS_Information *ats, |
89 | uint32_t ats_count); | ||
54 | 90 | ||
55 | /** | 91 | /** |
56 | * Information we track for a peer in the testbed. | 92 | * Information we track for a peer in the testbed. |
@@ -444,21 +480,56 @@ struct Experiment | |||
444 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; | 480 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; |
445 | }; | 481 | }; |
446 | 482 | ||
483 | /* | ||
484 | * Experiment related functions | ||
485 | */ | ||
486 | |||
487 | |||
488 | /** | ||
489 | * Execute the specified experiment | ||
490 | * | ||
491 | * @param e the Experiment | ||
492 | * @param ep_done_cb a episode is completed | ||
493 | * @param e_done_cb the experiment is completed | ||
494 | */ | ||
447 | void | 495 | void |
448 | GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, | 496 | GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, |
449 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, | 497 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, |
450 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb); | 498 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb); |
451 | 499 | ||
500 | /** | ||
501 | * Load an experiment from a file | ||
502 | * | ||
503 | * @param filename the file | ||
504 | * @return the Experiment or NULL on failure | ||
505 | */ | ||
452 | struct Experiment * | 506 | struct Experiment * |
453 | GNUNET_ATS_TEST_experimentation_load (char *filename); | 507 | GNUNET_ATS_TEST_experimentation_load (char *filename); |
454 | 508 | ||
509 | |||
510 | /** | ||
511 | * Stop an experiment | ||
512 | * | ||
513 | * @param e the experiment | ||
514 | */ | ||
455 | void | 515 | void |
456 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e); | 516 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e); |
457 | 517 | ||
518 | /* | ||
519 | * Traffic related functions | ||
520 | */ | ||
521 | |||
522 | void | ||
523 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); | ||
524 | |||
525 | void | ||
526 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); | ||
527 | |||
458 | 528 | ||
459 | struct TrafficGenerator * | 529 | struct TrafficGenerator * |
460 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 530 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, |
461 | struct BenchmarkPartner *dest, unsigned int rate, | 531 | struct BenchmarkPartner *dest, |
532 | unsigned int rate, | ||
462 | struct GNUNET_TIME_Relative duration); | 533 | struct GNUNET_TIME_Relative duration); |
463 | 534 | ||
464 | void | 535 | void |
@@ -470,6 +541,11 @@ GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg); | |||
470 | void | 541 | void |
471 | GNUNET_ATS_TEST_generate_traffic_stop_all (); | 542 | GNUNET_ATS_TEST_generate_traffic_stop_all (); |
472 | 543 | ||
544 | |||
545 | /* | ||
546 | * Logging related functions | ||
547 | */ | ||
548 | |||
473 | /** | 549 | /** |
474 | * Start logging | 550 | * Start logging |
475 | * | 551 | * |
@@ -481,7 +557,9 @@ GNUNET_ATS_TEST_generate_traffic_stop_all (); | |||
481 | */ | 557 | */ |
482 | struct LoggingHandle * | 558 | struct LoggingHandle * |
483 | GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, | 559 | GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, |
484 | char * testname, struct BenchmarkPeer *masters, int num_masters); | 560 | char * testname, |
561 | struct BenchmarkPeer *masters, | ||
562 | int num_masters); | ||
485 | 563 | ||
486 | /** | 564 | /** |
487 | * Stop logging | 565 | * Stop logging |
@@ -493,20 +571,40 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l); | |||
493 | 571 | ||
494 | /** | 572 | /** |
495 | * Log all data now | 573 | * Log all data now |
574 | * | ||
575 | * @param llogging handle to use | ||
496 | */ | 576 | */ |
497 | void | 577 | void |
498 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *); | 578 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l); |
499 | 579 | ||
500 | void | ||
501 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *, char *test); | ||
502 | |||
503 | void | ||
504 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); | ||
505 | 580 | ||
581 | /** | ||
582 | * Write logging data to file | ||
583 | * | ||
584 | * @param l logging handle to use | ||
585 | * @param test_name name of the current test | ||
586 | */ | ||
506 | void | 587 | void |
507 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); | 588 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *h, |
589 | char *test_name); | ||
508 | 590 | ||
591 | /* | ||
592 | * Topology related functions | ||
593 | */ | ||
509 | 594 | ||
595 | /** | ||
596 | * Create a topology for ats testing | ||
597 | * | ||
598 | * @param name test name | ||
599 | * @param cfg_file configuration file to use for the peers | ||
600 | * @param num_slaves number of slaves | ||
601 | * @param num_masters number of masters | ||
602 | * @param test_core connect to CORE service (GNUNET_YES) or transport (GNUNET_NO) | ||
603 | * @param done_cb function to call when topology is setup | ||
604 | * @param done_cb_cls cls for callback | ||
605 | * @param recv_cb callback to call when data are received | ||
606 | * @param perf_cb callback to call when performance info are received | ||
607 | */ | ||
510 | void | 608 | void |
511 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | 609 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, |
512 | unsigned int num_slaves, | 610 | unsigned int num_slaves, |
@@ -514,9 +612,12 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
514 | int test_core, | 612 | int test_core, |
515 | GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, | 613 | GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, |
516 | void *done_cb_cls, | 614 | void *done_cb_cls, |
517 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, | 615 | GNUNET_TRANSPORT_ReceiveCallback recv_cb, |
518 | GNUNET_ATS_TEST_LogRequest ats_perf_cb); | 616 | GNUNET_ATS_TEST_LogRequest ats_perf_cb); |
519 | 617 | ||
618 | /** | ||
619 | * Shutdown topology | ||
620 | */ | ||
520 | void | 621 | void |
521 | GNUNET_ATS_TEST_shutdown_topology (void); | 622 | GNUNET_ATS_TEST_shutdown_topology (void); |
522 | 623 | ||