Subject: Re: TCP/Westwood+ support.
To: Kentaro A. Kurahone <>
From: Charles M. Hannum <>
List: tech-net
Date: 01/03/2005 17:08:24
On Monday 03 January 2005 06:04, Kentaro A. Kurahone wrote:
> I went back and reworked the code mainly to fix up the broken fast
> retransmit.  I also took a stab at carving off the congestion control
> related code into a set of plugable functions accessed via a struct of
> fnpointers.

Looks okay, but shouldn't it do something more like this?

Also, since the peer MSS can't change after the connection is open, you might 
consider calculating the actual ssthresh value from the BWE timer, since that 
is likely to run much less often on a busy system.  (I.e. the output of the 
BWE timer would be the actual ssthresh value, not the estimate.)  It would be 
slower to notice a new rtt_min, but I'm not sure that matters.

static void
tcp_westwood_p_fast_retransmit(struct tcpcb *tp, struct tcphdr *th)
 tcp_seq onxt = tp->snd_nxt;
 uint32_t rtt_min = tp->westwood_rtt_min >> TCP_RTT_SHIFT;
 uint32_t ssthresh = 0;

  * Perform an Adaptive window decrease based off the
  * bandwidth estimate.
 ssthresh = (rtt_min * tp->westwood_bwe) / tp->t_peermss;
 if (ssthresh < 2 * tp->t_segsz)
  ssthresh = 2 * tp->t_segsz;
 tp->snd_ssthresh = ssthresh;
 if (tp->snd_cwnd > ssthresh)
  tp->snd_cwnd = ssthresh;

  * Do the fast retransmit.
 tp->snd_recover = tp->snd_max;
 tp->t_rtttime = 0;
 tp->snd_nxt = th->th_ack;
 (void) tcp_output(tp);
 if (SEQ_GT(onxt, tp->snd_nxt))
  tp->snd_nxt = onxt;