Flow Control
Flow control is a mechanism to ensure that the sender does not overwhelm the receiver
with too much data too quickly. It manages the pace of data transmission between sender
and receiver.
• Implemented by TCP using the Window Size (rwnd):
o The receiver advertises a window size indicating how much data it can
accept.
o The sender adjusts the amount of unacknowledged data it transmits, based
on this window.
• Sliding Window Protocol is used, where:
o A window of segments is sent without waiting for individual
acknowledgments.
o Once ACKs are received, the window slides forward.
Key Goal: Avoid buffer overflow at the receiver side.
Connection Management
TCP is a connection-oriented protocol, which means it establishes a connection before
data is transferred and properly tears it down afterward.
Connection Establishment (Three-Way Handshake):
1. SYN: Client sends a SYN (synchronize) segment to the server to initiate a
connection.
2. SYN-ACK: Server responds with a SYN-ACK (acknowledge) segment.
3. ACK: Client sends an ACK to confirm, and the connection is established.
Connection Termination (Four-Way Handshake):
1. FIN: One end initiates termination by sending a FIN (finish).
2. ACK: The other end acknowledges with an ACK.
3. FIN: The receiver of the FIN then sends its own FIN.
4. ACK: The original sender acknowledges with a final ACK.
Key Features:
• Reliable and orderly teardown.
• Allows both sides to finish transmission gracefully.
TCP Congestion Control
TCP congestion control ensures efficient use of the network while avoiding congestion
collapse. It uses dynamic strategies based on network feedback.
1. Slow Start
• Purpose: Gradually probe the network to find the available bandwidth.
• Mechanism:
o Starts with a small congestion window (cwnd), typically 1 MSS (Maximum
Segment Size).
o cwnd increases exponentially (doubles each round-trip time) until a
threshold (ssthresh) is reached or packet loss is detected.
Formula:
cwnd = cwnd + 1 MSS per ACK received
2. Congestion Avoidance
• Triggered after slow start, when cwnd >= ssthresh.
• Growth becomes linear to avoid overloading the network.
Formula:
cwnd = cwnd + (1 MSS / cwnd) for each ACK
• This results in cwnd increasing by roughly 1 MSS per RTT.
3. Fast Recovery
• Works in conjunction with Fast Retransmit.
• When 3 duplicate ACKs are received:
o Assume segment loss without waiting for a timeout.
o Retransmit the lost segment immediately (Fast Retransmit).
o Instead of going to Slow Start:
▪ Set ssthresh = cwnd / 2
▪ Set cwnd = ssthresh + 3 MSS (optimistic recovery).
▪ Exit fast recovery after one new ACK arrives.
4. Retrospective AIMD (Additive Increase Multiplicative Decrease)
AIMD is the core algorithm behind TCP congestion control.
• Additive Increase: During congestion avoidance, increase cwnd by 1 MSS per RTT
(linear).
• Multiplicative Decrease: On detecting loss (via timeout or dup ACKs), reduce cwnd
to half.
Conceptual Behavior:
• Slowly probes for more bandwidth (additive increase).
• Responds aggressively to congestion (multiplicative decrease).
Key Parameters:
• cwnd (congestion window): controls the number of packets in-flight.
• ssthresh (slow start threshold): controls the transition between slow start and
congestion avoidance.
Summary Table
Phase Increase Behavior Trigger to Exit Reaction to Loss
Slow Start Exponential When cwnd ≥ Enter Fast Recovery
ssthresh or Reset
Congestion Linear Packet loss Fast Recovery or
Avoidance AIMD
Fast Recovery cwnd reduced, then On receiving a Return to Congestion
gradual increase full ACK Avoidance
AIMD Add 1 MSS per RTT, cut - Responsive yet
cwnd by half on loss efficient
1. Network Layer: Introduction
• The Network Layer (Layer 3) in the OSI model is responsible for:
o Delivering packets from source to destination across multiple networks
(internetworking).
o Logical addressing using IP.
o Routing and forwarding decisions.
• Primary Functions:
o Packet forwarding
o Logical addressing (e.g., IP)
o Routing (finding optimal path)
o Fragmentation & reassembly
2. Forwarding vs. Routing
Forwarding Routing
Moving a packet to the correct output Determining the best path from source to
link destination
Performed by routers using forwarding Uses routing algorithms like Dijkstra, Bellman-
tables Ford
Fast operation Slower, computation-heavy process
3. Network Service Models
Defines how network layer services are provided:
• Best-effort service (IPv4): No guarantees on delivery, timing, or order.
• Quality of Service (QoS): Used in some advanced networks (e.g., MPLS).
• Examples of service types:
o Guaranteed delivery
o In-order delivery
o Guaranteed bandwidth (used in multimedia)
4. IPv4 Datagram Format
Main Fields:
• Version (4 bits): IPv4 = 4
• Header Length: Length of header
• Total Length: Size of entire packet
• Identification, Flags, Fragment Offset: For fragmentation
• TTL: Time to live (prevents looping)
• Protocol: TCP (6), UDP (17), etc.
• Source IP, Destination IP
• Checksum: For error checking header only
5. IPv4 Addressing & Classes
• IPv4 uses 32-bit addresses, written in dotted decimal (e.g., 192.168.1.1).
IPv4 Classes:
Class Range Default Subnet Mask Usage
A 1.0.0.0 – 126.255.255.255 255.0.0.0 (/8) Large networks
B 128.0.0.0 – 191.255.255.255 255.255.0.0 (/16) Medium networks
C 192.0.0.0 – 223.255.255.255 255.255.255.0 (/24) Small networks
D 224.0.0.0 – 239.255.255.255 - Multicast
E 240.0.0.0 – 255.255.255.255 - Reserved
6. Network Address & Broadcast Address
Given a network and subnet mask:
• Network Address: All host bits are 0.
• Broadcast Address: All host bits are 1.
Example:
IP: 192.168.1.10 /24
→ Network: 192.168.1.0
→ Broadcast: 192.168.1.255
7. Subnetting
Fixed Length Subnet Masking (FLSM):
• All subnets are of equal size.
• Easier to manage but wastes IPs if needs vary.
Variable Length Subnet Masking (VLSM):
• Subnets have different sizes.
• Optimized IP usage.
• Requires more complex route management.
8. Route Summarization (Supernetting)
• Aggregates multiple networks into a single summarized route.
• Reduces size of routing tables.
• Example:
o Networks: 192.168.0.0/24, 192.168.1.0/24
o Summarized: 192.168.0.0/23
9. DHCP (Dynamic Host Configuration Protocol)
• Assigns IP addresses dynamically.
• Steps:
1. Discover
2. Offer
3. Request
4. ACK
• Also assigns DNS, subnet mask, default gateway.
10. Internet Control Message Protocol (ICMP)
• Used for network diagnostics.
• Not for data transmission.
• Common ICMP messages:
o Echo Request/Reply → used in Ping
o Time Exceeded → used in Traceroute
11. NAT / PAT
• NAT (Network Address Translation):
o Maps private IPs to a public IP.
o Conserves global IPs.
• PAT (Port Address Translation):
o Also called NAT overload.
o Maps multiple private IPs to a single public IP using ports.
12. Routing: Static vs. Dynamic
Static Routing Dynamic Routing
Manually configured Automatically updated using routing protocols
Simple and secure Scales better for large networks
No overhead Consumes bandwidth and CPU for route updates
Not fault tolerant Can recover from link failures
13. Interior vs. Exterior Routing
• Interior Gateway Protocols (IGP):
o Used within an organization.
o Examples: RIP, OSPF, EIGRP
• Exterior Gateway Protocols (EGP):
o Used between organizations.
o Example: BGP (Border Gateway Protocol)