Transmission Control Protocol: 6CCS3INS Internet Systems Toktam Mahmoodi, Department of Informatics, KCL
Transmission Control Protocol: 6CCS3INS Internet Systems Toktam Mahmoodi, Department of Informatics, KCL
Key features
Transmission Control Protocol (TCP)
Multiplexing
TCP ports
Flow Control
Segmentation
Reliability
Acknowledgements
Congestion Control
Windowing
Outline
How does a host running multiple networked applications
differentiate between messages?
TCP conceptually divides the communications a host
protocols, e.g.
FTP: 20/21 SMTP (e-mail): 25
HTTP: 80 HTTPS: 443
Multiplexing
32 bits / 4 bytes
16 bits 16 bits
Connection-Oriented
A socket is the combination of a host's IP address and a
port number
137.73.9.232:80
Sockets
Server: a host that is ready to accept communication on one or
more ports
The server signals that it is ready to receive connections on a port
by informing the TCP software on the host: a Passive OPEN request
For example a web server application running on www.google.com
Client: a host that communicates with a server
A client signals that it wishes to connect to a server's socket by
sending a message to the server: an Active OPEN request
For example, a web browser running on your local PC
Both hosts can potentially be both client and server in the same
connection
Connection set-up
3-way handshake
1) SYN
2) SYN + ACK
3) ACK
Three-Way Handshake
A handshake is also used to close the connection
When a client has finished sending data and wishes to close the
connection it sends a finalise message
The server responds with an acknowledgement of the finalise
Finally, the client responds with an acknowledgement of the
acknowledgement
Connection tear-down
1) FIN
2) ACK
3) ACK
Connection tear-down
Transmission Control Protocol (TCP)
Multiplexing
TCP ports
Flow Control
Segmentation
Reliability
Acknowledgements
Congestion Control
Windowing
Outline
A host can only receive and process data at a certain
rate
At some point its buffers get full and it would have to either
overwrite unprocessed data or ignore incoming data
To resolve this, TCP allows the server to tell the client
how much data it can handle
The client will then reduce or increase the rate at which it sends
data to match the server
Flow control
One part of flow control is to split the message to be
sent into separately transmitted segments
This is like fragmentation in IP, but is independent and
for different reasons:
In IP, fragments are used to not exceed the limits of the physical
networks and network access layer protocols
In TCP, segments are used to not exceed the limits of the
receiving host, flow control, and to aid reliability of
communication
Segmentation
Every byte in a message sent from a client to a server
has a sequence number
For a given connection and host, there is an initial
sequence number (ISN) for bytes it sends
A segment will contain all data within a range of sequence
numbers: ISN+a to ISN+b
Client communicates its ISN in synchronisation
Sequence numbers
32 bits / 4 bytes
Sequence
Number in
32 bits the SYN
message, is
the ISN.
Outline
The main method by which TCP provides reliable
communication is for the server to send an
acknowledgement back to the client for every segment
it receives
A client uses acknowledgements to determine whether a
segment has been lost
If it believes a segment is lost, it will re-transmit it
Reliability
An acknowledgement states that the server has
received all data in the message before a given
sequence number
If the server has received segments with sequence numbers (1 -
20) and (21 - 30), it will send an acknowledgement with
sequence number 31.
If the server has received segments with sequence numbers (1 -
20) and (50 - 60), it will send an acknowledgement with
sequence number 21, as it has all data up to there.
Acknowledging sequences
Acknowledgements (ACK)
Acknowledgements
Acknowledgements
Acknowledgements
Acknowledgements
Acknowledgements
Acknowledgements
Client will REtransmit the lost segment(s) to the server.
Retransmission Policy I
2) DupACK: The client may decide packet X is lost, if it
repeatedly receives acknowledgements suggesting
other segments are being received but X has not
(typically 3 times).
For example, server receives segments (1-20), (30-40), (41-44)
it will send an acknowledgement with sequence number 31 for 3
times: (1-20), ACK 21, (30-40), ACK 21, (41-44), ACK 21
The repetition suggests to the client that one or more segments
starting from SN 21 are lost and needs resending.
Retransmission Policy II
32 bits / 4 bytes
32 bits
Outline
Flow control
end-to-end mechanism for regulating traffic between source and
destination (client and server).
Congestion control
Mechanism used by the network to limit congestion
Congestion Control
The amount of data that client can send at each time is
called the congestion window size - cwnd
The client then wait to receive ACK for the sent data and then
send more data.
Windowing
?
Windowing
TCP cwnd is initialised to one segment at the start of the
TCP connection, and increases slowly to examine the
available bandwidth.
In Slow Start,
cwnd is initialised to one
cwnd is increased exponentially to quickly capture the available
bandwidth
Factor of 2 if every packet is ACK’d
In Congestion Avoidance
cwnd is increased by 1/cwnd (linear increase)
24 Kbytes
16 Kbytes
8 Kbytes
time
In case of RTO
ssthresh will be set to half the current cwnd
cwnd will be reduced to one
Slow start is initiated
Current
cwnd size
16 bits