0% found this document useful (0 votes)
4 views46 pages

Transport Layer

The transport layer (Layer 4) in the TCP/IP model facilitates process-to-process communication and includes protocols like TCP, UDP, and SCTP. It provides essential services such as flow control, error control, multiplexing, and demultiplexing, while also managing addressing through port numbers. TCP is a connection-oriented and reliable protocol, whereas UDP is connectionless and faster but lacks reliability features.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views46 pages

Transport Layer

The transport layer (Layer 4) in the TCP/IP model facilitates process-to-process communication and includes protocols like TCP, UDP, and SCTP. It provides essential services such as flow control, error control, multiplexing, and demultiplexing, while also managing addressing through port numbers. TCP is a connection-oriented and reliable protocol, whereas UDP is connectionless and faster but lacks reliability features.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

4.

Transport Layer
INTRODUCTION

 The transport layer is responsible for providing services to the application layer, it receives
services from the network layer.
 Transport layer, (layer 4) in the TCP/IP model is responsible for process-to-process
communication, flow control, congestion control and so on.
 The original TCP/IP protocol suite specifies two protocols for the transport layer namely,
UDP and TCP.
 A new transport layer protocol SCTP (Stream Control Transmission Protocol )is recently
developed for signaling message transport over IP networks.
TRANSPORT LAYER SERVICES

1. Process-to-Process Communication
The first duty of a transport layer is to provide process-to-process communication. A process is an
application program running on the host and uses the services of the transport layer.
2. Addressing: Port Numbers
A process on the local host, called a client, needs services from a process on the remote host called a
server.
The client and server machines can run several applications programs simultaneously.
A remote computer can run several server programs at the same time, just as several local computers
can run one or more client programs at the same time.
The local host and the remote host are defined using IP addresses.
To define the processes, we need second identifiers, called port numbers.
In the TCP/IP protocol suite, the port numbers are integers between 0 and 65,535 (16 bits). Port
numbers are 16 bit long that help identify which process is sending or receiving data on a host.
 The client program defines itself with a port number, called the ephemeral port number. The
word 'ephemeral' means 'short lived' and is used because the life of a client is normally short.
 If the computer at the server site runs a server process and assigns a random number as the
port number, the process at the client site that wants to access that server and use its services
will not know the port number.
 TCP/IP has decided to use universal port numbers for servers; these are called well- known
port numbers. Every client process knows the well-known port number of the corresponding
server process.
 The IANA (Internet Assigned Number Authority) has divided the port numbers into three
range
1. Well Known Ports: The ports from 0 to 1023 are assigned and controlled by IANA. These
are well known ports.
2. Registered Ports: The ports ranging from 1024 to 49151 are not assigned or controlled by
IANA. They can be registered with IANA to avoid duplication.
3. Dynamic Ports (Ephemeral Ports): The ports ranging from 49,152 to 65,535 are neither
controlled nor registered. They can be used by any process. These are ephemeral ports.
The combination of an IP address and a port number is called a socket address.
3. Encapsulation and Decapsulation
 Encapsulation happens at sender site. The transport layer receives the data from application
layer and adds the transport-layer header. The packets at the transport layers in the Internet
are called user datagrams, segments, or packets.
 Decapsulation happens at the receiver site. When the message arrives at the destination
transport layer, the header is dropped and the transport layer delivers the message to the
process running at the application layer.
 4. Multiplexing and Demultiplexing
 Multiplexing and demultiplexing are the two very important services that are performed by
the transport layer.
 The transport layer at the source performs multiplexing while the transport layer at the
destination performs demultiplexing
 Whenever an entity accepts items from more than one source, it is referred to as multiplexing
(many to one); whenever an entity delivers items to more than one source, it is referred to as
demultiplexing (one to many).
 The processes P1 and P3 need to send requests to the corresponding server process running in
a server.
 5. Flow Control
The transport layer provides a flow control mechanism between the adjacent layers of the
TCP/IP model.
5.1 Pushing or Pulling
 Delivery of items from a producer to a consumer can occur in one of the two ways namely,
