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

CN Unit-II Notes

Uploaded by

Jeeva Arumugam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

CN Unit-II Notes

Uploaded by

Jeeva Arumugam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIT II TRANSPORT LAYER 9

1. Introduction - Transport-Layer Protocols:


2. UDP –
3. TCP: Connection Management –
4. Flow control –
5. Congestion Control –
6. Congestion avoidance (DECbit, RED) –
7. SCTP –
8. Quality of Service.

TRANSPORT LAYER:

TCP and UDP in Transport Layer

TCP (Transmission Control Protocol):


TCP is a layer 4 protocol which provides acknowledgement of the received packets and is also
reliable as it resends the lost packets. It is better than UDP but due to these features it has an
additional overhead. It is used by application protocols like HTTP and FTP.

UDP (User Datagram Protocol):


UDP is also a layer 4 protocol but unlike TCP it doesn’t provide acknowledgement of the sent
packets. Therefore, it isn’t reliable and depends on the higher layer protocols for the same. But
on the other hand it is simple, scalable and comes with lesser overhead as compared to TCP.
It is used in video and voice streaming.

Transport Layer protocols

 The transport layer is represented by two protocols: TCP and UDP.


 The IP protocol in the network layer delivers a datagram from a source host to the
destination host.
 Nowadays, the operating system supports multiuser and multiprocessing environments,
an executing program is called a process. When a host sends a message to other host
means that source process is sending a process to a destination process. The transport
layer protocols define some connections to individual ports known as protocol ports.
 An IP protocol is a host-to-host protocol used to deliver a packet from source host to
the destination host while transport layer protocols are port-to-port protocols that
work on the top of the IP protocols to deliver the packet from the originating port to the
IP services, and from IP services to the destination port.
 Each port is defined by a positive integer address, and it is of 16 bits.

UDP

 UDP stands for User Datagram Protocol.


 UDP is a simple protocol and it provides nonsequenced transport functionality.
 UDP is a connectionless protocol.
 This type of protocol is used when reliability and security are less important than
speed and size.
 UDP is an end-to-end transport level protocol that adds transport-level addresses,
checksum error control, and length information to the data from the upper layer.
 The packet produced by the UDP protocol is known as a user datagram.

User Datagram Format

The user datagram has a 16-byte header which is shown below:

Where,

 Source port address: It defines the address of the application process that has delivered
a message. The source port address is of 16 bits address.
 Destination port address: It defines the address of the application process that will
receive the message. The destination port address is of a 16-bit address.
 Total length: It defines the total length of the user datagram in bytes. It is a 16-bit field.
 Checksum: The checksum is a 16-bit field which is used in error detection.

TCP

 TCP stands for Transmission Control Protocol.


 It provides full transport layer services to applications.
 It is a connection-oriented protocol means the connection established between both the
ends of the transmission. For creating the connection, TCP generates a virtual circuit
between sender and receiver for the duration of a transmission.

Features Of TCP protocol

 Reliability: TCP assigns a sequence number to each byte transmitted and expects a
positive acknowledgement from the receiving TCP. If ACK is not received within a
timeout interval, then the data is retransmitted to the destination.
The receiving TCP uses the sequence number to reassemble the segments if they
arrive out of order or to eliminate the duplicate segments.
 Flow Control: When receiving TCP sends an acknowledgement back to the sender
indicating the number the bytes it can receive without overflowing its internal buffer.
The number of bytes is sent in ACK in the form of the highest sequence number that it
can receive without any problem. This mechanism is also referred to as a window
mechanism.
 Multiplexing: Multiplexing is a process of accepting the data from different
applications and forwarding to the different applications on different computers. At the
receiving end, the data is forwarded to the correct application. This process is known as
demultiplexing. TCP transmits the packet to the correct application by using the logical
channels known as ports.
 Logical Connections: The combination of sockets, sequence numbers, and window
sizes, is called a logical connection. Each connection is identified by the pair of sockets
used by sending and receiving processes.
 Full Duplex: TCP provides Full Duplex service, i.e., the data flow in both the
directions at the same time. To achieve Full Duplex service, each TCP should have
sending and receiving buffers so that the segments can flow in both the directions. TCP is
a connection-oriented protocol. Suppose the process A wants to send and receive the data
from process B. The following steps occur:
o Establish a connection between two TCPs.
o Data is exchanged in both the directions.
o The Connection is terminated.
Where,

 Source port address: It is used to define the address of the application program in a
source computer. It is a 16-bit field.
 Destination port address: It is used to define the address of the application program in a
destination computer. It is a 16-bit field.
 Sequence number: A stream of data is divided into two or more TCP segments. The 32-
bit sequence number field represents the position of the data in an original data stream.
 Acknowledgement number: A 32-field acknowledgement number acknowledge the data
from other communicating devices. If ACK field is set to 1, then it specifies the sequence
number that the receiver is expecting to receive.
 Header Length (HLEN): It specifies the size of the TCP header in 32-bit words. The
minimum size of the header is 5 words, and the maximum size of the header is 15 words.
Therefore, the maximum size of the TCP header is 60 bytes, and the minimum size of the
TCP header is 20 bytes.
 Reserved: It is a six-bit field which is reserved for future use.
 Control bits: Each bit of a control field functions individually and independently. A
