Skip to content
CY-403 · Computer Networks/Quick Revision Short Notes

Computer Networks (CY-403) - Unit 2 Short Notes

UNIT 2: COMPUTER NETWORKS - EXAM-FOCUSED SHORT NOTES

Based on rigorous analysis of RGPV past papers (2022-2025). Topics marked (Very High Frequency) are mandatory for 7-mark questions.


I. NETWORK FOUNDATIONS & REFERENCE MODELS

A. Network Criteria & Performance Metrics

  • Throughput: Actual data delivery rate (bps).

  • Delay (Latency): Sum of:

    • Transmission Delay: $$\displaystyle T_{tx} = \frac{\text{Packet Size (bits)}}{\text{Bandwidth (bps)}} $$

    • Propagation Delay: $$\displaystyle T_{prop} = \frac{\text{Distance (m)}}{\text{Propagation Speed (m/s)}} $$

    • Queuing Delay: Time waiting in buffer.

    • Processing Delay: Time to examine packet header.

  • Bandwidth: Maximum theoretical data rate (Hz or bps).

  • Efficiency/Utilization: $$\displaystyle \frac{\text{Useful Data}}{\text{Total Data Sent}} $$ or $$\displaystyle \frac{T_{prop}}{T_{prop} + T_{tx}} $$ for Stop-and-Wait.

B. Reference Models

1. ISO-OSI Seven-Layer Model (Very High Frequency)

Layer PDU Key Functions Example Devices/Protocols
7. Application Data Network process-to-process interface; user services (HTTP, FTP, SMTP). Browser, Mail Client
6. Presentation Data Data translation, encryption/decryption, compression. SSL/TLS, JPEG, ASCII
5. Session Data Dialog control, synchronization, checkpointing. NetBIOS, RPC
4. Transport Segment (TCP) / Datagram (UDP) Process-to-process delivery, reliability, flow control, multiplexing. TCP, UDP
3. Network Packet Logical addressing (IP), routing, congestion control. Router, IP, ICMP
2. Data Link Frame Physical addressing (MAC), framing, error control, flow control. Switch, Bridge, Ethernet
1. Physical Bits Bit transmission, voltage/encoding, physical media. Hub, Repeater, Cable
  • Peer-to-Peer Communication: Each layer at source provides service to the layer above and uses service of the layer below. Communication is between corresponding layers on different systems.

2. TCP/IP Protocol Suite / Five-Layer Model (Very High Frequency)

Layer Protocols Key Functions
Application HTTP, FTP, SMTP, DNS, DHCP Process-to-process communication.
Transport TCP, UDP End-to-end delivery, reliability (TCP), multiplexing.
Network IP, ICMP, ARP Logical addressing, routing, internetworking.
Data Link Ethernet (802.3), PPP, HDLC Framing, MAC addressing, local delivery.
Physical - Bit transmission over medium.
  • Comparison: OSI vs. TCP/IP

    • Design: OSI is theoretical, protocol-independent. TCP/IP is practical, protocol-centric.

    • Layers: TCP/IP combines OSI's Session/Presentation/Application into one Application layer.

    • Implementation: TCP/IP protocols (IP, TCP) came first; OSI model was created later to standardize.

    • Advantage of TCP/IP: Ubiquitous, robust, scalable. Disadvantage: Less rigid layering, harder to replace protocols.

C. Network Types & Topologies

  • Types: PAN (<10m), LAN (building/campus), MAN (city), WAN (country/globe), Internetwork (global).

  • Physical vs. Logical Topology: Physical = actual wire layout. Logical = data flow path (e.g., Ethernet logical bus, physical star).

  • Common Topologies:

    • Bus: Simple, single cable. Disadv: Single point of failure, difficult troubleshooting.

    • Star: Central hub/switch. Adv: Easy to manage, single link failure doesn't bring down network. Disadv: Hub/switch failure is critical.

    • Ring: Token passing. Disadv: Single failure breaks ring (unless dual ring like FDDI).

    • Mesh: Full/partial connectivity. Adv: High reliability, redundancy. Disadv: Expensive, complex.

    • Tree/Hybrid: Combination of topologies.


II. PHYSICAL LAYER & TRANSMISSION MEDIA

A. Guided Transmission Media

