diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/gnunet-service-ats_reservations.c | 2 | ||||
-rw-r--r-- | src/fragmentation/test_fragmentation.c | 2 | ||||
-rw-r--r-- | src/include/gnunet_bandwidth_lib.h | 23 | ||||
-rw-r--r-- | src/include/gnunet_transport_plugin.h | 7 | ||||
-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 | ||||
-rw-r--r-- | src/util/bandwidth.c | 9 |
10 files changed, 76 insertions, 11 deletions
diff --git a/src/ats/gnunet-service-ats_reservations.c b/src/ats/gnunet-service-ats_reservations.c index c489ba723..cb95ad80f 100644 --- a/src/ats/gnunet-service-ats_reservations.c +++ b/src/ats/gnunet-service-ats_reservations.c | |||
@@ -108,7 +108,7 @@ GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer, | |||
108 | if (NULL == tracker) | 108 | if (NULL == tracker) |
109 | { | 109 | { |
110 | tracker = GNUNET_new (struct GNUNET_BANDWIDTH_Tracker); | 110 | tracker = GNUNET_new (struct GNUNET_BANDWIDTH_Tracker); |
111 | GNUNET_BANDWIDTH_tracker_init (tracker, bandwidth_in, | 111 | GNUNET_BANDWIDTH_tracker_init (tracker, NULL, NULL, bandwidth_in, |
112 | MAX_BANDWIDTH_CARRY_S); | 112 | MAX_BANDWIDTH_CARRY_S); |
113 | GNUNET_assert (GNUNET_OK == | 113 | GNUNET_assert (GNUNET_OK == |
114 | GNUNET_CONTAINER_multipeermap_put (trackers, peer, tracker, | 114 | GNUNET_CONTAINER_multipeermap_put (trackers, peer, tracker, |
diff --git a/src/fragmentation/test_fragmentation.c b/src/fragmentation/test_fragmentation.c index c41272d42..5f102f439 100644 --- a/src/fragmentation/test_fragmentation.c +++ b/src/fragmentation/test_fragmentation.c | |||
@@ -241,7 +241,7 @@ main (int argc, char *argv[]) | |||
241 | "WARNING", | 241 | "WARNING", |
242 | NULL); | 242 | NULL); |
243 | for (i = 0; i < NUM_MSGS; i++) | 243 | for (i = 0; i < NUM_MSGS; i++) |
244 | GNUNET_BANDWIDTH_tracker_init (&trackers[i], | 244 | GNUNET_BANDWIDTH_tracker_init (&trackers[i], NULL, NULL, |
245 | GNUNET_BANDWIDTH_value_init ((i + 1) * 1024), | 245 | GNUNET_BANDWIDTH_value_init ((i + 1) * 1024), |
246 | 100); | 246 | 100); |
247 | GNUNET_PROGRAM_run (5, argv_prog, "test-fragmentation", "nohelp", options, | 247 | GNUNET_PROGRAM_run (5, argv_prog, "test-fragmentation", "nohelp", options, |
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h index 91ae3e2b8..0cade7902 100644 --- a/src/include/gnunet_bandwidth_lib.h +++ b/src/include/gnunet_bandwidth_lib.h | |||
@@ -52,6 +52,17 @@ struct GNUNET_BANDWIDTH_Value32NBO | |||
52 | }; | 52 | }; |
53 | GNUNET_NETWORK_STRUCT_END | 53 | GNUNET_NETWORK_STRUCT_END |
54 | 54 | ||
55 | |||
56 | /** | ||
57 | * Callback to be called by the bandwidth tracker if the tracker | ||
58 | * was updated and the client should update it's delay values | ||
59 | * | ||
60 | * @param cls a closure to pass | ||
61 | */ | ||
62 | void | ||
63 | typedef (*GNUNET_BANDWIDTH_tracker_update_cb) (void *cls); | ||
64 | |||
65 | |||
55 | /** | 66 | /** |
56 | * Struct to track available bandwidth. Combines a time stamp with a | 67 | * Struct to track available bandwidth. Combines a time stamp with a |
57 | * number of bytes transmitted, a quota and a maximum amount that | 68 | * number of bytes transmitted, a quota and a maximum amount that |
@@ -61,6 +72,10 @@ GNUNET_NETWORK_STRUCT_END | |||
61 | */ | 72 | */ |
62 | struct GNUNET_BANDWIDTH_Tracker | 73 | struct GNUNET_BANDWIDTH_Tracker |
63 | { | 74 | { |
75 | void *update_cb_cls; | ||
76 | |||
77 | GNUNET_BANDWIDTH_tracker_update_cb update_cb; | ||
78 | |||
64 | /** | 79 | /** |
65 | * Number of bytes consumed since we last updated the tracker. | 80 | * Number of bytes consumed since we last updated the tracker. |
66 | */ | 81 | */ |
@@ -129,7 +144,6 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, | |||
129 | uint64_t size); | 144 | uint64_t size); |
130 | 145 | ||
131 | 146 | ||
132 | |||
133 | /** | 147 | /** |
134 | * Compute the MIN of two bandwidth values. | 148 | * Compute the MIN of two bandwidth values. |
135 | * | 149 | * |
@@ -152,14 +166,19 @@ GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, | |||
152 | * bytes). | 166 | * bytes). |
153 | * | 167 | * |
154 | * @param av tracker to initialize | 168 | * @param av tracker to initialize |
169 | * @param update_cb callback to notify a client about the tracker being updated | ||
170 | * @param update_cb_cls cls for the callback | ||
155 | * @param bytes_per_second_limit initial limit to assume | 171 | * @param bytes_per_second_limit initial limit to assume |
156 | * @param max_carry_s maximum number of seconds unused bandwidth | 172 | * @param max_carry_s maximum number of seconds unused bandwidth |
157 | * may accumulate before it expires | 173 | * may accumulate before it expires |
158 | */ | 174 | */ |
159 | void | 175 | void |
160 | GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, | 176 | GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, |
177 | GNUNET_BANDWIDTH_tracker_update_cb update_cb, | ||
178 | void *update_cb_cls, | ||
161 | struct GNUNET_BANDWIDTH_Value32NBO | 179 | struct GNUNET_BANDWIDTH_Value32NBO |
162 | bytes_per_second_limit, uint32_t max_carry_s); | 180 | bytes_per_second_limit, |
181 | uint32_t max_carry_s); | ||
163 | 182 | ||
164 | 183 | ||
165 | /** | 184 | /** |
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index bf84819ad..187d5d508 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h | |||
@@ -576,6 +576,13 @@ struct GNUNET_TRANSPORT_PluginFunctions | |||
576 | GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout; | 576 | GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout; |
577 | 577 | ||
578 | /** | 578 | /** |
579 | * Function that will be called whenever the transport service wants to | ||
580 | * notify the plugin that the inbound quota changed and that the plugin | ||
581 | * should update it's delay for the next receive value | ||
582 | */ | ||
583 | //GNUNET_TRANSPORT_UpdateNextReceiveTimeout update_next_receive_timeout; | ||
584 | |||
585 | /** | ||
579 | * Function that is used to query keepalive factor. | 586 | * Function that is used to query keepalive factor. |
580 | * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to | 587 | * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to |
581 | * calculate the interval between keepalive packets. | 588 | * calculate the interval between keepalive packets. |
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 == |
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index 79497ad51..f056c1aee 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c | |||
@@ -120,6 +120,7 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, | |||
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | |||
123 | /** | 124 | /** |
124 | * Initialize bandwidth tracker. Note that in addition to the | 125 | * Initialize bandwidth tracker. Note that in addition to the |
125 | * 'max_carry_s' limit, we also always allow at least | 126 | * 'max_carry_s' limit, we also always allow at least |
@@ -130,15 +131,21 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, | |||
130 | * bytes). | 131 | * bytes). |
131 | * | 132 | * |
132 | * @param av tracker to initialize | 133 | * @param av tracker to initialize |
134 | * @param update_cb callback to notify a client about the tracker being updated | ||
135 | * @param update_cb_cls cls for the callback | ||
133 | * @param bytes_per_second_limit initial limit to assume | 136 | * @param bytes_per_second_limit initial limit to assume |
134 | * @param max_carry_s maximum number of seconds unused bandwidth | 137 | * @param max_carry_s maximum number of seconds unused bandwidth |
135 | * may accumulate before it expires | 138 | * may accumulate before it expires |
136 | */ | 139 | */ |
137 | void | 140 | void |
138 | GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, | 141 | GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, |
142 | GNUNET_BANDWIDTH_tracker_update_cb update_cb, | ||
143 | void *update_cb_cls, | ||
139 | struct GNUNET_BANDWIDTH_Value32NBO | 144 | struct GNUNET_BANDWIDTH_Value32NBO |
140 | bytes_per_second_limit, uint32_t max_carry_s) | 145 | bytes_per_second_limit, uint32_t max_carry_s) |
141 | { | 146 | { |
147 | av->update_cb = update_cb; | ||
148 | av->update_cb_cls = update_cb_cls; | ||
142 | av->consumption_since_last_update__ = 0; | 149 | av->consumption_since_last_update__ = 0; |
143 | av->last_update__ = GNUNET_TIME_absolute_get (); | 150 | av->last_update__ = GNUNET_TIME_absolute_get (); |
144 | av->available_bytes_per_s__ = ntohl (bytes_per_second_limit.value__); | 151 | av->available_bytes_per_s__ = ntohl (bytes_per_second_limit.value__); |
@@ -327,6 +334,8 @@ GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av, | |||
327 | update_tracker (av); | 334 | update_tracker (av); |
328 | old_limit = av->available_bytes_per_s__; | 335 | old_limit = av->available_bytes_per_s__; |
329 | av->available_bytes_per_s__ = new_limit; | 336 | av->available_bytes_per_s__ = new_limit; |
337 | if (NULL != av->update_cb) | ||
338 | av->update_cb (av->update_cb_cls); | ||
330 | if (old_limit > new_limit) | 339 | if (old_limit > new_limit) |
331 | update_tracker (av); /* maximum excess might be less now */ | 340 | update_tracker (av); /* maximum excess might be less now */ |
332 | } | 341 | } |