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

Transport Layer: Process-to-Process Delivery: Udp and TCP

The transport layer is responsible for process-to-process delivery by taking messages from applications and encapsulating them with transport headers to create segments. These segments are passed to the network layer, which adds its own headers to create datagrams. Datagrams are then passed to the data link layer, which adds headers to create frames for transmission. The transport layer uses port numbers to identify the sending and receiving processes and allow for multiplexing and demultiplexing of data between processes.

Uploaded by

22Angira Ghosh
Copyright
© © All Rights Reserved
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Transport Layer: Process-to-Process Delivery: Udp and TCP

The transport layer is responsible for process-to-process delivery by taking messages from applications and encapsulating them with transport headers to create segments. These segments are passed to the network layer, which adds its own headers to create datagrams. Datagrams are then passed to the data link layer, which adds headers to create frames for transmission. The transport layer uses port numbers to identify the sending and receiving processes and allow for multiplexing and demultiplexing of data between processes.

Uploaded by

22Angira Ghosh
Copyright
© © All Rights Reserved
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
You are on page 1/ 74

Transport Layer

Process-to-Process Delivery:
UDP and TCP
TCP/IP Internet protocol Stack
• Packets of information that passes through these layers are referred by different names in each layer.

• At the application level, data that needs to be exchanged is referred to as a message.

• Then the transport layer takes this message and adds transport layer headers to it. The resulting

encapsulated packet is called a segment.

• When the segment is passed on to the network layer, it wraps the segment with its own network

layer headers and it goes by the name of datagram.

• Then when the link layer takes over these datagrams, it adds link layer related headers and pass

those packets which is then known as frames to the physical layer for transmission.
How a user data from application layer of a sender
is gradually passing through each layer

datalink

layer
Transport Layer
 The network layer is only responsible for host to host
communication.

That is, it can only deliver messages to the destination computer.
 Once a message has been delivered to the destination, it
still needs to be handed over to the correct process and
transport layer has the responsibility to take care of that.
 Suppose you have three application processes running in your
machine. Now when your computer receives data from outside that
message needs to be directed to the correct application process. 
 The transport layer is responsible for process-to-
process delivery
 the delivery of a packet, part of a message, from one process to
another.
 Two processes communicate in a client/server relationship.
Types of data deliveries:
Types of data deliveries:
The data link layer is responsible for delivery of frames between two neighboring nodes over

a link. This is called node-to-node delivery.

The network layer is responsible for delivery of datagrams between two hosts. This is called

host-to-host delivery.

Communication on the Internet is not defined as the exchange of data between two nodes

or between two hosts. Real communication takes place between two processes. So that we

need process-to-process delivery.

However, at any moment, several processes may be running on the source host and several

on the destination host.


Process to process delivery: Unique identification of processes
Port numbers for Unique identification of processes
There are several ways to achieve process-to-process communication; the most common

one is through the client/server paradigm.

A process on the local host, called a client, needs services from a process usually on the

remote host, called a server. Both processes (client and server) have the same name.

For example, to get the day and time from a remote machine, we need a Daytime client

process running on the local host and a Daytime server process running on a remote

machine.

A remote computer can run several server programs at the same time, just as local

computers can run one or more client programs at the same time. For communication, we

must define the following:


Port numbers for Unique identification of
processes
 Transport layer actually does not directly deliver messages to
processes.
 There’s an intermediate software interface called a socket
layer that does the transmission of messages between the
underline network and the processes.
 Since a process can have one or more sockets through which it can
pass data to and from network and each of these sockets have a
unique identifier.
Multiplexing &
Demultiplexing
 Transport layer gathers chunks of data it
receives from different sockets and
encapsulate them with transport
headers.
 Passing these resulting segments to the
network layer is called multiplexing.
 The reverse process which is delivering data
to the correct socket by the transport
layer is called demultiplexing.
 Transport layer identifies the correct
socket using Port numbers
 A remote computer can run several server
programs at the same time, just as local
computers can run one or more client
programs at the same time. For
communication, we must define the following:
 1. Local host 2. Local process
3. Remote host 4. Remote process
Figure 23.3 IP addresses versus port numbers

Addresses

•Data link layer  MAC


address

•Network layer  IP
address

•Transport layer  Port


number (choose among

multiple processes

running on destination

host)
Addresses
 Whenever we need to deliver something to one specific destination among
many, we need an address.

 At the data link layer, we need a MAC address to choose one node among
several nodes if the connection is not point-to-point.
 A frame in the data link layer needs a destination MAC address for
delivery and a source address for the next node's reply.

 At the network layer, we need an IP address to choose one host among


millions.
 A datagram in the network layer needs a destination IP address for
delivery and a source IP address for the destination's reply.

 At the transport layer, we need a transport layer address, called a port


number, to choose among multiple processes running on the destination
host.
 The destination port number is needed for delivery; the source
port number is needed for the reply.
https://slide-finder.com/view/ECET-415-Lectures-56.329284.html
Port Numbers
•Port numbers are 16-bit integers (0  65,535)

Servers are privileged and use well know ports, with port numbers 0-1023

