/* TCP timeout routines */ #include #include "machdep.h" #include "timer.h" #include "mbuf.h" #include "netuser.h" #include "internet.h" #include "ip.h" #include "tcp.h" /* Timer timeout */ void tcp_timeout(arg) int *arg; { register struct tcb *tcb; tcb = (struct tcb *)arg; switch(tcb->state){ case TIME_WAIT: /* 2MSL timer has expired */ close_self(tcb,NORMAL); break; default: /* Retransmission timer has expired */ if(tcb->retry < RETRY){ tcb->retry++; tcb->snd.ptr = tcb->snd.una; /* Back off on retransmission timer; * on closed window probes, limit it to * BACKOFF x the current round trip estimate */ tcb->timer.start <<= 1; if(tcb->snd.wnd == 0) tcb->timer.start = min(tcb->timer.start,BACKOFF*tcb->srtt/MSPTICK); tcp_output(tcb); } else { /* Give up */ close_self(tcb,TIMEOUT); } } }