diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-21 16:40:02 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-21 16:40:02 +0000 |
commit | 93439a8d006ca880e16afeaec046b4b228f1e62c (patch) | |
tree | f271e7a5624130590ca55b2f01f6dfddc70691f2 /src | |
parent | 3f64fee3bd8ad3d97e13082e59f434f34326314d (diff) | |
download | gnunet-93439a8d006ca880e16afeaec046b4b228f1e62c.tar.gz gnunet-93439a8d006ca880e16afeaec046b4b228f1e62c.zip |
fixes for ats measurement
Diffstat (limited to 'src')
-rw-r--r-- | src/ats-tests/ats-testing.c | 103 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.h | 5 | ||||
-rw-r--r-- | src/ats-tests/gnunet-ats-sim.c | 12 | ||||
-rw-r--r-- | src/ats-tests/perf_ats.c | 3 |
4 files changed, 20 insertions, 103 deletions
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index 667edb71f..a8e451673 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c | |||
@@ -480,110 +480,13 @@ do_comm_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | |||
484 | static void | ||
485 | ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address, | ||
486 | int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
487 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
488 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) | ||
489 | { | ||
490 | struct BenchmarkPeer *me = cls; | ||
491 | struct BenchmarkPartner *p; | ||
492 | int c_a; | ||
493 | int log; | ||
494 | char *peer_id; | ||
495 | |||
496 | p = find_partner (me, &address->peer); | ||
497 | if (NULL == p) | ||
498 | { | ||
499 | /* This is not one of my partners | ||
500 | * Will happen since the peers will connect to each other due to gossiping | ||
501 | */ | ||
502 | return; | ||
503 | } | ||
504 | peer_id = GNUNET_strdup (GNUNET_i2s (&me->id)); | ||
505 | |||
506 | log = GNUNET_NO; | ||
507 | if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) || | ||
508 | (p->bandwidth_out != ntohl (bandwidth_out.value__))) | ||
509 | log = GNUNET_YES; | ||
510 | p->bandwidth_in = ntohl (bandwidth_in.value__); | ||
511 | p->bandwidth_out = ntohl (bandwidth_out.value__); | ||
512 | |||
513 | for (c_a = 0; c_a < ats_count; c_a++) | ||
514 | { | ||
515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information: %s %s %u\n", | ||
516 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", | ||
517 | p->me->no, | ||
518 | GNUNET_i2s (&p->dest->id), | ||
519 | GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)), | ||
520 | ntohl(ats[c_a].value)); | ||
521 | switch (ntohl (ats[c_a].type )) | ||
522 | { | ||
523 | case GNUNET_ATS_ARRAY_TERMINATOR: | ||
524 | break; | ||
525 | case GNUNET_ATS_UTILIZATION_OUT: | ||
526 | if (p->ats_utilization_up != ntohl (ats[c_a].value)) | ||
527 | log = GNUNET_YES; | ||
528 | p->ats_utilization_up = ntohl (ats[c_a].value); | ||
529 | |||
530 | break; | ||
531 | case GNUNET_ATS_UTILIZATION_IN: | ||
532 | if (p->ats_utilization_down != ntohl (ats[c_a].value)) | ||
533 | log = GNUNET_YES; | ||
534 | p->ats_utilization_down = ntohl (ats[c_a].value); | ||
535 | break; | ||
536 | case GNUNET_ATS_NETWORK_TYPE: | ||
537 | if (p->ats_network_type != ntohl (ats[c_a].value)) | ||
538 | log = GNUNET_YES; | ||
539 | p->ats_network_type = ntohl (ats[c_a].value); | ||
540 | break; | ||
541 | case GNUNET_ATS_QUALITY_NET_DELAY: | ||
542 | if (p->ats_delay != ntohl (ats[c_a].value)) | ||
543 | log = GNUNET_YES; | ||
544 | p->ats_delay = ntohl (ats[c_a].value); | ||
545 | break; | ||
546 | case GNUNET_ATS_QUALITY_NET_DISTANCE: | ||
547 | if (p->ats_distance != ntohl (ats[c_a].value)) | ||
548 | log = GNUNET_YES; | ||
549 | p->ats_distance = ntohl (ats[c_a].value); | ||
550 | GNUNET_break (0); | ||
551 | break; | ||
552 | case GNUNET_ATS_COST_WAN: | ||
553 | if (p->ats_cost_wan != ntohl (ats[c_a].value)) | ||
554 | log = GNUNET_YES; | ||
555 | p->ats_cost_wan = ntohl (ats[c_a].value); | ||
556 | break; | ||
557 | case GNUNET_ATS_COST_LAN: | ||
558 | if (p->ats_cost_lan != ntohl (ats[c_a].value)) | ||
559 | log = GNUNET_YES; | ||
560 | p->ats_cost_lan = ntohl (ats[c_a].value); | ||
561 | break; | ||
562 | case GNUNET_ATS_COST_WLAN: | ||
563 | if (p->ats_cost_wlan != ntohl (ats[c_a].value)) | ||
564 | log = GNUNET_YES; | ||
565 | p->ats_cost_wlan = ntohl (ats[c_a].value); | ||
566 | break; | ||
567 | default: | ||
568 | break; | ||
569 | } | ||
570 | } | ||
571 | if ((GNUNET_YES == top->logging) && (GNUNET_YES == log)) | ||
572 | { | ||
573 | // collect_log_now(); | ||
574 | } | ||
575 | GNUNET_free(peer_id); | ||
576 | } | ||
577 | |||
578 | |||
579 | static void * | 483 | static void * |
580 | ats_perf_connect_adapter (void *cls, | 484 | ats_perf_connect_adapter (void *cls, |
581 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 485 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
582 | { | 486 | { |
583 | struct BenchmarkPeer *me = cls; | 487 | struct BenchmarkPeer *me = cls; |
584 | 488 | ||
585 | me->ats_perf_handle = GNUNET_ATS_performance_init (cfg, | 489 | me->ats_perf_handle = GNUNET_ATS_performance_init (cfg, top->ats_perf_cb, me); |
586 | &ats_performance_info_cb, me); | ||
587 | if (NULL == me->ats_perf_handle) | 490 | if (NULL == me->ats_perf_handle) |
588 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 491 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
589 | "Failed to create ATS performance handle \n"); | 492 | "Failed to create ATS performance handle \n"); |
@@ -784,7 +687,8 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
784 | GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb, | 687 | GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb, |
785 | void *done_cb_cls, | 688 | void *done_cb_cls, |
786 | struct GNUNET_CORE_MessageHandler *handlers, | 689 | struct GNUNET_CORE_MessageHandler *handlers, |
787 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb) | 690 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, |
691 | GNUNET_ATS_AddressInformationCallback ats_perf_cb) | ||
788 | { | 692 | { |
789 | 693 | ||
790 | top = GNUNET_new (struct GNUNET_ATS_TEST_Topology); | 694 | top = GNUNET_new (struct GNUNET_ATS_TEST_Topology); |
@@ -795,6 +699,7 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
795 | top->done_cb_cls = done_cb_cls; | 699 | top->done_cb_cls = done_cb_cls; |
796 | top->test_core = test_core; | 700 | top->test_core = test_core; |
797 | top->transport_recv_cb = transport_recv_cb; | 701 | top->transport_recv_cb = transport_recv_cb; |
702 | top->ats_perf_cb = ats_perf_cb; | ||
798 | 703 | ||
799 | top->mps = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer)); | 704 | top->mps = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer)); |
800 | top->sps = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer)); | 705 | top->sps = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer)); |
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index 7dd05bb21..ce336511e 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h | |||
@@ -389,7 +389,7 @@ struct GNUNET_ATS_TEST_Topology | |||
389 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb; | 389 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb; |
390 | 390 | ||
391 | GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb; | 391 | GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb; |
392 | 392 | GNUNET_ATS_AddressInformationCallback ats_perf_cb; | |
393 | void *done_cb_cls; | 393 | void *done_cb_cls; |
394 | }; | 394 | }; |
395 | 395 | ||
@@ -401,7 +401,8 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
401 | GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb, | 401 | GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb, |
402 | void *done_cb_cls, | 402 | void *done_cb_cls, |
403 | struct GNUNET_CORE_MessageHandler *handlers, | 403 | struct GNUNET_CORE_MessageHandler *handlers, |
404 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb); | 404 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb, |
405 | GNUNET_ATS_AddressInformationCallback ats_perf_cb); | ||
405 | 406 | ||
406 | void | 407 | void |
407 | GNUNET_ATS_TEST_shutdown_topology (void); | 408 | GNUNET_ATS_TEST_shutdown_topology (void); |
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c index 7a7508503..0b0e9dd7e 100644 --- a/src/ats-tests/gnunet-ats-sim.c +++ b/src/ats-tests/gnunet-ats-sim.c | |||
@@ -62,6 +62,15 @@ transport_recv_cb (void *cls, | |||
62 | 62 | ||
63 | } | 63 | } |
64 | 64 | ||
65 | static void | ||
66 | ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address, | ||
67 | int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
68 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
69 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) | ||
70 | { | ||
71 | |||
72 | } | ||
73 | |||
65 | static void topology_setup_done (void *cls, | 74 | static void topology_setup_done (void *cls, |
66 | struct BenchmarkPeer *masters, | 75 | struct BenchmarkPeer *masters, |
67 | struct BenchmarkPeer *slaves) | 76 | struct BenchmarkPeer *slaves) |
@@ -88,7 +97,8 @@ main (int argc, char *argv[]) | |||
88 | &topology_setup_done, | 97 | &topology_setup_done, |
89 | NULL, | 98 | NULL, |
90 | handlers, | 99 | handlers, |
91 | &transport_recv_cb); | 100 | &transport_recv_cb, |
101 | &ats_performance_info_cb); | ||
92 | return 0; | 102 | return 0; |
93 | } | 103 | } |
94 | /* end of file perf_ats_topogy.c */ | 104 | /* end of file perf_ats_topogy.c */ |
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c index de991e926..c79e291b8 100644 --- a/src/ats-tests/perf_ats.c +++ b/src/ats-tests/perf_ats.c | |||
@@ -727,7 +727,8 @@ main (int argc, char *argv[]) | |||
727 | 727 | ||
728 | GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name, | 728 | GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name, |
729 | num_slaves, num_masters, test_core, | 729 | num_slaves, num_masters, test_core, |
730 | &do_benchmark, NULL, handlers, &transport_recv_cb); | 730 | &do_benchmark, NULL, handlers, &transport_recv_cb, |
731 | &ats_performance_info_cb); | ||
731 | 732 | ||
732 | return result; | 733 | return result; |
733 | } | 734 | } |