Tom Kelliher, CS 325
Apr. 2, 2008
Read 3.6-7.
Web server and mail user agent project discussions.
Congestion control.
Recall that:
MSS is data only. Path MTU discovery.
Segment structure:
Segment and acknowledgement numbers:
File size of 500 KB with an MSS of 1,000 B.
Segment number for a segment is segment number of first byte.
Acknowledgement number is next expected segment number.
A receiver will accept segments out of order, but will not acknowledge them if earlier segments have not been received.
Remote host handles echoing. Response time crucial for interactive applications.
Simplified TCP sender:
NextSeqNum = InitialSequenceNumber; // Must be pseudo-randomly chosen. SendBase = InitialSequenceNumber; while (1) { switch(event) { case: DataReceivedFromApplicationAbove create TCP segment with sequence number NextSeqNum; if (TimerNotRunning) start timer; // Use TimeoutInterval value. pass segment to IP NextSeqNum += length(Data); break; case: TimerTimeout retransmit not-yet-acknowledged segment with smallest segment number; start timer; // Double timeout interval. break; case: ACKReceivedWithACKFieldValueOfY if (y > SendBase) { SendBase = y; if (UnAcknowledgedSegmentsExist) start timer; // Use TimeoutInterval value. } break; } }
Example -- retransmit due to lost ACK:
Example -- only oldest segment gets retransmitted.
Example -- cumulative acknowledgement handles lost ACK:
Fast retransmit:
Only takes effect if three duplicate ACKs are received for a segment:
case: ACKReceivedWithACKFieldValueOfY if (y > SendBase) { SendBase = y; if (UnAcknowledgedSegmentsExist) start timer; // Use TimeoutInterval value. } else // Duplicate ACK. { IncrementDuplicateACKCount(y); if (DuplicateACKCount(y) == 3) resend segment y; } break;
Event | TCP Receiver Action |
Arrival of in-order segment with expected sequence number. All segments up to expected sequence number already acknowledged. | Delayed ACK. Wait up to 500 ms for arrival of another in-order segment. If next in-order segment does not arrive in this interval, send an ACK. |
Arrival of in-order segment with expected sequence number. One other in-order segment wait for ACK transmission. | Immediately send single cumulative ACK, ACKing both in-order segments. |
Arrival of out-of-order segment with higher-than-expected sequence number. Gap detected. | Immediately send duplicate ACK, indicating sequence number of next expected byte (which is the lower end of the gap). |
Arrival of segment that partially or completely fills in gap in received data. | Immediately send ACK, provided that segment starts at the lower end of gap. |
Fast retransmit example:
Don't confuse with congestion control!
Solution: Send segments with one byte of data, so as to receive updates as to current receive window size.
The three-way handshake:
Server vulnerable to SYN flooding at this point.
Client closes the connection:
Timed Wait: Client keeps connection ``around'' in case it needs to resend ACK to server's FIN.
Typical sequence of client TCP states:
This assumes the client begins the connection close sequence.
Typical sequence of server TCP states:
Again, this assumes the client begins the connection close sequence.