Media Bandwidth Attenuation Noise Immunity Cost Application
UTP (Cat 5e/6) Low-Medium High Low Very Low LAN (Ethernet), Phone
STP Medium Medium Medium Medium Noisy environments
Coaxial Medium Medium Medium Medium Cable TV, older LANs
Fiber Optic (SM) Very High Very Low Very High Very High Long-haul, backbone
Fiber Optic (MM) High Low High High LANs, shorter distances

B. Unguided Transmission Media

  • Radio: Omnidirectional, through walls, WiFi, cellular.

  • Microwave: Directional, line-of-sight, point-to-point backbones.

  • Infrared: Directional, short-range, line-of-sight, remote controls.

  • Satellite: Long delay, wide coverage, broadcast.

C. Data Transmission Fundamentals

1. Nyquist Theorem & Shannon's Capacity Formula (High Frequency)

  • Nyquist (Noiseless): Maximum bit rate for a noiseless channel of bandwidth B Hz using M signal levels.

$$R_{max} = 2B \log_2 M \text{ (bps)}$$

  • Shannon (Noisy): Maximum theoretical capacity C (bps) for a channel of bandwidth B Hz with signal-to-noise ratio SNR.

$$C = B \log_2 (1 + SNR)$$

> [!TIP] **Key Insight:** Nyquist gives achievable rate with *M* levels. Shannon gives *ultimate limit* due to noise. To approach Shannon limit, need complex coding.

2. Line Coding Techniques (Medium Frequency)

  • Unipolar: All positive (e.g., NRZ-L). Has DC component.

  • Polar: Positive/Negative (e.g., NRZ-I, NRZ-L). Better than unipolar.

  • Bipolar (AMI): 0=zero, 1=alternating +V/-V. No DC, easy error detection.

  • Manchester: Transition in middle of bit period. 1=high-to-low, 0=low-to-high. Self-clocking.

  • Differential Manchester: Transition at start of bit period. 0=transition, 1=no transition. More robust.

3. Multiplexing Techniques

  • FDM: Different frequencies for different signals (Radio, TV).

  • TDM: Different time slots. Synchronous TDM: Fixed slots, unused slots idle. Statistical TDM: Dynamic slot allocation.

    • Frame Size in TDM: Sum of bits from all input sources per cycle.
  • WDM: Optical version of FDM. Different wavelengths on same fiber.


III. DATA LINK LAYER

A. Functions & Services

  • Framing: Delineating packet boundaries (Byte/bit stuffing).

  • Physical Addressing: MAC addresses in frame header.

  • Error Control: Detection (CRC) & Correction (Hamming).

  • Flow Control: Matching sender/receiver speeds (Stop-and-Wait, Sliding Window).

  • Link Management: Establishing, maintaining, releasing link.

B. Framing & Bit/Byte Stuffing (High Frequency)

  • Byte-Oriented (Character Stuffing): Uses special flag byte (e.g., 0x7E). Insert escape byte (0x7D) before flag/escape in data.

  • Bit-Oriented (Bit Stuffing): Uses flag pattern 01111110. After 5 consecutive 1s in data, insert a 0. Receiver removes stuffed 0 after 5 ones.

    Example: Data 01111110 → Stuffed: 011111010 (0 inserted after 5 ones). Flag added: 01111110 011111010 01111110.

C. Error Detection & Correction (Very High Frequency)

