TCP (Transmission Control Protocol) : - Originally Defined in RFC 793 (September 1981) - UDP Features
TCP (Transmission Control Protocol) : - Originally Defined in RFC 793 (September 1981) - UDP Features
Connection-oriented
Establishment and teardown of the connections
Reliable
Missing or corrupt segments are detected and retransmitted
Full duplex
Each TCP connection supports a pair of byte streams, one flowing in each
direction
Flow control
Keep sender from overrunning receiver (end-to-end issue)
Congestion Control
Keep sender from overrunning network
Algorithm tries to fill available capacity
The sender has no idea what links will be traversed to reach the destination
TCP Overview
Application
process
Client
The client process
passes a stream of
data through the
socket
The application
reads the stream
of data from the
receive buffer
TCP
TCP
Send Buffer
Application
process
Server
TCP Segments
Receive Buffer
Basic Data Transfer (RFC 793): The TCP is able to transfer a continuous stream of octets in each
direction between its users by packaging some number of octets into segments for transmission
through the internet system. In general, the TCPs decide when to block and forward data at
their own convenience.
Current status of the sliding window mechanism
Maximum Segment Size (MSS): MTU of the directly connected network, minus the size of the
TCP and IP headers
standard MSS for TCP = 536 bytes (576 20 -20)
push operation
timer
Source Port
TCP Header
Destination Port
Sequence Number
Acknowledgment
AdvertisedWindow
Checksum
UrgPtr
(SrcPort, SrcIPAddr,DstPort,DstIPAddr)
Options (variable)
Checksum: 16 bits
The checksum field is the 16 bit one's
complement of the one's complement sum of
all 16 bit words in the TCP header, TCP data
and the pseudo header.
Required in both IPv4 and IPv6.
TCP Flags
Control Bits: 6 bits (from left to right)
This field communicates the current value of the urgent pointer as a positive offset
from the sequence number in this segment. The urgent pointer points to the sequence
number of the octet following the urgent data.
This field is only be interpreted in segments with the URG control bit set.
The two sides begin sending data only after this connection
establishment phase is over
Connection termination
Connection teardown is symmetric: each side has to close the connection
independently
As soon as a participant is done sending data, it closes one direction of the
connection
The other side can keep the other half of the bidirectional connection open
and continue sending data
The protocol places no restriction on a particular connection being used over and over again.
How does the TCP identify duplicate segments from previous incarnations of the connection?
The generator is bound to a (possibly fictitious) 32 bit clock whose low order bit is incremented
roughly every 4 microseconds.
Thus, the ISN cycles approximately every 4.55 hours.
Since TCP assumes that segments will stay in the network no more than the Maximum Segment
Lifetime (MSL) and that the MSL is less than 4.55 hours we can reasonably assume that ISN's will be
unique.
For a connection to be established or initialized, the two TCPs must synchronize on each
other's initial sequence numbers.
To avoid confusion TCP must prevent segments from one incarnation of a connection from
being used while the same sequence numbers may still be present in the network from an
earlier incarnation.
When new connections are created, an initial sequence number (ISN) generator is employed
which selects a new 32 bit ISN
This is done in an exchange of connection establishing segments carrying a control bit called "SYN"
(for synchronize) and the initial sequence numbers.
As a shorthand, segments carrying the SYN bit are also called SYNs
The solution requires a suitable mechanism for picking an initial sequence number and a
slightly involved handshake to exchange the ISN's.
Three-Way Handshake
active
participant
(client)
A timer is scheduled for
each of the first two
segments, and if the
expected response is not
received, the segment is
retransmitted
SYN
SeqNum=x
SYN+ACK,
SeqNum=y
Ack=x+1
ACK,
SeqNum=x+1
Ack=y+1
ACK,
SeqNum=x+1
Ack=y+1
passive
participant
(server)
The Acknowledgement Field
identifies the next sequence
number expected, thereby
implicitly acknowledging all
earlier sequence numbers
First data
segment
States involved in
closing a
connection
TimeOut based
Retransmissions are
NOT shown in the
diagram
client
server
SYN
SYN+ACK
ACK
Three-Way Handshake
Initiator
Sequence
FIN
ACK
FIN
ACK
Responder
Sequence
TIME_WAIT State
The TIME-WAIT state is required since the local side of the
connection does not know if its ACK was successfully delivered
Retransmission of the FIN segment
Delayed packets
FIN
ACK
FIN
ACK
SYN
FIN
FIN
FIN
ACK
ACK
FIN
FIN+ACK
ACK
Responder
Sequence