0% found this document useful (0 votes)
8 views19 pages

Unit-4 CN

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)
8 views19 pages

Unit-4 CN

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/ 19

1

UNIT-4
UNIT- IV: TRANSPORT LAYER
UDP – Segment header, Remote procedure call, Real- me transport protocols; TCP – service
model, Protocol, Segment header, Connec on establishment, Connec on release, Sliding
window, Timer management, Conges on control.

UDP – Segment header:


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 prior to data transfer. The UDP helps to
establish low-latency and loss-tolerating connections establish over the network. The UDP
enables process to process communication.
Though Transmission Control Protocol (TCP) is the dominant transport layer protocol used
with most of the Internet services; provides assured delivery, reliability, and much more but all
these services cost us additional overhead and latency. Here, UDP comes into the picture. For
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. There is no error checking in UDP, so it also saves bandwidth.
User Datagram Protocol (UDP) is more efficient in terms of both latency and bandwidth.

UDP Header –
UDP header is an 8-bytes fixed and simple header, while for TCP it may vary from 20 bytes to
60 bytes. The first 8 Bytes contains all necessary header information and the remaining part
consist of data. UDP port number fields are each 16 bits long, therefore the range for port
numbers is defined from 0 to 65535; port number 0 is reserved. Port numbers help to distinguish
different user requests or processes.
2
UNIT-4
Source Port: Source Port is a 2 Byte long field used to identify the port number of the
source.
Destination Port: It is a 2 Byte long field, used to identify the port of the destined packet.
Length: Length is the length of UDP including the header and the data. It is a 16-bits
field.
Checksum: Checksum is 2 Bytes long field. It is the 16-bit one’s complement of the
one’s complement sum of the UDP header, the pseudo-header of information 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, the Checksum calculation is not mandatory in UDP. No Error control or
flow control is provided by UDP. Hence UDP depends on IP and ICMP for error reporting.
Also, UDP provides port numbers so that is can differentiate between users’ requests.

Applications of UDP:
 Used for simple request-response communication when the size of data is less and
hence there is lesser concern about flow and error control.
 It is a suitable protocol for multicasting as UDP supports packet switching.
 UDP is used for some routing update protocols like RIP (Routing Information
Protocol).
 Normally used for real-time applications which cannot tolerate uneven delays
between sections of a received message.

Advantages of UDP:
1. Speed: UDP is faster than TCP because it does not have the overhead of establishing a
connection and ensuring reliable data delivery.
2. Lower latency: Since there is no connection establishment, there is lower latency and faster
response time.
3. Simplicity: UDP has a simpler protocol design than TCP, making it easier to implement
and manage.

Disadvantages of UDP:
1. No reliability: UDP does not guarantee delivery of packets or order of delivery, which can
lead to missing or duplicate data.
2. No congestion control: UDP does not have congestion control, which means that it can
send packets at a rate that can cause network congestion.
3. No flow control: UDP does not have flow control, which means that it can overwhelm the
receiver with packets that it cannot handle.
3
UNIT-4
Remote Procedure Call (RPC):
A remote procedure call is an inter process communication technique that is used for client-
server-based applications. It is also known as a subroutine call or a function call.
A client has a request message that the RPC translates and sends to the server. This request may
be a procedure or a function call to a remote server. When the server receives the request, it
sends the required response back to the client. The client is blocked while the server is
processing the call and only resumed execution after the server is finished.

The sequence of events in a remote procedure call are given as follows −


 The client stub (A network which has only one entry and exit point) is called by the
client.
 The client stub makes a system call to send the message to the server and puts the
parameters in the message.
 The message is sent from the client to the server by the client’s operating system.
 The message is passed to the server stub by the server operating system.
 The parameters are removed from the message by the server stub.
 Then, the server procedure is called by the server stub.
A diagram that demonstrates this is as follows –

Advantages of Remote Procedure Call:


Some of the advantages of RPC are as follows −
 Remote procedure calls support process oriented and thread-oriented models.
 The internal message passing mechanism of RPC is hidden from the user.
 The effort to re-write and re-develop the code is minimum in remote procedure calls.
4
UNIT-4
Disadvantages of Remote Procedure Call:
Some of the disadvantages of RPC are as follows −
 The remote procedure call is a concept that can be implemented in different ways. It is
not a standard.
 There is no flexibility in RPC for hardware architecture. It is only interaction based.
 There is an increase in costs because of remote procedure call.

Real Time Transport Protocol (RTP):


A protocol is designed to handle real-time traffic (like audio and video) of the Internet, is known
as Real Time Transport Protocol (RTP). RTP must be used with UDP. It does not have any
delivery mechanism like multicasting or port numbers. RTP supports different formats of files
like MPEG and MJPEG. It is very sensitive to packet delays and less sensitive to packet loss.
History of RTP: This protocol is developed by Internet Engineering Task Force (IETF) of four
members:
 S. Casner (Packet Design)
 V. Jacobson (Packet Design)
 H. Schulzrinne (Columbia University)
 R. Frederick (Blue Coat Systems Inc.)
Applications of RTP:
 RTP mainly helps in media mixing, sequencing and time-stamping.
 Voice over Internet Protocol (VoIP)
 Video Teleconferencing over Internet.
 Internet Audio and video streaming.
RTP Header Format: The diagram of header format of RTP packet is shown below:
5
UNIT-4
The header format of RTP is very simple and it covers all real-time applications. The
explanation of each field of header format is given below:
Version: This 2-bit field defines version number. The current version is 2.
P – The length of this field is 1-bit. If value is 1, then it denotes presence of padding (Bits or
characters that fill up unused portions of a data structure, such as a field, packet or frame.
Typically, padding is done at the end of the structure to fill it up with data, with the padding
usually consisting of 1 bits, blank characters or null characters.) at end of packet and if value
is 0, then there is no padding.
X – The length of this field is also 1-bit. If value of this field is set to 1, then its indicates an
extra extension header between data and basic header and if value is 0 then, there is no extra
extension.
Contributor count – This 4-bit field indicates number of contributors. Here maximum possible
number of contributors is 15 as a 4-bit field can allows number from 0 to 15.
M – The length of this field is 1-bit and it is used as end marker by application to indicate end
of its data.
Payload types – This field is of length 7-bit to indicate type of payload. We list applications of
some common types of payloads.
Sequence Number – The length of this field is 16 bits. It is used to give serial numbers to RTP
packets. It helps in sequencing. The sequence number for first packet is given a random number
and then every next packet’s sequence number is incremented by 1. This field mainly helps in
checking lost packets and order mismatch.
Time Stamp – The length of this field is 32-bit. It is used to find relationship between times of
different RTP packets. The timestamp for first packet is given randomly and then time stamp
for next packets given by sum of previous timestamp and time taken to produce first byte of
current packet. The value of 1 clock tick is varying from application to application.
Synchronization Source Identifier – This is a 32-bit field used to identify and define the source.
The value for this source identifier is a random number that is chosen by source itself. This
mainly helps in solving conflict arises when two sources started with the same sequencing
number.
Contributor Identifier – This is also a 32-bit field used for source identification where there is
more than one source present in session. The mixer source use Synchronization source
identifier and other remaining sources (maximum 15) use Contributor identifier.

TCP – service model:


 TCP service is obtained by both the sender and the receiver creating end points, called
sockets.
 Each socket has a socket number (address) consisting of the IP address of the host and
a 16-bit number local to that host, called a port.
6
UNIT-4
 A port is the TCP name for a TSAP: A Transport Services Access Point is an end-point
for communication between the Transport layer and the Session layer in the OSI (Open
Systems Interconnection) reference model.
 Each TSAP is an address that uniquely identifies a specific instantiation of a service.
 TSAPs are created by concatenating the node's Network Service Access Point (NSAP)