pushing or pulling.
1. If the sender delivers items whenever they are produced without the prior request from the
consumer the delivery is referred to as pushing.
2. If the producer delivers the items after the consumer has requested them, the delivery is
referred to as pulling.
In other words, the consumer needs to warn the producer to stop the delivery and to inform it
when it is ready again to receive the items.
When the consumer pulls the items, it requests them when it is ready. In this case, there is no
need for flow control.
5.2 Buffers
 Although flow control in the transport layer can be implemented in several ways, one of the
solutions is normally to use two buffers. One at the sending transport layer and the other at the
receiving transport layer.
 A buffer is a set of memory locations that can hold packets at the sender and receiver.
 The flow control communication can occur by sending signals from the consumer to producer.
 When the buffer of the sending transport layer is full, it informs the application layer to stop
passing chunks of messages; when there are some vacancies, it informs the application layer
that it can pass message chunks again.
 When the buffer of the receiving transport layer is full, it informs the sending transport layer to
stop sending packets. When there are some vacancies, it informs the sending transport layer
that it can send messages again.
6. Error Control
 The error control service in the transport layer, observes that the data delivered to the
receiver is error free and reliable.
 Error control at the transport layer is responsible to:
1. Detect and discard corrupted packets.
2. Keep track of lost and discarded packets and resend them.
3. Recognize duplicate packets and discard them.
4. Buffer out-of-order packets until the missing packets arrive.
Error control involves only the sending and receiving transport layers. We are assuming that
the message chunks exchanged between the application and transport layers are error free.
6.1 Sequence Numbers
6.2 Acknowledgements
6.3 Sliding Window
6.1 Sequence Numbers
 Error control mechanism requires that the sending transport layer knows which packet is
to be resent and the receiving transport layer knows which packet is a duplicate, or which
packet has arrived out of order.
 This can be done if the packets are numbered. We can add a field to the transport layer
packet to hold the sequence number of the packets.
 When a packet is corrupted or lost, the receiving transport layer can somehow inform the
sending transport layer to resend that packet using the sequence number.
 The receiving transport layer can also detect duplicate packets if two received packets have
the same sequence number. The out-of-order packets can be recognized by observing gaps
in the sequence numbers.
 Packets are numbered sequentially. However, because we need to include the sequence
number of each packet in the header, we need to set a limit. If the header of the packet
allows m bits for the sequence number, the sequence numbers range from 0 to 2m-1.
6.2 Acknowledgements
 In error control, we can use both positive and negative signals as error control. The receiver
side can send an acknowledgement (ACK) for each or a collection of packets that have
arrived safe and sound.
 The receiver can simply discard the corrupted packets. The sender can detect lost packets
if it uses a timer.
 When a packet is sent, the sender starts a timer; when the timer expires, if an ACK does not
arrive before the timer expires, the sender resends the packet.
 Duplicate packets can be silently discarded by the receiver. Out-of-order packets can be
either discarded (to be treated as lost packets by the sender), or stored until the missing
ones arrive.
 6.3 Sliding Window
Since the sequence numbers used modulo 2, a circle can represent the sequence number from 0 to
2m-1 as shown in Fig. 4.11.
The buffer is represented as a set of slices, called the sliding window, that occupy part of the circle
at any time.
At the sender site, when a packet is sent, the corresponding slice is marked. When all the slices are
marked, it means that the buffer is full and no further messages can be accepted from the
application layer.
When an acknowledgment arrives, the corresponding slice is unmarked. If some consecutive slices
from the beginning of the window are unmarked, the window slides over the range of the
corresponding sequence number to allow more free slices at the end of the window.
7. Congestion Control
 Congestion in a network may occur if the load on the network-the number of packets sent to the
network is greater than the capacity of the network - the number of packets a network can handle.
 Congestion control refers to the mechanisms and techniques to control the congestion and keep
the load below the capacity.
 Congestion control refers to techniques and mechanisms that can either prevent congestion,
