Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111550
b: refs/heads/master
c: a3cbdde
h: refs/heads/master
v: v3
  • Loading branch information
Gerrit Renker committed Sep 4, 2008
1 parent aed6981 commit 622b448
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 53ac9570c8145710aaed9e1eb850c2e991a4ebc1
refs/heads/master: a3cbdde8e9c38b66b4f13ac5d6ff1939ded0ff20
40 changes: 40 additions & 0 deletions trunk/net/dccp/ccids/ccid3.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ static int ccid3_debug;
/*
* Transmitter Half-Connection Routines
*/
/* Oscillation Prevention/Reduction: recommended by rfc3448bis, on by default */
static int do_osc_prev = true;

/*
* Compute the initial sending rate X_init in the manner of RFC 3390:
Expand Down Expand Up @@ -296,6 +298,9 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
hctx->s = ccid3_hc_tx_measure_packet_size(sk, skb->len);
ccid3_update_send_interval(hctx);

/* Seed value for Oscillation Prevention (sec. 4.5) */
hctx->r_sqmean = tfrc_scaled_sqrt(hctx->rtt);

} else {
delay = ktime_us_delta(hctx->t_nom, now);
ccid3_pr_debug("delay=%ld\n", (long)delay);
Expand Down Expand Up @@ -400,6 +405,38 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
hctx->s, hctx->p, hctx->x_calc,
(unsigned)(hctx->x_recv >> 6),
(unsigned)(hctx->x >> 6));
/*
* Oscillation Reduction (RFC 3448, 4.5) - modifying t_ipi according to
* RTT changes, multiplying by X/X_inst = sqrt(R_sample)/R_sqmean. This
* can be useful if few connections share a link, avoiding that buffer
* fill levels (RTT) oscillate as a result of frequent adjustments to X.
* A useful presentation with background information is in
* Joerg Widmer, "Equation-Based Congestion Control",
* MSc Thesis, University of Mannheim, Germany, 2000
* (sec. 3.6.4), who calls this ISM ("Inter-packet Space Modulation").
*/
if (do_osc_prev) {
r_sample = tfrc_scaled_sqrt(r_sample);
/*
* The modulation can work in both ways: increase/decrease t_ipi
* according to long-term increases/decreases of the RTT. The
* former is a useful measure, since it works against queue
* build-up. The latter temporarily increases the sending rate,
* so that buffers fill up more quickly. This in turn causes
* the RTT to increase, so that either later reduction becomes
* necessary or the RTT stays at a very high level. Decreasing
* t_ipi is therefore not supported.
* Furthermore, during the initial slow-start phase the RTT
* naturally increases, where using the algorithm would cause
* delays. Hence it is disabled during the initial slow-start.
*/
if (r_sample > hctx->r_sqmean && hctx->p > 0)
hctx->t_ipi = div_u64((u64)hctx->t_ipi * (u64)r_sample,
hctx->r_sqmean);
hctx->t_ipi = min_t(u32, hctx->t_ipi, TFRC_T_MBI);
/* update R_sqmean _after_ computing the modulation factor */
hctx->r_sqmean = tfrc_ewma(hctx->r_sqmean, r_sample, 9);
}

/* unschedule no feedback timer */
sk_stop_timer(sk, &hctx->no_feedback_timer);
Expand Down Expand Up @@ -749,6 +786,9 @@ static struct ccid_operations ccid3 = {
.ccid_hc_tx_getsockopt = ccid3_hc_tx_getsockopt,
};

module_param(do_osc_prev, bool, 0644);
MODULE_PARM_DESC(do_osc_prev, "Use Oscillation Prevention (RFC 3448, 4.5)");

#ifdef CONFIG_IP_DCCP_CCID3_DEBUG
module_param(ccid3_debug, bool, 0644);
MODULE_PARM_DESC(ccid3_debug, "Enable debug messages");
Expand Down
6 changes: 4 additions & 2 deletions trunk/net/dccp/ccids/ccid3.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
/* Two seconds as per RFC 3448 4.2 */
#define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC)

/* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */
#define TFRC_T_MBI 64
/* Maximum backoff interval t_mbi (RFC 3448, 4.3) */
#define TFRC_T_MBI (64 * USEC_PER_SEC)

/*
* The t_delta parameter (RFC 3448, 4.6): delays of less than %USEC_PER_MSEC are
Expand Down Expand Up @@ -76,6 +76,7 @@ enum ccid3_options {
* @x_recv - Receive rate in 64 * bytes per second
* @x_calc - Calculated rate in bytes per second
* @rtt - Estimate of current round trip time in usecs
* @r_sqmean - Estimate of long-term RTT (RFC 3448, 4.5)
* @p - Current loss event rate (0-1) scaled by 1000000
* @s - Packet size in bytes
* @t_rto - Nofeedback Timer setting in usecs
Expand All @@ -94,6 +95,7 @@ struct ccid3_hc_tx_sock {
u64 x_recv;
u32 x_calc;
u32 rtt;
u16 r_sqmean;
u32 p;
u32 t_rto;
u32 t_ipi;
Expand Down
15 changes: 15 additions & 0 deletions trunk/net/dccp/ccids/lib/tfrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ static inline u32 scaled_div32(u64 a, u64 b)
return result;
}

/**
* tfrc_scaled_sqrt - Compute scaled integer sqrt(x) for 0 < x < 2^22-1
* Uses scaling to improve accuracy of the integer approximation of sqrt(). The
* scaling factor of 2^10 limits the maximum @sample to 4e6; this is okay for
* clamped RTT samples (dccp_sample_rtt).
* Should best be used for expressions of type sqrt(x)/sqrt(y), since then the
* scaling factor is neutralised. For this purpose, it avoids returning zero.
*/
static inline u16 tfrc_scaled_sqrt(const u32 sample)
{
const unsigned long non_zero_sample = sample ? : 1;

return int_sqrt(non_zero_sample << 10);
}

/**
* tfrc_ewma - Exponentially weighted moving average
* @weight: Weight to be used as damping factor, in units of 1/10
Expand Down

0 comments on commit 622b448

Please sign in to comment.