with a transport identifier, and sometimes a packet and/or protocol type.
We explain some of the sockets calls with their respectful meaning in the following table. It
also should know that TCP does not support multicasting & broadcasting.

Different Socket Calls:


The table given below explains the socket calls in TCP service model –

 Port numbers below 1024 are reserved for standard services that can usually only be
started by privileged users (e.g., root in UNIX systems).
 They are called well-known ports.
7
UNIT-4

 Secure Shell (SSH) is a cryptographic network protocol for opera ng network services
securely over an unsecured network
 IMAP (Internet Message Access Protocol) is a standard email protocol that stores email
messages on a mail server, but allows the end user to view and manipulate the
messages as though they were stored locally on the end user's compu ng device(s).
 The Real Time Streaming Protocol (RTSP) is a network control protocol designed for
use in entertainment and communica ons systems to control streaming media
servers. The protocol is used for establishing and controlling media sessions between
end points.
 The Internet Prin ng Protocol (IPP) is a specialized Internet protocol for
communica on between client devices (computers, mobile phones, tablets, etc.) and
printers
All TCP connec ons are full duplex and point-to-point.

 Full duplex means that traffic can go in both direc ons at the same me.
 Point-to-point means that each connec on has exactly two end points.

 TCP does not support Mul cas ng or Broadcas ng.


 A TCP connec on is a byte stream, not a message stream.
 Message boundaries are not preserved end to end.

TCP-Protocol:
TCP (Transmission Control Protocol) is one of the main protocols of the Internet protocol suite.
It lies between the Application and Network Layers which are used in providing reliable
delivery services. It is a connection-oriented protocol for communications that helps in the
exchange of messages between different devices over a network. The Internet Protocol (IP),
which establishes the technique for sending data packets between computers, works with TCP.
8
UNIT-4
Working of TCP:
To make sure that each message reaches its target location intact, the TCP/IP model breaks
down the data into small bundles and afterward reassembles the bundles into the original
message on the opposite end. Sending the information in little bundles of information makes
it simpler to maintain efficiency as opposed to sending everything in one go.
After a particular message is broken down into bundles, these bundles may travel along
multiple routes if one route is jammed but the destination remains the same.

For example, In TCP, the connection is established by using three-way handshaking. The
client sends the segment with its sequence number. The server, in return, sends its segment
with its own sequence number as well as the acknowledgement sequence, which is one more
than the client sequence number. When the client receives the acknowledgment of its
segment, then it sends the acknowledgment to the server. In this way, the connection is
established between the client and the server.
Features of TCP/IP
Some of the most prominent features of Transmission control protocol are
1. Segment Numbering System
TCP keeps track of the segments being transmitted or received by assigning numbers to each
and every single one of them.
A specific Byte Number is assigned to data bytes that are to be transferred while segments are
assigned sequence numbers.
Acknowledgment Numbers are assigned to received segments.
9
UNIT-4
2. 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.
3. 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.
4. 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 (using a
sliding window)
5. 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.
6. 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

Advantages:
 It is a reliable protocol.
 It provides an error-checking mechanism as well as one for recovery.
 It gives flow control.
 It makes sure that the data reaches the proper destination in the exact order that it was
sent.
 Open Protocol, not owned by any organization or individual.

Disadvantages:
 TCP is made for Wide Area Networks; thus, its size can become an issue for small
networks with low resources.
 TCP runs several layers so it can slow down the speed of the network.
10
UNIT-4
 It is not generic in nature. Meaning, it cannot represent any protocol stack other than
the TCP/IP suite. E.g., it cannot work with a Bluetooth connection.
 No modifications since their development around 30 years ago.

TCP Segment structure


A TCP segment consists of data bytes to be sent and a header that is added to the data by TCP
as shown:

The header of a TCP segment can range from 20-60 bytes. 40 bytes are for options. If there
are no options, a header is 20 bytes else it can be of upmost 60 bytes.
Header fields:
Source Port Address –
A 16-bit field that holds the port address of the application that is sending the data segment.