before it happens, or remove congestion, after it has happened.
 Congestion control uses open loop congestion control to prevent the congestion and closed loop
congestion control to remove the congestion in a network once it occurs.
Connectionless and
Connection Oriented
Services
Connection Less Service
 In a connection less service the
packets are sent from one
machine to another without
connection establishment or
connection release.
Connection Oriented Service
In a connection oriented service connection is established first then data are transferred in
between sender & receiver. After the end of data transfer, connection is released.
Transport Layer Protocols
User Datagram Protocol (UDP)

 User Datagram Protocol (UDP) is a Transport Layer protocol.


 UDP is a part of the Internet Protocol suite, referred to as UDP/IP suite.
 Unlike TCP, it is an unreliable and connectionless protocol. So, there is no need to
establish a connection before data transfer.
 The UDP helps to establish low-latency connections over the network. The UDP enables
process-to-process communication.
Features of UDP
1.Connectionless
2.Faster transmission
3. No Acknowledgment mechanism
4. Lack of congestion Control
5. Lack of error Control
6. Simple
7. Port
8. Support Multicast
Datagram Format
UDP Services

1. Process to Process Communication


UDP provides process to process communication using sockets, a combination of IP addresses
and port numbers.
2. Connectionless Services
3. Error Control
A checksum is a technique used to determine the authenticity of received data, i.e., to detect
whether there was an error in transmission.
Along with the data that needs to be sent, the sender uses an algorithm to calculate the
checksum of the data and sends it along.
When the receiver gets the data, it calculates the checksum of the received data using the same
algorithm and compares it with the transmitted checksum. If they both match, it means the
transmission was error-free.
It is calculated on UDP Header, encapsulated data and IP pseudo header.
Checksum calculation is not mandatory in UDP.
4. Multiplexing & Demultiplexing
5. Encapsulation & Decapsulation
UDP receives data and adds the UDP header. UDP then passes the user datagram to IP with the
socket addresses.
IP adds its own header , using the value 17in the protocol field, indicating that the data has
come from the UDP protocol.
At receiver site UDP uses checksum to check the entire user datagram.
6.Queuing
Transmission Control Protocol (TCP)

 TCP (Transmission Control Protocol) is one of the main protocols of the Internet
protocol suite
 Transmission Control Protocol is a connection-oriented, reliable protocol . It creates virtual
connection between two communicating entities.
 TCP services
1. Process to Process communication
 2. Stream delivery system
TCP is really a stream-oriented protocol. It allows the sending process to provide data as a
stream of bytes and allows the receiving process to obtain data as a stream of bytes. TCP
creates an environment where the two processes appear to be connected by an imaginary
“tube” that carries their bytes across the Internet. The sending process produces (write to) the
stream and the receiving process consumes (read from) it.
 3. Sending & receiving buffers
 4.Segments
(TCP groups a number of bytes together into a packet called a segment)
 5.Full-Duplex Communication – TCP offers a full-duplex service, where data can flow in
both directions at the exact same time. Each TCP endpoint then has its sending and
receiving buffer, and segments move around in both directions.
 6. Multiplexing and Demultiplexing – TCP performs multiplexing at the sender and
demultiplexing at the receiver ends as several logical connections could be established
between port numbers over an actual connection. However, TCP is really a connection-
oriented protocol, an association must be established for each pair of processes.
7. Connection-Oriented Services – TCP is really a connection-oriented protocol. When a
process at site A really wants to send and receive data from another process at site B, the next
three phases occur :
The two TCP’s set up a logical connection between them.
Data are exchanged in both directions.
The bond is terminated.
There is no physical connection. TCP creates a stream-oriented atmosphere wherever it
accepts the responsibility of delivering the bytes to the other website.
8. Reliable Service – It is really a reliable protocol. It uses an acknowledgement mechanism
to test to safe and sound arrival of data. Also, it uses congestion control mechanisms.
TCP Features
 Segment Numbering System: TCP keeps track of the segments being transmitted
