Transport Layer Overview in Networking
Transport Layer Overview in Networking
MODULE-4
INTRODUCTION
❖ Position of Transport Layer: Sits between the application layer (above) and
the network layer (below).
❖ Process-to-Process Communication: Enables communication directly
between applications on two hosts (one local, one remote).
❖ Logical Connection: The transport layer creates a "virtual" or logical
connection that allows application layers on separate devices to communicate as
if they were directly linked.
❖ Global Reach: Communication is possible across the globe, with applications
assuming a direct link.
❖ Transport Layer Example: Illustrated by the example of two hosts – Alice’s in
Sky Research and Bob’s in Scientific Books – communicating as if directly
connected.
❖ End System Reliance: Only the two end systems (like Alice's and Bob's
computers) use the transport layer; intermediate devices, like routers, only use
the lower three layers (physical, data link, and network layers).
Page 1
BCS502 | COMPUTER NETWORKS
Transport Layer Position and Role: It provides services to the application layer
above it and receives services from the network layer below.
Page 2
BCS502 | COMPUTER NETWORKS
Port Numbers:
• Ephemeral Ports: Used by client processes, typically above 1023, for short-
lived communication.
• Well-Known Ports: Assigned to server processes to standardize and
simplify connections (e.g., port 13 for a daytime server).
Page 3
BCS502 | COMPUTER NETWORKS
Page 4
BCS502 | COMPUTER NETWORKS
Socket Addresses:
Page 5
BCS502 | COMPUTER NETWORKS
Flow Control:
• Ensures that the message production and consumption rates are balanced,
preventing data loss if the receiver cannot process messages as fast as they
arrive.
Page 6
BCS502 | COMPUTER NETWORKS
• Pulling: The receiver requests items when ready, avoiding the need for flow
control as the consumer controls the data flow.
• Involves four entities: the sender process, sender transport layer, receiver
transport layer, and receiver process.
• The sender process produces messages and pushes them to the sender
transport layer, which packages these into packets and pushes them to the
receiver.
• The receiver transport layer decapsulates packets and delivers messages to
the receiver process, typically via pulling.
Page 7
BCS502 | COMPUTER NETWORKS
• Sender to Sender Transport Layer: The sender transport layer signals the
application to pause/resume sending if its buffer is full or has vacancies.
• Receiver to Sender Transport Layer: The receiver transport layer signals
the sender to pause/resume sending based on buffer capacity.
Buffers:
• Buffers at both sender and receiver sides help manage message flow and
avoid overload.
• Communication of buffer status between sender and receiver helps prevent
data loss and maintains smooth message delivery.
Error Control:
Page 8
BCS502 | COMPUTER NETWORKS
Sequence Numbers:
Acknowledgment (ACK):
Page 9
BCS502 | COMPUTER NETWORKS
Sliding Window:
Page 10
BCS502 | COMPUTER NETWORKS
Congestion Control:
Connectionless Service:
Page 11
BCS502 | COMPUTER NETWORKS
Connection-Oriented Service:
Page 12
BCS502 | COMPUTER NETWORKS
o End-to-End Control: Only the two hosts (client and server) are involved,
without requiring router involvement.
o Support for Control Mechanisms:
▪ Flow Control: Manages data rate between sender and receiver.
▪ Error Control: Handles detection and retransmission of lost or
corrupted packets.
▪ Congestion Control: Mitigates network congestion by adjusting the
flow.
o Examples: Common transport-layer protocols like TCP (Transmission Control
Protocol) utilize connection-oriented services to ensure reliable and ordered data
transmission.
Page 13
BCS502 | COMPUTER NETWORKS
1. FSM Basics:
o States: Represent specific conditions in the protocol, like "closed," "open-
wait," or "established."
o Events: External inputs or conditions that trigger state transitions, such as
receiving a request or acknowledgment.
o Actions: The specific steps taken in response to an event, such as sending
an acknowledgment or request.
o Initial State: The starting point, often the "closed" state for connection-
oriented protocols.
Page 14
BCS502 | COMPUTER NETWORKS
1. Connection Establishment:
o Closed → Open-Wait-I: The machine sends an open request packet
after receiving a connection request from the local process.
o Open-Wait-I → Open-Wait-II: Upon receiving an acknowledgment
from the other end, it progresses to Open-Wait-II.
Page 15
BCS502 | COMPUTER NETWORKS
Page 16
BCS502 | COMPUTER NETWORKS
INTRODUCTION
Page 17
BCS502 | COMPUTER NETWORKS
Port Numbers
1. End-to-End Communication:
o Port numbers provide a way to establish communication directly between
applications or services, such as a web browser and a web server, by
addressing data packets to specific processes on a device.
2. Multiplexing and Demultiplexing:
o Multiplexing allows multiple applications on a single host to share the
same transport-layer protocol, each identified by its unique port number.
o Demultiplexing enables the transport layer at the receiving end to direct
incoming packets to the correct application, based on the destination port
number.
There are some well-known port numbers associated with common applications
and protocols. Here’s a sample of common port numbers for each transport-layer
protocol:
These port numbers are standardized, meaning they are recognized by servers and
clients worldwide, allowing applications and services to communicate seamlessly
across networks.
Page 18
BCS502 | COMPUTER NETWORKS
Unlike TCP, UDP does not establish a connection before sending data and does not
guarantee delivery, order, or error checking, making it lightweight and efficient.
Here’s an overview of UDP’s structure, benefits, and use cases:
1. Minimal Overhead: UDP’s simplicity means there’s little protocol overhead. It’s
ideal for applications that prioritize low latency over guaranteed delivery.
2. Small, Quick Messages: When sending small, time-sensitive data (like DNS
queries), UDP is more efficient as it skips the connection setup that TCP requires.
Page 19
BCS502 | COMPUTER NETWORKS
• Source Port (16 bits): The port number on the sender’s end.
• Destination Port (16 bits): The port number on the receiver’s end.
• Length (16 bits): Specifies the total length of the datagram, including
header and data. The maximum length is 65,535 bytes, but IP limits this
slightly lower.
• Checksum (16 bits): An optional field that provides minimal error-checking
for the data integrity.
• DNS (Domain Name System): Queries are brief and can tolerate
occasional packet loss.
• Streaming Media: Video and audio streams favor speed, even if some data
loss occurs.
• Online Games: Many games use UDP for fast data transmission, favoring
real-time updates over reliability.
Page 20
BCS502 | COMPUTER NETWORKS
Page 21
BCS502 | COMPUTER NETWORKS
Process-to-Process Communication:
Connectionless Services:
Flow Control:
Error Control:
❖ Checksum Calculation:
Page 22
BCS502 | COMPUTER NETWORKS
▪ The pseudoheader helps ensure the datagram isn’t delivered to the wrong
host or protocol by including the IP and protocol fields.
Congestion Control:
o UDP does not manage congestion. Its packets are assumed to be small and
sporadic, a feature originally intended to keep them from congesting the
network. However, modern UDP applications for video and audio streaming can
sometimes defy this assumption.
o UDP handles messages by encapsulating them into packets with headers and
decapsulating incoming packets to retrieve the data for the application layer.
Page 23
BCS502 | COMPUTER NETWORKS
Queuing:
o Ports and Queues: Each process using UDP is allocated a port and typically has
queues associated with it. Most implementations create both incoming and
outgoing queues, while some only have incoming queues.
UDP is very similar to a basic connectionless protocol, with the main difference being
the optional checksum for error detection. In UDP, if a packet is corrupted, it’s
discarded without notification, aligning with UDP’s focus on simplicity and efficiency.
Although UDP lacks many of the reliability features found in protocols like TCP, it is
ideal for specific applications where low latency and minimal overhead are prioritized
over reliability.
Connectionless Service
Page 24
BCS502 | COMPUTER NETWORKS
Advantages:
Disadvantages:
Applications that Tolerate Some Loss: For applications that prioritize speed over
reliability, occasional data loss is acceptable.
o Domain Name System (DNS): DNS uses UDP for queries as it needs a quick
request-response mechanism and tolerates occasional packet loss.
o Streaming Services (e.g., audio, video): Real-time streaming apps use UDP
because small losses in data do not severely impact the user experience, and the
low latency of UDP is more beneficial than the guaranteed delivery of TCP.
o Voice over IP (VoIP): Like streaming, VoIP applications need low latency to
maintain real-time communication, and occasional data loss is manageable.
o Simple Network Management Protocol (SNMP): SNMP, used for network
management and monitoring, also uses UDP to ensure prompt responses without
the delays associated with TCP connections.
Page 25
BCS502 | COMPUTER NETWORKS
TCP Services
Before discussing TCP in detail, let us explain the services offered by TCP to the pro
cesses at the application layer.
Connection-Oriented Service:
Process-to-Process Communication:
o Like UDP, TCP uses port numbers to establish a link between application
processes at the transport layer.
o TCP allows data to flow as a continuous stream of bytes, unlike UDP, which
transmits discrete packets. TCP segments this stream into packets (segments),
which are handled by the network layer.
o This stream delivery provides the impression of a direct "pipe" between
communicating applications.
Page 26
BCS502 | COMPUTER NETWORKS
Buffered Transmission:
o TCP uses sending and receiving buffers to manage differences in the rates at
which processes produce or consume data. The sender buffer stores bytes until
they are acknowledged by the receiver.
o Buffers also allow retransmissions and maintain efficient data flow despite delays
or network congestion.
Page 27
BCS502 | COMPUTER NETWORKS
Segmentation:
o Data streams are divided into manageable segments, each with a header for
control information.
o Segments might vary in size, typically containing hundreds to thousands of bytes,
and are encapsulated in IP packets for transmission.
Reliability Mechanisms:
Page 28
BCS502 | COMPUTER NETWORKS
Full-Duplex Communication
Multiplexing: At the sender's side, TCP combines data streams from multiple
application processes into a single stream of segments. This allows efficient use of
network resources by sharing the same connection.
Demultiplexing: At the receiver's side, TCP separates the incoming segments and
directs them to the appropriate application process based on the destination port
numbers. Each connection between a pair of processes requires a unique socket,
ensuring that data from different connections does not mix.
Connection-Oriented Service
1. Connection Establishment:
o A logical connection is established through a handshake process, typically
using the three-way handshake method:
▪ Process A sends a SYN (synchronize) segment to Process B.
▪ Process B responds with a SYN-ACK (synchronize-acknowledge)
segment.
▪ Process A sends an ACK (acknowledge) segment back to Process B,
completing the connection setup.
2. Data Exchange:
Page 29
BCS502 | COMPUTER NETWORKS
Reliable Service
Through these features, TCP provides a robust and reliable means of communication
over the Internet, making it suitable for applications that require guaranteed delivery
of data.
Page 30
BCS502 | COMPUTER NETWORKS
TCP Features
To provide its reliable and ordered services, TCP incorporates several key features:
Numbering System
TCP does not use a segment number field in its header. Instead, it employs two
key fields: the sequence number and the acknowledgment number, which
refer to byte numbers rather than segment numbers.
Byte Numbering
• Byte Tracking: TCP assigns a unique number to every byte (or octet)
transmitted within a connection. This numbering is maintained independently
for each direction (sender to receiver and vice versa).
• Starting Point: The numbering can start from any arbitrary value between 0
and 232 -1. For instance, if the first byte's number is 1057, the subsequent
bytes are numbered consecutively up to 7056 if a total of 6000 bytes are
sent.
Sequence Number
Page 31
BCS502 | COMPUTER NETWORKS
Acknowledgment Number
• Full Duplex Communication: Since TCP allows both parties to send and
receive data simultaneously, each party maintains its own byte numbering.
• Acknowledgment Mechanism: The acknowledgment number is used to
confirm receipt of data. It indicates the next byte the receiving party expects
to receive.
• Cumulative Acknowledgment: This means that if a party uses a specific
acknowledgment number, say 5643, it has successfully received all bytes up
to, but not including, byte number 5643. This does not imply that the party
has received exactly 5642 bytes, as the starting byte number can vary.
TCP Segment
The format of a TCP segment includes a header followed by the application data.
The header can range from 20 to 60 bytes in length, depending on whether it
includes optional fields.
Page 32
BCS502 | COMPUTER NETWORKS
Page 33
BCS502 | COMPUTER NETWORKS
o Indicates the byte number the receiver expects next. If a receiver has
successfully received byte number x, it sends x + 1 as the acknowledgment
number. This field can be used together with data in a process called
piggybacking.
5. Header Length (4 bits):
o Indicates the number of 32-bit words in the TCP header. The length can
range from 20 bytes (5 words) to 60 bytes (15 words).
6. Control (6 bits):
o Defines various control flags (bits) used for flow control, connection
establishment, termination, and data transfer modes. The flags include
SYN, ACK, FIN, RST, PSH, and URG. Multiple flags can be set
simultaneously.
Page 34
BCS502 | COMPUTER NETWORKS
Encapsulation
• A TCP segment encapsulates the data received from the application layer and
is placed within an IP datagram. The IP datagram is then encapsulated in a
frame at the data-link layer for transmission over the network.
Page 35
BCS502 | COMPUTER NETWORKS
This connection ensures that all segments belonging to a message are sent reliably
over a single logical pathway, facilitating acknowledgment and retransmission
processes for any lost or damaged frames.
Although TCP relies on IP, which is a connectionless protocol, TCP connections are
logical, not physical.
This means that while TCP controls the connection and manages the reliability of
data transmission, it uses the services of IP to deliver individual segments.
Page 36
BCS502 | COMPUTER NETWORKS
o The client initiates the connection by sending a SYN segment to the server.
o This segment has the SYN flag set and includes an Initial Sequence Number
(ISN) chosen by the client.
o This segment does not have an acknowledgment number or window size defined,
as it is purely for synchronization and does not carry data. However, it consumes
one sequence number, as it is acknowledged by the server.
o Upon receiving the SYN segment, the server responds with a SYN + ACK
segment. This segment has both the SYN and ACK flags set. The server uses
this segment to:
▪ Initialize its own sequence number for sending data back to the client.
▪ Acknowledge the receipt of the client's SYN segment by setting the
acknowledgment number to the client's ISN + 1.
Page 37
BCS502 | COMPUTER NETWORKS
▪ Define the receive window size (rwnd), which indicates how much data
the server can accept from the client.
o Like the SYN segment, this segment also consumes one sequence number
because it needs acknowledgment.
o Finally, the client sends an ACK segment back to the server. This segment has
the ACK flag set and acknowledges the receipt of the server's SYN + ACK
segment by including the acknowledgment number corresponding to the server's
sequence number + 1.
o If this ACK segment does not carry any data, it does not consume any sequence
numbers. However, some implementations may allow this segment to carry data,
in which case it would consume as many sequence numbers as the number of
bytes sent.
Each party is now able to send and receive data in both directions, benefiting from
the reliability and order guarantees that TCP provides.
Page 38
BCS502 | COMPUTER NETWORKS
The SYN flooding attack is a type of denial-of-service (DoS) attack that targets
the TCP connection establishment process, specifically the three-way handshake
mechanism.
This attack exploits the way TCP allocates resources when it receives SYN segments
from clients.
SYN flooding attacks fall under the category of denial of service (DoS) attacks,
where the attacker overloads the system with service requests, rendering it unable
to respond to legitimate requests.
Page 39
BCS502 | COMPUTER NETWORKS
Mitigation Strategies
Several strategies can be employed to mitigate the effects of SYN flooding attacks:
• Bidirectional Communication: Both the client and server can send data
and acknowledgments simultaneously. Data and acknowledgments are often
combined in the same segment, known as piggybacking.
1. Data Segments: After the connection is established, the client might send
2,000 bytes of data in two segments. The server then sends 2,000 bytes in
one segment back to the client.
2. Acknowledgment Segments: The first three segments from the client
carry both data and acknowledgment information, while the last segment
might carry only an acknowledgment, indicating that there is no additional
data to send.
3. PSH Flag: In the segments sent by the client, the PSH (push) flag can be
set to instruct the server’s TCP to deliver the received data to the application
Page 40
BCS502 | COMPUTER NETWORKS
layer immediately. In contrast, the server’s response may not set this flag,
allowing it to buffer the data until it is ready for processing.
Pushing Data
In scenarios where immediate data transfer and response are crucial (e.g.,
interactive applications), TCP provides the capability to push data:
Page 41
BCS502 | COMPUTER NETWORKS
However, there are situations where certain bytes need to be prioritized and
processed urgently. TCP provides a mechanism to handle such urgent data through
the URG flag.
1. Setting the URG Flag: When an application program needs to send urgent
data, it signals to the TCP layer by marking that segment with the URG bit set.
2. Urgent Pointer: The urgent data is placed at the beginning of the segment,
followed by regular data. The TCP header includes an urgent pointer field that
specifies the end of the urgent data. For instance, if the sequence number of the
segment is 15,000 and the urgent pointer indicates 200, the urgent data spans
from byte 15,000 to byte 15,200.
3. Delivery to Application: Although TCP delivers all bytes in order (including
both urgent and nonurgent data), it notifies the application program about the
presence of urgent data, allowing the application to handle it appropriately.
Page 42
BCS502 | COMPUTER NETWORKS
Important Note
It's crucial to understand that TCP's handling of urgent data is not synonymous with
priority service or out-of-band data. Instead, it allows the sender to mark certain
bytes in the stream for special treatment at the receiver's end, but the receiving TCP
still delivers data sequentially.
Connection Termination
In TCP, either party (client or server) can initiate the connection termination
process, though it is typically started by the client. There are two primary methods
for connection termination:
1. Three-Way Handshaking
2. Four-Way Handshaking with Half-Close Option
This is the most common method employed for terminating a TCP connection:
1. Client Sends FIN: The client sends a segment with the FIN (Finish) flag set,
indicating its intention to close the connection. This segment can either carry the
last chunk of data or be a control segment. If it’s purely a control segment, it
consumes one sequence number for acknowledgment.
2. Server Acknowledges and Sends FIN: Upon receiving the FIN segment, the
server acknowledges it by sending a FIN + ACK segment. This segment
confirms the receipt of the client’s FIN segment and indicates that it will also
close the connection in the other direction. Similar to the previous step, if it does
not contain data, it consumes one sequence number.
3. Client Sends ACK: The client responds with an ACK segment to acknowledge
the server's FIN. This segment carries the acknowledgment number, which is one
more than the sequence number received in the server's FIN segment. An ACK
Page 43
BCS502 | COMPUTER NETWORKS
segment in this context does not consume any sequence numbers if it does not
carry data.
Half-Close Option
A half-close allows one end of the connection to stop sending data while still being
able to receive data. This scenario can occur in various situations, such as when a
server needs all incoming data before processing it.
Example of Half-Close
1. Client Sends Data: The client sends data to the server, indicating that it has
finished sending by sending a FIN segment.
2. Server Acknowledges Half-Close: The server accepts the half-close by
sending an ACK segment, indicating it acknowledges the client's closure of
the connection for sending data.
Page 44
BCS502 | COMPUTER NETWORKS
3. Server Continues to Send Data: The server can still send data to the
client. After it has finished processing the incoming data, it will send a FIN
segment to close the connection in the server-to-client direction.
4. Final Acknowledgment: The client acknowledges this final FIN with an
ACK segment, completing the half-close process.
After a half-close, the client can no longer send data to the server, but data can still
flow in the opposite direction.
TCP is modeled as a finite state machine (FSM) to track the various states during
connection establishment, data transfer, and termination.
Each transition is labeled with two strings: the input (what TCP receives) and the
output (what TCP sends).
Page 45
BCS502 | COMPUTER NETWORKS
Here's a breakdown of the main states in TCP along with the typical transitions:
Page 46
BCS502 | COMPUTER NETWORKS
Page 47
BCS502 | COMPUTER NETWORKS
Page 48
BCS502 | COMPUTER NETWORKS
Scenarios
Let’s illustrate the TCP state transitions using a typical scenario where a client
establishes a connection with a server, transfers data, and then terminates the
connection.
1. Active Open: The client issues an active open command, sending a SYN
segment.
o State Transition: CLOSED → SYN-SENT
2. SYN + ACK Reception: The server responds with a SYN + ACK segment.
o State Transition: SYN-SENT → ESTABLISHED
3. ACK Sent: The client acknowledges the server's SYN + ACK by sending an
ACK.
o State Transition: ESTABLISHED (remains in this state for data
transfer)
Data Transfer
• Data is exchanged between the client and server while remaining in the
ESTABLISHED state. Acknowledgments are sent as data is transmitted.
1. Active Close: When the client has no more data to send, it sends a FIN
segment.
o State Transition: ESTABLISHED → FIN-WAIT-1
2. ACK Reception: The client receives an ACK for its FIN segment.
o State Transition: FIN-WAIT-1 → FIN-WAIT-2
3. FIN Reception: The client receives a FIN segment from the server and
sends back an ACK.
o State Transition: FIN-WAIT-2 → TIME-WAIT
Page 49
BCS502 | COMPUTER NETWORKS
4. Timer Expiration: After waiting for 2MSL seconds, the client moves to the
CLOSED state.
o State Transition: TIME-WAIT → CLOSED
1. Passive Open: The server remains in the LISTEN state until it receives a
SYN segment.
o State Transition: LISTEN → SYN-RCVD
2. ACK Reception: The server sends a SYN + ACK and waits for an ACK from
the client.
o State Transition: SYN-RCVD → ESTABLISHED
3. FIN Reception: Upon receiving the FIN from the client, the server sends an
ACK and transitions to the CLOSE-WAIT state.
o State Transition: ESTABLISHED → CLOSE-WAIT
4. Passive Close: The server receives a close command from its process and
sends a FIN segment.
o State Transition: CLOSE-WAIT → LAST-ACK
5. Final ACK Reception: The server receives the final ACK from the client and
transitions to the CLOSED state.
o State Transition: LAST-ACK → CLOSED
Page 50
BCS502 | COMPUTER NETWORKS
Page 51
BCS502 | COMPUTER NETWORKS
Send Window
The send window determines how much data the sender can transmit without
waiting for an acknowledgment.
1. Dynamic Size: The size of the send window can vary based on the receiver's
buffer capacity and network conditions (congestion control).
Page 52
BCS502 | COMPUTER NETWORKS
2. Window Management: The send window can open, close, or shrink based on
the sender's state and the receiver's ability to process incoming data. If the
receiver's buffer is full, the sender must reduce its send window accordingly.
3. Byte-Oriented: Unlike some other protocols (e.g., Selective Repeat), which use
packet-based windows, TCP's window size is measured in bytes. This means the
sender can send a continuous stream of data, optimizing bandwidth.
• In a simplified scenario where the send window size is set to 100 bytes, the
sender can transmit 100 bytes of data before waiting for an acknowledgment.
If the sender receives an acknowledgment for the first segment, it can
continue to send more data within the constraints of the window size.
Receive Window
Page 53
BCS502 | COMPUTER NETWORKS
The receive window manages how much data the receiver can accept at any given
time. This is critical for flow control, ensuring that the sender does not overwhelm
the receiver with data it cannot process.
1. Variable Size: The receive window size can change dynamically based on the
receiver’s buffer status. It is calculated as:
This means the receiver must keep track of how much data has been received
but not yet processed.
• If the receiver has a buffer size of 100 bytes and has already acknowledged
40 bytes, the current receive window would allow an additional 60 bytes to be
received: rwnd=100 (buffer size)−40 (acknowledged bytes)=60 bytes
Page 54
BCS502 | COMPUTER NETWORKS
By managing how much data can be sent before receiving an acknowledgment, TCP
prevents overwhelming the receiver, maintaining efficient communication.
Page 55
BCS502 | COMPUTER NETWORKS
1. Separation of Concerns: TCP separates flow control from error control. In this
context, we focus solely on flow control, assuming an error-free communication
channel.
2. Unidirectional vs. Bidirectional Communication: While we often discuss
flow control in unidirectional terms (data flowing from the sender to the
receiver), TCP operates in a bidirectional manner. However, understanding the
unidirectional flow simplifies the discussion.
3. Data Transfer Paths:
o Data flows from:
▪ Sender Process to Sending TCP (Path 1)
▪ Sending TCP to Receiving TCP (Path 2)
▪ Receiving TCP to Receiving Process (Path 3)
o Flow control feedback flows back from:
▪ Receiving TCP to Sending TCP (Path 4)
▪ Sending TCP to Sending Process (Path 5)
Most implementations do not provide flow control feedback from the receiving
application to the receiving TCP; instead, the receiving process pulls data
when it is ready.
4. Control of Data Flow: The sending TCP controls the sending process, while the
receiving TCP controls the sending TCP. This allows the receiving side to dictate
how much data the sender can transmit based on its ability to process incoming
data.
The primary mechanism for flow control in TCP is the adjustment of window sizes.
Each TCP connection has a fixed buffer size determined during connection
Page 56
BCS502 | COMPUTER NETWORKS
establishment, but the effective window sizes can change as data is sent and
acknowledged.
• Window Closure: The receive window closes (moves its left wall to the
right) when new bytes arrive, indicating the next expected byte.
• Window Opening: The receive window opens (moves its right wall to the
right) when the receiving process pulls data from the buffer. In practice, the
receive window should not shrink (the right wall does not move to the left).
The following example illustrates how flow and window management work in a
simple unidirectional data transfer scenario from a client to a server.
1. Connection Establishment:
o SYN Segment: The client sends a SYN segment to the server,
indicating its initial sequence number (seqNo = 100). The server
allocates a buffer size (e.g., 800 bytes) and sets its receive window
size (rwnd = 800).
Page 57
BCS502 | COMPUTER NETWORKS
Page 58
BCS502 | COMPUTER NETWORKS
Shrinking of Windows
In TCP flow control, while the receive window remains static (i.e., it cannot shrink),
the send window can shrink based on the receiver's feedback regarding its receive
window size (rwnd).
Page 59
BCS502 | COMPUTER NETWORKS
This condition ensures that the right wall of the send window does not move to the
left, maintaining a consistent flow of data. This relationship must hold true as long
as the last sent and acknowledged bytes are less than the new acknowledged bytes.
Window Shutdown
TCP allows a receiver to temporarily shut down the window by advertising an rwnd
of 0. This indicates to the sender that it should stop sending data until the receiver is
ready to accept more.
Although the sender's window does not technically shrink, it effectively pauses data
transmission until the receiver can accommodate new data.
Notably, even when the window is set to 0, the sender is permitted to send a 1-byte
segment to probe the connection, ensuring that it does not lead to a deadlock.
Page 60
BCS502 | COMPUTER NETWORKS
Silly Window Syndrome occurs when the sending or receiving application programs
process data too slowly, leading to the transmission of small segments, which can
significantly reduce network efficiency.
Sender-Generated Syndrome
When the sending application sends data in tiny increments (e.g., 1 byte at a time),
the TCP may create segments with minimal payload.
For example, if the sending TCP sends segments of 1 byte, the total overhead for
each segment (including TCP and IP headers) becomes disproportionately high.
Receiver-Generated Syndrome
The receiving application can also cause a silly window syndrome if it consumes data
slowly.
For instance, if a receiving application processes data one byte at a time while the
sending application transmits larger blocks, the receiver may frequently advertise a
window size of 1 byte.
This leads to the sender sending segments of only 1 byte, exacerbating efficiency
problems.
Page 61
BCS502 | COMPUTER NETWORKS
1. Checksum:
o Each TCP segment contains a mandatory 16-bit checksum to verify data
integrity.
o If a checksum is invalid, the segment is discarded by the receiver and treated
as lost.
2. Acknowledgment (ACK):
o TCP uses ACKs to confirm receipt of data segments. Control segments that
carry no data are also acknowledged.
o Different types of acknowledgments are used:
▪ Cumulative Acknowledgment (ACK): Acknowledges all bytes up to
the next expected byte. If segments are received out of order, they are
ignored until the expected segment arrives.
▪ Selective Acknowledgment (SACK): Provides additional feedback on
out-of-order or duplicated segments. SACK is optional and is
implemented as an option at the end of the TCP header.z
▪
Page 62
BCS502 | COMPUTER NETWORKS
3. Timeout:
o If an acknowledgment is not received within a specified time, the segment is
retransmitted.
Generating Acknowledgments
1. Piggybacking: If the receiver has data to send back, it includes an ACK with the
next expected sequence number.
2. Delayed ACK: If there’s only one in-order segment with no more data to send,
the receiver delays sending an ACK to reduce network traffic.
3. Immediate ACK: If the received segment is in order, and there are
unacknowledged segments, the receiver sends an ACK immediately.
4. Out-of-order ACK: If a segment arrives with an out-of-order sequence number,
an ACK is sent for the next expected sequence.
5. Handling Missing and Duplicate Segments: When a missing or duplicate
segment arrives, the receiver sends an ACK to confirm the next expected in-order
segment.
Retransmission Mechanisms
Page 63
BCS502 | COMPUTER NETWORKS
• TCP stores out-of-order segments temporarily and flags them until the
missing segments arrive. Only when the missing data arrives does TCP deliver
data in order to the application layer, ensuring ordered delivery.
Sender-Side FSM
• The sender-side FSM for TCP, similar to Selective Repeat (SR) protocol but
adjusted for TCP’s requirements, operates with:
o Fast Retransmission: Resending segments after three duplicate
ACKs.
o Window Size Adjustment: The window size is dynamically adjusted
based on the receiver’s available window (rwnd).
Page 64
BCS502 | COMPUTER NETWORKS
Receiver-Side FSM
• TCP’s cumulative ACK and out-of-order segment handling are close to SR, but
with cumulative acknowledgments, TCP can also resemble Go-Back-N (GBN).
• When SACK is used, TCP behaves more like the SR protocol.
Page 65
BCS502 | COMPUTER NETWORKS
Some Scenarios
In TCP error control, different scenarios illustrate how the protocol handles various
transmission issues. Each TCP segment is visually represented as a rectangle in
these scenarios, with specific details:
Normal Operation
Page 66
BCS502 | COMPUTER NETWORKS
Lost Segment
Page 67
BCS502 | COMPUTER NETWORKS
Fast Retransmission
Delayed Segment
• Due to IP’s connectionless nature, segments might reach the destination with
varied delays, sometimes resulting in timeouts and retransmissions.
• Example: If a segment arrives late after being retransmitted, it’s treated as a
duplicate and discarded by the receiver.
Page 68
BCS502 | COMPUTER NETWORKS
Duplicate Segment
Page 69
BCS502 | COMPUTER NETWORKS
TCP congestion control involves various policies to manage data flow in the network
efficiently, adapting to congestion levels dynamically.
Page 70
BCS502 | COMPUTER NETWORKS
Congestion Detection
Page 71
BCS502 | COMPUTER NETWORKS
• For every ACK received, cwnd doubles, leading to exponential growth until a
threshold (thresh) is reached.
• This aggressive growth quickly increases data flow but transitions to
congestion avoidance upon reaching the thresh.
Page 72
BCS502 | COMPUTER NETWORKS
Fast Recovery
Policy Transitions
• Taho TCP: Utilizes only Slow Start and Congestion Avoidance. If congestion is
detected (timeout or duplicate ACKs), sthresh is halved, and cwnd resets to 1.
• Reno TCP: Adds Fast Recovery, treating timeout as severe congestion but
treating duplicate ACKs as mild congestion.
• New Reno TCP: Optimizes Fast Recovery further, especially when multiple
segments are lost in a single window.
These mechanisms enable TCP to balance network utilization and congestion control,
optimizing data transfer while avoiding overloading network routers and links.
Page 73
BCS502 | COMPUTER NETWORKS
Taho TCP
Page 74
BCS502 | COMPUTER NETWORKS
Reno TCP
Page 75
BCS502 | COMPUTER NETWORKS
o Upon receiving three duplicate ACKs, Reno TCP enters Fast Recovery,
maintaining cwnd higher than in Taho, at ssthresh + 3 MSS. This prevents
starting from 1 MSS and enables faster recovery.
• Similar to Example 24.9, but at RTT 13, when three duplicate ACKs arrive:
o ssthresh is set to 6 MSS, cwnd to ssthresh + 3 = 9 MSS, and Fast
Recovery begins.
o After two more duplicate ACKs, the arrival of a non-duplicate ACK moves
Reno TCP to Congestion Avoidance, and cwnd is reduced to 6 MSS.
NewReno TCP
Page 76
BCS502 | COMPUTER NETWORKS
o Checks for additional lost segments beyond the first duplicate ACK trigger.
o If multiple segments are lost, NewReno continues retransmissions until all
lost segments are acknowledged, preventing excessive duplicate ACKs.
Page 77
BCS502 | COMPUTER NETWORKS
Page 78