CNT - Module 1
CNT - Module 1
Transport Layer
o The transport layer is a 4th layer from the top.
o The main role of the transport layer is to provide the communication
services directly to the application processes running on different hosts.
o The transport layer provides a logical communication between application
processes running on different hosts. Although the application processes on
different hosts are not physically connected, application processes use the
logical communication provided by the transport layer to send the messages
to each other.
o The transport layer protocols are implemented in the end systems but not in
the network routers.
o A computer network provides more than one protocol to the network
applications. For example, TCP and UDP are two transport layer protocols
that provide a different set of services to the network layer.
o All transport layer protocols provide multiplexing/demultiplexing service. It
also provides other services such as reliable data transfer, bandwidth
guarantees, and delay guarantees.
o Each of the applications in the application layer has the ability to send a
message by using TCP or UDP. The application communicates by using
either of these two protocols. Both TCP and UDP will then communicate
with the internet protocol in the internet layer. The applications can read and
write to the transport layer. Therefore, we can say that communication is a
two-way process.
The services provided by the transport layer protocols can be divided into five
categories:
o End-to-end delivery
o Addressing
o Reliable delivery
Network Analysis and Trouble Shooting Page 2
Module 1
o Flow control
o Multiplexing
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 the Network layer
requires the IP address for appropriate routing of packets, in a similar way
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.
4. 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 occurs. As a result, the retransmission of packets from the sources
The transport layer checks for errors in the messages coming from the application
layer by using error detection codes, and 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 has arrived or not and checks for the integrity of
data.
6. Flow Control
The transport layer provides a flow control mechanism between the
adjacent layers of the TCP/IP model. TCP also prevents 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
the receiver by sending a window back to the sender informing the size of
data it can receive.
TCP is a transport layer protocol as it is used in transmitting the data from the
sender to the receiver.
o Reliable
TCP is a reliable protocol as it follows the flow and error control mechanism. It
also supports the acknowledgment mechanism, which checks the state and sound
arrival of the data. In the acknowledgment mechanism, the receiver sends either
positive or negative acknowledgment to the sender so that the sender can get to
know whether the data packet has been received or needs to resend.
This protocol ensures that the data reaches the intended receiver in the same order
in which it is sent. It orders and numbers each segment so that the TCP layer on the
destination side can reassemble them based on their ordering.
o Connection-oriented
It is a connection-oriented service that means the data exchange occurs only after
the connection establishment. When the data transfer is completed, then the
connection will get terminated.
o Full duplex
It is a full-duplex means that the data can transfer in both directions at the same
time.
o Stream-oriented
TCP is a stream-oriented protocol as it allows the sender to send the data in the
form of a stream of bytes and also allows the receiver to accept the data in the form
of a stream of bytes. TCP creates an environment in which both the sender and
receiver are connected by an imaginary tube known as a virtual circuit. This virtual
circuit carries the stream of bytes across the internet.
o Source port: It defines the port of the application, which is sending the data.
So, this field contains the source port address, which is 16 bits.
o Destination port: It defines the port of the application on the receiving side.
So, this field contains the destination port address, which is 16 bits.
o Sequence number: This field contains the sequence number of data bytes in
a particular session.
o Acknowledgment number: When the ACK flag is set, then this contains
the next sequence number of the data byte and works as an acknowledgment
for the previous data received. For example, if the receiver receives the
segment number 'x', then it responds 'x+1' as an acknowledgment number.
o HLEN: It specifies the length of the header indicated by the 4-byte words in
the header. The size of the header lies between 20 and 60 bytes. Therefore,
the value of this field would lie between 5 and 15.
o Reserved: It is a 4-bit field reserved for future use, and by default, all are set
to zero.
o Flags
There are six control bits or flags:
1. URG: It represents an urgent pointer. If it is set, then the data is
processed urgently.
2. ACK: If the ACK is set to 0, then it means that the data packet does
90not contain an acknowledgment.
3. PSH: If this field is set, then it requests the receiving device to push
the data to the receiving application without buffering it.
4. RST: If it is set, then it requests to restart a connection.
5. SYN: It is used to establish a connection between the hosts.
6. FIN: It is used to release a connection, and no further data exchange
will happen.
Window size
It is a 16-bit field. It contains the size of data that the receiver can accept.
This field is used for the flow control between the sender and receiver and
also determines the amount of buffer allocated by the receiver for a segment.
The value of this field is determined by the receiver.
Checksum
It is a 16-bit field. This field is optional in UDP, but in the case of TCP/IP,
this field is mandatory.
Urgent pointer
It is a pointer that points to the urgent data byte if the URG flag is set to 1. It
defines a value that will be added to the sequence number to get the
sequence number of the last urgent byte.
Options
It provides additional options. The optional field is represented in 32-bits. If
this field contains the data less than 32-bit, then padding is required to obtain
the remaining bits.
The three steps involved in establishing a connection using the 3-way handshake
process in TCP are as follows:
1. The client sends the SYN (synchronize) message to the server: When a
client requests to connect to a server, it sends the message to the server with
the SYN flag set to 1. The message also includes:
o The sequence number (any random 32-bit number).
o The ACK (which is set to 0 in this case).
o The window size.
o The maximum segment size. For example, if the window size is 3000
bits and the maximum segment size is 300 bits, the connection can
send a maximum of 10 data segments (3000/300 = 10).
2.
The server responds with the SYN and the ACK (synchronize-
acknowledge) message to the client: After receiving the
synchronization request, the server sends the client an
acknowledgment by changing the ACK flag to '1'.
The ACK's acknowledgment number is one higher than the sequence
number received. If the client sends an SYN with a sequence number
of 2000, the server will send the ACK using acknowledgment number
= 20001.
If the server wants to create the connection, it sets the SYN flag to '1'
and transmits it to the client.
The SYN sequence number used here will be different from
the SYN used by the client. The server also informs the client of its
window size and maximum segment size. After this step is completed,
the connection is established from the client to the server.
3. The client sends the ACK (acknowledge) message to the server: The client
will set the ACK flag to '1' after receiving the SYN from the server and
transmits it with an acknowledgment number 1 greater than the
server's SYN sequence number. The SYN flag has been set to '0' in this case.
The connection between the server and the client is now formed after this
phase is completed.
Refer to the diagram below that explains the connection establishment process
using the 3-way handshake.
1. The client sends the FIN (finish) message to the server: When the client
decides to disconnect from the network, it transmits the message to the
server with a random sequence number and sets the FIN flag to '1'. ACK is
set to 0 in this case.
2. The server responds with the FIN and the ACK (finish-acknowledge)
message to the client: After receiving the request, the server acknowledges
the client's termination request by changing the ACK flag to '1'.
If the client sends a FIN with a sequence number of 2000, the server will
send the ACK using acknowledgment number = 20001.
If the server also decides to terminate the connection, it sets the FIN flag to
'1' and transmits it to the client.
The FIN sequence number used here will be different from the FIN used by
the client. After this step is completed, the connection between the client to
the server is disconnected.
3. The client sends the ACK (acknowledge) message to the server: The client
will set the ACK flag to '1' after receiving the FIN from the server and
transmits it with an acknowledgment number 1 greater than the
server's FIN sequence number. The FIN flag is set to '0' in this case. After
this step is completed, the connection is also disconnected from the server to
the client.
Refer to the diagram below that explains the connection termination process using
the 3-way handshake.
TCP Flow Control was created to control the data flow between the user and
the server. Flow control mainly refers to TCP's ability to prevent a sender
from delivering a receiver too many packets at once. It ensures that a certain
amount of bandwidth is available for sending and receiving data so that
operations can proceed without encountering serious problems.
The concept is that a node receiving data will communicate in some way
with the node sending the data to inform it of its current state.
This generally happens when we need to transmit data packets over a network.
A buffer at the TCP layer will store the data to a fixed limit and then bundle
them into segments. Data is retrieved from the receiver buffer after the
application is ready.
Flow control mostly refers to TCP's ability to simultaneously stop a sender
from sending too many packets to a receiver. From here receiver’s
window(buffer) comes into existence.
To prevent the loss of data packets, TCP uses the acknowledgement process.
Till now, we have run through the working of TCP flow control. Now, we
will see the protocol that is used for TCP flow control. This protocol is
known as SLINDING WINDOW PROTOCOL.
The TCP sliding window sets the maximum amount of data bytes (d) that one
system can send to another. The values of d depend on two factors:
The amount of space in the receive buffer depends on how rapidly the receiving
application reads data from the buffer, i.e., data processing time. The system stores
the data in the buffer until the receiving application reads the data from the receive
buffer. Every time the sending system is informed of the buffer's available space.
Window Size
In Sliding window protocols, the sending window for the sender and the receiving
window for the receiver are separate buffers with predetermined sizes.
The size of the sending window determines the sequence number of the outgoing
packets.
Range of sequence number: 0 to 2n-1, where n is the number of bits of one data
packet.
Sender’s window size: The size of the sending window is 2𝑛−1.
Receivers’ window size: The maximum number of frames a receiver can accept at
once is determined by the size of the receiving window.
Some of the important terms of the Receiver Window are as follows:
ReceiveBuffer: It is the buffer size used to store the data. It contains both the
available space as well as filled space.
LastByteReceived: The last byte of data that is received in the receive Buffer.
Generally, the message bytes are represented in bytes. So, in that case, the formula
will be
Receiver window = Receiver Buffer - (last byte received - last byte read).
Consider a situation where the receiver sends the ack of the previous packet
and waits for the next data packet, but the ack is lost mid-way, and the
sender is waiting for the ack.
In this case, there is a possibility of deadlock since both the sender and the
receiver are waiting for a message to start sending data.
TCP Retransmission
The TCP retransmission means resending the packets over the network that have
been either lost or damaged. Here, retransmission is a mechanism used by
protocols such as TCP to provide reliable communication. Here, reliable
communication means that the protocol guarantees packet's delivery even if the
data packet has been lost or damaged.
The networks are unreliable and do not guarantee the delay or the retransmission of
the lost or damaged packets. The network which uses a combination of
acknowledgment and retransmission of damaged or lost packets offers reliability.
Retransmission mechanism
Here, retransmission means the data packets have been lost, which leads to a lack
of acknowledgment. This lack of acknowledgment triggers a timer to timeout,
which leads to the retransmission of data packets. Here, the timer means that if no
acknowledgment is received before the timer expires, the data packet is
retransmitted.
In this scenario, the packet is received on the other side, but the acknowledgment is
lost, i.e., the ACK is not received on the sender side. Once the timeout period
expires, the packet is resent. There are two copies of the packets on the other side;
though the packet is received correctly, the acknowledgment is not received, so the
sender retransmits the packet. In this case, the retransmission could have been
avoided, but due to the loss of the ACK, the packet is retransmitted.
The sender sets the timeout period for an ACK. The timeout period can be of
two types:
o Too short: If the timeout period is too short, then the retransmissions will be
wasted.
o Too long: If the timeout period is too long, then there will be an excessive
delay when the packet is lost.
In order to overcome the above two situations, TCP sets the timeout as a function
of the RTT (round trip time) where round trip time is the time required for the
packet to travel from the source to the destination and then come back again.
The RTT can vary depending upon the network's characteristics, i.e., if the network
is congested, it means that the RTT is very high. We can estimate the RTT by
simply watching the ACKs.
Step 1: First, we measure the SampleRTT for each segment or ACK pair. When
the sender sends the packet, then we know the timer at which the packet is sent,
and also, we know the timer at which acknowledgment is received. Calculate the
time between these two, and that becomes the SampleRTT.
Step 2: We will not take only one sample. We will keep on taking different
samples and calculate the weighted average of these samples, and this becomes the
EstRTT (Estimated RTT).
where, α+ β = 1
timeout = 2 * EstRTT.
The timeout is set to be twice the estimated RTT. This is how the actual timeout
factor is calculated.
The above diagram shows that the sender sends the data, which is said to be an
original transmission. Within the timeout period, no acknowledgment is received.
So, the sender retransmits the data. After retransmitting the data, the
acknowledgment is received. Let's assume that acknowledgment is received for the
original transmission, not for the retransmission. Since we get the acknowledgment
of the original transmission, so SampleRTT is calculated between the time of the
original transmission and the time at which the acknowledgment is received. But
actually, the SampleRTT should have been between the time of the retransmission
and time of the acknowledgment.
The above diagram shows that the sender sends the original data packet for which
we get the acknowledgment also. But the acknowledgment is received after
retransmitting the data. If we assume that acknowledgment belongs to the
retransmission, then SampleRTT is calculated between the time of the
retransmission and the time of the acknowledgment.
In the above both the scenarios, there is an ambiguity of not knowing whether the
acknowledgment is for the original transmission or for the retransmission.
o If we consider the first scenario, the retransmission is done for the lost
packet. In this case, we are assuming that ACK belongs to the original
transmission due to which the SampleRTT is coming out to be very large.
o If we consider the second scenario, two same packets are sent so duplicity
occurs in this case. In this case, we are assuming that ACK belongs to the
retransmission due to which the SampleRTT is coming to be very small.
Karn/Partridge Algorithm
In the above two scenarios, retransmission occurs, and we have considered the
Sample RTT. But this algorithm does not consider the Sample RTT when
retransmitting. Since the retransmission has occurred, which means that something
happens in this round-trip time or some congestion may occur in a network. To
overcome this problem, this algorithm doubles the timeout after each
retransmission. This algorithm is implemented in the TCP network.
Limitation
Jacobson/Karels Algorithm
Here, Dev is a deviation factor, and δ is a factor between 0 and 1. The Dev is an
estimate of the variance from the EstRTT.
Where, µ =1 and ɸ =4
Fast Retransmission
The timeout-based strategy for retransmission is inefficient. TCP is a sliding-
window kind of protocol, so whenever the retransmission occurs, it starts sending
it from the lost packet onward.
Suppose I transmit the packets 0, 1, 2, and 3. Since packet 0 and packet 1 are
received on the other side, packet 2 is lost in a network.
I have received the acknowledgment of packet 0 and packet 1, so I send two
more packets, i.e., packet 4 and packet 5. When packets 3, 4, and 5 are sent,
then I will get the acknowledgment of packet 1 as TCP acknowledgments
are cumulative, so it acknowledges up to the packet that it has received in
order.
I have not received the acknowledgment of packet 2, 3,4, and 5 within the
timeout period, so I retransmit the packets 2, 3, 4, and 5.
Since packet 2 is lost, but other packets, i.e., 3, 4,5 are received on the other
side, they are still retransmitted because of this timeout mechanism.
Suppose n packet has been lost, but still, the packets n+1, n+2, and so on have been
received. The receiver is continuously receiving the packets and sending the ACK
packets saying that the receiver is still awaiting the nth packet. The receiver is
sending repeated or duplicate acknowledgments. In the above case, ACK of packet
1 is sent three-time as packet 2 has been lost. This duplicate ACK packet is an
indication that the nth packet is missing, but the later packets are received.
o The sender can take the "duplicate ACKs" as an early hint that the nth
packet has been lost so that the sender can do the retransmission as early as
possible, i.e., the sender should not wait until the timeout occurs.
o The sender can implement a fast transmission strategy in TCP. In a fast
transmission strategy, the sender should consider the triple duplicate ACKs
as a trigger and retransmit it.
TCP uses three duplicate ACKs as a trigger and then performs retransmission. In
the above case, when three ACKs of packet 1 are received, then the sender should
send the lost packet, i.e., packet 2, without waiting for the timeout period to occur.
o Connectionless
The UDP is a connectionless protocol as it does not create a virtual path to transfer
the data. It does not use the virtual path, so packets are sent in different paths
between the sender and the receiver, which leads to the loss of packets or received
out of order.
In the case of UDP, the datagrams are sent in some order will be received in the
same order is not guaranteed as the datagrams are not numbered.
o Ports
The UDP protocol uses different port numbers so that the data can be sent to the
correct destination. The port numbers are defined between 0 and 1023.
o Faster transmission
lost in TCP connection, that packet will be resent, so it guarantees the delivery of
the data packets.
o Acknowledgment mechanism
The UDP does have any acknowledgment mechanism, i.e., there is no handshaking
between the UDP sender and UDP receiver. If the message is sent in TCP, then the
receiver acknowledges that I am ready, then the sender sends the data. In the case
of TCP, the handshaking occurs between the sender and the receiver, whereas in
UDP, there is no handshaking between the sender and the receiver.
o Stateless
It is a stateless protocol that means that the sender does not get the
acknowledgement for the packet which has been sent.
In UDP, the header size is 8 bytes, and the packet size is upto 65,535 bytes. But
this packet size is not possible as the data needs to be encapsulated in the IP
datagram, and an IP packet, the header size can be 20 bytes; therefore, the
maximum of UDP would be 65,535 minus 20. The size of the data that the UDP
packet can carry would be 65,535 minus 28 as 8 bytes for the header of the UDP
packet and 20 bytes for IP header.
o Length: It is 16-bit field that specifies the entire length of the UDP packet
that includes the header also. The minimum value would be 8-byte as the
size of the header is 8 bytes.
o Checksum: It is a 16-bits field, and it is an optional field. This checksum
field checks whether the information is accurate or not as there is the
possibility that the information can be corrupted while transmission. It is an
optional field, which means that it depends upon the application, whether it
wants to write the checksum or not. If it does not want to write the
checksum, then all the 16 bits are zero; otherwise, it writes the checksum. In
UDP, the checksum field is applied to the entire packet, i.e., header as well
as data part whereas, in IP, the checksum field is applied to only the header
field.
User
Datagram
Transmission Control Protocol
Basis Protocol (TCP) (UDP)
User
Datagram
Transmission Control Protocol
Basis Protocol (TCP) (UDP)
terminating a
connection. UDP
is efficient for
broadcast and
multicast types of
network
transmission.
The delivery of
data to the
TCP is reliable as it
destination
Reliability guarantees the delivery of
cannot be
data to the destination router.
guaranteed in
UDP.
No
An acknowledgment
Acknowledgment acknowledgment
segment is present.
segment.
User
Datagram
Transmission Control Protocol
Basis Protocol (TCP) (UDP)
There is no
Sequencing of data is a sequencing of
feature of Transmission data in UDP. If
Control the order is
Sequence
Protocol (TCP). this means required, it has to
that packets arrive in order at be managed by
the receiver. the application
layer.
UDP is faster,
TCP is comparatively slower simpler, and
Speed
than UDP. more efficient
than TCP.
There is no
retransmission of
Retransmission of lost
lost packets in
Retransmission packets is possible in TCP,
the User
but not in UDP.
Datagram
Protocol (UDP).
UDP has an 8
TCP has a (20-60) bytes
Header Length bytes fixed-
variable length header.
length header.
User
Datagram
Transmission Control Protocol
Basis Protocol (TCP) (UDP)
UDP is
Weight TCP is heavy-weight.
lightweight.
It’s a
Uses handshakes such as connectionless
Handshaking Techniques
SYN, ACK, SYN-ACK protocol i.e. No
handshake
UDP is used
TCP is used by HTTP,
by DNS, DHCP,
Protocols HTTPs, FTP, SMTP and Teln
TFTP, SNMP, RI
et.
P, and VoIP.
UDP connection
The TCP connection is a
Stream Type is a message
byte stream.
stream.
User
Datagram
Transmission Control Protocol
Basis Protocol (TCP) (UDP)
This protocol is
used in situations
where quick
This protocol is primarily
communication is
utilized in situations when a
necessary but
safe and trustworthy
where
Applications communication procedure is
dependability is
necessary, such as in email,
not a concern,
on the web surfing, and
such as VoIP,
in military services.
game streaming,
video, and music
streaming, etc.