1. Error Detection Codes

  • VRC/LRC: Single parity bit per char (VRC) or per block (LRC). Can detect single-bit errors.

  • Checksum: Sum of data words (1's complement). Used in IP/TCP/UDP.

  • CRC (Cyclic Redundancy Check) – CALCULATION MANDATORY.

    • Polynomials: Data $D(x)$, Generator $G(x)$ (e.g., 10011 for CRC-CCITT).

    • Process:

      1. Append $r$ zeros to $D(x)$ ($r$ = degree of $G(x)$).

      2. Perform modulo-2 division (XOR) of augmented data by $G(x)$.

      3. Remainder $R(x)$ is the CRC checksum.

      4. Transmitted Codeword = Original Data + $R(x)$.

    • At Receiver: Divide received codeword by $G(x)$. If remainder = 0 → no error (assumed).

2. Error Correction Codes

  • Hamming Code: Adds $k$ parity bits to $m$ data bits to correct single-bit errors. $$\displaystyle 2^k \ge m + k + 1 $$.

  • Problem with Simple Parity: Can only detect odd number of errors, cannot correct. Hamming solves this.

D. Data Link Protocols & Flow Control (Very High Frequency)

1. Stop-and-Wait

  • Sender sends 1 frame, waits for ACK before next.

  • Efficiency (Link Utilization): $$\displaystyle U = \frac{1}{1 + 2a} $$ where $$\displaystyle a = \frac{T_{prop}}{T_{tx}} $$.

  • For ≥50% efficiency: $$\displaystyle 1 + 2a \le 2 \Rightarrow a \le 0.5 \Rightarrow T_{prop} \le 0.5 T_{tx} $$.

    \boxed{T_{prop} \le 0.5 \times T_{tx}}

2. Sliding Window Protocols (Very High Frequency)

Feature Go-Back-N (GBN) Selective Repeat (SR)
Window Size (Sender) $$\displaystyle W_s $$ (max $$\displaystyle 2^n - 1 $$) $$\displaystyle W_s $$ (max $$\displaystyle 2^{n-1} $$)
Window Size (Receiver) 1 (only in-order) $$\displaystyle W_r = W_s $$ (out-of-order buffering)
ACKs Cumulative (ACK n = all ≤ n OK) Individual (ACK for each frame)
Retransmission On timeout, resend all unacked frames. Only specific missing frames.
Efficiency Lower (wastes bandwidth on single loss). Higher (more complex receiver buffer).
Use Case TCP (with Fast Retransmit), older protocols. Modern reliable protocols, Selective ACK (SACK) in TCP.
  • Piggybacking: Attaching ACK to data frame going in reverse direction (used in full-duplex).

E. Multiple Access Protocols (MAC Sublayer) (Very High Frequency)

1. Static Allocation: FDMA, TDMA, CDMA (fixed assignment). 2. Random Access (Contention-Based):

  • Pure ALOHA: Transmit anytime. Throughput $$\displaystyle S = G e^{-2G} $$. Max $$\displaystyle S_{max} = 0.184 $$ at $$\displaystyle G=0.5 $$.

  • Slotted ALOHA: Transmit only at slot start. $$\displaystyle S = G e^{-G} $$. Max $$\displaystyle S_{max} = 0.368 $$ at $$\displaystyle G=1 $$.

    \boxed{S_{max}(\text{Slotted}) = \frac{1}{e} \approx 0.368}

  • CSMA & Variants:

    • 1-persistent: Sense channel, if idle transmit immediately; if busy, sense continuously.

    • Non-persistent: Sense, if idle transmit; if busy, wait random time, retry.

    • p-persistent (slotted): Sense at slot start, if idle transmit with prob $p$, else defer to next slot.

    • Comparison: 1-persistent → high collision, high delay. Non-persistent → lower collision, higher delay. p-persistent → balances.

  • Binary Exponential Backoff (BEB): After $$\displaystyle k^{th} $$ collision, choose random slot from $0$ to $$\displaystyle (2^k - 1) $$. $k$ capped (e.g., 10 for Ethernet).

3. Controlled Access: Reservation, Polling, Token Passing (brief).

F. LAN Standards & Protocols (IEEE 802) (Very High Frequency)

Standard Access Method Topology Key Features
802.3 (Ethernet) CSMA/CD Bus/Star Minimum Frame Size: $$\displaystyle 2 \times T_{prop} \times \text{Bandwidth} $$.
802.4 (Token Bus) Token Passing Logical Bus Physical star, logical bus. Deterministic.
802.5 (Token Ring) Token Passing Physical Ring Uses monitor station, beaconing for recovery.
802.11 (Wi-Fi) CSMA/CA Star (AP) No collision detection (hidden terminal). RTS/CTS optional.
FDDI Token Ring Dual Ring Fiber, 100 Mbps, high reliability.
  • Ethernet Minimum Frame Size Calculation:

    To detect collision, frame must be transmitted before signal reaches farthest end.

$$T_{tx} \ge 2 \times T_{prop} \Rightarrow \text{Min Frame Size} \ge 2 \times \text{Propagation Distance} \times \text{Bandwidth}$$

> **Example:** For 2.5 km, speed $$\displaystyle 2 \times 10^8 $$ m/s, 1 Gbps: $$\displaystyle T_{prop} = 12.5 \mu s $$, Min Frame = $$\displaystyle 2 \times 12.5 \mu s \times 10^9 $$ bps = **25,000 bits ≈ 3125 bytes**.

G. Data Link Layer Devices & Protocols

1. Bridges & Switches (Very High Frequency)

  • Layer 2 devices. Forward based on MAC address.

  • Transparent Bridging (Switch Operation):

    1. Learning: Build MAC table from source MAC of incoming frames.

    2. Forwarding: If dest MAC in table, forward out specific port; else flood.

    3. Filtering: If src & dest on same port, discard.

  • Spanning Tree Protocol (STP): Prevents loops in redundant topologies by blocking redundant paths.

  • Comparison: Hub (Physical layer, broadcasts to all). Bridge/Switch (Data Link, intelligent forwarding, reduces collisions).

2. Virtual LANs (VLANs) (Medium Frequency)

  • Concept: Logically group users/devices into separate broadcast domains on same physical switch.

  • Benefits: Security, segmentation, reduced broadcast traffic.

  • Tagging (IEEE 802.1Q): Inserts 4-byte VLAN tag in Ethernet frame header.

3. Point-to-Point Protocols

  • HDLC (High-Level Data Link Control): Bit-oriented, synchronous. Frame: Flag 01111110, Address, Control, Info, FCS, Flag.

  • PPP (Point-to-Point Protocol): For serial links (dial-up, DSL).

    • Phases: Link Establishment (LCP), Authentication (PAP/CHAP), Network Layer Protocol (NCP).

    • Frame: Flag, Address (0xFF), Control (0x03), Protocol (e.g., 0x0021 for IP), Data, FCS, Flag.

  • SLIP: Older, simple, no error detection, no multiplexing.

H. Data Link Layer Issues

  • Error Control vs. Flow Control: Error control ensures data integrity (retransmission). Flow control prevents overwhelming receiver (window size).

  • Framing Efficiency: Overhead from headers/trailers. Bit stuffing adds minimal overhead.


IV. NETWORK LAYER

A. Functions & Design Issues

  • Routing: Determining path (algorithms: DVR, LSR).

  • Forwarding: Moving packet from input to output link (using forwarding table).

  • Congestion Control: Preventing network overload.

  • Internetworking: Connecting heterogeneous networks (routers).

  • Addressing: Logical (IP) addresses.

B. IP Addressing (Very High Frequency)

1. IPv4

  • Classful Addressing (Legacy):

    | Class | First Bit | Range (First Octet) | Default Mask | Networks | Hosts/Net | | :--- | :--- | :--- | :--- | :--- | :--- | | A | 0 | 1-126 | 255.0.0.0 | 128 | 16M | | B | 10 | 128-191 | 255.255.0.0 | 16K | 64K | | C | 110 | 192-223 | 255.255.255.0 | 2M | 254 | | D | 1110 | 224-239 | - | Multicast | - | | E | 1111 | 240-255 | - | Experimental | - |

  • Limitations: Wasted addresses, no subnetting, routing table explosion.

  • Classless Inter-Domain Routing (CIDR) & Subnetting (Very High Frequency)

    • Notation: a.b.c.d/n (e.g., 192.168.1.0/24). n = network prefix bits.

    • Subnet Mask: 255.255.255.0 for /24. Convert prefix to dotted decimal.

    • Subnet Design Problem (Step-by-Step):

      1. Given network X.Y.Z.0/N and need S subnets.

      2. Borrow bits: $$\displaystyle 2^b \ge S $$ → $b$ = bits to borrow from host part.

      3. New Subnet Mask: Original mask + $b$ ones in host part.

      4. Subnet Increment: $$\displaystyle 2^{(32-N-b)} $$.

      5. Subnets: X.Y.Z.0, X.Y.Z.Increment, X.Y.Z.2*Increment...

      6. Each Subnet:

        • Network Address: First address (all host bits 0).

        • Usable Range: Network+1 to Broadcast-1.

        • Broadcast Address: Last address (all host bits 1).

    • Example: 192.168.10.0/24 → 4 subnets.

      • Borrow $$\displaystyle b=2 $$ bits (2^2=4). New mask: /26 (255.255.255.192).

      • Increment = $$\displaystyle 2^{(32-24-2)} = 64 $$.

      • Subnets: 192.168.10.0/26, 192.168.10.64/26, 192.168.10.128/26, 192.168.10.192/26.

      • First subnet usable: 192.168.10.1 - 192.168.10.62, Broadcast: 192.168.10.63.

    • VLSM (Variable Length Subnet Mask): Allocate different size subnets from same block (e.g., /26, /27, /28).

2. IPv6

  • Motivation: Address exhaustion, simpler header (no checksum, fixed 40-byte), built-in QoS (flow label), security (IPsec mandatory), autoconfiguration.

  • Format: 128-bit, hexadecimal, colon-separated (2001:0db8:85a3::8a2e:0370:7334). :: compresses consecutive zeros.

  • Header: Version, Traffic Class, Flow Label, Payload Length, Next Header, Hop Limit, Source/Dest Address (128-bit each). No options (use extension headers).

  • Comparison IPv4 vs IPv6:

    | Feature | IPv4 | IPv6 | | :--- | :--- | :--- | | Address Size | 32-bit | 128-bit | | Header | Variable (20-60 bytes) | Fixed 40 bytes | | Checksum | Yes (header) | No | | Fragmentation | Router & Source | Source only | | Options | Header options | Extension headers | | Address Notation | Dotted decimal | Hexadecimal colon-separated | | Autoconfig | Manual/DHCP | Stateless autoconfig (SLAAC) |

C. Address Resolution & Mapping

1. ARP (Address Resolution Protocol) (Very High Frequency)

  • Purpose: Map IP address → MAC address on local network.

  • Operation:

    1. Host checks ARP cache. If miss, broadcasts ARP Request: "Who has IP X.X.X.X? Tell Y.Y.Y.Y (my IP)".

    2. Host with IP X.X.X.X unicasts ARP Reply: "X.X.X.X is at MAC AA:BB:CC:DD:EE:FF".

    3. Both update ARP caches.

  • Proxy ARP: Router answers ARP for another host's IP (to hide subnet structure).

2. RARP (Reverse ARP) (High Frequency)

  • Purpose: Map MAC address → IP address (for diskless workstations).

  • Operation: Diskless station broadcasts its MAC, RARP server replies with assigned IP.

D. Routing Algorithms (Very High Frequency)

1. Distance Vector Routing (DVR) – Bellman-Ford (e.g., RIP)

  • Principle: Each router knows distance (cost) to neighbors. Shares its entire routing table with neighbors periodically.

  • Bellman-Ford Equation: $$\displaystyle D_x(y) = \min_{v \in \text{neighbors}} \left\{ c(x,v) + D_v(y) \right\} $$

    • $$\displaystyle D_x(y) $$ = cost from $x$ to $y$.

    • $c(x,v)$ = cost from $x$ to neighbor $v$.

  • Algorithm Steps:

    1. Initialize: $$\displaystyle D_x(y) = c(x,y) $$ if neighbor, else $\infty$; $$\displaystyle D_x(x)=0 $$.

    2. Iterate: For each destination $y$, update $$\displaystyle D_x(y) = \min \left[ D_x(y), c(x,v) + D_v(y) \right] $$ for all neighbors $v$.

    3. Repeat until no changes (convergence).

  • Problems:

    • Count-to-Infinity: Slow convergence for a failed link. Solved by Split Horizon (don't advertise route back to source) and Poisoned Reverse (advertise infinite cost back).

    • Slow Convergence.

    • Routing Loops.

2. Link State Routing (LSR) – Dijkstra's SPF (e.g., OSPF)

  • Principle: Each router has complete map (LSDB) of network topology (link costs).

  • Steps:

    1. Discover Neighbors & Link Cost: Hello packets.

    2. Build Link State Packets (LSP): Each router creates packet with its links and costs.

    3. Flood LSPs: Distribute LSPs to all other routers (reliable flooding).

    4. Build LSDB: Each router collects all LSPs → complete topology map.

    5. Compute Shortest Path: Run Dijkstra's algorithm on LSDB.

  • Dijkstra's Algorithm (SPF):

    1. Set $$\displaystyle N' = \{\text{source}\} $$, $$\displaystyle C(\text{source})=0 $$, $$\displaystyle C(\text{others})=\infty $$.

    2. Find node $w$ not in $N'$ with smallest $C(w)$.

    3. Add $w$ to $N'$. Update costs for neighbors $v$: $$\displaystyle C(v) = \min[C(v), C(w) + \text{cost}(w,v)] $$.

    4. Repeat until all nodes in $N'$.

  • Advantages: Fast convergence, no count-to-infinity, supports VLSM/CIDR. Disadv: More memory/CPU, flooding overhead.

3. Comparison: DVR vs. LSR

Feature DVR (RIP) LSR (OSPF)
Information Shared Entire routing table Link state only
Convergence Slow (count-to-infinity) Fast
Overhead Periodic full table updates Event-driven LSP flooding
Scalability Poor (large networks) Good (hierarchical areas)
Complexity Simple Complex (LSDB, SPF)

E. Congestion Control in Network Layer

  • Causes: Too many sources sending, slow processors, low bandwidth buffers.

  • General Principles & Techniques:

    1. Traffic-Aware Routing: Avoid congested paths.

    2. Admission Control: New connections denied if network congested.

    3. Traffic Shaping: Smooth bursty traffic.

      • Leaky Bucket: Constant output rate, input burst buffered/dropped.

      • Token Bucket: Tokens arrive at rate $r$. Bursts up to $b$ tokens allowed. More flexible.

        Comparison: Leaky Bucket = rigid, smooth output. Token Bucket = allows bursts, better for bursty sources.

    4. Load Shedding: Discard packets (e.g., based on priority).

    5. Congestion Signaling: Implicit (packet loss/delay) or Explicit (choke packets, ECN bits in IP header).

F. Internet Control & Support Protocols

1. ICMP (Internet Control Message Protocol) (Very High Frequency)

  • Purpose: Network layer protocol for error reporting & diagnostics.

  • Common Messages:

    • Destination Unreachable (Port, Protocol, Network).

    • Time Exceeded (TTL expired – traceroute).

    • Echo Request/Reply (ping).

    • Redirect (better next-hop).

  • Encapsulation: Inside IP datagram (Protocol number 1).

2. IPv4 Header Format (Medium Frequency)

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|Version|  IHL  |Type of Service|          Total Length         |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|        Identification         |Flags|      Fragment Offset    |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|  Time to Live |    Protocol   |         Header Checksum       |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|                       Source Address                          |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|                    Destination Address                        |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|                    Options                    |    Padding    |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

  • Key Fields: Version (4), IHL (header length in 32-bit words), Total Length, Identification/Flags/Fragment Offset (fragmentation), TTL, Protocol (6=TCP, 17=UDP), Header Checksum, Source/Dest IP.

G. Network Layer Devices

  • Router: Layer 3. Forwards packets based on IP address using routing table. Connects different networks.

  • Gateway: General term for device that connects networks using different protocols (often application-layer gateway, e.g., email gateway).


V. TRANSPORT LAYER

A. Services & Primitives

  • Process-to-Process Delivery: Uses port numbers (16-bit) to identify application processes.

  • Multiplexing: Multiple application processes → single network connection.

  • Demultiplexing: Incoming segments delivered to correct socket (IP + Port).

  • Connection-Oriented (TCP): Handshake, reliable, ordered.

  • Connectionless (UDP): No setup, best-effort.

B. User Datagram Protocol (UDP) (High Frequency)

  • Characteristics: Unreliable, connectionless, no flow/congestion control, no ordering, minimal overhead.

  • Header (8 bytes):

    
    0      7 8     15 16    23 24    31
    
    +--------+--------+--------+--------+
    
    |     Source Port    |   Dest Port   |
    
    +--------+--------+--------+--------+
    
    |      Length       |    Checksum    |
    
    +--------+--------+--------+--------+
    
    |          Data (optional)          |
    
    +-----------------------------------+
    
    
  • Applications: DNS, VoIP, streaming, DHCP, SNMP (where speed > reliability).

C. Transmission Control Protocol (TCP) (Very High Frequency)

1. TCP Header Format (High Frequency)


 0                   1                   2                   3

 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|          Source Port          |       Destination Port        |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|                        Sequence Number                        |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|                    Acknowledgment Number                      |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|  Data |           |U|A|P|R|S|F|                               |
| Offset| Reserved  |R|C|S|S|Y|I|            Window             |
|       |           |G|K|H|T|N|N|                               |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|            Checksum           |         Urgent Pointer        |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|                    Options                    |    Padding    |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

|                             data                              |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

  • Key Fields:

    • Seq/Ack Number: Byte-stream numbering (not packet number).

    • Flags:

      • URG (Urgent pointer valid)

      • ACK (Ack field valid – set after 3-way handshake)

      • PSH (Push function – deliver to app immediately)

      • RST (Reset connection)

      • SYN (Synchronize sequence numbers – connection setup)

      • FIN (Terminate connection)

    • Window Size: Receiver's advertised window (bytes).

    • Checksum: Covers header+data+pseudo-header (src/dst IP, protocol, TCP length).

2. Connection Management

  • Three-Way Handshake (Establishment):

    1. Client → Server: SYN=1, Seq=x

    2. Server → Client: SYN=1, ACK=1, Seq=y, Ack=x+1

    3. Client → Server: ACK=1, Seq=x+1, Ack=y+1

    Why 3-way? Prevents old duplicate SYN segments from causing invalid connections.

  • Four-Way Handshake (Termination – Graceful):

    1. Client → Server: FIN=1, Seq=u

    2. Server → Client: ACK=1, Ack=u+1 (may still send data)

    3. Server → Client: FIN=1, Seq=v, Ack=u+1

    4. Client → Server: ACK=1, Seq=u+1, Ack=v+1

    Why Graceful? Ensures all data is delivered before closing. Each side closes independently.

3. Flow Control

  • Sliding Window (Receiver-Advertised): Receiver tells sender its available buffer (Window Size in header). Sender cannot send more than Window bytes beyond last ACKed byte.

  • Window can shrink (zero window) if buffer full. Sender must stop and probe periodically.

4. Congestion Control (Very High Frequency)

  • Need: Prevent network collapse due to overloaded routers.

  • Variables:

    • cwnd (Congestion Window): Sender's limit based on network congestion (in bytes).

    • ssthresh (Slow Start Threshold): Threshold to switch from Slow Start to Congestion Avoidance.

    • rwnd (Receiver Window): Receiver's advertised limit.

    • Effective Window: min(cwnd, rwnd).

  • Algorithms:

    1. Slow Start:

      • Initially cwnd = 1 MSS (Maximum Segment Size).

      • For each ACK received: cwnd += 1 MSS.

      • Exponential growth until cwnd >= ssthresh.

    2. Congestion Avoidance:

      • When cwnd >= ssthresh.

      • For each RTT: cwnd += 1 MSS (Additive Increase).

    3. Fast Retransmit & Fast Recovery:

      • On 3 duplicate ACKs (indicates a single packet loss):

        • ssthresh = cwnd / 2

        • cwnd = ssthresh + 3 MSS (inflate for packets in flight)

        • Retransmit missing segment immediately.

      • On new ACK (acknowledges new data after fast recovery):

        • cwnd = ssthresh (back to congestion avoidance).

5. TCP Timer Management (Brief)

  • RTO (Retransmission Timeout): Calculated from RTT samples (Jacobson/Karels algorithm).

  • Persist Timer: Prevents zero-window deadlock (probe window).

  • Keepalive Timer: Detect dead connections.

D. Comparison: TCP vs. UDP (Very High Frequency)

Feature TCP UDP
Connection Connection-oriented (handshake) Connectionless
Reliability Guaranteed (ACKs, retransmission) Not guaranteed
Ordering In-order delivery No ordering
Flow Control Yes (sliding window) No
Congestion Control Yes (Slow Start, CA, Fast Recovery) No
Header Size 20-60 bytes 8 bytes
Speed Slower (overhead) Faster
Use Cases Web (HTTP), Email (SMTP), File Transfer (FTP) DNS, VoIP, Streaming, DHCP

VI. APPLICATION LAYER & APPLICATION PROTOCOLS

A. Domain Name System (DNS) (Very High Frequency)

  • Purpose: Hierarchical, distributed database translating domain names → IP addresses (and vice versa).

  • Components:

    • Resolvers: Client-side library/utility (nslookup, dig).

    • Name Servers: Authoritative (holds zone files), Root, TLD (.com, .org).

    • Zones: Administrative domain (e.g., example.com).

  • Resolution Process:

    1. Resolver queries local DNS server (usually ISP's).

    2. If not cached, local server may query Root server → gets TLD server for .com.

    3. TLD server gives authoritative server for example.com.

    4. Authoritative server returns IP.

    5. Caching: Each server caches results for TTL period.

  • Query Types:

    • Recursive: Server does entire lookup for client (typical from resolver to local server).

    • Iterative: Server returns best known answer (e.g., root → TLD).

B. World Wide Web & HTTP

1. HTTP (Hypertext Transfer Protocol) (High Frequency)

  • Architecture: Client/Server (Browser/Web Server).

  • Request Message:

    
    GET /index.html HTTP/1.1\r\n
    
    Host: www.example.com\r\n
    
    [Other headers]\r\n
    
    \r\n
    
    [Body for POST]
    
    
  • Response Message:

    
    HTTP/1.1 200 OK\r\n
    
    Content-Type: text/html\r\n
    
    [Other headers]\r\n
    
    \r\n
    
    [HTML Body]
    
    
  • HTTP/1.0 vs. 1.1 vs. 2:

    • 1.0: New TCP connection for each request (non-persistent).

    • 1.1: Persistent connections (keep-alive), pipelining, host header (virtual hosting).

    • 2: Binary framing, multiplexing (multiple streams over one connection), header compression.

2. WWW Architecture: URLs (scheme://host:port/path), HTML, browsers, web servers.

C. Electronic Mail

1. Email Architecture & Format

  • Agents:

    • MUA (Mail User Agent): Outlook, Thunderbird (composes/reads).

    • MTA (Mail Transfer Agent): Sendmail, Postfix (transfers between servers – SMTP).

    • MDA (Mail Delivery Agent): Procmail (delivers to mailbox).

  • Message Format (RFC 822):

    
    Header:
    
    From: [email protected]
    
    To: [email protected]
    
    Subject: Hello
    
    Date: ...
    
    ...
    
    [Blank line]
    
    Body:
    
    This is the message text.
    
    

2. SMTP (Simple Mail Transfer Protocol) (High Frequency)

  • Operation: Push protocol (MUA→MTA, MTA→MTA). Port 25.

  • Commands/Responses:

    
    S: 220 service ready
    
    C: HELO client.example.com
    
    S: 250 Hello
    
    C: MAIL FROM:<[email protected]>
    
    S: 250 OK
    
    C: RCPT TO:<[email protected]>
    
    S: 250 OK
    
    C: DATA
    
    S: 354 Start mail input; end with <CRLF>.<CRLF>
    
    C: [Message headers and body]
    
    C: .
    
    S: 250 OK: queued
    
    C: QUIT
    
    S: 221 Bye
    
    
  • ESMTP (Extended SMTP): Adds EHLO command and extensions (e.g., SIZE, STARTTLS for encryption).

3. POP3 & IMAP (Pull Protocols):

  • POP3: Downloads & deletes from server (simple, offline).

  • IMAP: Keeps mail on server, allows folder management, multiple clients.

D. Network Management – SNMP (Medium Frequency)

  • Architecture:

    • Manager: Central console (e.g., snmpwalk).

    • Agent: Software on managed device (router, switch).

    • MIB (Management Information Base): Database of manageable objects (variables).

  • Operations:

    • Get: Retrieve value.

    • GetNext: Retrieve next object in MIB (for table traversal).

    • Set: Change value.

    • Trap: Unsolicited notification from agent to manager (e.g., link down).

E. Other Protocols (Brief)

  • FTP: Two connections – Control (TCP port 21, commands) and Data (TCP port 20, separate connection per transfer). Active vs. Passive mode.

  • DHCP: Dynamic IP assignment. DORA process: Discover, Offer, Request, Acknowledge.

  • P2P: Decentralized (BitTorrent – tit-for-tat, trackers) vs. Centralized (Napster).


VII. INTERNETWORKING & SWITCHING

A. Switching Techniques (High Frequency)

Technique Principle Advantages Disadvantages
Circuit Switching Dedicated path setup (phone network). Guaranteed bandwidth, no delay per packet. Inefficient (idle time), setup delay, inflexible.
Packet Switching (Datagram) Each packet independent, routed separately (IP). Robust, efficient, no call setup. Packets may take different paths → out-of-order, variable delay.
Packet Switching (Virtual Circuit) Connection established, path fixed for all packets (ATM, Frame Relay). Ordered delivery, efficient headers. Requires connection setup, single point of failure in path.
Message Switching Store-and-forward entire message (email, telegraph). Can prioritize, convert formats. Large delay, requires large buffers.

B. Internetworking Devices (Very High Frequency)

Device Layer Address Used Function Example
Repeater/Hub Physical - Regenerates signal (analog/digital). Ethernet hub
Bridge/Switch Data Link MAC Forwards frames based on MAC table. Learns/filters/floods. Ethernet switch
Router Network IP Forwards packets based on routing table. Connects different networks. Home/enterprise router
Gateway Application - Protocol conversion between different architectures. Email gateway, protocol translator

Key Distinction: Hub (Layer 1, broadcasts). Switch (Layer 2, MAC-based, reduces collisions). Router (Layer 3, IP-based, connects networks). Gateway (Application layer, protocol conversion).


END OF UNIT 2 NOTES
Always verify calculations (subnetting, CRC, TDM, throughput) with units. Practice routing algorithm steps (Bellman-Ford, Dijkstra) with small graphs. Understand TCP state transitions (ESTABLISHED, FIN_WAIT, TIME_WAIT).

Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in