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

L4 - The Transport Layer

The document discusses the transport layer of the TCP/IP model. It describes the functions of the transport layer including providing connection-oriented and reliable delivery between applications, flow control, error checking, and multiplexing. It then explains the two main transport layer protocols - TCP and UDP, focusing on how TCP provides reliable connections using three-way handshakes for connection establishment and four-way handshakes for connection termination.

Uploaded by

Rod
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

L4 - The Transport Layer

The document discusses the transport layer of the TCP/IP model. It describes the functions of the transport layer including providing connection-oriented and reliable delivery between applications, flow control, error checking, and multiplexing. It then explains the two main transport layer protocols - TCP and UDP, focusing on how TCP provides reliable connections using three-way handshakes for connection establishment and four-way handshakes for connection termination.

Uploaded by

Rod
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

TCP/IP MODEL:

LECTURE 4: THE TRANSPORT LAYER


Objectives

• Discuss the functions and protocols of the transport


layer
Introduction

On a general level, the transport layer of the TCP/IP model is


responsible for:
1. Providing a connection-oriented and reliable service for
applications (Process to process delivery)
2. Flow control

3. Error checking

4. Multiplexing
Transport layer protocols

1. Transmission control protocol (TCP)


Connection oriented protocol
Connection must be established before two parties can communicate (similar to circuit
switching in voice networks but for applications)
Reliable
Slow
Used for transmission of mass data

2. User datagram protocol ( UDP)


Connectionless protocol
No need to establish an end-end connection before two devices can communicate (Simple
protocol)
Unreliability is high with UDP and two parties only use “best effort” service
Connection oriented and reliable transmission
• The transport layer uses TCP to provide a reliable, connection-oriented
service for applications through the following aspects:

1. Connection-oriented transport: In TCP, before any end of the link begins to


transfer data, the connection between two parties of the link must first be
established.

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)

4. The TCP connection is then established.


TCP Connection Establishment

SYN(seq=
a )

a+1 )
a ck=
q= b,
e
SYN(s
ACK(seq=a
+1,ack=b+1
)

Client Server
TCP Connection Termination

• TCP is a full-duplex transport layer protocol, i.e. two ends


of the connection could transmit or receive data at the same
time.
• Thus, the two parties should terminate the connection
individually.
• While the TCP connection is established through a three-
way handshake procedure, the TCP connection is
terminated through a four-way handshake procedure.
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)

• MSS (Maximum Segment Size) indicates the maximum size of


the segment that could be sent to the other end of a connection.
• When a connection is being established, each end of a link
should advertise its own MSS.
• The default value of the MSS is 536 bytes, so the allowable
length of an IP packet is 576 bytes(536 + 20 byte IP header
+20byte TCP header).
• Through the negotiation of MSS, the network resources are used
more efficiently and the network performance is improved.
Maximum segment size (MSS)

Host A Host B

Host A ( MSS )

Host B ( MSS )

• When a connection is to be established, the hosts need to negotiate the MSS.


• The default value of the MSS is 536 bytes, therefore the acceptable length of
an IP data message is 576 bytes if we add the IP header.
Sliding Window

• The TCP Sliding Window mechanism is used to control data


flow between two hosts by dynamically changing the
window (buffer) size.
• Every TCP/IP host supports full-duplex data transmission,
so there are 2 Sliding Windows: one is used for receiving,
the other is used for sending.
• Also TCP uses positive acknowledgement technology whose
acknowledgement number refers to the next expected
segment.
Sliding Window - Example

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

• The server sends to the client four (4) 1024-byte segments,


and the window size of sender is 4096 bytes.
• Receiver will acknowledge by using ACK4097, and modify
the window size to 2048 bytes (which means client (receiver)
only has 2048-byte buffer space).
• Therefore, sender changes its sending speed and sends 2048-
byte segments which the receiver can manage to process.
Limitation of the sliding window mechanism

• The sliding window mechanism provides reliable flow


control methods for data transmission between end-to-
end devices.
• However, it only takes effect on source and destination
devices.
• When there is congestion between intermediate devices
( like routers), sliding window does not work.
Error control
• The transport layer checks for errors in the messages coming from
the application layer:
• Detection
Error detection codes
Checksums
• Correction
 Forward error correction – Errors are corrected automatically using inbuilt
correction codes such as hamming, linear block codes, etc.
Backward error correction – Uses the ACK (acknowledged) and NACK (Not
Acknowledged) services to inform the sender if the data has arrived or not and checks
for the integrity of data.
Windowing mechanism
• When the destination equipment receives the data packets
sent by the source equipment, it will send an
acknowledgement to the sender.
• Once the sender receives the acknowledgement, it will
continue to send data packets.
• If the sender does not receive an acknowledgement, (after
the time expires) the sender will decrease the transmission
speed, and retransmit the packets in question.
Windowing Mechanism——Acknowledgement Technology
Transmission virtual circuit
source destination

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

Application data Data Data

Transmission
21 1028 Data 80 1027 Data
data packet

FTP Port HTTP Port


Multiplexing/demultiplexing

• 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

• After the virtual end-to-end connection is established, the data


transmission could begin.
• During the transmission procedure, the server and the host
continue to communicate using their protocol software, to check
whether the data has been correctly received.
• After the terminal equipment receives the data flow, it will sort
the data so that the transport layer could send the data to the
host correctly.
• After the data transmission finished, the two parties negotiate to
terminate the virtual link.
TCP Header Format
TCP data segment

IP Head TCP Head TCP Data


0 15 16 31

16 bit source port 16 bit destination port

32 bit sequence number

20 32 bit acknowledge number


bytes
Header U A P R S F
Reserved R C S S Y I 16 bit windows size
length G K H T N N
16 bit checksum 16 bit urgent pointer

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

• UDP provides a connectionless service for applications.

• Sessions are not established before communication takes place between source site

and destination 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 destination number: port number of destination 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.

You might also like