Destination Port Address –


11
UNIT-4
A 16-bit field that holds the port address of the application in the host that is receiving the
data segment.

Sequence Number –
A 32-bit field that holds the sequence number, i.e., the byte number of the first byte that is
sent in that particular segment. It is used to reassemble the message at the receiving end of
the segments that are received out of order.

Acknowledgement Number –
A 32-bit field that holds the acknowledgement number, i.e., the byte number that the receiver
expects to receive next. It is an acknowledgement for the previous bytes being received
successfully.

Header Length (HLEN) –


This is a 4-bit field that indicates the length of the TCP header by a number of 4-byte words
in the header, i.e., if the header is 20 bytes (min length of TCP header), then this field will
hold 5 (because 5 x 4 = 20) and the maximum length: 60 bytes, then it’ll hold the value
15(because 15 x 4 = 60). Hence, the value of this field is always between 5 and 15.

Control flags –
These are 6 1-bit control bits that control connection establishment, connection termination,
connection abortion, flow control, mode of transfer etc. Their function is:
 URG: Urgent pointer is valid
 ACK: Acknowledgement number is valid (used in case of cumulative
acknowledgement)
 PSH: Request for push
 RST: Reset the connection
 SYN: Synchronize sequence numbers
 FIN: Terminate the connection

Window size –
This field tells the window size of the sending TCP in bytes.

Checksum –
This field holds the checksum for error control. It is mandatory in TCP as opposed to UDP.
12
UNIT-4
Urgent pointer –
This field (valid only if the URG control flag is set) is used to point to data that is urgently
required that needs to reach the receiving process at the earliest. The value of this field is
added to the sequence number to get the byte number of the last urgent byte.

TCP Connection Establishment:


TCP is a connection-oriented protocol and every connection-oriented protocol needs to
establish a connection in order to reserve resources at both the communicating ends.
Connection Establishment –
1.Sender starts the process with the following:
 Sequence number (Seq=521):
contains the random initial sequence number generated at the sender side.
 Syn flag (Syn=1):
request the receiver to synchronize its sequence number with the above-provided sequence
number.
 Maximum segment size (MSS=1460 B):
sender tells its maximum segment size, so that receiver sends datagram which won’t require
any fragmentation. MSS field is present inside Option field in TCP header.
 Window size (window=14600 B):
sender tells about his buffer capacity in which he has to store messages from the receiver.

2. TCP is a full-duplex protocol so both sender and receiver require a window for
receiving messages from one another.
 Sequence number (Seq=2000):
contains the random initial sequence number generated at the receiver side.
 Syn flag (Syn=1):
request the sender to synchronize its sequence number with the above-provided sequence
number.
 Maximum segment size (MSS=500 B):
receiver tells its maximum segment size, so that sender sends datagram which won’t require
any fragmentation. MSS field is present inside Option field in TCP header.
13
UNIT-4
Since MSS receiver < MSS sender, both parties agree for minimum MSS i.e., 500 B to avoid
fragmentation of packets at both ends.
 Window size (window=10000 B):
receiver tells about his buffer capacity in which he has to store messages from the sender.
 Acknowledgement Number (Ack no.=522):
Since sequence number 521 is received by the receiver so, it makes a request for the next
sequence number with Ack no.=522 which is the next packet expected by the receiver since
Syn flag consumes 1 sequence no.
 ACK flag (ACk=1):
tells that the acknowledgement number field contains the next sequence expected by the
receiver.

3. Sender makes the final reply for connection establishment in the following way:
 Sequence number (Seq=522):
since sequence number = 521 in 1st step and SYN flag consumes one sequence number
hence, the next sequence number will be 522.
 Acknowledgement Number (Ack no.=2001):
since the sender is acknowledging SYN=1 packet from the receiver with sequence number
2000 so, the next sequence number expected is 2001.
 ACK flag (ACK=1):
