diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-18 19:16:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-18 19:16:42 +0000 |
commit | e029441fb8a138c17e3af50f1299281ee39f8c39 (patch) | |
tree | 8ca5bc1023f02abfbbd1bfce5c19ab146515b0c5 /src/transport/plugin_transport_udp.c | |
parent | 8ca7ed7cd3358c53425c1e5a572b4abd2f6c1392 (diff) | |
download | gnunet-e029441fb8a138c17e3af50f1299281ee39f8c39.tar.gz gnunet-e029441fb8a138c17e3af50f1299281ee39f8c39.zip |
-smoother calculation of flow delays, base it on the current message not the previous one
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 29ade08f0..27ebad74d 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -175,8 +175,8 @@ struct GNUNET_ATS_Session | |||
175 | 175 | ||
176 | /** | 176 | /** |
177 | * Desired delay for transmissions we received from other peer. | 177 | * Desired delay for transmissions we received from other peer. |
178 | * Adjusted to be per fragment (UDP_MTU), even though on the | 178 | * This is for full messages, the value needs to be adjusted for |
179 | * wire it was for "full messages". | 179 | * fragmented messages. |
180 | */ | 180 | */ |
181 | struct GNUNET_TIME_Relative flow_delay_from_other_peer; | 181 | struct GNUNET_TIME_Relative flow_delay_from_other_peer; |
182 | 182 | ||
@@ -343,12 +343,19 @@ struct UDP_FragmentationContext | |||
343 | 343 | ||
344 | /** | 344 | /** |
345 | * Transmission time for the next fragment. Incremented by | 345 | * Transmission time for the next fragment. Incremented by |
346 | * the "flow_delay_from_other_peer" for each fragment when | 346 | * the @e flow_delay_from_other_peer for each fragment when |
347 | * we setup the fragments. | 347 | * we setup the fragments. |
348 | */ | 348 | */ |
349 | struct GNUNET_TIME_Absolute next_frag_time; | 349 | struct GNUNET_TIME_Absolute next_frag_time; |
350 | 350 | ||
351 | /** | 351 | /** |
352 | * Desired delay for transmissions we received from other peer. | ||
353 | * Adjusted to be per fragment (UDP_MTU), even though on the | ||
354 | * wire it was for "full messages". | ||
355 | */ | ||
356 | struct GNUNET_TIME_Relative flow_delay_from_other_peer; | ||
357 | |||
358 | /** | ||
352 | * Message timeout | 359 | * Message timeout |
353 | */ | 360 | */ |
354 | struct GNUNET_TIME_Absolute timeout; | 361 | struct GNUNET_TIME_Absolute timeout; |
@@ -1874,7 +1881,7 @@ enqueue_fragment (void *cls, | |||
1874 | udpw->transmission_time = frag_ctx->next_frag_time; | 1881 | udpw->transmission_time = frag_ctx->next_frag_time; |
1875 | frag_ctx->next_frag_time | 1882 | frag_ctx->next_frag_time |
1876 | = GNUNET_TIME_absolute_add (frag_ctx->next_frag_time, | 1883 | = GNUNET_TIME_absolute_add (frag_ctx->next_frag_time, |
1877 | session->flow_delay_from_other_peer); | 1884 | frag_ctx->flow_delay_from_other_peer); |
1878 | udpw->frag_ctx = frag_ctx; | 1885 | udpw->frag_ctx = frag_ctx; |
1879 | udpw->qc = &qc_fragment_sent; | 1886 | udpw->qc = &qc_fragment_sent; |
1880 | udpw->qc_cls = plugin; | 1887 | udpw->qc_cls = plugin; |
@@ -2108,6 +2115,10 @@ udp_plugin_send (void *cls, | |||
2108 | frag_ctx->cont_cls = cont_cls; | 2115 | frag_ctx->cont_cls = cont_cls; |
2109 | frag_ctx->start_time = GNUNET_TIME_absolute_get (); | 2116 | frag_ctx->start_time = GNUNET_TIME_absolute_get (); |
2110 | frag_ctx->next_frag_time = s->last_transmit_time; | 2117 | frag_ctx->next_frag_time = s->last_transmit_time; |
2118 | frag_ctx->flow_delay_from_other_peer | ||
2119 | = GNUNET_TIME_relative_divide (s->flow_delay_from_other_peer, | ||
2120 | 1 + (msgbuf_size / | ||
2121 | UDP_MTU)); | ||
2111 | frag_ctx->timeout = GNUNET_TIME_relative_to_absolute (to); | 2122 | frag_ctx->timeout = GNUNET_TIME_relative_to_absolute (to); |
2112 | frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */ | 2123 | frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */ |
2113 | frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */ | 2124 | frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */ |
@@ -2325,7 +2336,7 @@ udp_disconnect_session (void *cls, | |||
2325 | 2336 | ||
2326 | 2337 | ||
2327 | /** | 2338 | /** |
2328 | * Handle an ACK message. | 2339 | * Handle a #GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK message. |
2329 | * | 2340 | * |
2330 | * @param plugin the UDP plugin | 2341 | * @param plugin the UDP plugin |
2331 | * @param msg the (presumed) UDP ACK message | 2342 | * @param msg the (presumed) UDP ACK message |
@@ -2344,6 +2355,7 @@ read_process_ack (struct Plugin *plugin, | |||
2344 | struct GNUNET_ATS_Session *s; | 2355 | struct GNUNET_ATS_Session *s; |
2345 | struct GNUNET_TIME_Relative flow_delay; | 2356 | struct GNUNET_TIME_Relative flow_delay; |
2346 | 2357 | ||
2358 | /* check message format */ | ||
2347 | if (ntohs (msg->size) | 2359 | if (ntohs (msg->size) |
2348 | < sizeof(struct UDP_ACK_Message) + sizeof(struct GNUNET_MessageHeader)) | 2360 | < sizeof(struct UDP_ACK_Message) + sizeof(struct GNUNET_MessageHeader)) |
2349 | { | 2361 | { |
@@ -2357,6 +2369,8 @@ read_process_ack (struct Plugin *plugin, | |||
2357 | GNUNET_break_op(0); | 2369 | GNUNET_break_op(0); |
2358 | return; | 2370 | return; |
2359 | } | 2371 | } |
2372 | |||
2373 | /* Locate session */ | ||
2360 | address = GNUNET_HELLO_address_allocate (&udp_ack->sender, | 2374 | address = GNUNET_HELLO_address_allocate (&udp_ack->sender, |
2361 | PLUGIN_NAME, | 2375 | PLUGIN_NAME, |
2362 | udp_addr, | 2376 | udp_addr, |
@@ -2387,9 +2401,13 @@ read_process_ack (struct Plugin *plugin, | |||
2387 | } | 2401 | } |
2388 | GNUNET_HELLO_address_free (address); | 2402 | GNUNET_HELLO_address_free (address); |
2389 | 2403 | ||
2404 | /* evaluate flow delay: how long should we wait between messages? */ | ||
2390 | if (UINT32_MAX == ntohl (udp_ack->delay)) | 2405 | if (UINT32_MAX == ntohl (udp_ack->delay)) |
2391 | { | 2406 | { |
2392 | /* Other peer asked for us to terminate the session */ | 2407 | /* Other peer asked for us to terminate the session */ |
2408 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
2409 | "Asked to disconnect UDP session of %s\n", | ||
2410 | GNUNET_i2s (&udp_ack->sender)); | ||
2393 | udp_disconnect_session (plugin, | 2411 | udp_disconnect_session (plugin, |
2394 | s); | 2412 | s); |
2395 | return; | 2413 | return; |
@@ -2409,12 +2427,9 @@ read_process_ack (struct Plugin *plugin, | |||
2409 | GNUNET_i2s (&udp_ack->sender)); | 2427 | GNUNET_i2s (&udp_ack->sender)); |
2410 | /* Flow delay is for the reassembled packet, however, our delay | 2428 | /* Flow delay is for the reassembled packet, however, our delay |
2411 | is per packet, so we need to adjust: */ | 2429 | is per packet, so we need to adjust: */ |
2412 | flow_delay = GNUNET_TIME_relative_divide (flow_delay, | ||
2413 | 1 + (s->frag_ctx->payload_size / | ||
2414 | UDP_MTU)); | ||
2415 | s->flow_delay_from_other_peer = flow_delay; | 2430 | s->flow_delay_from_other_peer = flow_delay; |
2416 | 2431 | ||
2417 | 2432 | /* Handle ACK */ | |
2418 | if (GNUNET_OK != | 2433 | if (GNUNET_OK != |
2419 | GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag, | 2434 | GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag, |
2420 | ack)) | 2435 | ack)) |
@@ -2430,14 +2445,13 @@ read_process_ack (struct Plugin *plugin, | |||
2430 | return; | 2445 | return; |
2431 | } | 2446 | } |
2432 | 2447 | ||
2448 | /* Remove fragmented message after successful sending */ | ||
2433 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2449 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2434 | "Message from %s at %s full ACK'ed\n", | 2450 | "Message from %s at %s full ACK'ed\n", |
2435 | GNUNET_i2s (&udp_ack->sender), | 2451 | GNUNET_i2s (&udp_ack->sender), |
2436 | udp_address_to_string (plugin, | 2452 | udp_address_to_string (plugin, |
2437 | udp_addr, | 2453 | udp_addr, |
2438 | udp_addr_len)); | 2454 | udp_addr_len)); |
2439 | |||
2440 | /* Remove fragmented message after successful sending */ | ||
2441 | fragmented_message_done (s->frag_ctx, | 2455 | fragmented_message_done (s->frag_ctx, |
2442 | GNUNET_OK); | 2456 | GNUNET_OK); |
2443 | } | 2457 | } |