L4 - The Transport Layer
L4 - The Transport Layer
3. Error checking
4. Multiplexing
Transport layer protocols
2. MMS:
When using TCP, two nodes indicate to each other the maximum segment size (MMS)
or the maximum length of the data packet that could be sent to another end of the link.
This is done during connection establishment and helps to use bandwidth resources
more efficiently.
TCP Connection Establishment
• The TCP connection is established through a three-way handshake
procedure:
1. Request end (or Client end) sends a SYN (synchronization) field, indicating
the client’s request to connect to the port of the server, with Initial
Sequence Number (ISN) “a” – (I want to connect to the port for this application: syn: a)
2. The Server replies ‘SYN’ with sequence number “b”. At the same time, the
acknowledgement number is set to be “a+1” to acknowledge the SYN
packet of the client. (I have seen your request (ack: a+1) and I accept (syn: b) )
3. The Client then sends an acknowledgement packet with acknowledgement
number set to be “b+1” to acknowledge the SYN packet of the server. ( I
acknowledge your acceptance (ack: b+1) in response to (ack: a+1)
SYN(seq=
a )
a+1 )
a ck=
q= b,
e
SYN(s
ACK(seq=a
+1,ack=b+1
)
Client Server
TCP Connection Termination
FIN(seq=a)
e q=a + 1)
AC K (s
)
,a ck = a+ 1
FIN(s e q =b
ACK(seq=b+1
)
Client Server
TCP Connection Termination
1. The client sends a FIN (Finish) field, indicating the client’s intention to
terminate the connection, with initial sequence number “a”.
2. The Server sets the acknowledgement number to be “a+1” to acknowledge
the FIN packet of the Client.
3. The Server then sends FIN field with sequence number “b” to
acknowledgement number “a+1”.
4. Finally, the client send the acknowledgement packet with acknowledgement
number set to be “b+1”.
• The TCP connection is then terminated.
Flow control
• Flow control is used to prevent a fast sender from
overwhelming a slow receiver.
• If a receiver is overloaded with too much data, then the
receiver discards the packets and asks for the
retransmission of packets.
• This increases network congestion and thus, reduces
system performance.
• Flow control is basically achieved using:
MSS
Sliding window mechanisms
Maximum segment size (MSS)
Host A Host B
Host A ( MSS )
Host B ( MSS )
len 1024
len 1024 win4096
len 1024 win4096
len 1024 win4096
To modify the win4096 The sender
windows size is too fast!
4 0 9 7 win2048
ack
len 1024
win2048
len 1024
win2048
49 win2048
ac k 2 0
len 1024
win2048
len 1024
win2048
Sliding Window
Host Host
Send 1,2,3
Acknowledge 4
Send 4,5,6
Acknowledge 4
Send 4,5,6
Windowing mechanism
• As the slide shows, a virtual end-to-end link is established between the source and
destination equipment, and data packets are sent.
• The source equipment sends 3 data packets (1,2,3) to the destination at a goal (and
starts a timer).
• When the destination equipment receives the data packets, it will acknowledge them by
the sequence number of the fourth data packet which is 4.
• When the source equipment receives the acknowledgement, it will continue to send the
next three data packets (4, 5, 6).
• As the example shows, because the destination equipment has not received the fourth
data packet correctly, the destination equipment still uses acknowledgement number 4
as the reply.
• Hence, the fourth data packet will be retransmitted by the source equipment.
• After the destination equipment receives the fourth data packet, and acknowledge it by
the acknowledgement number 7, the next three data packets could be sent continuously.
Multiplexing / demultiplexing
• Multiplexing indicates that the same transport layer connection is
used by multiple applications (e.g. http, ftp, telnet, etc.) to transmit
data.
• And based on the FIFO (first in first out) rule, the segments are to
be sent. These segments could be with the same or different
destinations.
• Forexample, if two servers www.google.com and ftp.google.com are
sending data packets to a destination host at the same time. The
following is the end-to-end communication procedure of the
transport layer.
Multiplexing/demultiplexing
Transmission virtual circuit
WWW.GOOGLE.COM Host
FTP.GOOGLE.COM
Transmission
21 1028 Data 80 1027 Data
data packet
• When the www and ftp applications are launched, the server will allocate a
port number for each application. (Note: This port number is different
from the physical port of the network equipment but is simply a virtual
interface between the application and the transport layer protocol).
• In the transport layer, a virtual connection is established between the
server and the host.
• In order to begin the data transmission, the two applications of the server
and terminal host will inform their own operating systems to initialize the
connection.
Multiplexing/demultiplexing
options
data
TCP Header fields
• TCP uses IP as the network layer protocol, thus the TCP segment is
encapsulated into the IP packet.
• It has the following fields:
• Source and Destination Port:
Every TCP segment includes the source and destination port number, used to find the
sending and receiving application.
Using these two numbers, together with the source and destination IP address in the IP
header, a unique TCP connection could be confirmed.
• Sequence Number:
A 32-bit number that allows a destination host to reassemble segments in the order in
which they were transmitted.
TCP Header fields
• Acknowledgment Number:
A 32-bit field that identifies the sequence number of the next
expected packet from the source
The Acknowledgement Number is the last data sequence
number plus one.
• Header length: It indicates the header length (4 bytes)
• Window Size: A 16-bit field used for flow control (It indicates the
number of bytes a receiver is expected to receive).
• Checksum: 16 bit for error detection.
UDP protocol
• Sessions are not established before communication takes place between source site
• There is no need to maintain the state of connection, receiving and sending, so the
server can send the same message to the other clients at the same time. .
• UDP is suitable for the applications with requirement of high transmission speed.
UDP Header Format
UDP Header UDP Data
0 15 16 31
16 bit destination
16 bit source port
port
8bytes
16 bit UDP
16 bit UDP length
checksum
data
UDP Header Format
• UDP, like TCP, also uses IP as network layer protocol, therefore a UDP segment is
encapsulated in an IP packet.
• But since UDP doesn’t provide reliable transmission like TCP, its segment
format is relatively simple.
• UDP header fields
16-bit source port number: Port number for source application
16-bit UDP length: refers to the length of both UDP header and UDP data part
(minimum value is 8)
Summary questions
1. Explain any three functions of the transport layer in the TCP/IP model.
2. What are the differences in the working principles of TCP and UDP?
3. List any two applications that use TCP as a transport layer protocol.
4. List any two applications that use UDP as a transport layer protocol.
5. With the aid of a diagram, explain the fields in the TCP header
6. With the aid of a diagram, explain the three way handshake procedure
used to establish a TCP connection.