tells that the acknowledgement number field contains the next sequence expected by the
sender.
14
UNIT-4

TCP Connection Termination(release):


In TCP 3-way Handshake Process we studied that how connections are established between
client and server in Transmission Control Protocol (TCP) using SYN bit segments. In this
article, we will study how TCP close connection between Client and Server. Here we will
also need to send bit segments to a server which FIN bit is set to 1.

TCP supports two types of connection releases like most connection-oriented transport
protocols:
1) Graceful connection release –
In the Graceful connection release, the connection is open until both parties have closed their
sides of the connection.

2) Abrupt connection release –


15
UNIT-4
In an Abrupt connection release, either one TCP entity is forced to close the connection or
one user closes both directions of data transfer.

Abrupt connection release:


An abrupt connection release is carried out when an RST segment is sent. An RST segment
can be sent for the below reasons:
 When a non-SYN segment was received for a non-existing TCP connection.
 In an open connection, some TCP implementations send an RST segment when a
segment with an invalid header is received. This will prevent attacks by closing the
corresponding connection.
 When some implementations need to close an existing TCP connection, they send an
RST segment. They will close an existing TCP connection for the following reasons:
1) Lack of resources to support the connection
2) The remote host is now unreachable and has stopped responding.

When a TCP entity sends an RST segment, it should contain 00 if it does not belong to any
existing connection else it should contain the current value of the sequence number for the
connection and the acknowledgment number should be set to the next expected in- sequence
number on this connection.

Graceful Connection Release:


The common way of terminating a TCP connection is by using the TCP header’s FIN flag.
This mechanism allows each host to release its own side of the connection individually.
16
UNIT-4

How mechanism works In TCP:


Step 1 (FIN From Client) –
Suppose that the client application decides it wants to close the connection. (Note that the
server could also choose to close the connection). This causes the client to send a TCP
segment with the FIN bit set to 1 to the server and to enter the FIN_WAIT_1 state. While in
the FIN_WAIT_1 state, the client waits for a TCP segment from the server with an
acknowledgment (ACK).
Step 2 (ACK From Server) –
When the Server received the FIN bit segment from Sender (Client), Server Immediately
sends acknowledgement (ACK) segment to the Sender (Client).
Step 3 (Client waiting) –
While in the FIN_WAIT_1 state, the client waits for a TCP segment from the server with an
acknowledgment. When it receives this segment, the client enters the FIN_WAIT_2 state.
While in the FIN_WAIT_2 state, the client waits for another segment from the server with the
FIN bit set to 1.
Step 4 (FIN from Server) –
The server sends the FIN bit segment to the Sender (Client) after some time when the Server
sends the ACK segment (because of some closing process in the Server).
Step 5 (ACK from Client) –
When the Client receives the FIN bit segment from the Server, the client acknowledges the
server’s segment and enters the TIME_WAIT state. The TIME_WAIT state lets the client
resend the final acknowledgment in case the ACK is lost. The time spent by clients in the
TIME_WAIT state depends on their implementation, but their typical values are 30 seconds,
1 minute, and 2 minutes. After the wait, the connection formally closes and all resources on
the client-side (including port numbers and buffer data) are released.

TCP Timers:
Various types of TCP timers are used for making sure that excessive delay in the transmission
of data is not encountered when communication begins. Most of these timers are delicate and
handle issues that are not found immediately at the first analysis of the transmission of data.
Look at the below section to know about how the timer makes sure proper data transfers from
one end to another.
17
UNIT-4
1) Time Out Timer or Retransmission Timer:
 A timeout timer begins, when the sender transmits a segment to the receiver.
 Before expiring the timer, if the ACK is received, then nothing is lost.
 Otherwise, that particular segment is considered lost and it becomes necessary to
retransmit the segment again and restart the timer.
 It is required to look at the various RTTs for finding out how the retransmission
timeout interval is being calculated.

