diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-02-09 19:15:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-02-09 19:15:47 +0000 |
commit | 09104d9e153cfce464ef38cda9ccbba4b029ae11 (patch) | |
tree | 4e31100cf6f0bd5ef925bd40a27abc96bbed4601 /src/core/gnunet-service-core_sessions.c | |
parent | cca6080579e6c7b1be3bff72a31a528779177fb6 (diff) | |
download | gnunet-09104d9e153cfce464ef38cda9ccbba4b029ae11.tar.gz gnunet-09104d9e153cfce464ef38cda9ccbba4b029ae11.zip |
implement #3295: only transmit background traffic if there is excess bandwidth
Diffstat (limited to 'src/core/gnunet-service-core_sessions.c')
-rw-r--r-- | src/core/gnunet-service-core_sessions.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c index 080bbf88b..4e0ef5e30 100644 --- a/src/core/gnunet-service-core_sessions.c +++ b/src/core/gnunet-service-core_sessions.c | |||
@@ -508,13 +508,20 @@ try_transmission (struct Session *session) | |||
508 | enum GNUNET_CORE_Priority maxp; | 508 | enum GNUNET_CORE_Priority maxp; |
509 | enum GNUNET_CORE_Priority maxpc; | 509 | enum GNUNET_CORE_Priority maxpc; |
510 | struct GSC_ClientActiveRequest *car; | 510 | struct GSC_ClientActiveRequest *car; |
511 | int excess; | ||
511 | 512 | ||
512 | if (GNUNET_YES != session->ready_to_transmit) | 513 | if (GNUNET_YES != session->ready_to_transmit) |
513 | return; | 514 | return; |
514 | msize = 0; | 515 | msize = 0; |
515 | min_deadline = GNUNET_TIME_UNIT_FOREVER_ABS; | 516 | min_deadline = GNUNET_TIME_UNIT_FOREVER_ABS; |
516 | /* check 'ready' messages */ | 517 | /* if the peer has excess bandwidth, background traffic is allowed, |
517 | maxp = GNUNET_CORE_PRIO_BACKGROUND; | 518 | otherwise not */ |
519 | excess = GSC_NEIGHBOURS_check_excess_bandwidth (&session->peer); | ||
520 | if (GNUNET_YES == excess) | ||
521 | maxp = GNUNET_CORE_PRIO_BACKGROUND; | ||
522 | else | ||
523 | maxp = GNUNET_CORE_PRIO_BEST_EFFORT; | ||
524 | /* determine highest priority of 'ready' messages we already solicited from clients */ | ||
518 | pos = session->sme_head; | 525 | pos = session->sme_head; |
519 | while ((NULL != pos) && | 526 | while ((NULL != pos) && |
520 | (msize + pos->size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)) | 527 | (msize + pos->size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)) |
@@ -527,7 +534,12 @@ try_transmission (struct Session *session) | |||
527 | } | 534 | } |
528 | if (maxp < GNUNET_CORE_PRIO_CRITICAL_CONTROL) | 535 | if (maxp < GNUNET_CORE_PRIO_CRITICAL_CONTROL) |
529 | { | 536 | { |
530 | maxpc = GNUNET_CORE_PRIO_BACKGROUND; | 537 | /* if highest already solicited priority from clients is not critical, |
538 | check if there are higher-priority messages to be solicited from clients */ | ||
539 | if (GNUNET_YES == excess) | ||
540 | maxpc = GNUNET_CORE_PRIO_BACKGROUND; | ||
541 | else | ||
542 | maxpc = GNUNET_CORE_PRIO_BEST_EFFORT; | ||
531 | for (car = session->active_client_request_head; NULL != car; car = car->next) | 543 | for (car = session->active_client_request_head; NULL != car; car = car->next) |
532 | { | 544 | { |
533 | if (GNUNET_YES == car->was_solicited) | 545 | if (GNUNET_YES == car->was_solicited) |
@@ -545,11 +557,15 @@ try_transmission (struct Session *session) | |||
545 | } | 557 | } |
546 | 558 | ||
547 | now = GNUNET_TIME_absolute_get (); | 559 | now = GNUNET_TIME_absolute_get (); |
548 | if ((0 == msize) || | 560 | if ( ( (GNUNET_YES == excess) || |
549 | ((msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) && | 561 | (maxpc >= GNUNET_CORE_PRIO_BEST_EFFORT) ) && |
550 | (min_deadline.abs_value_us > now.abs_value_us))) | 562 | ( (0 == msize) || |
563 | ( (msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) && | ||
564 | (min_deadline.abs_value_us > now.abs_value_us))) ) | ||
551 | { | 565 | { |
552 | /* not enough ready yet, try to solicit more */ | 566 | /* not enough ready yet (tiny message & cork possible), or no messages at all, |
567 | and either excess bandwidth or best-effort or higher message waiting at | ||
568 | client; in this case, we try to solicit more */ | ||
553 | solicit_messages (session, | 569 | solicit_messages (session, |
554 | msize); | 570 | msize); |
555 | if (msize > 0) | 571 | if (msize > 0) |
@@ -565,7 +581,8 @@ try_transmission (struct Session *session) | |||
565 | } | 581 | } |
566 | return; | 582 | return; |
567 | } | 583 | } |
568 | /* create plaintext buffer of all messages, encrypt and transmit */ | 584 | /* create plaintext buffer of all messages (that fit), encrypt and |
585 | transmit */ | ||
569 | { | 586 | { |
570 | static unsigned long long total_bytes; | 587 | static unsigned long long total_bytes; |
571 | static unsigned int total_msgs; | 588 | static unsigned int total_msgs; |