diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-30 14:16:20 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-30 14:16:20 +0000 |
commit | e34f367380ed951b51895e24d99a81a12899278c (patch) | |
tree | f69a83bde0e96cb3def8af1cefa4e7b5548e7bc2 /src/transport | |
parent | ff57ba65e29db50bd42e540ba95cb938a5ef8008 (diff) | |
download | gnunet-e34f367380ed951b51895e24d99a81a12899278c.tar.gz gnunet-e34f367380ed951b51895e24d99a81a12899278c.zip |
extending bandwidth tracker api to support notifications
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 20 | ||||
-rw-r--r-- | src/transport/plugin_transport_bluetooth.c | 2 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 2 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 2 | ||||
-rw-r--r-- | src/transport/transport_api.c | 18 |
5 files changed, 37 insertions, 7 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index b82bd8694..58cb0fbb3 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -1689,6 +1689,15 @@ send_session_connect_ack_message (const struct GNUNET_HELLO_Address *address, | |||
1689 | 1689 | ||
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | static void | ||
1693 | inbound_bw_tracker_update (void *cls) | ||
1694 | { | ||
1695 | struct Neighbour *n = cls; | ||
1696 | |||
1697 | /* Quota was updated, tell plugins to update the time to receive next */ | ||
1698 | |||
1699 | } | ||
1700 | |||
1692 | 1701 | ||
1693 | /** | 1702 | /** |
1694 | * Create a fresh entry in the neighbour map for the given peer | 1703 | * Create a fresh entry in the neighbour map for the given peer |
@@ -1712,7 +1721,7 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer) | |||
1712 | n->util_payload_bytes_sent = 0; | 1721 | n->util_payload_bytes_sent = 0; |
1713 | n->util_total_bytes_recv = 0; | 1722 | n->util_total_bytes_recv = 0; |
1714 | n->util_total_bytes_sent = 0; | 1723 | n->util_total_bytes_sent = 0; |
1715 | GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, | 1724 | GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, &inbound_bw_tracker_update, n, |
1716 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, | 1725 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, |
1717 | MAX_BANDWIDTH_CARRY_S); | 1726 | MAX_BANDWIDTH_CARRY_S); |
1718 | n->task = GNUNET_SCHEDULER_add_now (&master_task, n); | 1727 | n->task = GNUNET_SCHEDULER_add_now (&master_task, n); |
@@ -2535,6 +2544,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2535 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 2544 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
2536 | { | 2545 | { |
2537 | struct NeighbourMapEntry *n; | 2546 | struct NeighbourMapEntry *n; |
2547 | struct GST_BlacklistCheck *blc; | ||
2538 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 2548 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
2539 | struct BlacklistCheckSwitchContext *blc_ctx; | 2549 | struct BlacklistCheckSwitchContext *blc_ctx; |
2540 | int c; | 2550 | int c; |
@@ -2601,8 +2611,11 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, | |||
2601 | } | 2611 | } |
2602 | 2612 | ||
2603 | GNUNET_CONTAINER_DLL_insert (pending_bc_head, pending_bc_tail, blc_ctx); | 2613 | GNUNET_CONTAINER_DLL_insert (pending_bc_head, pending_bc_tail, blc_ctx); |
2604 | blc_ctx->blc = GST_blacklist_test_allowed (peer, address->transport_name, | 2614 | if (NULL != (blc = GST_blacklist_test_allowed (peer, address->transport_name, |
2605 | &switch_address_bl_check_cont, blc_ctx); | 2615 | &switch_address_bl_check_cont, blc_ctx))) |
2616 | { | ||
2617 | blc_ctx->blc = blc; | ||
2618 | } | ||
2606 | } | 2619 | } |
2607 | 2620 | ||
2608 | 2621 | ||
@@ -3338,7 +3351,6 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target) | |||
3338 | return test_connected (lookup_neighbour (target)); | 3351 | return test_connected (lookup_neighbour (target)); |
3339 | } | 3352 | } |
3340 | 3353 | ||
3341 | |||
3342 | /** | 3354 | /** |
3343 | * Change the incoming quota for the given peer. | 3355 | * Change the incoming quota for the given peer. |
3344 | * | 3356 | * |
diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c index 8d751f443..266276730 100644 --- a/src/transport/plugin_transport_bluetooth.c +++ b/src/transport/plugin_transport_bluetooth.c | |||
@@ -1943,7 +1943,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) | |||
1943 | 0, GNUNET_NO); | 1943 | 0, GNUNET_NO); |
1944 | GNUNET_STATISTICS_set (plugin->env->stats, _("# Bluetooth MAC endpoints allocated"), | 1944 | GNUNET_STATISTICS_set (plugin->env->stats, _("# Bluetooth MAC endpoints allocated"), |
1945 | 0, 0); | 1945 | 0, 0); |
1946 | GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, | 1946 | GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL, |
1947 | GNUNET_BANDWIDTH_value_init (100 * 1024 * | 1947 | GNUNET_BANDWIDTH_value_init (100 * 1024 * |
1948 | 1024 / 8), 100); | 1948 | 1024 / 8), 100); |
1949 | plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); | 1949 | plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index be3f3f8d9..a50aaa436 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -3007,7 +3007,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3007 | p->defrag_ctxs = GNUNET_CONTAINER_heap_create ( | 3007 | p->defrag_ctxs = GNUNET_CONTAINER_heap_create ( |
3008 | GNUNET_CONTAINER_HEAP_ORDER_MIN); | 3008 | GNUNET_CONTAINER_HEAP_ORDER_MIN); |
3009 | p->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, p); | 3009 | p->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, p); |
3010 | GNUNET_BANDWIDTH_tracker_init (&p->tracker, | 3010 | GNUNET_BANDWIDTH_tracker_init (&p->tracker, NULL, NULL, |
3011 | GNUNET_BANDWIDTH_value_init ((uint32_t) udp_max_bps), 30); | 3011 | GNUNET_BANDWIDTH_value_init ((uint32_t) udp_max_bps), 30); |
3012 | plugin = p; | 3012 | plugin = p; |
3013 | 3013 | ||
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index e3dd24fdb..36e09fdd7 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -1949,7 +1949,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) | |||
1949 | 0, GNUNET_NO); | 1949 | 0, GNUNET_NO); |
1950 | GNUNET_STATISTICS_set (plugin->env->stats, _("# WLAN MAC endpoints allocated"), | 1950 | GNUNET_STATISTICS_set (plugin->env->stats, _("# WLAN MAC endpoints allocated"), |
1951 | 0, 0); | 1951 | 0, 0); |
1952 | GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, | 1952 | GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, NULL, NULL, |
1953 | GNUNET_BANDWIDTH_value_init (100 * 1024 * | 1953 | GNUNET_BANDWIDTH_value_init (100 * 1024 * |
1954 | 1024 / 8), 100); | 1954 | 1024 / 8), 100); |
1955 | plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); | 1955 | plugin->fragment_data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); |
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 292aca5f0..ac7c55599 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -419,6 +419,23 @@ neighbour_find (struct GNUNET_TRANSPORT_Handle *h, | |||
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | |||
423 | static void | ||
424 | outbound_bw_tracker_update (void *cls) | ||
425 | { | ||
426 | struct Neighbour *n = cls; | ||
427 | struct GNUNET_TIME_Relative delay; | ||
428 | if (NULL == n->hn) | ||
429 | return; | ||
430 | |||
431 | delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, | ||
432 | n->th->notify_size + n->traffic_overhead); | ||
433 | GNUNET_CONTAINER_heap_update_cost (n->h->ready_heap, | ||
434 | n->hn, delay.rel_value_us); | ||
435 | schedule_transmission (n->h); | ||
436 | } | ||
437 | |||
438 | |||
422 | /** | 439 | /** |
423 | * Add neighbour to our list | 440 | * Add neighbour to our list |
424 | * | 441 | * |
@@ -439,6 +456,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
439 | n->is_ready = GNUNET_YES; | 456 | n->is_ready = GNUNET_YES; |
440 | n->traffic_overhead = 0; | 457 | n->traffic_overhead = 0; |
441 | GNUNET_BANDWIDTH_tracker_init (&n->out_tracker, | 458 | GNUNET_BANDWIDTH_tracker_init (&n->out_tracker, |
459 | outbound_bw_tracker_update, n, | ||
442 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, | 460 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, |
443 | MAX_BANDWIDTH_CARRY_S); | 461 | MAX_BANDWIDTH_CARRY_S); |
444 | GNUNET_assert (GNUNET_OK == | 462 | GNUNET_assert (GNUNET_OK == |