The well-known ports are the Internet services that have been assigned a specific port. For instance,

SMTP is assigned port 25 and HTTP is assigned port 80 and FTP 21, . Servers listen on the

network for requests at the well-known ports.

This port number, however, cannot be chosen randomly.

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.


IANA Port Numbers
 Internet Assigned Numbers Authority (IANA) maintains a list of port
number assignment
 Well-known ports (0-1023)  controlled and assigned by IANA
 Registered ports (1024-49151)  IANA registers and lists use of ports
as a convenience (49151 is ¾ of 65536)
 Registered port numbers in the 1,025 through 49,151 range reflect
network services provided by a particular hardware or software
developer’s products (e.g., the value 1,512 was registered by Microsoft
for use by its NetBIOS Name Services implementation, commonly known
as Windows Internet Name Services [WINS]).
 Dynamic ports (49152-65535)  ephemeral ports
 The client program defines itself with a port number, chosen randomly by the transport layer
software running on the client host. This is the ephemeral port number.
 For well-known port numbers, see /etc/services on a UNIX or Linux machine
Socket address

•Process-to-process delivery needs two identifiers


IP address and Port number
Combination of IP address and port number is called a socket
address (a socket is a communication endpoint)

Client socket address uniquely identifies client process


Server socket address uniquely identifies server process
Socket Addressing
•Transport-layer protocol
needs a pair of socket

addresses

Client socket address


Server socket
address

socket pair for a


TCP connection is a 4-

tuple

Local IP
address, local port,
Position of UDP, TCP, and SCTP in TCP/IP suite
Transport Layer protocols
 The SCTP (Stream Control Transmission Protocol) is a reliable
communications protocol in computer networking which operates at
the transport layer  that can be used on top of IP networks for end-to-
end communications
 The User Datagram Protocol (UDP) is called a connectionless,
unreliable transport protocol.
 Transmission Control Protocol (TCP) is a connection-oriented,
reliable protocol;
 It creates a virtual connection between two TCPs of sending and receiving
hosts to send data.
 In addition, TCP uses flow and error control mechanisms at the transport
level
USER DATAGRAM PROTOCOL (UDP)
UDP is unreliable & connectionless
 Though Transmission Control Protocol (TCP) is the dominant
transport layer protocol used with most of Internet
services;
 provides assured delivery, reliability and much more but all these
services cost us with additional overhead and latency.
 Here, UDP comes into picture.
 User Datagram Protocol (UDP) is a  unreliable and
connectionless Transport Layer protocol. 
 Source of UDP packets doest not require acknowledgement from
receiver. So UDP is unreliable
 For the real-time services like computer gaming, voice or video communication,
live conferences; we need UDP. Since high performance is needed, UDP permits
packets to be dropped instead of processing delayed packets. 
 Note that with UDP there is no handshaking between
sending and receiving transport-layer entities before
sending a segment.
 For this reason, UDP is said to be connectionless.
How UDP works?
 UDP takes messages from application process, attaches source and
destination port number fields for the multiplexing/demultiplexing
service, adds two other fields, and passes the resulting "segment"
to the network layer.
 The network layer encapsulates the segment into an IP datagram
and then makes a best-effort attempt to deliver the segment to the
receiving host.
 If the segment arrives at the receiving host, UDP uses the port
numbers and the IP source and destination addresses to deliver the
data in the segment to the correct application process.
Applications of UDP:
 UDP is used for simple request response communication when size of
data is less and hence there is lesser concern about flow and error
control.
 UDP is used for some routing update protocols like RIP(Routing
Information Protocol).
 UDP does not introduce any delay to establish a connection between
sender and receiver host.
 This is probably the principle reason why DNS runs over UDP rather than TCP -- DNS
would be much slower if it ran over TCP. HTTP uses TCP rather than UDP, since
reliability is critical for Web pages with text.
 Following implementations uses UDP as a transport layer protocol:
 NTP (Network Time Protocol)
 DNS (Domain Name Service)
 BOOTP, DHCP.
 NNP (Network News Protocol)
 TFTP, RIP, OSPF.
 Application layer can do some of the tasks through UDP
 Trace Route
 Record Route
 Time stamp
User datagram format

Source Port : Source Port is 2 Byte long field used to identify port number of source.

Destination Port : It is 2 Byte long field, used to identify the port of destined packet.

Length : Length is the length of UDP including header and the data. It is 16-bits field.
Pseudoheader for checksum calculation
The pseudo header is the part of the header of the

IP packet in which the user datagram is to be

encapsulated with some fields filled with 0s 

If the IP header is corrupted, it may be delivered

to the wrong host.

The protocol field is added to ensure that the packet

belongs to UDP, and not to TCP.


Checksum : Checksum is 2 Bytes long field. It is the 16-bit one’s complement of the one’s complement sum

of the
The UDP
value of header, pseudo
the protocol header
field of information
for UDP is 17 from the IP header and the data, padded with zero

octets at the end (if necessary) to make a multiple of two octets.

Notes – Unlike TCP, Checksum calculation is not mandatory in UDP. No Error control or flow control is
To know
provided more about checksum calculation follow the link: https://www.ques10.com/p/10930/how-
by UDP.
is-checksum-computed-in-udp-1/
Queues in UDP
Well-known ports used with UDP

