diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-10-16 13:25:39 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-10-16 13:25:39 +0000 |
commit | 7c6e0bd5902d4ea469e793cba73f7116ff82292d (patch) | |
tree | daa17a1cc0c8917d2d7afce7c6e2ecb998cf2da1 /src/transport | |
parent | 306b7db80adac0ef62955f2264ee0cbdc5982ed8 (diff) | |
download | gnunet-7c6e0bd5902d4ea469e793cba73f7116ff82292d.tar.gz gnunet-7c6e0bd5902d4ea469e793cba73f7116ff82292d.zip |
changes
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 10 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 16 | ||||
-rw-r--r-- | src/transport/transport.h | 12 | ||||
-rw-r--r-- | src/transport/transport_api.c | 24 |
4 files changed, 53 insertions, 9 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 065e8c4e6..3a0fbbef3 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -568,10 +568,18 @@ handle_send_transmit_continuation (void *cls, int success, | |||
568 | struct SendTransmitContinuationContext *stcc = cls; | 568 | struct SendTransmitContinuationContext *stcc = cls; |
569 | struct SendOkMessage send_ok_msg; | 569 | struct SendOkMessage send_ok_msg; |
570 | 570 | ||
571 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Payload: %u, On wire %u \n", bytes_payload, bytes_on_wire); | 571 | //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Payload: %u, On wire %u result: %i\n", bytes_payload, bytes_on_wire, success); |
572 | /* | ||
573 | if (GNUNET_OK == success) | ||
574 | GNUNET_assert (bytes_on_wire >= bytes_payload); | ||
572 | 575 | ||
576 | else | ||
577 | GNUNET_assert (bytes_on_wire <= bytes_payload); | ||
578 | */ | ||
573 | send_ok_msg.header.size = htons (sizeof (send_ok_msg)); | 579 | send_ok_msg.header.size = htons (sizeof (send_ok_msg)); |
574 | send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); | 580 | send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK); |
581 | send_ok_msg.bytes_msg = htonl (bytes_payload); | ||
582 | send_ok_msg.bytes_physical = htonl (bytes_on_wire); | ||
575 | send_ok_msg.success = htonl (success); | 583 | send_ok_msg.success = htonl (success); |
576 | send_ok_msg.latency = | 584 | send_ok_msg.latency = |
577 | GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_FOREVER_REL); | 585 | GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_FOREVER_REL); |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index c7bfe6237..e22110f5f 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -692,12 +692,11 @@ call_continuation (struct UDP_MessageWrapper *udpw, int result) | |||
692 | (GNUNET_OK == result) ? "OK" : "SYSERR"); | 692 | (GNUNET_OK == result) ? "OK" : "SYSERR"); |
693 | if (NULL != udpw->cont) | 693 | if (NULL != udpw->cont) |
694 | { | 694 | { |
695 | /* FIXME: add bytes used on wire here */ | ||
696 | /* Calls transport continuation if message was not fragmented, | ||
697 | * GNUNET_FRAGMENT if just an fragment was sent | ||
698 | */ | ||
699 | |||
700 | /* Call continuation for fragmented message */ | 695 | /* Call continuation for fragmented message */ |
696 | /* | ||
697 | * Transport continuation for unfragmented message | ||
698 | * send_next_fragment for fragmented message | ||
699 | */ | ||
701 | udpw->cont (udpw->cont_cls, &udpw->session->target, result, udpw->payload_size, udpw->msg_size); | 700 | udpw->cont (udpw->cont_cls, &udpw->session->target, result, udpw->payload_size, udpw->msg_size); |
702 | } | 701 | } |
703 | 702 | ||
@@ -1233,7 +1232,6 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1233 | udpw->timeout = frag_ctx->timeout; | 1232 | udpw->timeout = frag_ctx->timeout; |
1234 | udpw->frag_ctx = frag_ctx; | 1233 | udpw->frag_ctx = frag_ctx; |
1235 | memcpy (udpw->msg_buf, msg, msg_len); | 1234 | memcpy (udpw->msg_buf, msg, msg_len); |
1236 | frag_ctx->on_wire_size += msg_len; | ||
1237 | enqueue (plugin, udpw); | 1235 | enqueue (plugin, udpw); |
1238 | schedule_select (plugin); | 1236 | schedule_select (plugin); |
1239 | } | 1237 | } |
@@ -2072,7 +2070,11 @@ udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) | |||
2072 | GNUNET_STATISTICS_update (plugin->env->stats, | 2070 | GNUNET_STATISTICS_update (plugin->env->stats, |
2073 | "# bytes transmitted via UDP", | 2071 | "# bytes transmitted via UDP", |
2074 | sent, GNUNET_NO); | 2072 | sent, GNUNET_NO); |
2075 | call_continuation(udpw, GNUNET_OK); | 2073 | if (NULL != udpw->frag_ctx) |
2074 | { | ||
2075 | udpw->frag_ctx->on_wire_size += udpw->msg_size; | ||
2076 | } | ||
2077 | call_continuation (udpw, GNUNET_OK); | ||
2076 | network_down_error = GNUNET_NO; | 2078 | network_down_error = GNUNET_NO; |
2077 | } | 2079 | } |
2078 | 2080 | ||
diff --git a/src/transport/transport.h b/src/transport/transport.h index 3cca8e268..338783585 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -262,6 +262,18 @@ struct SendOkMessage | |||
262 | */ | 262 | */ |
263 | uint32_t success GNUNET_PACKED; | 263 | uint32_t success GNUNET_PACKED; |
264 | 264 | ||
265 | |||
266 | /** | ||
267 | * Size of message sent | ||
268 | */ | ||
269 | uint32_t bytes_msg GNUNET_PACKED; | ||
270 | |||
271 | /** | ||
272 | * Size of message sent over wire | ||
273 | * Includes plugin and protocol specific overhead | ||
274 | */ | ||
275 | uint32_t bytes_physical GNUNET_PACKED; | ||
276 | |||
265 | /** | 277 | /** |
266 | * Latency estimate. | 278 | * Latency estimate. |
267 | */ | 279 | */ |
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 7fef0cf3e..81877743e 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -146,6 +146,11 @@ struct Neighbour | |||
146 | */ | 146 | */ |
147 | int is_ready; | 147 | int is_ready; |
148 | 148 | ||
149 | /** | ||
150 | * Sending consumed more bytes on wire than payload was announced | ||
151 | * This overhead is added to the delay of next sending operation | ||
152 | */ | ||
153 | size_t traffic_overhead; | ||
149 | }; | 154 | }; |
150 | 155 | ||
151 | 156 | ||
@@ -348,6 +353,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
348 | n->id = *pid; | 353 | n->id = *pid; |
349 | n->h = h; | 354 | n->h = h; |
350 | n->is_ready = GNUNET_YES; | 355 | n->is_ready = GNUNET_YES; |
356 | n->traffic_overhead = 0; | ||
351 | GNUNET_BANDWIDTH_tracker_init (&n->out_tracker, | 357 | GNUNET_BANDWIDTH_tracker_init (&n->out_tracker, |
352 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, | 358 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, |
353 | MAX_BANDWIDTH_CARRY_S); | 359 | MAX_BANDWIDTH_CARRY_S); |
@@ -410,6 +416,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
410 | struct GNUNET_PeerIdentity me; | 416 | struct GNUNET_PeerIdentity me; |
411 | uint16_t size; | 417 | uint16_t size; |
412 | uint32_t ats_count; | 418 | uint32_t ats_count; |
419 | uint32_t bytes_msg; | ||
420 | uint32_t bytes_physical; | ||
413 | 421 | ||
414 | GNUNET_assert (h->client != NULL); | 422 | GNUNET_assert (h->client != NULL); |
415 | if (msg == NULL) | 423 | if (msg == NULL) |
@@ -508,11 +516,22 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) | |||
508 | break; | 516 | break; |
509 | } | 517 | } |
510 | okm = (const struct SendOkMessage *) msg; | 518 | okm = (const struct SendOkMessage *) msg; |
519 | bytes_msg = ntohl (okm->bytes_msg); | ||
520 | bytes_physical = ntohl (okm->bytes_physical); | ||
511 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message, transmission %s.\n", | 521 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message, transmission %s.\n", |
512 | "SEND_OK", ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed"); | 522 | "SEND_OK", ntohl (okm->success) == GNUNET_OK ? "succeeded" : "failed"); |
523 | |||
513 | n = neighbour_find (h, &okm->peer); | 524 | n = neighbour_find (h, &okm->peer); |
514 | if (n == NULL) | 525 | if (n == NULL) |
515 | break; | 526 | break; |
527 | |||
528 | GNUNET_assert (0 == n->traffic_overhead); | ||
529 | if (bytes_physical >= bytes_msg) | ||
530 | { | ||
531 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Overhead for %u byte message: %u \n", | ||
532 | bytes_msg, bytes_physical - bytes_msg); | ||
533 | n->traffic_overhead = bytes_physical - bytes_msg; | ||
534 | } | ||
516 | GNUNET_break (GNUNET_NO == n->is_ready); | 535 | GNUNET_break (GNUNET_NO == n->is_ready); |
517 | n->is_ready = GNUNET_YES; | 536 | n->is_ready = GNUNET_YES; |
518 | if ((n->th != NULL) && (n->hn == NULL)) | 537 | if ((n->th != NULL) && (n->hn == NULL)) |
@@ -783,9 +802,12 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
783 | if (NULL != h->control_head) | 802 | if (NULL != h->control_head) |
784 | delay = GNUNET_TIME_UNIT_ZERO; | 803 | delay = GNUNET_TIME_UNIT_ZERO; |
785 | else if (NULL != (n = GNUNET_CONTAINER_heap_peek (h->ready_heap))) | 804 | else if (NULL != (n = GNUNET_CONTAINER_heap_peek (h->ready_heap))) |
805 | { | ||
786 | delay = | 806 | delay = |
787 | GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, | 807 | GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, |
788 | n->th->notify_size); | 808 | n->th->notify_size + n->traffic_overhead); |
809 | n->traffic_overhead = 0; | ||
810 | } | ||
789 | else | 811 | else |
790 | return; /* no work to be done */ | 812 | return; /* no work to be done */ |
791 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 813 | LOG (GNUNET_ERROR_TYPE_DEBUG, |