TCP: reliable data transfer
00 sendbase = initial_sequence number
01 nextseqnum = initial_sequence number
05 event: data received from application above
06 create TCP segment with sequence number nextseqnum
07 start timer for segment nextseqnum
09 nextseqnum = nextseqnum + length(data)
10 event: timer timeout for segment with sequence number y
11 retransmit segment with sequence number y
12 compue new timeout interval for segment y
13 restart timer for sequence number y
14 event: ACK received, with ACK field value of y
15 if (y > sendbase) { /* cumulative ACK of all data up to y */
16 cancel all timers for segments with sequence numbers < y
19 else { /* a duplicate ACK for already ACKed segment */
20 increment number of duplicate ACKs received for y
21 if (number of duplicate ACKS received for y == 3) {
22 /* TCP fast retransmit */
23 resend segment with sequence number y
24 restart timer for segment y
26 } /* end of loop forever */