0% found this document useful (0 votes)
15 views

Transmission Control Protocol: 6CCS3INS Internet Systems Toktam Mahmoodi, Department of Informatics, KCL

The document discusses Transmission Control Protocol (TCP) and its key features including multiplexing using ports, flow control using segmentation and windowing, reliability using acknowledgements, and congestion control using window sizing.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Transmission Control Protocol: 6CCS3INS Internet Systems Toktam Mahmoodi, Department of Informatics, KCL

The document discusses Transmission Control Protocol (TCP) and its key features including multiplexing using ports, flow control using segmentation and windowing, reliability using acknowledgements, and congestion control using window sizing.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Transmission Control Protocol

6CCS3INS Internet Systems


2014-15 Toktam Mahmoodi, Department of Informatics, KCL
Transmission Control Protocol (TCP)
 Operates above IP to offer a number of additional
features, and address issues not tackled by IP
 Multiplexing: Two hosts can have multiple simultaneous
'conversations' without getting confused about which data
belongs to which conversation
 Reliability: Data transmitted is checked and re-transmitted
where necessary
 Flow Control: A receiving host/network can only accept and
process a given amount of data at once, so the sender must
control how fast they send data.
 Congestion Control: The network in between source and
destination receive data from multiple sources and can
potentially get congested.

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

can be involved with, into ports.


 A port is identified by a number, used in each message

between hosts so that they know which communication


the message belongs to.
 A few ports are reserved for specific application

protocols, e.g.
 FTP: 20/21 SMTP (e-mail): 25
 HTTP: 80 HTTPS: 443

Multiplexing
32 bits / 4 bytes

16 bits 16 bits

TCP header – source & destination ports


 In using TCP, hosts must establish a connection
 Data can only be sent during the connection
 Requires connection setup/teardown
 This is to ensure
 Reliability
 Resource reservation to ensure quality of service
 Flow/congestion control

Connection-Oriented
 A socket is the combination of a host's IP address and a
port number
137.73.9.232:80

 Every TCP connections is between two sockets, i.e. two


hosts using particular ports

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

Client and server


 Three-way handshake:
 A handshake is a sequence of messages sent between a client
and server to set up the connection before the message data is
sent
 The handshake involves three steps:
 Client sends a synchronise message to the server
 Server sends a message back acknowledging the synchronise,
and giving permission for communication to take place
 Client sends a message acknowledging the
acknowledgement

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.

TCP header – Sequence Number


 A maximum segment size (MSS) for a connection is
maximum amount of data allowed in one segment
transmitted over that connection

 Specified by server to client during synchronisation


handshake

Maximum segment size


 Transmission Control Protocol (TCP)
 Multiplexing
 TCP ports
 Flow Control
 Segmentation
 Reliability
 Acknowledgements
 Congestion Control
 Windowing

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.

 How segment is identified lost by the client?

1) RTO: The client may decide a packet is lost if it has not


received an acknowledgement for it after a given period
of time.
 Retransmission Time Out (RTO)

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

TCP header – Acknowledgement


 Transmission Control Protocol (TCP)
 Multiplexing
 TCP ports
 Flow Control
 Segmentation
 Reliability
 Acknowledgements
 Congestion Control
 Windowing

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

 The two are not really separable.


 In either case, mechanisms are needed for limiting the amount
of traffic entering the network

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.

 The cwnd size will be adjusted during communication if


more/less data is delivered to the server.
 This can be recognised from the rate with which ACK messages
are delivered to the client.

Windowing
?

Windowing
 TCP cwnd is initialised to one segment at the start of the
TCP connection, and increases slowly to examine the
available bandwidth.

 The cwnd increase rate depends whether TPC is in


 Slow start, or
 Congestion Avoidance

TCP Congestion Control - cwnd


 TCP congestion control is in Slow Start state at the beginning of the
connection

 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

TCP Congestion Control – slow start


 TCP Congestion control enters congestion avoidance
state, after cwnd reaches certain threshold
 The threshold is called slow start threshold and shown as
ssthresh

 In Congestion Avoidance
 cwnd is increased by 1/cwnd (linear increase)

TCP Congestion Control – congestion avoidance


 Round Trip Time (RTT) or Round Trip Delay (RTD) is
 the amount of time it takes for an ACK to be received by the
sender
 starting from the time the original packet was sent
 e.g. ping time

 The rate with which cwnd increases in the congestions


control is RTT.
 it’s the clock of TCP.

Round Trip Time


 On detecting a packet loss, client assumes that network
is congested congestion
 Client drastically reduces the congestion window

 Reducing cwnd reduces amount of data that can be sent


per RTT
 Less traffic in the network
 TCP Throughput decreases

TCP Congestion Control – packet loss


Long-lived TCP session (“sawtooth” curve)
congestion
window

24 Kbytes

16 Kbytes

8 Kbytes

time

TCP congestion window


 If packet loss occurs, TCP
 reduces the cwnd
 retransmits the sequence starting from the lost packet.

 In case of loss detection via DupAck


 cwnd will be reduced to half
 TCP remains in congestion avoidance

 In case of RTO
 ssthresh will be set to half the current cwnd
 cwnd will be reduced to one
 Slow start is initiated

TCP Retransmission Behaviour


Effect of RTO expiry
32 bits / 4 bytes

Current
cwnd size

16 bits

TCP header – Window


 Offset – 4 bits: Length of the TCP header in 32-bit words.
 Reserved – 6 bits: reserved for future uses ( all 0’s)
 Checksum – 16 bits: this is a one's complement of a one's
complement sum of 16-bit words (similar to IPv4 checksum)
 Urgent Pointer – 16 bits
Position of where the urgent
data ends (as a SN)

TCP Header - more


Flags:
 RST: If a host receives unexpected TCP data it will respond with a
reset message to stop the connection
 PSH: A client can request that all the data ready to send should be
sent. Flag indicates this event to the server
 URG: urgent data
 ACK: acknowledgement
 SYN: synchronisation
message
 FIN: the connection
termination message

TCP Header - Flags


Options:
 Various TCP options - varies in length
 An important TCP option is the MSS - 16 bits
 This is used for the server to specify the largest segment size
it is willing to accept
 It may only be used in the
SYN message.
 The server can declare
the MSS in the message
acknowledging SYN

TCP Header - Options field


 RFCs
 TCP 793
 TCP and IP 879
 Maximum Segment Size 879
 Other issues relevant to TCP 2001

 W. Richard Stevens, "TCP/IP Illustrated, Volume 1: The


Protocols", Addison-Wesley Professional computing
series, 1994
 The TCP/IP guide: http://www.tcpipguide.com/

Relevant RFCs & Extra Reading

You might also like