diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-09-04 01:30:19 -0400 |
---|---|---|
committer | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2008-09-04 01:45:42 -0400 |
commit | 68c89ee53571a441799c03d5e240c6441bced620 (patch) | |
tree | a355d77fd0bf9e57375601286bf4b792456b423e /net/dccp | |
parent | 22338f09bd60434a3f1d6608f0fa55972067985f (diff) |
dccp ccid-3: Update the computation of X_recv
This updates the computation of X_recv with regard to Errata 610/611 for
RFC 4342 and draft rfc3448bis-06, ensuring that at least an interval of 1
RTT is used to compute X_recv. The change is wrapped into a new function
ccid3_hc_rx_x_recv().
Further changes:
----------------
* feedback is not sent when no data packets arrived (bytes_recv == 0), as per
rfc3448bis-06, 6.2;
* take the timestamp for the feedback /after/ dccp_send_ack() returns, to avoid
taking the transmission time into account (in case layer-2 is busy);
* clearer handling of failure in ccid3_first_li().
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 64 | ||||
-rw-r--r-- | net/dccp/ccids/lib/packet_history.c | 30 | ||||
-rw-r--r-- | net/dccp/ccids/lib/packet_history.h | 13 |
3 files changed, 66 insertions, 41 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 8e64d9665a21..f2f9514dbad2 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -533,9 +533,6 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk, | |||
533 | enum ccid3_fback_type fbtype) | 533 | enum ccid3_fback_type fbtype) |
534 | { | 534 | { |
535 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | 535 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
536 | struct dccp_sock *dp = dccp_sk(sk); | ||
537 | ktime_t now = ktime_get_real(); | ||
538 | s64 delta = 0; | ||
539 | 536 | ||
540 | switch (fbtype) { | 537 | switch (fbtype) { |
541 | case CCID3_FBACK_INITIAL: | 538 | case CCID3_FBACK_INITIAL: |
@@ -565,42 +562,33 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk, | |||
565 | /* | 562 | /* |
566 | * When parameters change (new loss or p > p_prev), we do not | 563 | * When parameters change (new loss or p > p_prev), we do not |
567 | * have a reliable estimate for R_m of [RFC 3448, 6.2] and so | 564 | * have a reliable estimate for R_m of [RFC 3448, 6.2] and so |
568 | * need to reuse the previous value of X_recv. However, when | 565 | * always check whether at least RTT time units were covered. |
569 | * X_recv was 0 (due to early loss), this would kill X down to | ||
570 | * s/t_mbi (i.e. one packet in 64 seconds). | ||
571 | * To avoid such drastic reduction, we approximate X_recv as | ||
572 | * the number of bytes since last feedback. | ||
573 | * This is a safe fallback, since X is bounded above by X_calc. | ||
574 | */ | 566 | */ |
575 | if (hcrx->x_recv > 0) | 567 | hcrx->x_recv = tfrc_rx_hist_x_recv(&hcrx->hist, hcrx->x_recv); |
576 | break; | 568 | break; |
577 | /* fall through */ | ||
578 | case CCID3_FBACK_PERIODIC: | 569 | case CCID3_FBACK_PERIODIC: |
579 | /* | 570 | /* |
580 | * FIXME: check if delta is less than or equal to 1 RTT using | 571 | * Step (2) of rfc3448bis-06, 6.2: |
581 | * the receiver RTT sample. This is described in Errata 610/611 | 572 | * - if no data packets have been received, just restart timer |
582 | * of RFC 4342 which reference section 6.2 of RFC 3448. | 573 | * - if data packets have been received, re-compute X_recv |
583 | */ | 574 | */ |
584 | delta = ktime_us_delta(now, hcrx->tstamp_last_feedback); | 575 | if (hcrx->hist.bytes_recvd == 0) |
585 | if (delta <= 0) | 576 | goto prepare_for_next_time; |
586 | DCCP_BUG("delta (%ld) <= 0", (long)delta); | 577 | hcrx->x_recv = tfrc_rx_hist_x_recv(&hcrx->hist, hcrx->x_recv); |
587 | else | ||
588 | hcrx->x_recv = scaled_div32(hcrx->hist.bytes_recvd, delta); | ||
589 | break; | 578 | break; |
590 | default: | 579 | default: |
591 | return; | 580 | return; |
592 | } | 581 | } |
593 | 582 | ||
594 | ccid3_pr_debug("Interval %ldusec, X_recv=%u, 1/p=%u\n", | 583 | ccid3_pr_debug("X_recv=%u, 1/p=%u\n", hcrx->x_recv, hcrx->p_inverse); |
595 | (long)delta, hcrx->x_recv, hcrx->p_inverse); | ||
596 | 584 | ||
597 | hcrx->tstamp_last_feedback = now; | 585 | dccp_sk(sk)->dccps_hc_rx_insert_options = 1; |
598 | hcrx->last_counter = dccp_hdr(skb)->dccph_ccval; | ||
599 | hcrx->hist.bytes_recvd = 0; | ||
600 | hcrx->feedback = fbtype; | ||
601 | |||
602 | dp->dccps_hc_rx_insert_options = 1; | ||
603 | dccp_send_ack(sk); | 586 | dccp_send_ack(sk); |
587 | |||
588 | prepare_for_next_time: | ||
589 | tfrc_rx_hist_restart_byte_counter(&hcrx->hist); | ||
590 | hcrx->last_counter = dccp_hdr(skb)->dccph_ccval; | ||
591 | hcrx->feedback = fbtype; | ||
604 | } | 592 | } |
605 | 593 | ||
606 | static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | 594 | static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) |
@@ -639,7 +627,7 @@ static u32 ccid3_first_li(struct sock *sk) | |||
639 | { | 627 | { |
640 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | 628 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); |
641 | u32 s = tfrc_rx_hist_packet_size(&hcrx->hist), | 629 | u32 s = tfrc_rx_hist_packet_size(&hcrx->hist), |
642 | rtt = tfrc_rx_hist_rtt(&hcrx->hist), x_recv, p, delta; | 630 | rtt = tfrc_rx_hist_rtt(&hcrx->hist), x_recv, p; |
643 | u64 fval; | 631 | u64 fval; |
644 | 632 | ||
645 | /* | 633 | /* |
@@ -650,16 +638,9 @@ static u32 ccid3_first_li(struct sock *sk) | |||
650 | if (unlikely(hcrx->feedback == CCID3_FBACK_NONE)) | 638 | if (unlikely(hcrx->feedback == CCID3_FBACK_NONE)) |
651 | return 5; | 639 | return 5; |
652 | 640 | ||
653 | delta = ktime_to_us(net_timedelta(hcrx->tstamp_last_feedback)); | 641 | x_recv = tfrc_rx_hist_x_recv(&hcrx->hist, hcrx->x_recv); |
654 | x_recv = scaled_div32(hcrx->hist.bytes_recvd, delta); | 642 | if (x_recv == 0) |
655 | if (x_recv == 0) { /* would also trigger divide-by-zero */ | 643 | goto failed; |
656 | DCCP_WARN("X_recv==0\n"); | ||
657 | if (hcrx->x_recv == 0) { | ||
658 | DCCP_BUG("stored value of X_recv is zero"); | ||
659 | return ~0U; | ||
660 | } | ||
661 | x_recv = hcrx->x_recv; | ||
662 | } | ||
663 | 644 | ||
664 | fval = scaled_div32(scaled_div(s, rtt), x_recv); | 645 | fval = scaled_div32(scaled_div(s, rtt), x_recv); |
665 | p = tfrc_calc_x_reverse_lookup(fval); | 646 | p = tfrc_calc_x_reverse_lookup(fval); |
@@ -667,7 +648,10 @@ static u32 ccid3_first_li(struct sock *sk) | |||
667 | ccid3_pr_debug("%s(%p), receive rate=%u bytes/s, implied " | 648 | ccid3_pr_debug("%s(%p), receive rate=%u bytes/s, implied " |
668 | "loss rate=%u\n", dccp_role(sk), sk, x_recv, p); | 649 | "loss rate=%u\n", dccp_role(sk), sk, x_recv, p); |
669 | 650 | ||
670 | return p == 0 ? ~0U : scaled_div(1, p); | 651 | if (p > 0) |
652 | return scaled_div(1, p); | ||
653 | failed: | ||
654 | return UINT_MAX; | ||
671 | } | 655 | } |
672 | 656 | ||
673 | static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | 657 | static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) |
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c index 5c4ded1cf422..547ad098ea6a 100644 --- a/net/dccp/ccids/lib/packet_history.c +++ b/net/dccp/ccids/lib/packet_history.c | |||
@@ -385,6 +385,36 @@ int tfrc_rx_handle_loss(struct tfrc_rx_hist *h, | |||
385 | } | 385 | } |
386 | EXPORT_SYMBOL_GPL(tfrc_rx_handle_loss); | 386 | EXPORT_SYMBOL_GPL(tfrc_rx_handle_loss); |
387 | 387 | ||
388 | /* Compute the sending rate X_recv measured between feedback intervals */ | ||
389 | u32 tfrc_rx_hist_x_recv(struct tfrc_rx_hist *h, const u32 last_x_recv) | ||
390 | { | ||
391 | u64 bytes = h->bytes_recvd, last_rtt = h->rtt_estimate; | ||
392 | s64 delta = ktime_to_us(net_timedelta(h->bytes_start)); | ||
393 | |||
394 | WARN_ON(delta <= 0); | ||
395 | /* | ||
396 | * Ensure that the sampling interval for X_recv is at least one RTT, | ||
397 | * by extending the sampling interval backwards in time, over the last | ||
398 | * R_(m-1) seconds, as per rfc3448bis-06, 6.2. | ||
399 | * To reduce noise (e.g. when the RTT changes often), this is only | ||
400 | * done when delta is smaller than RTT/2. | ||
401 | */ | ||
402 | if (last_x_recv > 0 && delta < last_rtt/2) { | ||
403 | tfrc_pr_debug("delta < RTT ==> %ld us < %u us\n", | ||
404 | (long)delta, (unsigned)last_rtt); | ||
405 | |||
406 | delta = (bytes ? delta : 0) + last_rtt; | ||
407 | bytes += div_u64((u64)last_x_recv * last_rtt, USEC_PER_SEC); | ||
408 | } | ||
409 | |||
410 | if (unlikely(bytes == 0)) { | ||
411 | DCCP_WARN("X_recv == 0, using old value of %u\n", last_x_recv); | ||
412 | return last_x_recv; | ||
413 | } | ||
414 | return scaled_div32(bytes, delta); | ||
415 | } | ||
416 | EXPORT_SYMBOL_GPL(tfrc_rx_hist_x_recv); | ||
417 | |||
388 | void tfrc_rx_hist_purge(struct tfrc_rx_hist *h) | 418 | void tfrc_rx_hist_purge(struct tfrc_rx_hist *h) |
389 | { | 419 | { |
390 | int i; | 420 | int i; |
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index ba5832bbc348..6552be63cb0a 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h | |||
@@ -93,7 +93,8 @@ struct tfrc_rx_hist_entry { | |||
93 | * @rtt_sample_prev: Used during RTT sampling, points to candidate entry | 93 | * @rtt_sample_prev: Used during RTT sampling, points to candidate entry |
94 | * @rtt_estimate: Receiver RTT estimate | 94 | * @rtt_estimate: Receiver RTT estimate |
95 | * @packet_size: Packet size in bytes (as per RFC 3448, 3.1) | 95 | * @packet_size: Packet size in bytes (as per RFC 3448, 3.1) |
96 | * @bytes_recvd: Number of bytes received since last sending feedback | 96 | * @bytes_recvd: Number of bytes received since @bytes_start |
97 | * @bytes_start: Start time for counting @bytes_recvd | ||
97 | */ | 98 | */ |
98 | struct tfrc_rx_hist { | 99 | struct tfrc_rx_hist { |
99 | struct tfrc_rx_hist_entry *ring[TFRC_NDUPACK + 1]; | 100 | struct tfrc_rx_hist_entry *ring[TFRC_NDUPACK + 1]; |
@@ -105,6 +106,7 @@ struct tfrc_rx_hist { | |||
105 | /* Receiver sampling of application payload lengths */ | 106 | /* Receiver sampling of application payload lengths */ |
106 | u32 packet_size, | 107 | u32 packet_size, |
107 | bytes_recvd; | 108 | bytes_recvd; |
109 | ktime_t bytes_start; | ||
108 | }; | 110 | }; |
109 | 111 | ||
110 | /** | 112 | /** |
@@ -169,6 +171,15 @@ static inline u32 tfrc_rx_hist_rtt(const struct tfrc_rx_hist *h) | |||
169 | return h->rtt_estimate; | 171 | return h->rtt_estimate; |
170 | } | 172 | } |
171 | 173 | ||
174 | static inline void tfrc_rx_hist_restart_byte_counter(struct tfrc_rx_hist *h) | ||
175 | { | ||
176 | h->bytes_recvd = 0; | ||
177 | h->bytes_start = ktime_get_real(); | ||
178 | } | ||
179 | |||
180 | extern u32 tfrc_rx_hist_x_recv(struct tfrc_rx_hist *h, const u32 last_x_recv); | ||
181 | |||
182 | |||
172 | extern void tfrc_rx_hist_add_packet(struct tfrc_rx_hist *h, | 183 | extern void tfrc_rx_hist_add_packet(struct tfrc_rx_hist *h, |
173 | const struct sk_buff *skb, const u64 ndp); | 184 | const struct sk_buff *skb, const u64 ndp); |
174 | 185 | ||