or received by assigning numbers to each . Acknowledgment Numbers are
assigned to received segments.
 Connection Oriented: It means sender and receiver are connected to each other
till the completion of the process. The order of the data is maintained i.e. order
remains same before and after transmission.
 Full Duplex: In TCP data can be transmitted from receiver to the sender or vice –
versa at the same time. It increases efficiency of data flow between sender and
receiver.
 Flow Control: Flow control limits the rate at which a sender transfers data.
This is done to ensure reliable delivery. The receiver continually hints to the
sender on how much data can be received
 Error Control: TCP implements an error control mechanism for reliable
data transfer. Error control is byte-oriented. Segments are checked for error
detection. Error Control includes – Corrupted Segment & Lost Segment
Management, Out-of-order segments, Duplicate segments, etc.
 Congestion Control: TCP takes into account the level of congestion in the
network. Congestion level is determined by the amount of data sent by a
sender.
TCP Segment Format
 Source port: this is a 16 bit field that specifies the port number of the sender.
 Destination port: this is a 16 bit field that specifies the port number of the receiver.
 Sequence number: the sequence number is a 32 bit field that indicates how much data is
sent during the TCP session. When you establish a new TCP connection (3 way handshake)
then the initial sequence number is a random 32 bit value. The receiver will use this
sequence number and sends back an acknowledgment. Protocol analyzers like wireshark
will often use a relative sequence number of 0 since it’s easier to read than some high
random number.
 Acknowledgment number: this 32 bit field is used by the receiver to request the next TCP
segment. This value will be the sequence number incremented by 1.
 DO/ Header Length: this is the 4 bit data offset field, also known as the header length. It
indicates the length of the TCP header so that we know where the actual data begins.
 RSV: these are 6 bits for the reserved field. They are unused and are always set to 0.
 Flags: there are 6 bits for flags, we also call them control bits. We use them to establish
connections, send data and terminate connections:
 URG: urgent pointer. When this bit is set, the data should be treated as priority over other data.
 ACK: used for the acknowledgment.
 PSH: this is the push function. This tells an application that the data should be transmitted
immediately and that we don’t want to wait to fill the entire TCP segment.
 RST: this resets the connection, when you receive this you have to terminate the connection
right away. This is only used when there are unrecoverable errors and it’s not a normal way to
finish the TCP connection.
 SYN: we use this for the initial three way handshake and it’s used to set the initial sequence
number.
 FIN: this finish bit is used to end the TCP connection. TCP is full duplex so both parties will
have to use the FIN bit to end the connection. This is the normal method how we end an
connection.
 Window: the 16 bit window field specifies how many bytes the receiver is willing to
receive. It is used so the receiver can tell the sender that it would like to receive more data
than what it is currently receiving. It does so by specifying the number of bytes beyond the
sequence number in the acknowledgment field.
 Checksum: 16 bits are used for a checksum to check if the TCP header is OK or not.
 Urgent pointer: these 16 bits are used when the URG bit has been set, the urgent pointer is
used to indicate where the urgent data ends.
 Options: this field is optional and can be anywhere between 0 and 320 bits.
TCP Connection Establishment & Termination
Data Transfer
Connection Termination
State Transition Diagram
Windows in TCP

Send Window
We can categorize the data into 4 groups:
 Bytes that sent and acknowledged (blue)
 Bytes that sent but not yet acknowledged (yellow)
 Bytes that not sent and the recipient ready to receive (green)
 Bytes that not sent and the recipient NOT prepared to receive (grey)
 Category 3 is also referred to as the usable window because this is the
window the sender can use.
 Receive Window
The receive window has 3 categories:
 Bytes that received and acknowledged
 Bytes that not yet received but the transmitter permitted to send
 Bytes that not yet received and the transmitter may NOT allow to send
 Category 2 is known as Receive Window, also be referred to as RCV.WND.
 Similar to the send window, a pointer RCV.NXT, standing for the Receive
Next pointer, pointing to the first byte of the receive window.

You might also like