CN Unit-II Notes
CN Unit-II Notes
TRANSPORT LAYER:
UDP
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
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 –
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.
Window size (window=10000 B): receiver tells about his buffer capacity in which he
has to store messages from the sender.
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).
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.
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.
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
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.