Computer
Networks
TCP
Connection
Management
Presented by(Group -5):
[Link] - AP23111260041
[Link] - AP23111260003
[Link] - AP23111260029
TCP
TCP:
• Transmission Control Protocol (TCP) is a connection-
oriented, reliable transport layer protocol.
• Ensures data is delivered accurately and in order.
Connection-oriented:
• TCP establishes a dedicated connection before data
transfer.
• Ensures both sender and receiver are ready and
synchronized.
Key Features:
• Reliability: Guarantees delivery of packets.
• Ordering: Maintains the sequence of data.
• Error checking: Detects and retransmits lost or
corrupted data.
[Link] -
AP23111260041
TCP CONNECTION
MANAGEMENT
Phase 1
Connection Establishment –
Set up a reliable connection and
synchronize sequence numbers.
Phase 2
Data Transfer –
[Connection
Send and receive packets Establishment] → [Data
reliably while maintaining
order and retransmitting lost
Transfer] → [Connection
data. Termination]
Phase 3
Connection Termination –
Close the connection gracefully,
release resources, and ensure all data
is delivered.
[Link] -
AP23111260041
THREE-WAY
HANDSHAKE
Ensures reliable connection
setup.
• SYN (Synchronize): Client sends a request
to start communication.
• SYN-ACK (Synchronize-Acknowledge):
Server acknowledges the request.
• ACK (Acknowledge): Client confirms, and
connection is established.
Initial Sequence Number
(ISN):
Randomly chosen to track byte
ordering in data transfer.
[Link] -
ACTIVE OPEN & PASSIVE OPEN
ACTIVE OPEN: PASSIVE OPEN:
• Initiated by client. • Initiated by server.
• Actively sends SYN to start • Waits for SYN from client to
connection. start connection.
• Begins the three-way • Listens on a specific port for
handshake to establish a incoming connection
reliable connection. requests.
• Allocates necessary resources • Responds with SYN-ACK
for the outgoing connection. when a client request is
• Prepares to send and receive received.
data once the connection is • Ensures the server is ready
established. to accept multiple
connections concurrently.
[Link] -
AP23111260041
TCP CONNECTION
TERMINATION
Four-step termination process:
01 02
FIN: Initiating party ACK: Receiver
requests to close. acknowledge
s.
03 04
FIN: Receiver ACK: Initiator
requests acknowledge TIME-WAIT state:
closure. s. Ensures all packets are
delivered and delayed
duplicates are cleared.
Typical duration = 2 ×
Maximum Segment Lifetime
(MSL).
[Link] -
AP23111260041
TCP Data
Transfer and
Segments
• TCP sends data in segments, not
packets.
• Segment = TCP Header + Data.
• MSS (Maximum Segment Size):
• Maximum amount of data in one
TCP segment.
• MTU (Maximum Transmission
Unit):
• Maximum size of an IP packet on
a network (e.g., 1500 bytes for
Ethernet).
• Typical:
⚬ MTU = 1500 bytes
⚬ TCP Header ≈ 20 bytes
⚬ MSS ≈ 1460 bytes [Link] -
TCP Flow
Control
• Prevents receiver buffer overflow.
• Receiver advertises RcvWindow
(rwnd).
• Sender can send only rwnd bytes
before waiting for ACKs.
• Ensures the sender does not send
faster than the receiver can read
Why Flow control matters..?
• If receiver is slow → buffer fills → rwnd
decrease
• If receiver is fast → rwnd increases
• Helps synchronize sender with receiver
capability
RcvWindow = RcvBuffer − (LastByteReceived −
LastByteRead)
[Link] -
Reliability
Mechanisms
Techniques
1 Checksum – Detects errors in data.
ACKs (Acknowledgements) – Confirm
2
received data.
3 Cumulative ACKs –
Acknowledges all bytes up to
a point.
4 Retransmission – If ACK not
received before timeout.
5 Sliding Window ARQ (Automatic Repeat
Request):
• Only unacknowledged segments are
retried.
🚨 TCP accepts out-of-order segments but does not ACK them until
missing ones arrive.
[Link] -
Pipelining in
TCP
Without pipelining: With
pipelining:
• Sender sends one • Multiple segments in flight
segment • Overlaps transmission and
• Waits entire RTT for ACK ACKs
• → Very low utilization • → Higher throughput
Important
Concepts
• RTT (Round Trip Time)
• Sender does not wait for ACK
to send next segment
• Faster and efficient data
transfer
[Link] -
Pipelined Protocols
Go-Back-N (GBN) Selective Repeat
(SR)
• Sender can send up to N
• Sender also sends up to N
unacknowledged packets
packets
• Receiver sends cumulative ACKs
• Receiver accepts out-of-order
only
packets
• If one packet is lost:
• Sends individual ACKs
• → All later packets are discarded
• Only lost packet is retransmitted
• → Sender retransmits all
unacknowledged packets
[Link] -
AP23111260003
CONGESTION
• Congestion occurs when network load exceeds capacity.
• Too many packets are present in the network → packet delay
+ packet loss
causes Effec
• High data transmission rate
ts
by senders • Increased delay
• Insufficient buffer space in • Packet loss
• Lower throughput
routers
• Retransmissions → worsens
• Slow/overloaded routers
congestion
• Bursty traffic
• Possible network collapse
• Lack of congestion control (congestion collapse)
mechanisms
Two broad approaches towards congestion control:
End-End Network-
• Assisted
routers provide feedback to
• no explicit feedback from end systems
network • single bit indicating
• congestion inferred from end- congestion (ECN)
system observed loss,delay • explicit rate sender should
approach taken by TC send it.
ECN (Explicit Congestion Notification)
• Router marks packet instead of dropping it.
• Receiver informs sender via ECN-Echo flag → sender
reduces cwnd.
• Helps prevent packet loss + stabilize network.
TCP CONGESTION CONTROL
POLICY
TCP’s general policy for handling congestion consists of following
three phases-
[Link]
START
Initially, sender sets congestion window size = Maximum
PHASE-
Segment Size
(1 MSS).
• The congestion window (cwnd) is determined by the
network's
capacity and is adjusted based on network conditions
to avoid
congestion.
• After receiving each acknowledgement, sender
increases the congestion window size by
exponentially.
• In this phase, the size of the congestion window
SLOW START &
EXPONENTIAL
• After 1 round trip time, congestion window size =
INCREASE
(2)1 = 2 MSS
• After 2 round trip time, congestion window size =
(2)2 = 4 MSS
• After 3 round trip time, congestion window size = (2)3 = 8
MSS and so on.
• This phase continues until the congestion window
THRESHOLD
size reaches the slow start threshold.
• Threshold= Maximum number of TCP segments that
receiver
window can accommodate / 2 = (Receiver window size /
Maximum Segment Size) / 2
CONGESTION
AVOIDANCE
• After reaching the threshold,Sender increases
the
congestion window size linearly to avoid the
congestion.
• On receiving each acknowledgement, sender
increments
the congestion window size by 1.
• The followed formula is-
Congestion window size = Congestion window size
+1
CONGESTION DETECTION
Case-01: Timeout Detection
When the timeout expires before an ACK arrives, it indicates
strong congestion and possible
packet loss. Reaction:
• Set ssthresh = cwnd / 2
• Reset cwnd = 1 MSS
• Restart Slow Start
Case-02: 3 Duplicate ACKs
Receiving 3 duplicate ACKs indicates mild
congestion and a likely single packet loss.
Reaction:
• Set ssthresh = cwnd / 2
• Reduce cwnd to ssthresh
• Resume Congestion Avoidance
EXAMPL
Example 1: Slow ES
Start
A TCP connection starts with cwnd = 1 MSS and ssthresh = 16 MSS. Show the growth of cwnd
during Slow Start until it reaches ssthresh.
• Slow Start doubles cwnd every RTT.
• Grows exponentially: 1 → 2 → 4 → 8 → 16
… Example 2:
• Continues until ssthresh is reached
Timeout
Assume cwnd = 20 MSS when a timeout occurs. What will be the new cwnd and ssthresh?
What phase does TCP enter again?
Timeout → heavy congestion (strong signal)
• New ssthresh = cwnd / 2 = 20 / 2 = 10 MSS
• New cwnd = 1 MSS
• TCP returns to Slow Start
So the connection must restart from small window size.
Example 3:
AIMD
If cwnd = 12 MSS and ACKs continue normally for one RTT, what will be the new cwnd? What
happens if packet loss occurs after that?
Additive Increase:
• cwnd = cwnd + 1 MSS
• New cwnd = 12 + 1 = 13 MSS
Multiplicative Decrease (on packet loss):
• cwnd = cwnd / 2
• New cwnd = 13 / 2 = 6.5 MSS ≈ 6 MSS
AIMD ensures fairness and controls
congestion by growing slowly and reducing
quickly.