aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-10-16 13:25:39 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-10-16 13:25:39 +0000
commit7c6e0bd5902d4ea469e793cba73f7116ff82292d (patch)
treedaa17a1cc0c8917d2d7afce7c6e2ecb998cf2da1 /src/transport/transport_api.c
parent306b7db80adac0ef62955f2264ee0cbdc5982ed8 (diff)
downloadgnunet-7c6e0bd5902d4ea469e793cba73f7116ff82292d.tar.gz
gnunet-7c6e0bd5902d4ea469e793cba73f7116ff82292d.zip
changes
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r--src/transport/transport_api.c24
1 files changed, 23 insertions, 1 deletions
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,