UDP port number fields are each 16 bits long, therefore range for port numbers defined from 0 to 65535; port

number 0 is reserved.
In UNIX, the well-known ports are stored in a file called /etc/services.
Each line in this file gives the name of the server and the well-known port
number.
We can use the grep utility to extract the line corresponding to the
desired application.
Note that FTP can use port 21 with either UDP or TCP.

SNMP uses two port numbers (161 and 162), each for a different
purpose
TCP

•TCP is a connection-oriented protocol;

•It creates a virtual connection between two TCPs


(Sender & Receiver) to send data.

•In addition, TCP uses flow and error control


mechanisms at the transport level.
Well-known ports used by TCP

23.35
TCP supports Stream oriented delivery
Sending and receiving buffers
TCP segments

A segment is a piece of application data chopped into a transportable size by

TCP and wrapped with a TCP header


Note

The bytes of data being transferred in


each connection are numbered by TCP.
The numbering starts with a randomly
generated number.

23.39
Example

The following shows the sequence number for each


segment:

The value in the sequence number field of a segment defines the


number of the first data byte contained in that segment.

10001
Sequence Number of segment 1 number of 1st byte of segment 1
TCP segment format
TCP flags

TCP flags are used within TCP packet transfers to indicate a particular connection

state or provide additional information. Therefore, they can be used for

troubleshooting purposes or to control how a particular connection is handled.

There are a few TCP flags that are much more commonly used than others as

such SYN, ACK, and FIN. 
Connection establishment Connection close
TCP sequence number & acknowledgement number

Two fields are used sequence number and acknowledgment number. Both

refer to byte number and not segment number

•Sequence Numbers
Sequence number is associated with every byte TCP sends
Sequence number for each segment is the number of the first byte
carried in that segment

Used to detect packet loss,  reordering  and duplicate removal


•Acknowledgement Numbers
The ACK number denotes the number of the next byte that this party
expects to receive (cumulative)
URG-

The Urgent Pointer is used to indicate the priority to process data.


The Urgent Pointer is only valid, if the URG Flag is set.
The Urgent pointer points to the Sequence Number of the last octet in a sequence of Urgent data.
Urgent data shall immediately be processed to the application layer by the receiving TCP.
Connection establishment using three-way handshaking
Note

A SYN segment cannot carry data, but it


consumes one sequence number.
23.47
Note

A SYN + ACK segment cannot


carry data, but does consume one
sequence number.
Note

An ACK segment, if carrying no data,


consumes no sequence number.
Data transfer

Connection establishment Data transfer


Connection termination using three-way handshaking
Note

The FIN segment consumes one


sequence number if it does
not carry data.
Note

The FIN + ACK segment consumes


one sequence number if it
does not carry data.
Sliding window
Example 1

What is the value of the receiver window (rwnd) for host A


if the receiver, host B, has a buffer size of 5000 bytes and
1000 bytes of received and unprocessed data?

Solution
The value of rwnd = 5000 − 1000 = 4000. Host B can
receive only 4000 bytes of data before overflowing its
buffer. Host B advertises this value in its next segment to A.
Example 2

What is the size of the window for host A if the value of


rwnd is 3000 bytes and the value of cwnd is 3500 bytes?

Solution
The size of the window is the smaller of rwnd and cwnd,
which is 3000 bytes.
Example 3

210 209 208 207 206 205 204 203 202 201 200

Above figure shows an unrealistic example of a sliding window.


•The sender has sent bytes up to 202 (shown in grey)
•We assume that cwnd is 20 (in reality this value is thousands of bytes).
•The receiver has sent an acknowledgment number of 200 with an rwnd of 9
bytes (in reality this value is thousands of bytes).
•The size of the sender window is the minimum of rwnd and cwnd, i.e.,
min(20,9) or 9 bytes.
•Bytes 200 to 202 are sent, but not acknowledged. Bytes 203 to 208 can be
sent without worrying about acknowledgment.
•Bytes 209 and above cannot be sent.
Figure 23.23 Example 23.6
Note

Some points about TCP sliding windows:


❏ The size of the window is the lesser of rwnd and
cwnd.
❏ The source does not have to send a full window’s
worth of data.
❏ The window can be opened or closed by the
receiver, but should not be shrunk.
❏ The destination can send an acknowledgment at
any time as long as it does not result in a shrinking
window.
❏ The receiver can temporarily shut down the
window; the sender, however, can always send a
segment of 1 byte after the window is shut down.

23.66
Note

ACK segments do not consume


sequence numbers and are not
acknowledged.
Note

In modern implementations, a
retransmission occurs if the
retransmission timer expires or three
duplicate ACK segments have arrived.
Note

No retransmission timer is set for an


ACK segment.
Note

Data may arrive out of order and be


temporarily stored by the receiving TCP,
but TCP guarantees that no out-of-order
segment is delivered to the process.
Normal operation
Handling of Lost segment
Note

The receiver TCP delivers only ordered


data to the process.
Fast retransmission

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy