summaryrefslogtreecommitdiff
path: root/src/transport
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/transport
parent0205ef3adaf5aca84807cec3e83ea41eda8df889 (diff)
Diffstat (limited to 'src/transport')
-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
/**
* Tracking utilization of outbound bandwidth
*/
- uint32_t util_bytes_sent;
+ uint32_t util_payload_bytes_sent;
/**
* Tracking utilization of inbound bandwidth
*/
- uint32_t util_bytes_recv;
+ uint32_t util_payload_bytes_recv;
+
+ /**
+ * Tracking utilization of outbound bandwidth
+ */
+ uint32_t util_total_bytes_sent;
+
+ /**
+ * Tracking utilization of inbound bandwidth
+ */
+ uint32_t util_total_bytes_recv;
+
+
/**
@@ -1196,13 +1208,10 @@ transmit_send_continuation (void *cls,
("# bytes in message queue for other peers"),
bytes_in_send_queue, GNUNET_NO);
if (GNUNET_OK == success)
- {
- n->util_bytes_sent += size_payload;
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
("# messages transmitted to other peers"),
1, GNUNET_NO);
- }
else
GNUNET_STATISTICS_update (GST_stats,
gettext_noop
@@ -1648,8 +1657,10 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer)
n->state = S_NOT_CONNECTED;
n->latency = GNUNET_TIME_UNIT_FOREVER_REL;
n->last_util_transmission = GNUNET_TIME_absolute_get();
- n->util_bytes_recv = 0;
- n->util_bytes_sent = 0;
+ n->util_payload_bytes_recv = 0;
+ n->util_payload_bytes_sent = 0;
+ n->util_total_bytes_recv = 0;
+ n->util_total_bytes_sent = 0;
GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
MAX_BANDWIDTH_CARRY_S);
@@ -2369,31 +2380,51 @@ send_utilization_data (void *cls,
void *value)
{
struct NeighbourMapEntry *n = value;
- struct GNUNET_ATS_Information atsi[2];
+ struct GNUNET_ATS_Information atsi[4];
+ uint32_t bps_pl_in;
+ uint32_t bps_pl_out;
uint32_t bps_in;
uint32_t bps_out;
struct GNUNET_TIME_Relative delta;
delta = GNUNET_TIME_absolute_get_difference(n->last_util_transmission, GNUNET_TIME_absolute_get());
+
+ bps_pl_in = 0;
+ if (0 != n->util_payload_bytes_recv)
+ bps_pl_in = (1000LL * 1000LL * n->util_payload_bytes_recv) / (delta.rel_value_us);
+ bps_pl_out = 0;
+ if (0 != n->util_payload_bytes_sent)
+ bps_pl_out = (1000LL * 1000LL * n->util_payload_bytes_sent) / delta.rel_value_us;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' payload: received %u Bytes/s, sent %u Bytes/s \n",
+ GNUNET_i2s (key), bps_pl_in, bps_pl_out);
+
bps_in = 0;
- if (0 != n->util_bytes_recv)
- bps_in = (1000LL * 1000LL * n->util_bytes_recv) / (delta.rel_value_us);
+ if (0 != n->util_total_bytes_recv)
+ bps_in = (1000LL * 1000LL * n->util_total_bytes_recv) / (delta.rel_value_us);
bps_out = 0;
- if (0 != n->util_bytes_sent)
- bps_out = (1000LL * 1000LL * n->util_bytes_sent) / delta.rel_value_us;
+ if (0 != n->util_total_bytes_sent)
+ bps_out = (1000LL * 1000LL * n->util_total_bytes_sent) / delta.rel_value_us;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s'received %u Bytes/s, sent %u Bytes/s \n",
- GNUNET_i2s (key), bps_in, bps_out);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' total: received %u Bytes/s, sent %u Bytes/s \n",
+ GNUNET_i2s (key), bps_in, bps_out);
- atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_UP);
+ atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_OUT);
atsi[0].value = htonl (bps_out);
- atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_DOWN);
+ atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_IN);
atsi[1].value = htonl (bps_in);
+
+ atsi[2].type = htonl (GNUNET_ATS_UTILIZATION_PAYLOAD_OUT);
+ atsi[2].value = htonl (bps_pl_out);
+ atsi[3].type = htonl (GNUNET_ATS_UTILIZATION_PAYLOAD_IN);
+ atsi[3].value = htonl (bps_pl_in);
+
GST_ats_update_metrics (key, n->primary_address.address,
- n->primary_address.session, atsi, 2);
- n->util_bytes_recv = 0;
- n->util_bytes_sent = 0;
+ n->primary_address.session, atsi, 4);
+ n->util_payload_bytes_recv = 0;
+ n->util_payload_bytes_sent = 0;
+ n->util_total_bytes_recv = 0;
+ n->util_total_bytes_sent = 0;
n->last_util_transmission = GNUNET_TIME_absolute_get();
return GNUNET_OK;
}
@@ -2419,7 +2450,7 @@ utilization_transmission (void *cls,
}
void
-GST_neighbours_notify_payload (const struct GNUNET_PeerIdentity *peer,
+GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_MessageHeader *message)
@@ -2428,10 +2459,51 @@ GST_neighbours_notify_payload (const struct GNUNET_PeerIdentity *peer,
n = lookup_neighbour (peer);
if (NULL == n)
{
- GNUNET_break (0);
return;
}
- n->util_bytes_recv += ntohs(message->size);
+ n->util_total_bytes_recv += ntohs(message->size);
+}
+
+void
+GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct NeighbourMapEntry *n;
+ n = lookup_neighbour (peer);
+ if (NULL == n)
+ {
+ return;
+ }
+ n->util_payload_bytes_recv += ntohs(message->size);
+}
+
+
+void
+GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
+ size_t size)
+{
+ struct NeighbourMapEntry *n;
+ n = lookup_neighbour (peer);
+ if (NULL == n)
+ {
+ return;
+ }
+ n->util_total_bytes_sent += size;
+}
+
+void
+GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer,
+ size_t size)
+{
+ struct NeighbourMapEntry *n;
+ n = lookup_neighbour (peer);
+ if (NULL == n)
+ {
+ return;
+ }
+ n->util_payload_bytes_sent += size;
}
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,
void
-GST_neighbours_notify_payload (const struct GNUNET_PeerIdentity *peer,
+GST_neighbours_notify_data_recv (const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Address *address,
struct Session *session,
const struct GNUNET_MessageHeader *message);
+void
+GST_neighbours_notify_payload_recv (const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session,
+ const struct GNUNET_MessageHeader *message);
+
+void
+GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer,
+ size_t size);
+
+void
+GST_neighbours_notify_data_sent (const struct GNUNET_PeerIdentity *peer,
+ size_t size);
+
/**
* For an existing neighbour record, set the active connection to
* 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
end ()
{
unsigned long long delta;
-
+ unsigned long long rate;
char *value_name;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n");
delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
- FPRINTF (stderr, "\nThroughput was %llu kb/s\n",
- total_bytes * 1024 / delta);
+ rate = (1000LL * 1000LL * total_bytes) / (1024 * delta);
+ FPRINTF (stderr, "\nThroughput was %llu KiBytes/s\n",
+ rate);
+
GNUNET_asprintf (&value_name, "reliable_%s", test_plugin);
- GAUGER ("TRANSPORT", value_name, (int) (total_bytes / 1024 / delta),
+ GAUGER ("TRANSPORT", value_name, (int) rate,
"kb/s");
GNUNET_free (value_name);
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
end ()
{
unsigned long long delta;
-
+ unsigned long long rate;
char *value_name;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n");
delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us;
- FPRINTF (stderr, "\nThroughput was %llu kb/s\n",
- total_bytes * 1024 / delta);
+ rate = (1000LL* 1000ll * total_bytes) / (1024 * delta);
+ FPRINTF (stderr, "\nThroughput was %llu KiBytes/s\n",
+ rate);
+
GNUNET_asprintf (&value_name, "unreliable_%s", test_plugin);
- GAUGER ("TRANSPORT", value_name, (int) (total_bytes / 1024 / delta),
+ GAUGER ("TRANSPORT", value_name, (int) rate,
"kb/s");
GNUNET_free (value_name);