You are on page 1of 6


3 Transport layer
3.3.1 Transport Layer Primitives

Transport Layer: The transport layer is the layer in the open system interconnection (OSI)
model responsible for end-to-end communication over a network. It provides logical
communication between application processes running on different hosts within a layered
architecture of protocols and other network components.

Functions of Transport Layer:

1. Service Point Addressing: Transport Layer header includes service point address which
is port address. This layer gets the message to the correct process on the computer
unlike Network Layer, which gets each packet to the correct computer.
2. Segmentation and Reassembling: A message is divided into segments; each segment
contains sequence number, which enables this layer in reassembling the message.
Message is reassembled correctly upon arrival at the destination and replaces packets
which were lost in transmission.
3. Connection Control: It includes 2 types:
o Connectionless Transport Layer: Each segment is considered as an independent
packet and delivered to the transport layer at the destination machine.
o Connection Oriented Transport Layer: Before delivering packets, connection is made
with transport layer at the destination machine.
4. Flow Control: In this layer, flow control is performed end to end.
5. Error Control: Error Control is performed end to end in this layer to ensure that the
complete message arrives at the receiving transport layer without any error. Error
Correction is done through retransmission.

What is Primitives?

A service is specified by a set of primitives. A primitive means operation. To access the

service a user process can access these primitives. These primitives are different for
connection oriented service and connectionless service.

Page | 1
There are five types of service primitives:

Primitive TPDU Meaning

LISTEN None Block until some process tries to
CONNECT Connection Request Tries to establishing a connection
SEND Data Send the data
RECEIVE None Block until a data TPDU arrives
DISCONNECT Disconnect Request Release the connection

1] LISTEN: When a server is ready to accept an incoming connection it executes the

LISTEN primitive. It blocks waiting for an incoming connection.

2] CONNECT: It connects the server by establishing a connection. Response is awaited.

3] SEND: Then the client executes SEND primitive to transmit its request followed by the
execution of RECIEVE to get the reply. Send the message.

4] RECIEVE: Then the RECIEVE call blocks the server.

5] DISCONNECT: This primitive is used for terminating the connection. After this
primitive one can’t send any message. When the client sends DISCONNECT packet then
the server also sends the DISCONNECT packet to acknowledge the client. When the
server package is received by client then the process is terminated.

3.3.2 Transport Layer Protocols:

The transport layer receives data from the application, and breaks it into chunks
called segments, and sends them to the network router for delivery. Two transport layer
protocols are used on the Internet. The transport layer uses two protocols as follows,

1. TCP (Transmission Control Protocol)

2. UDP (User Datagram Protocol)

1] TCP (Transmission Control Protocol): The transmission control protocol (TCP) is used for
applications in which reliable connections between hosts are necessary. TCP checks for
transmission errors, lost packets, packets out of order, etc., and tries to automatically
correct these without "bothering" the application program. It also does flow control,
slowing transmission if it is too fast for the receiver.

 It is Connection Oriented Transmission.

 In this type of transmission the receiving device sends an acknowledgment, back to
the source after a packet or group of packet is received.

Page | 2
 This type of transmission is also known as reliable transport method. Because
connection oriented transmission requires more packets be sent across network, it is
considered a slower transmission method.
 If the data that is sent has problems, the destination requests the source for
retransmission by acknowledging only packets that have been received and are
 Once the destination computer receives all of the data necessary to reassemble the
packet, the transport layer assembles the data in the correct sequence and then
passes it up, to the session layer.

TCP Handshake

Fig. Three-Way Handshaking of TCP

A three-way handshake is primarily used to create a TCP socket connection. It works


 A client node sends a SYN data packet over an IP network to a server on the same or
an external network. The objective of this packet is to ask/infer if the server is open
for new connections.
 The target server must have open ports that can accept and initiate new
connections. When the server receives the SYN packet from the client node, it
responds and returns a confirmation receipt – the ACK packet or SYN/ACK packet.
 The client node receives the SYN/ACK from the server and responds with an ACK

After completion of this process, the connection is created and the host and server can

TCP Header Format: TCP is the primary transport protocol used to provide reliable, full-
duplex connections. The most common use of TCP is to exchange TCP data encapsulated in
an IP datagram. TCP is typically implemented on hosts only to provide reliable end-to-end

Page | 3
data delivery. The unit of transfer between the TCP software on two machines is called a
TCP segment. Segments are exchanged to establish connections, transfer data, send
acknowledgements, advertise window sizes and close connections.

Fig. TCP Encapsulation

Each TCP header has ten required fields totalling 20 bytes (160 bits) in size. They can also
optionally include an additional data section up to 40 bytes in size.

Fig. TCP Header Format

 Source and destination TCP port numbers are the communication endpoints for sending
and receiving devices.

 Message senders use sequence numbers to mark the ordering of a group of messages.
Both senders and receivers use the acknowledgment numbers field to communicate the
sequence numbers of messages that are either recently received or expected to be sent.

 Hlen: The number of 32-bit words in the TCP header. This indicates where the data
begins. The length of the TCP header is always a multiple of 32 bits.

 Reserved: in TCP headers always has a value of zero. This field serves the purpose of
aligning the total header size as a multiple of four bytes (important for the efficiency of
computer data processing).

Page | 4
 There are six flags in the TCP header. One or more can be turned on at the same time.

URG The URGENT POINTER field contains valid data

ACK The acknowledgement number is valid
PSH The receiver should pass this data to the
application as soon as possible
RST Reset the connection
SYN Synchronize sequence numbers to initiate a
FIN The sender is finished sending data.

 Window: TCP senders use a number called window size to regulate how much data they
send to a receiver before requiring an acknowledgment in return. If the window size
becomes too small, network data transfer will be unnecessarily slow, while if the
window size becomes too large, the network link can become saturated (unusable for
any other applications) or the receiver may not be able to process incoming data quickly
enough (also resulting in slow performance).

 Checksum: The checksum value inside a TCP header is generated by the protocol sender
as a mathematical technique to help the receiver detect messages that are corrupted or
tampered with.

 Urgent Pointer: The urgent pointer is valid only if the URG flag is set. TCP's urgent mode
is a way for the sender to transmit emergency data to the other end. This feature is
rarely used.

2] UDP (User Datagram Protocol): UDP is a Transport Layer protocol. UDP is a part of
Internet Protocol suite, referred as UDP/IP suite. Unlike TCP, it is unreliable and
connectionless protocol. So, there is no need to establish connection prior to data transfer.

UDP provides two services not provided by the IP layer. It provides port numbers to help
distinguish different user requests and, optionally, a checksum capability to verify that the
data arrived intact.

UDP just sends the packets, which means that it has much lower bandwidth overhead and
latency. With UDP, packets may take different paths between sender and receiver and, as a
result, some packets may be lost or received out of order.

UDP permits packets to be dropped instead of processing delayed packets. There is no error
checking in UDP, so it also save bandwidth.

Page | 5
UDP Header Format:

Fig. UDP Header Format

 Source Port. 16 bits: The port number of the sender. Cleared to zero if not used.

 Destination Port. 16 bits: The port number of the receiver.

 Length. 16 bits: The length in bytes of the UDP header and the encapsulated data. The
minimum value for this field is 8.

 Checksum: This field stores the checksum value generated by the sender before sending.
IPv4 has this field as optional so when checksum field does not contain any value it is
made 0 and all its bits are set to zero.

Page | 6