Unit-4 CN
Unit-4 CN
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 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.
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-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.
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.
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.
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.
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 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.
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.
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.
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