CN Module 5 Part 2 2024
CN Module 5 Part 2 2024
Dr. Jagadamba G
Dept. of ISE, Siddaganga Institute of Technology,
Tumakuru
1
Objectives
2
Introduction to Transport
Layer
It provides services to the application layer and receives services
from the network layer.
It provides a logical communication between the application
process on 2 different nodes.
The transport layer acts as a link between a client program and a
server program, a process-to-process connection.
The transport layer is the heart of the TCP/IP protocol suite; it is
the end-to-end logical vehicle for transferring data from one
point to another in the Internet.
3
Service Provided By Transport
Layer
• Process to process communication(port to port )
• Segmentation and reassembly
• Multiplexing and demultiplexing
• Connection control protocols- UDP and TCP
• Flow control and Error control
• Congestion control
4
Process to Process communication
5
Process to Process communication
Assume a process – daytime.
A process daytime gives the request by specifying port number as 52,000 from host 1
to process n host 2 with port number 13.
6
Multiplexing and demultiplexing
7
TCP/IP protocol suite
9
Port Numbers at transport layer
10
Port Numbers at transport layer
11
Some well-known ports used with UDP and TCP
12
Activity: How to see the port number?
Go to network
Go to listening port
You can see the port numbers for various instances
13
Port Addresses at transport layer
• A client program defines itself with a port number
• The server process also define itself with the port number
• Usually the system has three address
1. MAC address: Physical address
2. IP Address: Network address defined at network layer
3. Port address: Process address defined at transport layer
In real communication any device can be identified through MAC and IP
address.
But in the device many processes will be running. To decide to which process
that data has to reach is decided by the port address.
14
USER DATAGRAM PROTOCOL
15
USER DATAGRAM PROTOCOL
16
User Datagram
• UDP packets, called user datagrams have 8 Byte fixed size
header made of 4 fields, each of 2 bytes
First two fields define the source and destination port numbers (16 bits
each).
Third field is total length (16 bits) of user datagram.
Fourth field is checksum = UDP header + UDP data coming from
application layer+ Pseudo header of IP
• Even though the total length is 16 bits, the total length needs to be
lesser than 65535 bytes. Because UDP datagram is stored in a IP
datagram
17
Tutorial
The following is the content of a UDP header in hexadecimal
format : CB84000D001C001C.
18
d. What is the length of the data?
The length of the data is the length of
the whole packet minus the length of
the header, so the length of the data is
28 − 8 = 20 bytes.
i)The source port number is the first four hexadecimal digits (AB94)16, . If we convert
this CB84 to decimal, we get 43924, which means that the source port number is 43924.
ii) The destination port number is the second four hexadecimal digits (000D)16, If we
convert this 000D to decimal, we get 13, which means that the destination port number is
13.
iii) The third four hexadecimal digits (001C)16 define the length of the whole UDP
packet. If we convert this 001C to decimal, we get 28, so the length is 28 bytes.
iv) The length of the data is the length of the whole packet minus the length of the
header, so the length of the data is 28 − 8 = 20 bytes.
v) Since the destination port number is 13 (well-known port), the packet is from the client
to the server.
vi) The client process is the Daytime
20
UDP Services
Process-to-Process Communication.
Connectionless Services
Flow Control
Error Control
Checksum
Congestion Control
Encapsulation and Decapsulation.
Queuing
Multiplexing and Demultiplexing
21
UDP Services
Process-to-Process Communication: Using socket addresses, a
combination of IP addresses and port numbers.
Connectionless Services :
Each user datagram sent by UDP is an independent datagram
even if they are coming from same source or destined to same
destination.
No connection establishment or termination
User datagrams are not numbered.
Each user datagram can travel on a different path
UDP cannot send stream data only can send short messages
22
UDP Services
23
UDP Services
Connectionless Service:
• UDP packet is independent.
• An advantage or disadvantage depending on the application
requirements.
• Ex. A client application needs to send a short request to a server and to
receive a short response.
• In the connection oriented service, at least 9 packets are exchanged
between the client and the server; in connectionless service only 2
packets are exchanged.
Lack of Error Control
• Benefit more from the services of UDP than from those of TCP.
• UDP is suitable for a process that requires simple request-response
communication with little concern for flow and error control.
• UDP is suitable for a process with internal flow-control and error-control
mechanisms.
For example, the Trivial File Transfer Protocol (TFTP) process includes flow and error control.
It can easily use UDP.
29
TRANSMISSION CONTROL
PROTOCOL
TRANSMISSION CONTROL PROTOCOL
Sequence number: 32-bit field defines the number assigned to the first
byte.
Acknowledgment number: 32-bit field defines the byte number that the
receiver of the segment is expecting to receive from the other party.
Header length: 4 bit field indicates the number of 4 byte words in the
TCP header
TCP Segment
Source port address
Destination port address
Control: Field defines 6 different control bits or flags.
Full-Duplex Communication
TCP offers full-duplex service, Each TCP endpoint then has its
own sending and receiving buffer, and segments move in both
directions.
Multiplexing and Demultiplexing
TCP performs multiplexing at the sender and demultiplexing at the
receiver.
Connection-Oriented Service
TCP is a connection-oriented protocol that uses Three phase
transfer
Connection is logical
Reliable Transfer
TCP is a reliable transport protocol. It uses an acknowledgment
mechanism to check the safe and sound arrival of data.
TCP Features
Numbering System :
TCP software keeps track of the segments.
Sequence number and the acknowledgment number.
Two fields refer to a byte number and not a segment number.
Byte Number:
Numbering does not necessarily start from 0.
32
An arbitrary number between 0 and 2 − 1 for first byte.
Example: if the number happens to be 1057 and the total data to
be sent is 6000 bytes, the bytes are numbered from 1057 to 7056
TCP Features
Sequence Number
TCP assigns a sequence number to each segment that is
being sent.
The sequence number of the first segment is the ISN (initial
sequence number), which is a random number.
The sequence number of any other segment is the sequence
number of the previous segment plus the number of bytes
Tutorial 10- Example
https://www.youtube.com/watch?v=8XJPZttC4RM
A TCP Connection
TCP is connection-oriented.
Logical path between the source and destination.
How TCP, which uses the services of IP, a connectionless
protocol, can be connection-oriented.
In TCP, connection-oriented transmission requires three
phases:
Connection establishment
Data transfer
Connection termination.
A TCP Connection
Connection Establishment
ready to accept a connection. This request is called a passive open. The server
The client sends the first segment, a SYN segment, in which only the SYN flag
The client chooses a random number called the initial sequence number
(ISN).
number.
A TCP Connection
Three-Way Handshaking
The server sends the second segment, a SYN + ACK segment with
two flag bits set as: SYN and ACK. This segment has a dual purpose.
First, it is a SYN segment for communication in the other direction.
The server also acknowledges the receipt of the SYN segment from
the client by setting the ACK flag and displaying the next sequence
number it expects to receive.
it also needs to define the receive window size, rwnd
A SYN + ACK segment cannot carry data, but it does consume one
sequence number
A TCP Connection
Three-Way Handshaking
Half-close
A TCP Connection
Half-Close
In TCP, one end can stop sending data while still receiving
data. This is called a half-close.
Either the server or the client can issue a half-close request.
Good Example for Half Close is Sorting data.
The data transfer from the client to the server stops.
The client half-closes the connection by sending a FIN
segment.
The server accepts the half-close by sending the ACK
segment.
After half-closing the connection, data can travel from the
server to the client and acknowledgments can travel from the
client to the server. The client cannot send any more data to
the server.
State Transition Diagram
Solution
1) Source port number:- (2 byte) -> 0532
2) Destination port number:- (2 byte) -> 0217
3) Sequence number:- 000000001 -> 1
4) Acknowledgement number:- 00000000 -> 0
5) Length of the header (4 bits) -> 5
6) Type of the segment -> 0X02
7) Window size -> 07FF
68