您的位置:首页 > 理论基础 > 计算机网络

tcp-hybla

2016-01-21 13:43 1071 查看
hybla算法针对不同RTT的连接使用不同的慢启动和拥塞避免策略

基本思想 

D = 25ms 
T = max(rtt/8D, 1) 
R = max(rtt/D, 8) - (T << 3) 
以 8D 为间隔对连接RTT进行分级 T, T 中又细分8小级 R

慢启动阶段: 

每级 cwnd 基本增长值为 (2^T - 1) 
每小级每次额外增长 (2^T * (F(R)/128 - 1)) 个窗口

拥塞避免阶段: 

每级 cwnd 基本增长值为 (T^2 / cwnd)

具体实现

static int rtt0 = 25;
static inline void hybla_recalc_param (struct sock *sk)
{
struct hybla *ca = inet_csk_ca(sk);
/* T = rh0 = max(rtt/8D, 1) */
ca->rho_3ls = max_t(u32, tcp_sk(sk)->srtt / msecs_to_jiffies(rtt0), 8);
ca->rho = ca->rho_3ls >> 3;

ca->rho2_7ls = (ca->rho_3ls * ca->rho_3ls) << 1;
ca->rho2 = ca->rho2_7ls >>7;
}
static void hybla_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
{
...

/* R =  max(rtt/D, 8) - (T << 3) */
rho_fractions = ca->rho_3ls - (ca->rho << 3);
if (tp->snd_cwnd < tp->snd_ssthresh) {
is_slowstart = 1;
/*
* increment = 2^T * F(R) - 128
*/
increment = ((1 << ca->rho) * hybla_fraction(rho_fractions) )- 128;
} else {
increment = ca->rho2_7ls / tp->snd_cwnd;
if (increment < 128)
tp->snd_cwnd_cnt++;
}
/*
* float increment / 128 = (2^T * F(R) - 128) / 128
*                       = (2^T * (F(R)-128+128)) / 128 - 1
*                       = 2^T  + 2^T * (F(R)-128)/128  - 1
*                       = (2^T - 1) + (2^T * (F(R)-128) / 128)
*                       = (2^T - 1) + (2^T * (F(R)/128 - 1))
*/
odd = increment % 128;
tp->snd_cwnd += increment >> 7;
ca->snd_cwnd_cents += odd;

/* check when fractions goes >=128 and increase cwnd by 1. */
while (ca->snd_cwnd_cents >= 128) {
tp->snd_cwnd++;
ca->snd_cwnd_cents -= 128;
tp->snd_cwnd_cnt = 0;
}
/* check when cwnd has not been incremented for a while */
if (increment == 0 && odd == 0 && tp->snd_cwnd_cnt >= tp->snd_cwnd) {
tp->snd_cwnd++;
tp->snd_cwnd_cnt = 0;
}
...
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  tcp 算法 拥塞控制