TCP: Transmission Control Protocol
• Overview• Connection set-up and termination• Interactive• Bulk transfer• Timers• Improvements
TCP: Overview• Connection oriented, byte stream service• Full or half duplex service• Reliability (ARQ)
– Sliding window with variable sized window– Stream is sent in segments (IP datagrams)– SN for bytes– Receiver buffer reorders bytes– Checksum on header and data– Discards duplicate data– Flow control
TCP: Overview
IP Header TCP Header TCP Data
TCP segment
Source port # Destination port #Sequence #
Acknowledgement #HL reserv flags Window size
Checksum Urgent pointerOptions if any
65535-20-20=65495
TCP: Flags• URG: The urgent pointer is used• ACK: The acknowledgement number is valid• PSH: The receiver should pass this data to the
application as soon as possible• RST: Reset the connection• SYN: Synchronize sequence numbers to initiate
a connection. • FIN: The sender is finished sending data
TCP: Set-Up Syn=1 Ack = 0
A:SYN, MSS, SN=ISN
B: SYN, MSS, SN=ISNSyn1 ack 1
B: ACK
A: ACK
A B
Fullduplex
TCP: Termination
A:FIN
B: ack of FIN
B: FIN
A: ack of FIN
A B
Bothsidesclose
TCP windows
1 2 3 4 5 6 7 8 9 10 11
sent andacked
sent butnot acked
can sendasap
min{offered window from receiver,cwnd}
usablewindow
Actually,
Transmission window: cwnd
1
cwnd1
ack1
2 23 ack2
ack34 4
567
Doublingevery RT!
TCP Timeout and Retransmission
Each packet has a retransmission timer• It is initialized by the retransmission time out
(RTO) value• When the timer expires, a time out occurs and
the data is retransmitted• If a retransmission fails then the time-out doubles
i.e., exponential backoff.
It’s important to find a good RTO value
TCP• Slow start: cwnd =1
cwnd exponentially increasing• Congestion avoidance: cwnd reaches ssthresh,
cwnd linearly increasing
TCP: Tahoe and Reno
Tahoe: slow start + congestion avoidanceReno: fast retransmit + fast recovery