From 6115a1150c65bd4a33ed61c6e96594c4a73d86ac Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 8 Feb 2015 11:46:36 +0000 Subject: more dead and duplicate code elimination --- src/ats-tests/ats-testing.c | 15 ---- src/ats/ats_api_scanner.c | 11 +-- src/ats/gnunet-service-ats_normalization.c | 2 +- src/ats/plugin_ats_mlp.c | 42 +--------- src/include/gnunet_ats_service.h | 96 ++-------------------- src/transport/gnunet-service-transport.c | 2 - src/transport/gnunet-service-transport_clients.c | 3 - .../gnunet-service-transport_neighbours.c | 77 +---------------- .../gnunet-service-transport_neighbours.h | 27 ------ 9 files changed, 14 insertions(+), 261 deletions(-) diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index c90cbf3c7..a566a242c 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c @@ -613,21 +613,6 @@ ats_performance_info_cb (void *cls, p->ats_distance = ntohl (ats[c_a].value); GNUNET_break (0); break; - case GNUNET_ATS_COST_WAN: - if (p->ats_cost_wan != ntohl (ats[c_a].value)) - log = GNUNET_YES; - p->ats_cost_wan = ntohl (ats[c_a].value); - break; - case GNUNET_ATS_COST_LAN: - if (p->ats_cost_lan != ntohl (ats[c_a].value)) - log = GNUNET_YES; - p->ats_cost_lan = ntohl (ats[c_a].value); - break; - case GNUNET_ATS_COST_WLAN: - if (p->ats_cost_wlan != ntohl (ats[c_a].value)) - log = GNUNET_YES; - p->ats_cost_wlan = ntohl (ats[c_a].value); - break; default: break; } diff --git a/src/ats/ats_api_scanner.c b/src/ats/ats_api_scanner.c index ddc755a04..ce1c90567 100644 --- a/src/ats/ats_api_scanner.c +++ b/src/ats/ats_api_scanner.c @@ -78,23 +78,14 @@ GNUNET_ATS_print_property_type (enum GNUNET_ATS_Property type) return "UTILIZATION_UP"; case GNUNET_ATS_UTILIZATION_IN: return "UTILIZATION_DOWN"; - case GNUNET_ATS_UTILIZATION_PAYLOAD_OUT: - return "UTILIZATION_PAYLOAD_UP"; - case GNUNET_ATS_UTILIZATION_PAYLOAD_IN: - return "UTILIZATION_PAYLOAD_DOWN"; case GNUNET_ATS_NETWORK_TYPE: return "NETWORK_TYPE"; case GNUNET_ATS_QUALITY_NET_DELAY: return "DELAY"; case GNUNET_ATS_QUALITY_NET_DISTANCE: return "DISTANCE"; - case GNUNET_ATS_COST_WAN: - return "COST_WAN"; - case GNUNET_ATS_COST_LAN: - return "COST_LAN"; - case GNUNET_ATS_COST_WLAN: - return "COST_WLAN"; default: + GNUNET_break (0); return NULL; } } diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c index 0d0b63e9d..23b7b0cb7 100644 --- a/src/ats/gnunet-service-ats_normalization.c +++ b/src/ats/gnunet-service-ats_normalization.c @@ -324,7 +324,7 @@ property_normalize (struct Property *p, /* Normalize the values of this property */ if (GNUNET_NO == limits_changed) { - /* normalize just this address */ + /* normalize just this address */ normalize_address (p, &address->peer, address); diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c index fbaed1eaa..89be5ae7d 100644 --- a/src/ats/plugin_ats_mlp.c +++ b/src/ats/plugin_ats_mlp.c @@ -596,45 +596,6 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp) } -/** - * Translate ATS properties to text - * Just intended for debugging - * - * @param ats_index the ATS index - * @return string with result - */ -static const char * -mlp_ats_to_string (int ats_index) -{ - switch (ats_index) { - case GNUNET_ATS_ARRAY_TERMINATOR: - return "GNUNET_ATS_ARRAY_TERMINATOR"; - case GNUNET_ATS_UTILIZATION_OUT: - return "GNUNET_ATS_UTILIZATION_OUT"; - case GNUNET_ATS_UTILIZATION_IN: - return "GNUNET_ATS_UTILIZATION_IN"; - case GNUNET_ATS_UTILIZATION_PAYLOAD_OUT: - return "GNUNET_ATS_UTILIZATION_PAYLOAD_OUT"; - case GNUNET_ATS_UTILIZATION_PAYLOAD_IN: - return "GNUNET_ATS_UTILIZATION_PAYLOAD_IN"; - case GNUNET_ATS_COST_LAN: - return "GNUNET_ATS_COST_LAN"; - case GNUNET_ATS_COST_WAN: - return "GNUNET_ATS_COST_LAN"; - case GNUNET_ATS_COST_WLAN: - return "GNUNET_ATS_COST_WLAN"; - case GNUNET_ATS_NETWORK_TYPE: - return "GNUNET_ATS_NETWORK_TYPE"; - case GNUNET_ATS_QUALITY_NET_DELAY: - return "GNUNET_ATS_QUALITY_NET_DELAY"; - case GNUNET_ATS_QUALITY_NET_DISTANCE: - return "GNUNET_ATS_QUALITY_NET_DISTANCE"; - default: - GNUNET_break (0); - return "unknown"; - } -} - /** * Translate glpk status error codes to text * @param retcode return code @@ -1217,7 +1178,8 @@ mlp_create_problem_add_invariant_rows (struct GAS_MLP_Handle *mlp, struct MLP_Pr { for (c = 0; c < mlp->pv.m_q; c++) { - GNUNET_asprintf(&name, "c7_q%i_%s", c, mlp_ats_to_string(mlp->pv.q[c])); + GNUNET_asprintf (&name, "c7_q%i_%s", c, + GNUNET_ATS_print_property_type (mlp->pv.q[c])); p->r_q[c] = mlp_create_problem_create_constraint (p, name, GLP_FX, 0.0, 0.0); GNUNET_free (name); mlp_create_problem_set_value (p, p->r_q[c], p->c_q[c], -1, __LINE__); diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index 188f9091b..0bfaeb65d 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h @@ -98,11 +98,6 @@ enum GNUNET_ATS_Network_Type */ #define GNUNET_ATS_MaxBandwidthString "unlimited" -/** - * Number of property types supported by ATS - */ -#define GNUNET_ATS_PropertyCount 11 - /** * Enum defining all known property types for ATS Enum values are used @@ -129,7 +124,7 @@ enum GNUNET_ATS_Property * * Unit: [bytes/second] */ - GNUNET_ATS_UTILIZATION_OUT, + GNUNET_ATS_UTILIZATION_OUT = 1, /** * Actual traffic on this connection from the other peer to this peer. @@ -137,29 +132,13 @@ enum GNUNET_ATS_Property * * Unit: [bytes/second] */ - GNUNET_ATS_UTILIZATION_IN, - - /** - * Actual traffic on this connection from this peer to the other peer. - * Only payload from layers > transport - * - * Unit: [bytes/second] - */ - GNUNET_ATS_UTILIZATION_PAYLOAD_OUT, - - /** - * Actual traffic on this connection from the other peer to this peer. - * Only payload from layers > transport - * - * Unit: [bytes/second] - */ - GNUNET_ATS_UTILIZATION_PAYLOAD_IN, + GNUNET_ATS_UTILIZATION_IN = 2, /** * Is this address located in WAN, LAN or a loopback address * Value is element of GNUNET_ATS_Network_Type */ - GNUNET_ATS_NETWORK_TYPE, + GNUNET_ATS_NETWORK_TYPE = 3, /** * Delay @@ -173,77 +152,20 @@ enum GNUNET_ATS_Property * WLAN : 2 * Dialup: 500 */ - GNUNET_ATS_QUALITY_NET_DELAY, + GNUNET_ATS_QUALITY_NET_DELAY = 4, /** * Distance on network layer (required for distance-vector routing). * * Unit: [DV-hops] */ - GNUNET_ATS_QUALITY_NET_DISTANCE, - - /** - * Network overhead on WAN (Wide-Area Network) - * - * How many bytes are sent on the WAN when 1 kilobyte (1024 bytes) - * of application data is transmitted? - * A factor used with connect cost, bandwidth cost and energy cost - * to describe the overhead produced by the transport protocol - * - * Unit: [bytes/kb] - * - * Interpretation: less is better - * - * Examples: - * - * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb] - * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb] - * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb] - * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb] - */ - GNUNET_ATS_COST_WAN, + GNUNET_ATS_QUALITY_NET_DISTANCE = 5 - /** - * Network overhead on LAN (Local-Area Network) - * - * How many bytes are sent on the LAN when 1 kilobyte (1024 bytes) - * of application data is transmitted? - * A factor used with connect cost, bandwidth cost and energy cost - * to describe the overhead produced by the transport protocol - * - * Unit: [bytes/kb] - * - * Interpretation: less is better - * - * Examples: - * - * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb] - * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb] - * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb] - * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb] - */ - GNUNET_ATS_COST_LAN, +/** + * Number of property types supported by ATS + */ +#define GNUNET_ATS_PropertyCount 6 - /** - * Network overhead on WLAN (Wireless Local Area Network) - * - * How many bytes are sent on the LAN when 1 kilobyte (1024 bytes) - * of application data is transmitted? - * A factor used with connect cost, bandwidth cost and energy cost - * to describe the overhead produced by the transport protocol - * - * Unit: [bytes/kb] - * - * Interpretation: less is better - * - * Examples: - * - * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb] - * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb] - * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb] - * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb] - */ - GNUNET_ATS_COST_WLAN }; diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 3746f0597..336925f4f 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -576,8 +576,6 @@ GST_receive_callback (void *cls, gettext_noop ("# bytes payload received"), ntohs (message->size), GNUNET_NO); - GST_neighbours_notify_payload_recv (address, - message); ret = process_payload (address, session, message); diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 0aef9f97e..8e0b3fe68 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -700,9 +700,6 @@ handle_send_transmit_continuation (void *cls, struct SendTransmitContinuationContext *stcc = cls; struct SendOkMessage send_ok_msg; - if (GNUNET_OK == success) - GST_neighbours_notify_payload_sent (&stcc->target, - bytes_payload); send_ok_msg.header.size = htons (sizeof (send_ok_msg)); send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); send_ok_msg.bytes_msg = htonl (bytes_payload); 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 @@ -412,16 +412,6 @@ struct NeighbourMapEntry */ enum GST_ACK_State ack_state; - /** - * Tracking utilization of outbound bandwidth - */ - uint32_t util_payload_bytes_sent; - - /** - * Tracking utilization of inbound bandwidth - */ - uint32_t util_payload_bytes_recv; - /** * Tracking utilization of outbound bandwidth */ @@ -2840,8 +2830,6 @@ send_utilization_data (void *cls, { struct NeighbourMapEntry *n = value; 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; @@ -2850,19 +2838,6 @@ send_utilization_data (void *cls, return GNUNET_OK; 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) && (0 != delta.rel_value_us)) - 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) && (0 != delta.rel_value_us)) - 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_total_bytes_recv) && (0 != delta.rel_value_us)) bps_in = (1000LL * 1000LL * n->util_total_bytes_recv) / (delta.rel_value_us); @@ -2880,17 +2855,9 @@ send_utilization_data (void *cls, atsi[0].value = htonl (bps_out); 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 (n->primary_address.address, n->primary_address.session, - atsi, 4); - n->util_payload_bytes_recv = 0; - n->util_payload_bytes_sent = 0; + atsi, 2); n->util_total_bytes_recv = 0; n->util_total_bytes_sent = 0; n->last_util_transmission = GNUNET_TIME_absolute_get (); @@ -2940,27 +2907,6 @@ GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address, } -/** - * Track information about payload (useful data) we received from the - * given address (used to notify ATS about our utilization of - * allocated resources). - * - * @param address the address we got data from - * @param message the message we received (really only the size is used) - */ -void -GST_neighbours_notify_payload_recv (const struct GNUNET_HELLO_Address *address, - const struct GNUNET_MessageHeader *message) -{ - struct NeighbourMapEntry *n; - - n = lookup_neighbour (&address->peer); - if (NULL == n) - return; - n->util_payload_bytes_recv += ntohs (message->size); -} - - /** * Track information about data we transmitted using the given @a * address and @a session (used to notify ATS about our utilization of @@ -2986,27 +2932,6 @@ GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address, } -/** - * Track information about payload (useful data) we transmitted using the - * given address (used to notify ATS about our utilization of - * allocated resources). - * - * @param address the address we transmitted data to - * @param message the message we sent (really only the size is used) - */ -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; -} - - /** * Master task run for every neighbour. Performs all of the time-related * activities (keep alive, send next message, disconnect if idle, finish diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 637e7609b..070ee01a9 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h @@ -221,19 +221,6 @@ GST_neighbours_notify_data_recv (const struct GNUNET_HELLO_Address *address, const struct GNUNET_MessageHeader *message); -/** - * Track information about payload (useful data) we received from the - * given address (used to notify ATS about our utilization of - * allocated resources). - * - * @param address the address we got data from - * @param message the message we received (really only the size is used) - */ -void -GST_neighbours_notify_payload_recv (const struct GNUNET_HELLO_Address *address, - const struct GNUNET_MessageHeader *message); - - /** * Track information about data we transmitted using the given @a * address and @a session (used to notify ATS about our utilization of @@ -249,20 +236,6 @@ GST_neighbours_notify_data_sent (const struct GNUNET_HELLO_Address *address, size_t size); -/** - * Track information about payload (useful data) we transmitted using the - * given address (used to notify ATS about our utilization of - * allocated resources). - * - * @param address the address we transmitted data to - * @param message the message we sent (really only the size is used) - */ -void -GST_neighbours_notify_payload_sent (const struct GNUNET_PeerIdentity *peer, - size_t size); - - - /** * For an existing neighbour record, set the active connection to * use the given address. -- cgit v1.2.3