summaryrefslogtreecommitdiff
path: root/net/dccp/ccids/ccid3.c
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 07:30:19 +0200
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 07:45:34 +0200
commit535c55df136ad2783d444e54d518a8fae8bdbf79 (patch)
tree8f7b18bc7b82270e78061c4c22bf722534b743a1 /net/dccp/ccids/ccid3.c
parent3306c781ff13aea89606435c134ec84e3c608681 (diff)
dccp tfrc/ccid-3: Computing Loss Rate from Loss Event Rate
This adds a function to take care of the following cases occurring in the computation of the Loss Rate p: * 1/(2^32-1) is mapped into 0% as per RFC 4342, 8.5; * 1/0 is mapped into the maximum of 100%; * we want to avoid that p = 1/x is rounded down to 0 when x is very large, since this means accidentally re-entering slow-start (indicated by p==0). In the last case, the minimum-resolution value of p is returned. Furthermore, a bug in ccid3_hc_rx_getsockopt is fixed (1/0 was mapped into ~0U), which now allows to consistently print the scaled p-values as printf("Loss Event Rate = %u.%04u %%\n", rx_info.tfrcrx_p / 10000, rx_info.tfrcrx_p % 10000); Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/ccids/ccid3.c')
-rw-r--r--net/dccp/ccids/ccid3.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 4c422fb2189f..206204551f4d 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -410,10 +410,10 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
/* Update loss event rate (which is scaled by 1e6) */
pinv = opt_recv->ccid3or_loss_event_rate;
- if (pinv == ~0U || pinv == 0) /* see RFC 4342, 8.5 */
+ if (pinv == 0)
hctx->p = 0;
- else /* can not exceed 100% */
- hctx->p = scaled_div(1, pinv);
+ else
+ hctx->p = tfrc_invert_loss_event_rate(pinv);
/*
* Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3
@@ -854,8 +854,7 @@ static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
return -EINVAL;
rx_info.tfrcrx_x_recv = hcrx->x_recv;
rx_info.tfrcrx_rtt = hcrx->rtt;
- rx_info.tfrcrx_p = hcrx->p_inverse == 0 ? ~0U :
- scaled_div(1, hcrx->p_inverse);
+ rx_info.tfrcrx_p = tfrc_invert_loss_event_rate(hcrx->p_inverse);
len = sizeof(rx_info);
val = &rx_info;
break;