Measured RTT(RTTm)
The time needed by the segment to reach the destination and also get acknowledgement, even
though the acknowledgement includes another segment also, is known as measured round-
trip time (RTTm).

Smoothed RTT(RTTs)
The average weight of RTTm is known as smoothed RTT (RTTs). There is a possibility of
changes in RTTm and its fluctuation is very high that's why RTO cannot be calculated using a
single measurement.

Deviated RTT(RTTd)
RTTs alone are not used by most implementation. So, for finding the RTO (Retransmission
Time Out) RTT deviated also needs to be calculated.

2) Time Wait Timer:


 Time Wait Timer is one of the TCP timers that is used at the time of connection
termination.
 After transmitting the last ACK for the second FIN, the sender begins the time wait
timer and terminates the TCP connection.
 When the TCP connection is closed, there is a possibility that some datagrams still try
to make their way using the internet so that they can access the closed port.
 The quiet timer is designed so that it can prevent just a closed port to reopen again
quickly.
 Generally, the quiet timer is set to twice the maximum segment lifeline so that it
makes sure that all the segments still heading for the port must be terminated.

3) Keep Alive Timer:


 The keep alive timer is used by the TCP for preventing the long idle connections
between the TCPs.
18
UNIT-4
 Keep alive timer is used in the situation when the client starts a TCP connection for
transmitting data to the server, and after some time stops sending the data, then the
connection opens forever.
 Whenever the server hears from the client, the server resets the keep-alive timer for 2
hours.
 Sometimes the condition occurs when the server does not hear from the client for 2
hours, then 10 probe segments are transmitted by the server to the client.
 The server transmits these probe segments at a time interval of 75 seconds.
 After transmitting these segments, if the server does not get any response from the
client, then it is supposed that the client seems to be down.
 When the client seems to be down, the connection is discarded by the server
automatically.

4) Persistent Timer:
 The persistent timer is one of the TCP timers used in TCP for dealing with one of the
deadlock situations,i.e. zero-window-size deadlock situations.
 If the other end closes its receiver window, then also it keeps the window size
information flowing.
 Whenever the sender receives an ACK from the receiver side with a zero window
size, then it begins the persistent timer.
 In this situation, when the persistent timer goes off, then the sender transmits the
special type of segment to the receiver.
 This special type of segment is commonly known as the probe segment and this
special type of segment has only 1 byte of new data.
 The sequence number of this segment is never acknowledged.
 This sequence number is also not considered even when calculating the sequence
number for the rest data.
 When the receiver transmits the response to the probe segment, then through this
response the window size updates.
 If it is found that the updated window size is non-zero, then it represents that the data
can be transmitted now.
 And if the size of the updated window is still found to be zero, then the persistent
timer needs to be set again and this process continues till we get a non-zero window
size.

Congestion control:
Before understanding what is TCP congestion control, let’s first understand what you mean
by congestion in the TCP network. Congestion is an important factor in packet switched
network. It refers to the state of a network where the message traffic becomes so heavy that
the network response time slows down leading to the failure of the packet. It leads to packet
19
UNIT-4
loss. Due to this, it is necessary to control the congestion in the network, however, it cannot
be avoided.
TCP congestion control refers to the mechanism that prevents congestion from happening or
removes it after congestion takes place. When congestion takes place in the network, TCP
handles it by reducing the size of the sender’s window. The window size of the sender is
determined by the following two factors:
 Receiver window size
 Congestion window size

Approaches for Congestion Control:

Congestion in TCP is handled by using these three phases:


 Slow Start
 Congestion Avoidance
 Congestion Detection

1) Slow Start Phase:


In the slow start phase, the sender sets congestion window size = maximum segment size (1
MSS) at the initial stage. The sender increases the size of the congestion window by 1 MSS
after receiving the ACK (acknowledgment). The size of the congestion window increases
exponentially in this phase. The formula for determining the size of the congestion window is
Congestion window size = Congestion window size + Maximum segment size

You might also like