aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_neighbours.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-08 11:46:36 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-08 11:46:36 +0000
commit6115a1150c65bd4a33ed61c6e96594c4a73d86ac (patch)
treef2bb2a57f540a3799cd112b5235f1c4222fd283e /src/transport/gnunet-service-transport_neighbours.c
parentcd0a6e382eafd7fd241a00a10527333d73985fca (diff)
downloadgnunet-6115a1150c65bd4a33ed61c6e96594c4a73d86ac.tar.gz
gnunet-6115a1150c65bd4a33ed61c6e96594c4a73d86ac.zip
more dead and duplicate code elimination
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c77
1 files changed, 1 insertions, 76 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 750e1a793..15bb0bdab 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -415,16 +415,6 @@ struct NeighbourMapEntry
415 /** 415 /**
416 * Tracking utilization of outbound bandwidth 416 * Tracking utilization of outbound bandwidth
417 */ 417 */
418 uint32_t util_payload_bytes_sent;
419
420 /**
421 * Tracking utilization of inbound bandwidth
422 */
423 uint32_t util_payload_bytes_recv;
424
425 /**
426 * Tracking utilization of outbound bandwidth
427 */
428 uint32_t util_total_bytes_sent; 418 uint32_t util_total_bytes_sent;
429 419
430 /** 420 /**
@@ -2840,8 +2830,6 @@ send_utilization_data (void *cls,
2840{ 2830{
2841 struct NeighbourMapEntry *n = value; 2831 struct NeighbourMapEntry *n = value;
2842 struct GNUNET_ATS_Information atsi[4]; 2832 struct GNUNET_ATS_Information atsi[4];
2843 uint32_t bps_pl_in;
2844 uint32_t bps_pl_out;
2845 uint32_t bps_in; 2833 uint32_t bps_in;
2846 uint32_t bps_out; 2834 uint32_t bps_out;
2847 struct GNUNET_TIME_Relative delta; 2835 struct GNUNET_TIME_Relative delta;
@@ -2850,19 +2838,6 @@ send_utilization_data (void *cls,
2850 return GNUNET_OK; 2838 return GNUNET_OK;
2851 delta = GNUNET_TIME_absolute_get_difference (n->last_util_transmission, 2839 delta = GNUNET_TIME_absolute_get_difference (n->last_util_transmission,
2852 GNUNET_TIME_absolute_get ()); 2840 GNUNET_TIME_absolute_get ());
2853
2854 bps_pl_in = 0;
2855
2856 if ((0 != n->util_payload_bytes_recv) && (0 != delta.rel_value_us))
2857 bps_pl_in = (1000LL * 1000LL * n->util_payload_bytes_recv) / (delta.rel_value_us);
2858 bps_pl_out = 0;
2859 if ((0 != n->util_payload_bytes_sent) && (0 != delta.rel_value_us))
2860 bps_pl_out = (1000LL * 1000LL * n->util_payload_bytes_sent) / delta.rel_value_us;
2861 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2862 "`%s' payload: received %u Bytes/s, sent %u Bytes/s\n",
2863 GNUNET_i2s (key),
2864 bps_pl_in,
2865 bps_pl_out);
2866 bps_in = 0; 2841 bps_in = 0;
2867 if ((0 != n->util_total_bytes_recv) && (0 != delta.rel_value_us)) 2842 if ((0 != n->util_total_bytes_recv) && (0 != delta.rel_value_us))
2868 bps_in = (1000LL * 1000LL * n->util_total_bytes_recv) / (delta.rel_value_us); 2843 bps_in = (1000LL * 1000LL * n->util_total_bytes_recv) / (delta.rel_value_us);
@@ -2880,17 +2855,9 @@ send_utilization_data (void *cls,
2880 atsi[0].value = htonl (bps_out); 2855 atsi[0].value = htonl (bps_out);
2881 atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_IN); 2856 atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_IN);
2882 atsi[1].value = htonl (bps_in); 2857 atsi[1].value = htonl (bps_in);
2883
2884 atsi[2].type = htonl (GNUNET_ATS_UTILIZATION_PAYLOAD_OUT);
2885 atsi[2].value = htonl (bps_pl_out);
2886 atsi[3].type = htonl (GNUNET_ATS_UTILIZATION_PAYLOAD_IN);
2887 atsi[3].value = htonl (bps_pl_in);
2888
2889 GST_ats_update_metrics (n->primary_address.address, 2858 GST_ats_update_metrics (n->primary_address.address,
2890 n->primary_address.session, 2859 n->primary_address.session,
2891 atsi, 4); 2860 atsi, 2);
2892 n->util_payload_bytes_recv = 0;
2893 n->util_payload_bytes_sent = 0;
2894 n->util_total_bytes_recv = 0; 2861 n->util_total_bytes_recv = 0;
2895 n->util_total_bytes_sent = 0; 2862 n->util_total_bytes_sent = 0;
2896 n->last_util_transmission = GNUNET_TIME_absolute_get (); 2863 n->last_util_transmission = GNUNET_TIME_absolute_get ();
@@ -2941,27 +2908,6 @@ GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address,
2941 2908
2942 2909
2943/** 2910/**
2944 * Track information about payload (useful data) we received from the
2945 * given address (used to notify ATS about our utilization of
2946 * allocated resources).
2947 *
2948 * @param address the address we got data from
2949 * @param message the message we received (really only the size is used)
2950 */
2951void
2952GST_neighbours_notify_payload_recv (const struct GNUNET_HELLO_Address *address,
2953 const struct GNUNET_MessageHeader *message)
2954{
2955 struct NeighbourMapEntry *n;
2956
2957 n = lookup_neighbour (&address->peer);
2958 if (NULL == n)
2959 return;
2960 n->util_payload_bytes_recv += ntohs (message->size);
2961}
2962
2963
2964/**
2965 * Track information about data we transmitted using the given @a 2911 * Track information about data we transmitted using the given @a
2966 * address and @a session (used to notify ATS about our utilization of 2912 * address and @a session (used to notify ATS about our utilization of
2967 * allocated resources). 2913 * allocated resources).
@@ -2987,27 +2933,6 @@ GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address,
2987 2933
2988 2934
2989/** 2935/**
2990 * Track information about payload (useful data) we transmitted using the
2991 * given address (used to notify ATS about our utilization of
2992 * allocated resources).
2993 *
2994 * @param address the address we transmitted data to
2995 * @param message the message we sent (really only the size is used)
2996 */
2997void
2998GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer,
2999 size_t size)
3000{
3001 struct NeighbourMapEntry *n;
3002
3003 n = lookup_neighbour (peer);
3004 if (NULL == n)
3005 return;
3006 n->util_payload_bytes_sent += size;
3007}
3008
3009
3010/**
3011 * Master task run for every neighbour. Performs all of the time-related 2936 * Master task run for every neighbour. Performs all of the time-related
3012 * activities (keep alive, send next message, disconnect if idle, finish 2937 * activities (keep alive, send next message, disconnect if idle, finish
3013 * clean up after disconnect). 2938 * clean up after disconnect).