aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-10-18 12:37:02 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-10-18 12:37:02 +0000
commit18642e4b759b39aa644d8a232c31c2a755d707bb (patch)
treed49d6df6e161ce47ea66d8aa1f2411dff9bef6dc /src
parent0205ef3adaf5aca84807cec3e83ea41eda8df889 (diff)
downloadgnunet-18642e4b759b39aa644d8a232c31c2a755d707bb.tar.gz
gnunet-18642e4b759b39aa644d8a232c31c2a755d707bb.zip
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c116
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h16
-rw-r--r--src/transport/test_transport_api_reliability.c11
-rw-r--r--src/transport/test_transport_api_unreliability.c11
4 files changed, 123 insertions, 31 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 5195c90cd..53505407e 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -540,12 +540,24 @@ struct NeighbourMapEntry
540 /** 540 /**
541 * Tracking utilization of outbound bandwidth 541 * Tracking utilization of outbound bandwidth
542 */ 542 */
543 uint32_t util_bytes_sent; 543 uint32_t util_payload_bytes_sent;
544 544
545 /** 545 /**
546 * Tracking utilization of inbound bandwidth 546 * Tracking utilization of inbound bandwidth
547 */ 547 */
548 uint32_t util_bytes_recv; 548 uint32_t util_payload_bytes_recv;
549
550 /**
551 * Tracking utilization of outbound bandwidth
552 */
553 uint32_t util_total_bytes_sent;
554
555 /**
556 * Tracking utilization of inbound bandwidth
557 */
558 uint32_t util_total_bytes_recv;
559
560
549 561
550 562
551 /** 563 /**
@@ -1196,13 +1208,10 @@ transmit_send_continuation (void *cls,
1196 ("# bytes in message queue for other peers"), 1208 ("# bytes in message queue for other peers"),
1197 bytes_in_send_queue, GNUNET_NO); 1209 bytes_in_send_queue, GNUNET_NO);
1198 if (GNUNET_OK == success) 1210 if (GNUNET_OK == success)
1199 {
1200 n->util_bytes_sent += size_payload;
1201 GNUNET_STATISTICS_update (GST_stats, 1211 GNUNET_STATISTICS_update (GST_stats,
1202 gettext_noop 1212 gettext_noop
1203 ("# messages transmitted to other peers"), 1213 ("# messages transmitted to other peers"),
1204 1, GNUNET_NO); 1214 1, GNUNET_NO);
1205 }
1206 else 1215 else
1207 GNUNET_STATISTICS_update (GST_stats, 1216 GNUNET_STATISTICS_update (GST_stats,
1208 gettext_noop 1217 gettext_noop
@@ -1648,8 +1657,10 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
1648 n->state = S_NOT_CONNECTED; 1657 n->state = S_NOT_CONNECTED;
1649 n->latency = GNUNET_TIME_UNIT_FOREVER_REL; 1658 n->latency = GNUNET_TIME_UNIT_FOREVER_REL;
1650 n->last_util_transmission = GNUNET_TIME_absolute_get(); 1659 n->last_util_transmission = GNUNET_TIME_absolute_get();
1651 n->util_bytes_recv = 0; 1660 n->util_payload_bytes_recv = 0;
1652 n->util_bytes_sent = 0; 1661 n->util_payload_bytes_sent = 0;
1662 n->util_total_bytes_recv = 0;
1663 n->util_total_bytes_sent = 0;
1653 GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, 1664 GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
1654 GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, 1665 GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
1655 MAX_BANDWIDTH_CARRY_S); 1666 MAX_BANDWIDTH_CARRY_S);
@@ -2369,31 +2380,51 @@ send_utilization_data (void *cls,
2369 void *value) 2380 void *value)
2370{ 2381{
2371 struct NeighbourMapEntry *n = value; 2382 struct NeighbourMapEntry *n = value;
2372 struct GNUNET_ATS_Information atsi[2]; 2383 struct GNUNET_ATS_Information atsi[4];
2384 uint32_t bps_pl_in;
2385 uint32_t bps_pl_out;
2373 uint32_t bps_in; 2386 uint32_t bps_in;
2374 uint32_t bps_out; 2387 uint32_t bps_out;
2375 struct GNUNET_TIME_Relative delta; 2388 struct GNUNET_TIME_Relative delta;
2376 2389
2377 delta = GNUNET_TIME_absolute_get_difference(n->last_util_transmission, GNUNET_TIME_absolute_get()); 2390 delta = GNUNET_TIME_absolute_get_difference(n->last_util_transmission, GNUNET_TIME_absolute_get());
2391
2392 bps_pl_in = 0;
2393 if (0 != n->util_payload_bytes_recv)
2394 bps_pl_in = (1000LL * 1000LL * n->util_payload_bytes_recv) / (delta.rel_value_us);
2395 bps_pl_out = 0;
2396 if (0 != n->util_payload_bytes_sent)
2397 bps_pl_out = (1000LL * 1000LL * n->util_payload_bytes_sent) / delta.rel_value_us;
2398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' payload: received %u Bytes/s, sent %u Bytes/s \n",
2399 GNUNET_i2s (key), bps_pl_in, bps_pl_out);
2400
2378 bps_in = 0; 2401 bps_in = 0;
2379 if (0 != n->util_bytes_recv) 2402 if (0 != n->util_total_bytes_recv)
2380 bps_in = (1000LL * 1000LL * n->util_bytes_recv) / (delta.rel_value_us); 2403 bps_in = (1000LL * 1000LL * n->util_total_bytes_recv) / (delta.rel_value_us);
2381 bps_out = 0; 2404 bps_out = 0;
2382 if (0 != n->util_bytes_sent) 2405 if (0 != n->util_total_bytes_sent)
2383 bps_out = (1000LL * 1000LL * n->util_bytes_sent) / delta.rel_value_us; 2406 bps_out = (1000LL * 1000LL * n->util_total_bytes_sent) / delta.rel_value_us;
2384 2407
2385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s'received %u Bytes/s, sent %u Bytes/s \n",
2386 GNUNET_i2s (key), bps_in, bps_out);
2387 2408
2409 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' total: received %u Bytes/s, sent %u Bytes/s \n",
2410 GNUNET_i2s (key), bps_in, bps_out);
2388 2411
2389 atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_UP); 2412 atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_OUT);
2390 atsi[0].value = htonl (bps_out); 2413 atsi[0].value = htonl (bps_out);
2391 atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_DOWN); 2414 atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_IN);
2392 atsi[1].value = htonl (bps_in); 2415 atsi[1].value = htonl (bps_in);
2416
2417 atsi[2].type = htonl (GNUNET_ATS_UTILIZATION_PAYLOAD_OUT);
2418 atsi[2].value = htonl (bps_pl_out);
2419 atsi[3].type = htonl (GNUNET_ATS_UTILIZATION_PAYLOAD_IN);
2420 atsi[3].value = htonl (bps_pl_in);
2421
2393 GST_ats_update_metrics (key, n->primary_address.address, 2422 GST_ats_update_metrics (key, n->primary_address.address,
2394 n->primary_address.session, atsi, 2); 2423 n->primary_address.session, atsi, 4);
2395 n->util_bytes_recv = 0; 2424 n->util_payload_bytes_recv = 0;
2396 n->util_bytes_sent = 0; 2425 n->util_payload_bytes_sent = 0;
2426 n->util_total_bytes_recv = 0;
2427 n->util_total_bytes_sent = 0;
2397 n->last_util_transmission = GNUNET_TIME_absolute_get(); 2428 n->last_util_transmission = GNUNET_TIME_absolute_get();
2398 return GNUNET_OK; 2429 return GNUNET_OK;
2399} 2430}
@@ -2419,7 +2450,7 @@ utilization_transmission (void *cls,
2419} 2450}
2420 2451
2421void 2452void
2422GST_neighbours_notify_payload (const struct GNUNET_PeerIdentity *peer, 2453GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
2423 const struct GNUNET_HELLO_Address *address, 2454 const struct GNUNET_HELLO_Address *address,
2424 struct Session *session, 2455 struct Session *session,
2425 const struct GNUNET_MessageHeader *message) 2456 const struct GNUNET_MessageHeader *message)
@@ -2428,10 +2459,51 @@ GST_neighbours_notify_payload (const struct GNUNET_PeerIdentity *peer,
2428 n = lookup_neighbour (peer); 2459 n = lookup_neighbour (peer);
2429 if (NULL == n) 2460 if (NULL == n)
2430 { 2461 {
2431 GNUNET_break (0);
2432 return; 2462 return;
2433 } 2463 }
2434 n->util_bytes_recv += ntohs(message->size); 2464 n->util_total_bytes_recv += ntohs(message->size);
2465}
2466
2467void
2468GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
2469 const struct GNUNET_HELLO_Address *address,
2470 struct Session *session,
2471 const struct GNUNET_MessageHeader *message)
2472{
2473 struct NeighbourMapEntry *n;
2474 n = lookup_neighbour (peer);
2475 if (NULL == n)
2476 {
2477 return;
2478 }
2479 n->util_payload_bytes_recv += ntohs(message->size);
2480}
2481
2482
2483void
2484GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
2485 size_t size)
2486{
2487 struct NeighbourMapEntry *n;
2488 n = lookup_neighbour (peer);
2489 if (NULL == n)
2490 {
2491 return;
2492 }
2493 n->util_total_bytes_sent += size;
2494}
2495
2496void
2497GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer,
2498 size_t size)
2499{
2500 struct NeighbourMapEntry *n;
2501 n = lookup_neighbour (peer);
2502 if (NULL == n)
2503 {
2504 return;
2505 }
2506 n->util_payload_bytes_sent += size;
2435} 2507}
2436 2508
2437 2509
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h
index bd043a4b6..4875dd6d6 100644
--- a/src/transport/gnunet-service-transport_neighbours.h
+++ b/src/transport/gnunet-service-transport_neighbours.h
@@ -205,11 +205,25 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
205 205
206 206
207void 207void
208GST_neighbours_notify_payload (const struct GNUNET_PeerIdentity *peer, 208GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
209 const struct GNUNET_HELLO_Address *address, 209 const struct GNUNET_HELLO_Address *address,
210 struct Session *session, 210 struct Session *session,
211 const struct GNUNET_MessageHeader *message); 211 const struct GNUNET_MessageHeader *message);
212 212
213void
214GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
215 const struct GNUNET_HELLO_Address *address,
216 struct Session *session,
217 const struct GNUNET_MessageHeader *message);
218
219void
220GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer,
221 size_t size);
222
223void
224GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
225 size_t size);
226
213/** 227/**
214 * For an existing neighbour record, set the active connection to 228 * For an existing neighbour record, set the active connection to
215 * use the given address. 229 * use the given address.
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index d129350c2..7bad5ff4e 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -118,16 +118,19 @@ static void
118end () 118end ()
119{ 119{
120 unsigned long long delta; 120 unsigned long long delta;
121 121 unsigned long long rate;
122 char *value_name; 122 char *value_name;
123 123
124
124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); 125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n");
125 126
126 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; 127 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
127 FPRINTF (stderr, "\nThroughput was %llu kb/s\n", 128 rate = (1000LL * 1000LL * total_bytes) / (1024 * delta);
128 total_bytes * 1024 / delta); 129 FPRINTF (stderr, "\nThroughput was %llu KiBytes/s\n",
130 rate);
131
129 GNUNET_asprintf (&value_name, "reliable_%s", test_plugin); 132 GNUNET_asprintf (&value_name, "reliable_%s", test_plugin);
130 GAUGER ("TRANSPORT", value_name, (int) (total_bytes / 1024 / delta), 133 GAUGER ("TRANSPORT", value_name, (int) rate,
131 "kb/s"); 134 "kb/s");
132 GNUNET_free (value_name); 135 GNUNET_free (value_name);
133 136
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index 9bae154de..153a88685 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -126,16 +126,19 @@ static void
126end () 126end ()
127{ 127{
128 unsigned long long delta; 128 unsigned long long delta;
129 129 unsigned long long rate;
130 char *value_name; 130 char *value_name;
131 131
132
132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); 133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n");
133 134
134 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; 135 delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
135 FPRINTF (stderr, "\nThroughput was %llu kb/s\n", 136 rate = (1000LL* 1000ll * total_bytes) / (1024 * delta);
136 total_bytes * 1024 / delta); 137 FPRINTF (stderr, "\nThroughput was %llu KiBytes/s\n",
138 rate);
139
137 GNUNET_asprintf (&value_name, "unreliable_%s", test_plugin); 140 GNUNET_asprintf (&value_name, "unreliable_%s", test_plugin);
138 GAUGER ("TRANSPORT", value_name, (int) (total_bytes / 1024 / delta), 141 GAUGER ("TRANSPORT", value_name, (int) rate,
139 "kb/s"); 142 "kb/s");
140 GNUNET_free (value_name); 143 GNUNET_free (value_name);
141 144