3. Transport Layer Responsibilities
Various responsibilities of a Transport Layer –
• Process to process delivery
• End-to-end Connection between hosts
• Multiplexing and Demultiplexing
• Data integrity and Error correction
• Flow control
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
4. Process to Process Delivery
• While Data Link Layer requires the MAC address (48
bits address contained inside the Network Interface
Card of every host machine) of source - destination
hosts to correctly deliver a frame and
• Network layer requires the IP address for appropriate
routing of packets
• Transport Layer requires a Port number to correctly
deliver the segments of data to the correct process
amongst the multiple processes running on a particular
host.
• A port number is a 16 bit address used to identify any
client-server program uniquely.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
5. End-to-end Connection Between Hosts
• Transport layer is also responsible for creating the end-
to-end Connection between hosts for which it mainly
uses TCP and UDP.
• TCP is a secure, connection- orientated protocol which
uses a handshake protocol to establish a robust
connection between two end- hosts.
• TCP ensures reliable delivery of messages and is used
in various applications.
• UDP on the other hand is a stateless and unreliable
protocol which ensures best-effort delivery.
• It is suitable for the applications which have little
concern with flow or error control and requires to send
bulk of data like video conferencing.
• It is a often used in multicasting protocols.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
6. Multiplexing and Demultiplexing
• Multiplexing allows simultaneous use of different
applications over a network which are running on a host.
• Transport layer provides this mechanism which enables
us to send packet streams from various applications
simultaneously over a network.
• Transport layer accepts these packets from different
processes differentiated by their port numbers and
passes them to network layer after adding proper
headers.
• Similarly Demultiplexing is required at the receiver side to
obtain the data coming from various processes.
• Transport receives the segments of data from network
layer and delivers it to the appropriate process running on
the receiver’s machine.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
7. Congestion Control
• Congestion is a situation in which too many sources over
a network attempt to send data and the router buffers
start overflowing due to which loss of packets occur.
• As a result retransmission of packets from the sources
increase the congestion further.
• In this situation Transport layer provides Congestion
Control in different ways.
• It uses open loop congestion control to prevent the
congestion and closed loop congestion control to
remove the congestion in a network once it occurred.
• TCP provides AIMD- additive increase multiplicative
decrease , leaky bucket technique for congestion control.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
8. Data integrity and Error correction
Transport layer checks
• for errors in the messages coming from application
layer by using error detection codes,
• computing checksums,
• it checks whether the received data is not corrupted and
uses the ACK and NACK services to inform the sender
if the data is arrived or not and checks for the integrity
of data.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
9. Flow control
• Transport layer provides a flow control mechanism
between the adjacent layers of the TCP/IP model.
• TCP also prevents the data loss due to a fast sender
and slow receiver by imposing some flow control
techniques.
• It uses the method of sliding window protocol which is
accomplished by receiver by sending a window back to
the sender informing the size of data it can receive.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
10. Introduction to UDP
UDP is located between the application layer and the IP
layer, and serves as the intermediary between the
application programs and the network operations.
UDP is a connectionless transport protocol, i.e. it doesn't
guarantee either packet delivery or that packets arrive in
sequential order.
With UDP, bytes of data are grouped together in discrete
packets which are sent over the network.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
11. Packets may travel along different paths depending
on the state of the network.
No two packets are guaranteed the same route.
Each packet has a time-to-live (TTL) counter, which
is updated when it is routed along to the next point in
the network. When the timer expires, it will be
discarded, and the recipient will not be notified.
If a packet does arrive, it will always arrive intact.
Packets that are corrupt or only partially delivered are
discarded.
Introduction contd…
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
12. In TCP/IP protocol suite, using IP to transport
datagram (similar to IP datagram).
Allows a application to send datagram to other
application on the remote machine.
Delivery and duplicate detection are not guaranteed.
Low overhead: faster than TCP
Introduction contd…
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
13. End-to-End: an application sends/receives data to/from
another application.
Connectionless: Application does not need to pre-establish
communication before sending data; application does not need
to terminate communication when finished.
Message-oriented: application sends/receives individual
messages (UDP datagram), not packets.
Best-effort: same best-effort delivery semantics as IP. I.e.
message can be lost, duplicated, and corrupted.
Arbitrary interaction: application communicates with many
or one other applications.
Operating system independent: identifying application does
not depend on O/S.
UDP Characteristics
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
14. Process to Process Communication
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
15. Port Number
Process-to-process communication: client-server paradigm
Both process (client and server) have the same name
Daytime client process / daytime server
Today OS supports multi-user and multi-processors
A remote computer can run several server programs at
same time
A local computer can run several client programs at same
time
For communication, we must define the
local host, local process, remote host, remote process
Process to Process Communication
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
16. UDP Port numbers
• The Daytime Protocol is a service in the Internet Protocol Suite RFC 867.
• It is intended for testing and measurement purposes in computer networks.
• A host may connect to a server that supports the Daytime Protocol on either TCP or
UDP port 13.
• The server returns an ASCII character string of the current date and time in an
unspecified format.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
17. IP vs. Port numbers
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
18. Process to Process Communication
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
19. UDP packets, called user datagrams, have a fixed-size
header of 8 bytes.
UDP Packets
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
20. The following is a dump of a UDP header in hexadecimal format.
a. What is the source port number?
b. What is the destination port number?
c. What is the total length of the user datagram?
d. What is the length of the data?
e. Is the packet directed from a client to a server or vice versa?
f. What is the client process?
UDP Packets: Problem
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
21. a. The source port number is the first four hexadecimal digits
(CB84)16 or 52100.
b. The destination port number is the second four hexadecimal digits
(000D)16 or 13.
c. The third four hexadecimal digits (001C)16 define the length of the
whole UDP packet as 28 bytes.
d. The length of the data is the length of the whole packet
minus the length of the header, or 28 – 8 = 20 bytes.
e. Since the destination port number is 13 (well-known port), the
packet is from the client to the server.
f. The client process is the Daytime
UDP Packets: Solution
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
23. Pseudoheader & Header
• Source Port/Destination Port: A port (socket/session) Virtual
circuit between two communicating processes on two different
computers or devices
• The source port is the port on the sending device.
• The destination port is a TCP port on a receiving device that
corresponds with the source port on the sending device
• Length: contains information about the length of the frame
• Checksum: The checksum is a 16-bit cyclic redundancy check
(CRC) that is computed by adding the length of all header fields
plus the length of the data payload field (the sum of all fields in
the TCP segment).
• Placed in the frame by the sending station.
• The recipient also calculates the checksum and compares its
calculation with the value in the checksum field.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
25. Checksum calculation at receiver
Add the peudoheader to UDP user datagram
Fill the checksum field with 0s
Divide the total bits into 16-bit (2 bytes) sections
If the total number of bytes is not even, add 1 byte of padding
(all 0s). The padding is only for the purpose of calculating the
checksum and will be discarded afterwards.
Add all 16-bit sections using one’s complement arithmetic
Complement the result, which is a 16-bit number, and insert
in the checksum field
Drop the peudoheader and any added padding
Deliver the user datagram to the IP layer for encapsulation
Checksum calculation at the Sender
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
26. Checksum calculation at receiver
Add the peudoheader to UDP user datagram
Add padding if needed
Divide the total bits into 16-bit (2 bytes) sections
Add all 16-bit sections using one’s complement
arithmetic
Complement the result
If the result is all 0s, drop the peudoheader and any
added padding and accept the user datagram.
If the result anything else, discard the user datagram
Checksum calculation at the Receiver
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
29. Encapsulation and Layering
UDP message is encapsulated into an IP datagram.
IP datagram in turn is encapsulated into a physical frame for
actually delivery.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
30. Queues in UDP
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
32. Multiplexing and Demultiplexing
• Multiplexing and Demultiplexing services are provided in
almost every protocol architecture ever designed.
• UDP and TCP perform the demultiplexing and
multiplexing jobs by including two special fields in the
segment headers: the source port number field and the
destination port number field.
• Multiplexing – Gathering data from multiple application
processes of sender, enveloping that data with header
and sending them as a whole to the intended receiver is
called as multiplexing.
• Demultiplexing – Delivering received segments at
receiver side to the correct app layer processes is called
as demultiplexing.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
36. Multiplexing and Demultiplexing
Sender: multiplexing of UDP datagrams.
UDP datagrams are received from multiple application programs.
A single sequence of UDP datagrams is passed to IP layer.
Receiver: demultiplexing of UDP datagrams.
Single sequence of UDP datagrams received from IP layer.
UDP datagram received is passed to appropriate application.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
37. UDP Design
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
38. UDP package involves five components:
a control-block table,
input queues,
a control-block module,
an input module, and
an output module.
Components of UDP
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
39. Components of UDP
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
40. Control-Block Table
In our package, UDP has a control-block table to
keep track of the open ports. Each
entry in this table has a minimum of four fields:
the state, which can be FREE or IN-USE,
the process ID, the port number, and the
corresponding queue number.
UDP Design: Control Block Table
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
41. Input Queues
Our UDP package uses a set of input queues, one for
each process. In this design, we do not use output
queues.
UDP Design: Input Queues
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
42. The first activity is the arrival of a user datagram with
destination port number 52,012.
The input module searches for this port number and
finds it.
Queue number 38 has been assigned to this port, which
means that the port has been previously used.
The input module sends the data to queue 38.
The control-block table does not change.
How it Works?
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
43. After a few seconds, a process starts.
It asks the operating system for a port number and is
granted port number 52,014.
Now the process sends its ID (4,978) and the port
number to the control-block module to create an entry
in the table.
The module takes the first FREE entry and inserts the
information received.
The module does not allocate a queue at this moment
because no user datagrams have arrived for this
destination
How it Works?
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
44. How it Works?
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
45. UDP communication can be more efficient than
guaranteed-delivery data streams.
Unlike TCP streams, which establish a connection,
UDP causes fewer overheads.
Real-time applications that demand up-to-the-second
or better performance may be candidates for UDP, as
there are fewer delays due to error checking and flow
control of TCP.
UDP sockets can receive data from more than one host
machine.
Some network protocols specify UDP as the transport
mechanism.
Advantages of UDP
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
46. When sending a packet, the application must create a
DatagramPacket that will contain the data.
The address and port information must also be set.
When the packet is ready for transmission, the send
method of DatagramSocket should be invoked.
Sending UDP Packets
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
49. A client-server application such as DNS uses the
services of UDP because a client needs to send a short
request to a server and to receive a quick response
from it.
The request and response can each fit in one user
datagram.
Since only one message is exchanged in each direction,
the connectionless feature is not an issue; the client or
server does not worry that messages are delivered out
of order.
Example 1
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
50. A client-server application such as SMTP, which is used in
electronic mail, cannot use the services of UDP because a user
can send a long e-mail message, which may include multimedia
(images, audio, or video).
If the application uses UDP and the message does not fit in one
single user datagram, the message must be split by the
application into different user datagrams.
Here the connectionless service may create problems.
The user datagrams may arrive and be delivered to the receiver
application out of order.
The receiver application may not be able to reorder the pieces.
This means the connectionless service has a disadvantage for an
application program that sends long messages.
Example 2
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
51. Watching a real-time stream video on our computer.
Such a program is considered a long file; it is divided into
many small parts and broadcast in real time.
The parts of the message are sent one after another.
If the transport layer is supposed to resend a corrupted or
lost frame, the synchronizing of the whole transmission
may be lost.
The viewer suddenly sees a blank screen and needs to
wait until the second transmission arrives. This is not
tolerable.
Example 3
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
52. However, if each small part of the screen is sent using one
single user datagram, the receiving UDP can easily ignore
the corrupted or lost packet and deliver the rest to the
application program.
That part of the screen is blank for a very short period of
the time, which most viewers do not even notice.
However, video cannot be viewed out of order, so
streaming audio, video, and voice applications that run
over UDP must reorder or drop frames that are out of
sequence.
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
53. UDP limitations:
Lack of Guaranteed Delivery
Lack of Guaranteed Packet Sequencing
Lack of Flow Control
Overcoming UDP Limitations
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
54. Packets sent via UDP may become lost in transit.
UDP packets can also become damaged or lost.
For some applications, the loss of individual packets
may not have a noticeable effect (e.g. video streams).
For other applications, loss of packets is not acceptable
(e.g. file transfers).
Lack of Guaranteed Delivery
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
55. If guaranteed delivery is required,
avoid packet-based communication, and use a
more suitable transport mechanism (e.g. TCP).
send acknowledgement to sender after receiving
packets.
Lack of Guaranteed Delivery
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
56. Applications that require sequential access to
data should include a sequence number in the
contents of a datagram packet.
This enables detection of duplicate packets and
also missing packets.
Lack of Guaranteed Packet Sequencing
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.
57. The technique of flow control is important to avoid
flooding a system with more data than it can handle
due to limited bandwidth.
One technique of flow control is to limit the number
of unacknowledged packets.
E.g.: increase control when number of
acknowledgement packets received is much less than
the number of packets sent.
Lack of Flow Control
Dept. of Computer Science, Pondicherry University, Puducherry-605014, India.