aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c116
1 files changed, 94 insertions, 22 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