Understanding Transport Layer Services
Understanding Transport Layer Services
UNIT 4
Although the network layer moves packets To communicate over a network, the
between machines, it may not be reliable. The transport layer provides a set of simple
network might lose packets, routers could operations called transport service
crash, or packets may arrive out of order. The primitives. These are commands or
transport layer ensures that: functions that applications can use to
establish and manage connections.
• Lost or damaged packets are
retransmitted.
Here are the five key primitives in a
• Data is delivered in the correct order.
simple transport service:
• Connections are maintained even if there
are network failures.
A practical way to handle this is to give each Ensuring Duplicate Packets Don’t
packet a limited lifetime (the time it is allowed Cause Problems
to live in the network).
• Sequence Numbers: Each packet gets
Techniques to limit lifetime: a unique sequence number. These
• Restricted network design: numbers are chosen so that they aren't
Designing the network so that packets reused until enough time has passed
can't loop around indefinitely. that old packets can't still be floating
• Hop counter: Each packet has a around in the network.
counter (hop count) that decreases
every time it passes through a router. • Waiting Period (T): The system waits
When the count reaches zero, the for a certain time (T seconds) to ensure
packet is discarded. that all old packets are gone before
• Timestamping: Each packet gets a using the same sequence number
timestamp, and routers discard again.
packets older than a set time.
• FIN: One side sends a finish (FIN) 4. Flow Control: Prevents the sender from
message to signal it has no more data overwhelming the receiver, often using the
to send. sliding window mechanism.
• ACK: The other side acknowledges the
FIN and might continue sending data. 5. Multiplexing: Enables multiple
• FIN: The second party sends its own applications to share a single network
FIN message once it has finished connection by using port numbers.
sending its data.
• ACK: Finally, the first party 6. Crash Recovery: Allows systems to
acknowledges the second FIN, closing recover from crashes without losing data or
the connection. corrupting ongoing communications.
How it Works:
• If the bucket (queue) overflows (too many
packets arrive), excess packets are
discarded.
• It ensures a steady output rate, suitable
for managing congestion in the network.
How it Works:
• Tokens are added to the bucket at a fixed
rate.
• To send a packet, a token must be
removed from the bucket.
• If there are no tokens, packets wait until
tokens are available.
• The bucket has a maximum token
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept
capacity, preventing unlimited bursts.
Additive Increase, Multiplicative
Decrease (AIMD):
Types of Feedback for Congestion:
A common approach in congestion control is
AIMD, used by TCP. Here’s how it works:
Different ways the network can tell the sender
to slow down include: • Additive Increase: The sender
• Explicit & Precise: Routers tell the
slowly increases its sending rate.
exact rate to send (e.g., XCP). • Multiplicative Decrease: When
• Explicit but Imprecise: Routers just
congestion happens (detected by
send a warning signal but don’t
packet loss or delay), the sender
specify how much to slow down (e.g.,
reduces its rate more aggressively (by
ECN with TCP).
a bigger fraction).
• Implicit: The sender infers congestion
by measuring things like delay or
Over time, this method ensures fairness and
packet loss (e.g., TCP CUBIC).
efficient use of the network’s capacity. It
prevents one user from hogging all the
bandwidth and helps the network converge to
the right operating point.
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept
To fix this, wireless networks like Wi-Fi use
quick retransmissions to resend lost packets
In wireless networks, packets are often lost
before TCP even notices, preventing
due to transmission errors, not because of
unnecessary slowdowns.
congestion like in wired networks.
However, wireless networks also have
But TCP, the protocol used to control
changing capacities (e.g., due to signal
congestion, slows down whenever it sees
strength), which TCP can struggle to handle.
packet loss, assuming there's network
congestion.
In more complex wireless setups, like mesh
networks, specialized protocols are needed to
This is a problem for wireless networks, where
manage these issues effectively.
packet loss is common and not always related
to congestion.
In short, wireless networks need extra
techniques to handle packet loss and
changing speeds so that TCP can work
properly without slowing down too much.
Transmission Control •
data.
Sending acknowledgments to confirm
Protocol: Introduction •
receipt.
Retransmitting lost data.
• Controlling data flow and managing
network congestion.
7. Urgent Data
• TCP has a rarely used urgent data
feature for high-priority messages
(e.g., CTRL-C interrupt).
• When urgent data is received, it
interrupts the receiving application to
be processed immediately.
2. TCP Segments:
• Data is divided into chunks called
segments before transmission.
• Each segment has a header (20 bytes)
and data (variable size).
• TCP decides the segment size based on
network limits, so data can be transferred
efficiently without being too large for the
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept
network to handle.
For example:
• If a packet with 1500 bytes (Ethernet’s
typical MTU) tries to pass through a
network link that only allows 1400
3. MTU (Maximum Transfer Unit):
bytes, the packet is too large to fit
through that link in one piece.
• MTU is the largest packet size a
• The router handling this link will need to
network link can handle. For example,
split the 1500-byte packet into smaller
on Ethernet networks, the MTU is
chunks, or fragments, so they’re each
usually 1500 bytes.
within the 1400-byte limit.
• If a segment is larger than the MTU, it
must be split or fragmented, which
slows down transmission and
4. Sliding Window Protocol:
increases the risk of data issues.
• TCP uses a sliding window protocol
• TCP uses Path MTU Discovery to
to control the flow of data.
find the smallest MTU along the path,
• The sender keeps track of how much
adjusting the segment size to prevent
data has been sent but not yet
fragmentation.
acknowledged by the receiver.
• The window size represents the
amount of data that can be sent before
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept needing an acknowledgment.
6. Handling Out-of-Order Segments:
5. Acknowledgments:
• Sometimes, segments arrive out of
• When a segment arrives, the receiver
order due to network delays or routing
sends an acknowledgment (ACK)
issues.
with the next sequence number it
• TCP can receive segments out of
expects.
sequence (like bytes 3072-4095
• For example, if it receives data up to
arriving before bytes 2048-3071).
byte 2047, it will send an ACK with the
• It waits until missing data arrives and
number 2048, indicating it’s ready for
then reassembles everything in the
the next segment starting at byte
correct order.
2048.
• If the sender doesn’t receive an
7. Reliable Data Transfer:
acknowledgment in time, it
• TCP resends data if an acknowledgment
retransmits the segment, assuming
isn’t received within a certain time.
it may have been lost.
• It ensures that data is reassembled in
the correct order, providing a reliable,
ordered byte stream to applications.
2. Sequence Number
• Every byte in TCP is assigned a unique
number, called the sequence number.
• Sequence Number Field: Indicates the
byte position of the segment's first byte in
the overall data stream, helping in data
ordering.
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept
6. Flags (8 individual 1-bit flags)
• CWR (Congestion Window Reduced)
3. Acknowledgment Number
and ECE (ECN-Echo): Used for managing
• Used by the receiver to indicate the
congestion when ECN is enabled, telling
next expected byte from the sender,
the sender to slow down.
thus acknowledging all prior data.
• URG (Urgent): Signals that the Urgent
• This is cumulative, meaning it covers
pointer field has urgent data, which should
all bytes received up to that point.
be processed immediately.
• ACK (Acknowledgement): Indicates that
4. TCP Header Length
the segment includes an acknowledgment.
• Shows how long the TCP header is,
• PSH (Push): Asks the receiver to deliver
measured in 32-bit words.
the received data immediately without
• Important to know where the actual
waiting for a full buffer.
data starts in the segment, especially
• RST (Reset): Used to reset connections if
if optional headers are added.
there's an error or confusion, such as after
a host crash.
5. Reserved Bits
• SYN (Synchronize): Used to start
• A 4-bit field that remains unused but
connections; it’s set to 1 for the initial
is reserved for potential future use.
handshake message.
• FIN (Finish): Used to gracefully close a
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept connection by signaling the end of data.
10. Options
7. Window Size Provides additional information not covered by
• Indicates the number of bytes the the regular header.
receiver is willing to accept, starting
from the acknowledged byte. This is part • Examples include:
of TCP’s sliding window for flow control. • MSS (Maximum Segment Size):
Specifies the largest segment a host
8. Checksum can accept.
• A value calculated to check for errors in • Window Scale: Allows a larger
the header and data. If the data changes
window size by shifting the Window
during transit, the checksum won’t
field value.
match, and the segment can be
• Timestamp: Provides round-trip
discarded.
timing and ensures old data isn’t
9. Urgent Pointer confused with new data on fast
• Points to where urgent data starts in the connections.
sequence. Used in cases when the URG • SACK (Selective
flag is set, but it’s rarely used in Acknowledgement): A receiver can
practice. tell the sender which specific parts of
data have been received, helping
improve retransmission efficiency.
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept
TCP Connection Establishment
TCP connection establishment using
the three-way handshake process:
Client Server
1. Connection Request (SYN)
Sen • Initiator (Client): The client wants to
d
establish a connection with a server,
SYN
SYN so it sends a SYN (synchronize)
Receiv packet to the server. This packet
ed includes:
Send
SYN + • A sequence number (SEQ) to
ACK start counting the bytes that will
be sent.
• The SYN flag set to 1 to indicate
Sen the connection request.
d • The ACK flag is 0 because it’s the
ACK first message, and no
ACK acknowledgment is needed yet.
Receiv
ed
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept
• If there is a process listening, it
2. Connection Acknowledgment (SYN- acknowledges the client’s
ACK) connection request by sending a SYN-
• Server: When the server receives the ACK packet, which includes:
SYN packet, it: • A new sequence number (SEQ)
• Checks if a process is listening on from the server.
the requested port (the destination • An acknowledgment number
port in the packet). (ACK) set to the client’s initial
• If there is no process, it sends back SEQ number + 1, to acknowledge
an RST (reset) packet to reject it received the client’s SYN.
the connection. • The SYN and ACK flags are set
to 1 to indicate both connection
request and acknowledgment.
1. Initial Setup
• Receiver Buffer: The receiver has a buffer
size of 4096 bytes.
• Sender Transmits Data: The sender
begins by transmitting data in segments.
TCP Sliding Window
2. Data Transmission and Acknowledgment
• Sending Data: The sender sends a 2048-
byte segment.
• Acknowledgement: The receiver
successfully receives the segment and
acknowledges it. At this point, the receiver's
buffer is half-full (2048 bytes remain).
• Window Size Update: The receiver
informs the sender that it can still accept
2048 bytes more.
Prepared by [Link], [Link], CSE (AI&ML,DS) Dept
• Further Sending: The sender can send
another 2048 bytes, but the receiver now
has limited buffer space.
• Window Size Becomes Zero: If the
sender tries to send more data than the
buffer can handle, the receiver sets the
window size to 0, indicating it cannot
accept more data until some is read by
the application.