control bit defines the use of a segment or serves as a validity check for other fields.
There are total six types of flags in control field:

 URG: The URG field indicates that the data in a segment is urgent.
 ACK: When ACK field is set, then it validates the acknowledgement number.
 PSH: The PSH field is used to inform the sender that higher throughput is needed so if
possible, data must be pushed with higher throughput.
 RST: The reset bit is used to reset the TCP connection when there is any confusion
occurs in the sequence numbers.
 SYN: The SYN field is used to synchronize the sequence numbers in three types of
segments: connection request, connection confirmation ( with the ACK bit set ), and
confirmation acknowledgement.
 FIN: The FIN field is used to inform the receiving TCP module that the sender has
finished sending data. It is used in connection termination in three types of segments:
termination request, termination confirmation, and acknowledgement of termination
confirmation.
o Window Size: The window is a 16-bit field that defines the size of the window.
o Checksum: The checksum is a 16-bit field used in error detection.
o Urgent pointer: If URG flag is set to 1, then this 16-bit field is an offset from the
sequence number indicating that it is a last urgent data byte.
o Options and padding: It defines the optional fields that convey the additional
information to the receiver.
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): 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.
Since MSSreceiver < MSSsender, both parties agree for minimum MSS i.e., 500 B to avoid
fragmentation of packets at both ends.

Therefore, receiver can send maximum of 14600/500 = 29 packets.


This is the receiver's sending window size.

 Window size (window=10000 B): receiver tells about his buffer capacity in which he
has to store messages from the sender.

Therefore, sender can send a maximum of 10000/500 = 20 packets.


This is the sender's sending window size.

 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.
Since the connection establishment phase of TCP makes use of 3 packets, it is also known as 3-way
Handshaking (SYN, SYN + ACK, ACK).

What is the TCP Flow Control mechanism?


Overview

TCP Flow Control is a protocol designed to manage the data flow between the user and the
server. It ensures that there is a specific bandwidth for sending and receiving data so the data can
be processed without facing any major issues. In order to achieve this, the TCP protocol uses a
mechanism called the sliding window protocol.

The sliding window protocol

In the sliding window protocol method, when we are establishing a connection between sender
and receiver, there are two buffers created. Each of these two buffers are assigned to the sender,
called the sending window, and to the receiver, called the receiving window.
When the sender sends data to the receiver, the receiving window sends back the remaining
receiving buffer space. As a result, the sender cannot send more data than the available receiving
buffer space. We’ll understand the concept better once we take a look at the illustration below:

Explanation

In this example, the sending window sends data to the receiving window. The receiving window
sends the acknowledgment after receiving the data and then the sending window sends another
data frame.

However, this time, along with the received acknowledgment, the receiving window also sends
another message saying that the available memory is full.

The sending window pauses the transmission of data until it gets the acknowledgment of the
receiving window that space has been released and it can continue the transmission process.

TCP Congestion Control


TCP uses a congestion window and a congestion policy that avoid congestion. Previously, we
assumed that only the receiver can dictate the sender’s window size. We ignored another entity
here, the network. If the network cannot deliver the data as fast as it is created by the sender, it
must tell the sender to slow down. In other words, in addition to the receiver, the network is a
second entity that determines the size of the sender’s window.

Congestion policy in TCP –

1. Slow Start Phase: starts slowly increment is exponential to threshold


2. Congestion Avoidance Phase: After reaching the threshold increment is by 1
3. Congestion Detection Phase: Sender goes back to Slow start phase or Congestion
avoidance phase.
Slow Start Phase : exponential increment – In this phase after every RTT the congestion
window size increments exponentially

Initially cwnd = 1
After 1 RTT, cwnd = 2^(1) = 2
2 RTT, cwnd = 2^(2) = 4
3 RTT, cwnd = 2^(3) = 8

Congestion Avoidance Phase : additive increment – This phase starts after the threshold value
also denoted as ssthresh. The size of cwnd(congestion window) increases additive. After each
RTT cwnd = cwnd + 1.

Initially cwnd = i
After 1 RTT, cwnd = i+1
2 RTT, cwnd = i+2
3 RTT, cwnd = i+3

Congestion Detection Phase : multiplicative decrement – If congestion occurs, the congestion


window size is decreased. The only way a sender can guess that congestion has occurred is the
need to retransmit a segment. Retransmission is needed to recover a missing packet that is
assumed to have been dropped by a router due to congestion. Retransmission can occur in one of
two cases: when the RTO timer times out or when three duplicate ACKs are received.

 Case 1 : Retransmission due to Timeout – In this case congestion possibility is high.

(a) ssthresh is reduced to half of the current window size.


(b) set cwnd = 1
(c) start with slow start phase again.

 Case 2 : Retransmission due to 3 Acknowledgement Duplicates – In this case


congestion possibility is less.

(a) ssthresh value reduces to half of the current window size.


(b) set cwnd= ssthresh
(c) start with congestion avoidance phase

Example – Assume a TCP protocol experiencing the behavior of slow start. At 5th
transmission round with a threshold (ssthresh) value of 32 goes into congestion avoidance
phase and continues till 10th transmission. At 10th transmission round, 3 duplicate ACKs
are received by the receiver and enter into additive increase mode. Timeout occurs at
16th transmission round. Plot the transmission round (time) vs congestion window size of
TCP segments.

You might also like