static __inline__ void tcp_ww_re_calc(struct sock* sk, struct tcp_opt* tp, __u32 ack_seq, ww_time_t ack_time) { __u32 re_sample = 0; __u32 scale; __u32 T; __u32 acked; static u_int re_shift = TCP_WW_BE_SHIFT; static __u32 re_alpha = 3; /* 0.75 << 2 */ if ( tcp_ww_time_is_zero(tp->ww.re_ack_time) ) { /* This is the first packet in the RTT cycle */ tp->ww.re_ack_time = ack_time; tp->ww.re_ack_seq = ack_seq; tp->ww.srtt = tp->srtt; return; } /* We only want to proceed with the RE calculation if * we can distinguish the arrival time of the two packets. */ if ( !tcp_ww_time_diff(ack_time, tp->ww.re_ack_time)) return; /* Cumulative time of ACKs in an RTT cycle * Cumulative bytes acked so far */ T = tcp_ww_get_time_diff(tp->ww.re_ack_time, ack_time, &scale); /* Assumption: We will never run the kernel with 1 usec tick :) */ if (T >= ((tp->ww.srtt>>3)*(1000000/HZ))) { /* * Proceed RE Calculation */ acked = ack_seq - tp->ww.re_ack_seq; if ( acked == 0 ) /* No data */ return; /* Following adjustments are need to maintain accuracy */ re_sample = (scale*acked)/T); if ( ! tp->ww.re_est ) /* First sample */ tp->ww.re_est = re_sample; else { tp->ww.re_est = re_alpha*tp->ww.re_est + ((1<ww.re_est >>= re_shift; } #ifdef TCP_WW_DEBUG printk("TCPWW-%x-%lu: RE: acked=%lu T=%lu re_sample=%lu re_est=%lu ww_srtt=%lu\n", (u_int)sk, jiffies, (u_long)acked, (u_long)T, (u_long)re_sample, (u_long)tp->ww.re_est, (u_long)tp->ww.srtt); #endif tp->ww.re_ack_seq = 0; tcp_ww_time_set_zero(&(tp->ww.re_ack_time)); tp->ww.srtt = tp->srtt; } }