aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests/perf_ats.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-21 21:08:52 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-21 21:08:52 +0000
commit3770eff61976eb1befadf76b6a8a9d2f3da80762 (patch)
tree6ad2be75d0c4df4af9bb58e274397b54c170f869 /src/ats-tests/perf_ats.c
parent61cb58f43e90c66637e395bd852832a49c61794b (diff)
downloadgnunet-3770eff61976eb1befadf76b6a8a9d2f3da80762.tar.gz
gnunet-3770eff61976eb1befadf76b6a8a9d2f3da80762.zip
logging on demand + log bandwidth
Diffstat (limited to 'src/ats-tests/perf_ats.c')
-rw-r--r--src/ats-tests/perf_ats.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c
index 822666b2f..66ad94bc5 100644
--- a/src/ats-tests/perf_ats.c
+++ b/src/ats-tests/perf_ats.c
@@ -750,27 +750,15 @@ static int
750comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other, 750comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other,
751 const struct GNUNET_MessageHeader *message) 751 const struct GNUNET_MessageHeader *message)
752{ 752{
753 int c_s;
754 struct BenchmarkPeer *me = cls; 753 struct BenchmarkPeer *me = cls;
755 struct BenchmarkPartner *p = NULL; 754 struct BenchmarkPartner *p = NULL;
756 755
757 for (c_s = 0; c_s < num_slaves; c_s++) 756 if (NULL == (p = find_partner (me, other)))
758 {
759 if (0
760 == memcmp (other, &me->partners[c_s].dest->id,
761 sizeof(struct GNUNET_PeerIdentity)))
762 {
763 p = &me->partners[c_s];
764 break;
765 }
766 }
767 if (NULL == p)
768 { 757 {
769 GNUNET_break(0); 758 GNUNET_break(0);
770 return GNUNET_SYSERR; 759 return GNUNET_SYSERR;
771 } 760 }
772 761
773
774 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 762 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
775 "Master [%u]: Received PONG from [%u], next message\n", me->no, 763 "Master [%u]: Received PONG from [%u], next message\n", me->no,
776 p->dest->no); 764 p->dest->no);
@@ -920,23 +908,11 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
920{ 908{
921 struct BenchmarkPeer *me = cls; 909 struct BenchmarkPeer *me = cls;
922 struct BenchmarkPartner *p; 910 struct BenchmarkPartner *p;
923 int c_s;
924 int c_a; 911 int c_a;
912 int log;
925 char *peer_id; 913 char *peer_id;
926 914
927 p = NULL; 915 p = find_partner (me, &address->peer);
928 for (c_s = 0; c_s < me->num_partners; c_s++)
929 {
930
931 if (0 == memcmp (&address->peer, &me->partners[c_s].dest->id,
932 sizeof (struct GNUNET_PeerIdentity)))
933 {
934 p = &me->partners[c_s];
935 break;
936 }
937
938 }
939
940 if (NULL == p) 916 if (NULL == p)
941 { 917 {
942 /* This is not one of my partners 918 /* This is not one of my partners
@@ -944,9 +920,15 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
944 */ 920 */
945 return; 921 return;
946 } 922 }
947
948 peer_id = GNUNET_strdup (GNUNET_i2s (&me->id)); 923 peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
949 924
925 log = GNUNET_NO;
926 if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
927 (p->bandwidth_out != ntohl (bandwidth_out.value__)))
928 log = GNUNET_YES;
929 p->bandwidth_in = ntohl (bandwidth_in.value__);
930 p->bandwidth_out = ntohl (bandwidth_out.value__);
931
950 for (c_a = 0; c_a < ats_count; c_a++) 932 for (c_a = 0; c_a < ats_count; c_a++)
951 { 933 {
952 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information: %s %s %u\n", 934 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information: %s %s %u\n",
@@ -960,36 +942,52 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
960 case GNUNET_ATS_ARRAY_TERMINATOR: 942 case GNUNET_ATS_ARRAY_TERMINATOR:
961 break; 943 break;
962 case GNUNET_ATS_UTILIZATION_UP: 944 case GNUNET_ATS_UTILIZATION_UP:
945 if (p->ats_utilization_up != ntohl (ats[c_a].value))
946 log = GNUNET_YES;
963 p->ats_utilization_up = ntohl (ats[c_a].value); 947 p->ats_utilization_up = ntohl (ats[c_a].value);
948
964 break; 949 break;
965 case GNUNET_ATS_UTILIZATION_DOWN: 950 case GNUNET_ATS_UTILIZATION_DOWN:
951 if (p->ats_utilization_down != ntohl (ats[c_a].value))
952 log = GNUNET_YES;
966 p->ats_utilization_down = ntohl (ats[c_a].value); 953 p->ats_utilization_down = ntohl (ats[c_a].value);
967 break; 954 break;
968 case GNUNET_ATS_NETWORK_TYPE: 955 case GNUNET_ATS_NETWORK_TYPE:
956 if (p->ats_network_type != ntohl (ats[c_a].value))
957 log = GNUNET_YES;
969 p->ats_network_type = ntohl (ats[c_a].value); 958 p->ats_network_type = ntohl (ats[c_a].value);
970 break; 959 break;
971 case GNUNET_ATS_QUALITY_NET_DELAY: 960 case GNUNET_ATS_QUALITY_NET_DELAY:
961 if (p->ats_delay != ntohl (ats[c_a].value))
962 log = GNUNET_YES;
972 p->ats_delay = ntohl (ats[c_a].value); 963 p->ats_delay = ntohl (ats[c_a].value);
973 break; 964 break;
974 case GNUNET_ATS_QUALITY_NET_DISTANCE: 965 case GNUNET_ATS_QUALITY_NET_DISTANCE:
966 if (p->ats_distance != ntohl (ats[c_a].value))
967 log = GNUNET_YES;
975 p->ats_distance = ntohl (ats[c_a].value); 968 p->ats_distance = ntohl (ats[c_a].value);
976 GNUNET_break (0); 969 GNUNET_break (0);
977 break; 970 break;
978 case GNUNET_ATS_COST_WAN: 971 case GNUNET_ATS_COST_WAN:
972 if (p->ats_cost_wan != ntohl (ats[c_a].value))
973 log = GNUNET_YES;
979 p->ats_cost_wan = ntohl (ats[c_a].value); 974 p->ats_cost_wan = ntohl (ats[c_a].value);
980 break; 975 break;
981 case GNUNET_ATS_COST_LAN: 976 case GNUNET_ATS_COST_LAN:
977 if (p->ats_cost_lan != ntohl (ats[c_a].value))
978 log = GNUNET_YES;
982 p->ats_cost_lan = ntohl (ats[c_a].value); 979 p->ats_cost_lan = ntohl (ats[c_a].value);
983 break; 980 break;
984 case GNUNET_ATS_COST_WLAN: 981 case GNUNET_ATS_COST_WLAN:
982 if (p->ats_cost_wlan != ntohl (ats[c_a].value))
983 log = GNUNET_YES;
985 p->ats_cost_wlan = ntohl (ats[c_a].value); 984 p->ats_cost_wlan = ntohl (ats[c_a].value);
986 break; 985 break;
987 break;
988 default: 986 default:
989 break; 987 break;
990 } 988 }
991 } 989 }
992 if (GNUNET_YES == logging) 990 if ((GNUNET_YES == logging) && (GNUNET_YES == log))
993 collect_log_now(); 991 collect_log_now();
994 GNUNET_free(peer_id); 992 GNUNET_free(peer_id);
995} 993}