UNIT 1: Computer Networks Fundamentals
1. Introduction to Computer Networks
Definition: A computer network is an interconnection of autonomous computers/l devices (hosts) via communication links (wired/wireless) and switches/routers, enabling resource sharing and communication using standardized protocols.
Key Components:
-
Hosts/End Systems: Sources/destinations of data (computers, servers, IoT devices).
-
Routers/Switches: Forward packets between networks (layer 3) or within a LAN (layer 2).
-
Communication Links: Guided (cables, fiber) or unguided (radio waves) media.
-
Protocols: Rules governing data format, timing, and error handling (e.g., TCP, IP, Ethernet).
Types of Networks:
| Type | Scale | Example | Key Feature |
|---|---|---|---|
| PAN | Personal (≤10m) | Bluetooth, Zigbee | Connects personal devices |
| LAN | Local (building/campus) | Ethernet, Wi-Fi | High speed, single admin |
| WAN | Wide (city/country) | Internet, MPLS | Long-distance, multiple admins |
| Internetwork | Global | The Internet | Network of networks |
Network Topologies:
| Topology | Description | Advantages | Disadvantages |
|---|---|---|---|
| Bus | Single backbone cable | Simple, cheap | Single point of failure, collisions |
| Star | All nodes connect to central hub/switch | Easy to manage, fault isolation | Hub/switch failure brings down network |
| Ring | Nodes form closed loop | Deterministic access (token) | Single node failure breaks ring |
| Mesh | Every node connected to every other | High reliability, redundancy | Expensive, complex cabling |
| Hybrid | Combination (e.g., star-bus) | Flexible, scalable | Complex design |
Switching Techniques:
-
Circuit Switching: Dedicated path established before communication (e.g., PSTN). Guaranteed bandwidth, but inefficient for bursty traffic.
-
Packet Switching:
-
Datagram (connectionless): Each packet routed independently (e.g., IP). No setup, packets may take different paths, possible reordering.
-
Virtual Circuit (connection-oriented): Logical path established first (e.g., ATM, Frame Relay). Packets follow same path, in-order delivery.
-
-
Message Switching: Store-and-forward of entire messages (obsolete, used in early email systems). High delay, requires large buffers.
[!TIP] Exam Focus: Distinguish circuit vs. packet switching clearly. Virtual circuit is connection-oriented at network layer, unlike TCP's transport-layer connection.
2. Network Architecture Models
2.1 OSI Reference Model
7 Layers (Bottom-Up):
| Layer | Function | Protocols/Devices | Service Primitives |
|---|---|---|---|
| 7. Application | User interface, network services | HTTP, SMTP, DNS | REQUEST, INDICATION, RESPONSE, CONFIRM |
| 6. Presentation | Data translation, encryption, compression | SSL/TLS, JPEG, MPEG | — |
| 5. Session | Dialog control, synchronization | NetBIOS, RPC | — |
| 4. Transport | End-to-end reliability, flow control | TCP (conn-oriented), UDP (conn-less) | — |
| 3. Network | Routing, logical addressing, fragmentation | IP, ICMP, ARP, routers | — |
| 2. Data Link | Framing, MAC addressing, error control | Ethernet, PPP, switches, bridges | — |
| 1. Physical | Bit transmission over media | RS-232, Ethernet (PHY), hubs | — |
Critique & Limitations:
-
Theoretical elegance but complex; some layers (e.g., session) are thin in practice.
-
Protocol stack overhead; not all functions are strictly layered (e.g., some protocols span layers).
-
Timing mismatch: OSI designed in late 1970s; TCP/IP gained market dominance first.
-
No clear distinction between some services (e.g., presentation/session often merged into application layer in TCP/IP).
2.2 TCP/IP Reference Model
4 Layers:
| Layer | Function | Protocols |
|---|---|---|
| Application | Combines OSI's App, Pres, Sess | HTTP, SMTP, DNS, SSH |
| Transport | End-to-end communication | TCP (reliable), UDP (unreliable) |
| Internet | Routing, logical addressing, fragmentation | IP, ICMP, ARP |
| Network Interface (Link) | Framing, physical transmission | Ethernet, Wi-Fi, PPP |
Advantages:
-
Practical, simplified model; widely implemented.
-
Protocols independent of underlying hardware.
-
Scalable and robust (designed for internetworking).
Disadvantages:
-
Less rigorous layering; some functions (e.g., routing) span layers.
-
No standard session/presentation layers; handled by applications.
-
Originally lacked explicit congestion control (added later in TCP).
2.3 Comparison: OSI vs. TCP/IP
| Aspect | OSI Model | TCP/IP Model |
|---|---|---|
| Layers | 7 layers | 4 layers |
| Approach | Theoretical, general | Practical, specific to Internet |
| Protocols | Protocol-independent | Protocol-specific (TCP/IP suite) |
| Session/Presentation | Explicit layers | Merged into Application layer |
| Network Layer | Connection-oriented (X.25) & connectionless | Primarily connectionless (IP) |
| Data Link Layer | LLC & MAC sublayers | No clear sublayer distinction |
| Adoption | Never fully implemented | De facto standard |
| Routing | Network layer handles routing | Internet layer handles routing |
[!TIP] Exam Key: OSI is reference model; TCP/IP is implementation model. OSI's network layer can support both VC & datagram; TCP/IP's internet layer is strictly datagram. TCP provides connection-oriented service on top of connectionless IP.
3. Physical Layer
3.1 Transmission Media
Guided Media:
-
Twisted Pair (UTP/STP): 100 m limit, 10 Mbps–10 Gbps, cheap, susceptible to EMI.
-
Coaxial Cable: 500 m, 10–500 Mbps, better shielding, used in cable TV.
-
Fiber Optic: 100+ km, 10 Mbps–100 Gbps+, low attenuation, immune to EMI, expensive.
Unguided Media:
-
Radio Waves: Omnidirectional, penetrate walls, Wi-Fi, Bluetooth.
-
Microwave: Directional, line-of-sight, satellite, terrestrial links.
-
Infrared: Short-range, line-of-sight, remote controls.
-
Satellite: Geostationary (~36,000 km, 270 ms delay) or LEO.
Broadband Access:
-
DSL: Uses existing phone lines, frequency division (voice low, data high), ADSL: up to 24 Mbps down, 1.4 Mbps up.
-
Cable: Shared coaxial, DOCSIS standards, up to 1 Gbps down.
-
FTTH: Fiber to home, PON (Passive Optical Network), highest speeds (10+ Gbps).
3.2 Signal Transmission Theory
Nyquist Formula (Noiseless Channel):
$$ \text{Max Bit Rate} = 2B \log_2 M \text{ bps} $$
-
$B$ = bandwidth (Hz)
-
$M$ = number of discrete signal levels
Example: $$\displaystyle B = 3 $$ kHz, $$\displaystyle M = 4 $$ (2 bits/level) → $$\displaystyle 2 \times 3000 \times \log_2 4 = 12,000 $$ bps.
Shannon's Theorem (Noisy Channel):
$$ C = B \log_2 (1 + \text{SNR}) \text{ bps} $$
-
$C$ = channel capacity (max reliable data rate)
-
$$\displaystyle \text{SNR} = \frac{S}{N} $$ (signal power/noise power, often in dB: $$\displaystyle \text{SNR}_{\text{dB}} = 10 \log_{10}(\text{SNR}) $$)
Example: $$\displaystyle B = 4 $$ kHz, $$\displaystyle \text{SNR}_{\text{dB}} = 30 $$ dB → $$\displaystyle \text{SNR} = 1000 $$ → $$\displaystyle C = 4000 \log_2(1001) \approx 39,863 $$ bps.
[!TIP] Common Pitfall: Nyquist assumes no noise and gives theoretical max for given $M$. Shannon gives practical max for given SNR. Increasing $M$ in Nyquist increases bit rate but requires better SNR (Shannon limit).
3.3 Multiplexing
-
FDM: Each signal modulated to different frequency band (e.g., radio stations, cable TV).
-
TDM: Time slots assigned to channels. Synchronous TDM: fixed slots (wastes slots if channel idle). Statistical TDM: slots allocated dynamically (higher efficiency, needs buffering).
TDM Frame Size (bits) = sum of all channel bit rates × slot time.
3.4 Line Coding
Convert binary data to physical signals.
| Scheme | 0 → Signal | 1 → Signal | Features |
|---|---|---|---|
| NRZ-L | High | Low | No clock recovery, DC balance issue |
| NRZ-I | Transition at start of 1 | No transition for 0 | Better clock sync than NRZ-L |
| RZ | Pulse to mid-level then zero | Pulse to high then zero | Self-clocking, but more bandwidth |
| Manchester | Low→High transition mid-bit | High→Low transition mid-bit | Self-clocking, DC balanced, used in Ethernet |
| Diff. Manchester | Transition at start of every bit; mid-bit transition for 0 | No mid-bit transition for 1 | Better noise immunity |
Example: Binary
10110in Manchester:10 01 10 01 10(assuming start high? Actually: 1=high→low, 0=low→high →10 01 10 01 10? Let's define: convention varies; typically 1=transition high→low, 0=low→high. So1→10,0→01,1→10,1→10,0→01→10 01 10 10 01).
4. Data Link Layer
4.1 Functions & Services
-
Framing: Encapsulate packet into frame (header + payload + trailer).
-
Error Control: Detection (CRC) & correction (Hamming).
-
Flow Control: Prevent fast sender overwhelming slow receiver (stop-and-wait, sliding window).
-
Access Control: Multiple stations sharing medium (MAC protocols).
-
Addressing: MAC address (48-bit, burned into NIC). Types:
-
Unicast: Single destination (LSB of first byte = 0).
-
Multicast: Group (LSB of first byte = 1, e.g., IPv4 224.0.0.0–239.255.255.255 maps to 01:00:5E:xx:xx:xx).
-
Broadcast: All stations (FF:FF:FF:FF:FF:FF).
-
4.2 Error Detection & Correction
Parity Check:
-
Single bit: detect odd number of errors.
-
2D parity: detect & correct single-bit errors.
Checksum:
- Internet checksum (ones complement sum of 16-bit words), used in IP/TCP/UDP.
Simple, but weak error detection.
CRC (Cyclic Redundancy Check):
-
Generator polynomial $G(x)$ (e.g., $$\displaystyle x^3 + x + 1 = 1011 $$).
-
Append $r$ zeros ($$\displaystyle r = \deg(G) $$) to data $D(x)$.
-
Divide $$\displaystyle D(x) \cdot x^r $$ by $G(x)$ (mod 2), get remainder $R(x)$.
-
Transmit $$\displaystyle D(x) \cdot x^r + R(x) $$.
-
Receiver divides by $G(x)$; remainder 0 → no error (if $G(x)$ chosen well, detects all 1,2-bit errors, odd errors, burst ≤ $r$ bits).
Example: Data
1101011011($$\displaystyle D(x)=x^9+x^8+x^6+x^4+x^3+x^1+1 $$), $$\displaystyle G(x)=10011 $$ ($$\displaystyle r=4 $$). Compute CRC → codeword.
Hamming Code (Single-bit error correction):
-
$k$ data bits, $r$ parity bits: $$\displaystyle 2^r \ge k + r + 1 $$.
-
Parity bits at positions $$\displaystyle 2^i $$.
-
Compute parity over specific data bits.
-
Receiver recalculates, syndrome points to error position.
4.3 Framing & Stuffing
-
Byte Stuffing (PPP): Escape byte
0x7Dused to insert0x7E(flag) or0x7Din data. -
Bit Stuffing (HDLC): After 5 consecutive
1s, insert a0to avoid flag01111110.
Example: Data
011110111110111101111110111101111110with bit stuffing →011110111111011111011111101111101111110? Actually: insert0after every five1s. Original:01111 011111 011111 0111111 011111 011111 0? Let's chunk:01111 0 11111 0 11111 0 111111 0 11111 0 11111 0? Need exact:011110111110111101111110111101111110→ break:01111 011111 011111 0111111 011111 011111 0? Actually count: positions: after first 5 ones? Better: scan left to right:01111(5 ones? 0 then four 1s? Actually:0 1111→ 4 ones. Then0→ no. Next11111→ five ones → stuff0. So:01111 0 11111 0 11111 0 111111 0 11111 0 11111 0? Let's do properly: string:0 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0. Count consecutive 1s: after first0:1111(4) → no stuff. Then0. Then11111(5) → stuff0after. So becomes11111 0. Then0. Then11111(5) → stuff0. Then0. Then111111(6) → after 5 ones, stuff0, then one more1? Actually:111111→ after first 5:11111 0 1. Then0. Then11111→ stuff0. Then0. Then11111→ stuff0. Then0. So final:0 1111 0 11111 0 0 11111 0 0 11111 0 1 0 11111 0 0 11111 0 0? Messy. But exam expects clear step.
4.4 Flow & Error Control Protocols
Stop-and-Wait:
-
Sender sends 1 frame, waits for ACK before next.
-
Efficiency = $$\displaystyle \frac{1}{1 + 2a} $$ where $$\displaystyle a = \frac{\text{propagation delay}}{\text{frame transmission time}} $$.
-
Utilization low for long propagation delays (e.g., satellite).
Sliding Window:
-
Sender can have up to $W$ unacknowledged frames.
-
Receiver window size $$\displaystyle W_r $$ (often 1 for Go-Back-N, >1 for Selective Repeat).
Go-Back-N (GBN):
-
Sender window $$\displaystyle W_s $$, receiver window $$\displaystyle W_r = 1 $$.
-
If frame $n$ lost/damaged, receiver discards all subsequent frames and sends ACK for $n-1$ (duplicate ACK).
-
Sender times out, retransmits $n$ and all following.
-
Efficiency ≈ $$\displaystyle \frac{W_s}{1 + 2a} $$ (if $$\displaystyle W_s \le 1 + 2a $$).
-
Link Utilization = $$\displaystyle \frac{\text{useful time}}{\text{total time}} $$.
Selective Repeat (SR):
-
Both windows $$\displaystyle W_s = W_r = 2^{m-1} $$ (if sequence number $m$ bits).
-
Receiver buffers out-of-order frames, sends ACK for each correctly received.
-
Sender retransmits only missing frames (on timeout or 3 duplicate ACKs).
-
More efficient but requires larger buffers and more complex.
Hybrid ARQ:
-
Combines FEC (Forward Error Correction) and ARQ.
-
Types: Type I (FEC only, no ARQ), Type II (FEC + incremental redundancy), Type III (FEC + ARQ with combining).
4.5 Multiple Access Protocols
Random Access (Contention):
-
Pure ALOHA: Transmit anytime; throughput $$\displaystyle S = G e^{-2G} $$ (max $$\displaystyle S_{\max} = 0.184 $$ at $$\displaystyle G=0.5 $$).
-
Slotted ALOHA: Time slots; throughput $$\displaystyle S = G e^{-G} $$ (max $$\displaystyle S_{\max} = 0.368 $$ at $$\displaystyle G=1 $$).
-
Binary Exponential Backoff (BEB): After collision, wait random $$\displaystyle k \times T_{slot} $$, $$\displaystyle k \in [0, 2^i-1] $$ after $i$ collisions.
CSMA (Carrier Sense Multiple Access):
-
1-persistent: Sense channel; if idle, transmit; if busy, sense continuously.
-
Non-persistent: Sense; if busy, wait random time, then sense again.
-
p-persistent (for slotted): If idle, transmit with prob $p$, else defer to next slot.
CSMA/CD (Collision Detection, Ethernet):
- Minimum Frame Size ensures collision detected before transmission ends.
$$\displaystyle \text{Min Frame Size} \ge 2 \times \text{Propagation Delay} \times \text{Bandwidth} $$.
Example: 2 km cable, signal speed $$\displaystyle 2 \times 10^8 $$ m/s → propagation delay $$\displaystyle = \frac{2000}{2 \times 10^8} = 10 \ \mu s $$. For 10 Mbps Ethernet → min frame $$\displaystyle = 2 \times 10 \ \mu s \times 10^7 \ \text{bps} = 200 $$ bits ≈ 25 bytes (Ethernet uses 64 bytes).
CSMA/CA (Collision Avoidance, Wi-Fi):
-
DIFS (Distributed InterFrame Space) for data; SIFS (Short IFS) for ACK.
-
RTS/CTS optional to avoid hidden terminal problem.
-
Virtual Carrier Sense: NAV (Network Allocation Vector) indicates channel reserved.
4.6 LAN Standards
| Standard | Access Method | Topology | Frame Format | Key Features |
|---|---|---|---|---|
| IEEE 802.3 (Ethernet) | CSMA/CD | Bus/Star | Preamble, Dest MAC, Src MAC, Type, Data, CRC | 10 Mbps–400 Gbps, dominant LAN tech |
| IEEE 802.4 (Token Bus) | Token passing | Bus (logical ring) | Token, control, data | Deterministic, used in manufacturing |
| IEEE 802.5 (Token Ring) | Token passing | Ring | Start delimiter, access control, data, CRC, end delimiter | 4/16 Mbps, IBM legacy, FDDI similar (dual ring, 100 Mbps) |
| IEEE 802.11 (Wi-Fi) | CSMA/CA | Star (AP) | Frame control, duration, addr1–4, seq, data, CRC | Infrastructure/ad-hoc, 802.11n/ac/ax (MIMO, OFDM) |
4.7 Data Link Protocols
HDLC (High-Level Data Link Control):
-
Bit-oriented, supports both async & sync.
-
Frame Format: Flag
01111110, Address, Control, Information, FCS, Flag. -
Modes: Normal Response (NRM), Asynchronous Response (ARM), Asynchronous Balanced (ABM).
-
Control Field: $N(S)$ (seq), $N(R)$ (ack), P/F bit.
PPP (Point-to-Point Protocol):
-
Phases: Link establishment (LCP), authentication (PAP/CHAP), network layer (NCP), link termination.
-
Frame Format: Flag, Address (
0xFF), Control (0x03), Protocol (e.g.,0x0021for IP), Data, FCS, Flag. -
Byte Stuffing: Flag
0x7E, escape0x7D.
SLIP (Serial Line Internet Protocol):
-
Obsolete, simple:
END(0xC0) frame delimiter,ESC(0xDB) stuffing. -
No error detection, no multi-protocol support.
Frame Relay:
-
Virtual circuit (PVC/SVC), packet-switched, no error correction (only detection, higher layers handle).
-
Architecture: DTE (user device) ↔ DCE (switch) via access link.
-
Frame Format: Flag, DLCI (virtual circuit ID), control, data, FCS, flag.
-
Congestion: DE (Discard Eligible), FECN/BECN bits.
4.8 Bridges & Switches
| Device | Layer | Function | Learning | Forwarding |
|---|---|---|---|---|
| Hub | Physical | Broadcast all ports | No | No |
| Bridge | Data Link | Connect LAN segments, filter by MAC | Store-and-forward, learns MAC→port | Flood if unknown, forward if known & different port |
| Switch | Data Link | Multi-port bridge, per-port collision domain | Same as bridge, aging timer | Same, often cut-through possible |
| Router | Network | Connects networks, routes by IP | No (uses routing table) | Forward based on longest prefix match |
Transparent Bridging:
-
Bridges learn source MAC→port.
-
Forward if dest MAC known & on different port; flood if unknown or broadcast.
-
Spanning Tree Protocol (STP): Prevents loops by blocking redundant links (root bridge, root ports, designated ports).
Switch Learning:
-
Initially MAC table empty.
-
On frame arrival: record source MAC→ingress port.
-
If dest MAC in table & on different port → forward to that port.
-
If dest MAC unknown/broadcast → flood to all except ingress.
-
Entries aged out if inactive for timeout.
[!TIP] Exam Distinction: Hub = layer 1, repeat signal; Switch = layer 2, uses MAC; Router = layer 3, uses IP. Switches break collision domains, not broadcast domains.
5. Network Layer
5.1 Functions & Design Issues
-
Routing: Determine path from source to destination (routing algorithms).
-
Forwarding: Move packet from input to output link (per-hop decision).
-
Congestion Control: Prevent network overload (traffic-aware routing, admission control, load shedding).
-
Fragmentation/Reassembly: Handle MTU differences (IPv4: at routers; IPv6: only at source).
-
Virtual Circuits vs. Datagram Subnets:
-
VC Subnet: Connection setup, per-hop state (VC number), in-order delivery (e.g., Frame Relay, ATM).
-
Datagram Subnet: No setup, each packet independent, routing per packet (e.g., IP).
-
5.2 IP Addressing (IPv4)
Classful Addressing:
| Class | First Bits | Network ID | Host ID | Range (first octet) | Default Mask |
|---|---|---|---|---|---|
| A | 0 | 8 bits | 24 bits | 0–127 | 255.0.0.0 |
| B | 10 | 16 bits | 16 bits | 128–191 | 255.255.0.0 |
| C | 110 | 24 bits | 8 bits | 192–223 | 255.255.255.0 |
| D | 1110 | — | — | 224–239 | Multicast |
| E | 1111 | — | — | 240–255 | Reserved |
Limitations: Wasted addresses (class B too large for many orgs), no subnetting flexibility, routing table explosion.
CIDR (Classless Inter-Domain Routing):
-
Notation:
a.b.c.d/nwhere $n$ = network prefix length. -
Example:
192.168.1.0/24→ network mask255.255.255.0. -
Allows variable-length subnetting, efficient allocation.
-
Aggregation: Route summarization (e.g.,
192.168.0.0/16covers192.168.0.0/24to192.168.255.0/24).
Subnetting:
-
Borrow bits from host portion to create subnets.
-
Subnet Mask: 32-bit number with contiguous 1s for network+subnet.
-
Example:
200.133.175.0/24→ create 16 subnets (need 4 bits, $$\displaystyle 2^4=16 $$). New mask/28(255.255.255.240).-
Subnet 0:
200.133.175.0/28→ hosts200.133.175.1–200.133.175.14, broadcast200.133.175.15. -
Subnet 1:
200.133.175.16/28→ hosts17–30, broadcast31. -
... Subnet 15:
200.133.175.240/28→ hosts241–254, broadcast255.
-
Supernetting (aggregation): Combine contiguous networks into larger prefix (reverse of subnetting).
IPv6 Overview:
-
128-bit address (hex colon notation:
2001:0db8:85a3::8a2e:0370:7334). -
Header: Fixed 40 bytes, no options, removed checksum, flow label.
-
Address Types: Unicast (global, link-local
fe80::/10), multicast, anycast. -
No broadcast; uses multicast.
-
Built-in security (IPsec mandatory), autoconfiguration (SLAAC).
5.3 Routing Algorithms
Distance Vector Routing (DVR):
-
Bellman-Ford Equation: $$\displaystyle D_x(y) = \min_v \{ c(x,v) + D_v(y) \} $$.
-
Each router maintains distance vector (cost to each dest).
-
Periodically exchange entire vector with neighbors.
-
Count-to-Infinity Problem: Slow convergence on link failure; Split Horizon, Poison Reverse mitigate.
-
RIP: Uses hop count (max 15), updates every 30 sec.
Link State Routing (LSR):
-
Each router discovers neighbors, measures cost, builds LSP (Link State Packet).
-
Flood LSPs to all routers → each has complete topology.
-
Dijkstra's Algorithm: Compute shortest path tree from self.
Initialize: tree = {self}, dist[self]=0, others=∞ Repeat: pick node w not in tree with min dist[w] add w to tree, update dist[v] for neighbors v of w: dist[v] = min(dist[v], dist[w] + cost(w,v)) -
OSPF uses LSR, areas to scale.
Comparison:
| Feature | DVR | LSR |
|---|---|---|
| Convergence | Slow (count-to-infinity) | Fast (flooding) |
| Overhead | Periodic full exchange | Flood on change, large initial |
| Scalability | Poor (routing loops) | Good (hierarchical areas) |
| Memory | Stores only neighbor vectors | Stores full topology map |
| Example | RIP, IGRP | OSPF, IS-IS |
Shortest Path Routing:
-
Metrics: Hop count, bandwidth, delay, reliability, cost.
-
Dijkstra's (LSR) or Bellman-Ford (DVR) compute paths.
Example: Given graph with nodes A,B,C,D, compute shortest path from A to all.
5.4 Internet Control Protocols
ARP (Address Resolution Protocol):
-
Maps IP address → MAC address on local network.
-
Broadcast ARP request: "Who has IP X? Tell Y (MAC Y)".
-
Target replies with ARP reply (unicast).
-
Cache ARP entries (typically 15 min).
RARP (Reverse ARP):
-
Diskless workstation boot: "Who has MAC X? My IP?" → RARP server replies with IP.
-
Obsolete, replaced by BOOTP/DHCP.
ICMP (Internet Control Message Protocol):
-
Error-reporting & diagnostic messages (carried in IP).
-
Common Types:
-
0/8: Echo Reply/Request (ping). -
3: Destination Unreachable (code: network unreachable, port unreachable, etc.). -
11: Time Exceeded (TTL expired, traceroute). -
5: Redirect (router suggests better next hop).
-
-
Query messages:
12/13Timestamp,17/18Address Mask Request/Reply.
5.5 Fragmentation & Reassembly
Need: Different networks have different MTU (Maximum Transmission Unit). IP must handle fragmentation if packet larger than outgoing link's MTU.
IPv4 Header Fields:
-
Identification: Same for all fragments of a packet.
-
Flags:
DF(Don't Fragment),MF(More Fragments). -
Fragment Offset: 13 bits, units of 8 bytes → offset = byte number / 8.
Reassembly:
-
Only at destination (or at router if configured).
-
Uses identification, source IP, dest IP, protocol to identify fragments.
-
Waits for all fragments (timer prevents indefinite wait).
-
Problem: One lost fragment → entire packet lost.
Example: 4000-byte packet (20-byte header, 3980 data), MTU 1500 bytes. First fragment: offset=0, MF=1, data 1480. Second: offset=185 (1480/8), MF=1, data 1480. Third: offset=370, MF=0, data 1020.
6. Transport Layer
6.1 Functions & Services
-
Process-to-Process Communication: Uses port numbers (16-bit) to distinguish apps.
-
Reliability: ACKs, retransmission (TCP).
-
Flow Control: Receiver advertises window size.
-
Congestion Control: Adjust sending rate based on network congestion.
-
Connection-oriented vs. Connectionless:
-
Connection-oriented (TCP): Handshake, stateful, reliable, ordered.
-
Connectionless (UDP): No setup, best-effort, low overhead.
-
6.2 UDP (User Datagram Protocol)
-
Header (8 bytes):
-
Source Port (16), Dest Port (16)
-
Length (header+data, 16)
-
Checksum (16, optional in IPv4, mandatory in IPv6)
-
-
Features: No connection setup, no congestion control, no ordering, minimal overhead.
-
Applications: DNS, VoIP, video streaming, DHCP.
6.3 TCP (Transmission Control Protocol)
Header Format (20–60 bytes):
| Field | Size (bits) | Purpose |
|---|---|---|
| Source Port | 16 | Sender's port |
| Dest Port | 16 | Receiver's port |
| Sequence Number | 32 | Byte number of first data in segment |
| Acknowledgment Number | 32 | Next expected byte (if ACK flag set) |
| Data Offset | 4 | Header length (32-bit words) |
| Reserved | 3 | Must be 0 |
| Flags (URG, ACK, PSH, RST, SYN, FIN) | 9 | Control bits |
| Window Size | 16 | Receiver's buffer space (bytes) |
| Checksum | 16 | Error detection (covers pseudo-header) |
| Urgent Pointer | 16 | Byte offset to urgent data (if URG set) |
| Options | variable | MSS, window scale, timestamps, SACK permitted |
Connection Establishment: Three-Way Handshake
Client Server
SYN=1, seq=x ------------>
SYN=1, seq=y, ACK=x+1 <------------
ACK=y+1 ------------>
-
Prevents old duplicate connection initiations.
-
SYN consumes one sequence number.
Connection Termination: Four-Way Handshake (graceful)
Finisher (e.g., client) Other (server)
FIN=1, seq=u ------------>
ACK=u+1 <------------
FIN=1, seq=v <------------
ACK=v+1 ------------>
-
Each direction closed separately (half-close possible).
-
TIME_WAIT state (2×MSL) ensures last ACK received, prevents old duplicates.
Flow Control: Sliding window. Receiver advertises Window Size in header. Sender must not send more than rwnd bytes beyond last ACKed byte.
Congestion Control (RFC 5681, updated by RFC 6582, 8312):
-
Slow Start:
cwndstarts at 1–10 MSS, doubles each RTT untilssthresh. -
Congestion Avoidance: After
cwnd >= ssthresh, increasecwndby ~1 MSS per RTT (additive increase). -
Fast Retransmit: On 3 duplicate ACKs, retransmit missing segment, set
ssthresh = cwnd/2,cwnd = ssthresh + 3 MSS. -
Fast Recovery: On duplicate ACKs, inflate
cwnd(simulate ACK of new data), then on new ACK, setcwnd = ssthresh. -
Timeout:
cwndset to 1 MSS,ssthresh = cwnd/2, enter slow start.
Load Shedding (Congestion Avoidance at source):
-
Leaky Bucket: Output at constant rate, bursty input smoothed (queue discipline).
-
Token Bucket: Tokens accumulate at rate $r$, up to $b$ tokens. Packet of size $s$ needs $s$ tokens. Allows burst up to $b$ tokens.
6.4 Sliding Window in Transport
-
GBN: Sender window $$\displaystyle W_s $$, receiver window $$\displaystyle W_r=1 $$. Cumulative ACK. Retransmit all after timeout/duplicate ACK.
-
SR: Sender/receiver windows $$\displaystyle W_s=W_r=2^{m-1} $$ (if $m$-bit seq num). Individual ACK, selective retransmission.
-
Piggybacking: ACK carried in data segment going opposite direction (saves bandwidth).
Link Utilization (for GBN):
$$ U = \frac{W_s}{1 + 2a} \quad \text{where} \quad a = \frac{\text{propagation delay}}{\text{frame transmission time}} $$
Max $U \approx 1$ if $$\displaystyle W_s \ge 1 + 2a $$.
7. Application Layer
7.1 Domain Name System (DNS)
-
Hierarchy: Root servers (.) → TLD servers (
.com,.org, country-code) → Authoritative servers (domain owner). -
Resolution:
-
Recursive: Resolver asks server, server returns final answer (may query others).
-
Iterative: Server returns referral to lower server if not authoritative.
-
-
Caching: Resolvers cache responses (TTL in record).
-
Resource Records:
-
A: IPv4 address. -
AAAA: IPv6 address. -
CNAME: Canonical name (alias). -
MX: Mail exchange (priority). -
NS: Name server. -
PTR: Reverse lookup (IP → name).
-
7.2 Email
Architecture:
-
User Agent (UA): Outlook, Thunderbird (compose, send, receive).
-
Mail Server: Stores mailbox, runs SMTP (send) and POP3/IMAP (receive).
-
SMTP (Simple Mail Transfer Protocol):
-
Push protocol (client → server, server → server).
-
Commands:
HELO,MAIL FROM,RCPT TO,DATA,QUIT. -
ESMTP (Extended SMTP):
EHLO,SIZE,STARTTLS.
-
-
POP3 (Post Office Protocol v3):
-
Download-and-delete (or keep) model.
-
Commands:
USER,PASS,LIST,RETR,DELE,QUIT.
-
-
IMAP (Internet Message Access Protocol):
-
Remote mailbox access, folders, partial fetch.
-
Commands:
LOGIN,SELECT,FETCH,STORE,LOGOUT.
-
-
MIME (Multipurpose Internet Mail Extensions):
- Encodes non-ASCII:
Content-Type(text/plain, image/jpeg),Content-Transfer-Encoding(base64, quoted-printable).
- Encodes non-ASCII:
7.3 World Wide Web (WWW)
-
HTTP/HTTPS (Hypertext Transfer Protocol / Secure):
-
Request:
Method (GET/POST/HEAD),URL,HTTP/1.1,Headers, optionalBody. -
Response:
Status Code (200 OK, 404 Not Found, 500),Headers,Body. -
Stateless (cookies, sessions for state).
-
HTTPS: HTTP over TLS/SSL (port 443).
-
-
URL:
scheme://host:port/path?query#fragment. -
Browsers: Render HTML, CSS, JavaScript.
7.4 File Transfer (FTP)
-
Two Connections:
-
Control Connection (port 21): persistent, commands/responses.
-
Data Connection (port 20 or dynamic): ephemeral, actual file transfer.
-
-
Modes:
-
Active: Server opens data connection to client (client sends
PORT). -
Passive: Client opens data connection to server (server sends
PASV).
-
-
Commands:
USER,PASS,LIST,RETR,STOR,QUIT.
7.5 Network Management (SNMP)
-
Components:
-
Manager: Central console (e.g.,
snmpwalk). -
Agent: Software on managed device (router, switch).
-
MIB (Management Information Base): Database of managed objects (OID tree).
-
-
Operations:
GET,GETNEXT,SET,TRAP(asynchronous notification). -
Versions: SNMPv1 (no security), v2c (community string), v3 (user authentication, encryption).
7.6 Other Protocols
-
SSH (Secure Shell): Secure remote login (port 22), replaces Telnet/rlogin.
-
TLS/SSL: Cryptographic protocols for secure communication (HTTPS, SMTPS).
8. Cross-Layer & Advanced Topics
8.1 Network Devices Comparison
| Device | OSI Layer | Function | Intelligence | Broadcast Domain |
|---|---|---|---|---|
| Hub | Physical | Signal regeneration | None | Single |
| Switch | Data Link | MAC learning/forwarding | Per-port filtering | Single (unless VLANs) |
| Bridge | Data Link | Connects two LAN segments | MAC table | Single |
| Router | Network | IP routing, subnet separation | Routing table | Multiple (per interface) |
| Gateway | Application | Protocol conversion (e.g., SMTP↱X.400) | High | Multiple |
8.2 Remote Bridging
-
Concept: Bridge two distant LANs over a WAN link (e.g., two offices connected via leased line).
-
Implementation: Transparent bridging (STP) over WAN; may use Tunneling (e.g., GRE).
-
Challenges:
-
Latency: STP convergence slow over high-delay links.
-
Scalability: STP limits topology; remote bridges may cause loops.
-
Bandwidth: WAN links often slower than LANs → bottleneck.
-
STP Issues: Remote link treated as single hop; failure detection slow.
-
8.3 Quality of Service (QoS)
-
Need: Different applications have different requirements (delay, jitter, loss).
-
Techniques:
-
Traffic Shaping: Smooth bursty traffic (leaky bucket, token bucket).
-
Priority Queuing: Higher priority queues served first.
-
Resource Reservation: RSVP (ReSerVation Protocol) reserves resources along path.
-
Differentiated Services (DiffServ): PHB (Per-Hop Behavior) based on DS field in IP header (EF, AF classes).
-
Integrated Services (IntServ): Fine-grained per-flow reservation (not scalable).
-
-
Congestion Control vs. QoS: Congestion control prevents overload; QoS manages traffic during congestion.
8.4 Virtual LANs (VLANs)
-
Definition: Logical segmentation of LAN into broadcast domains, regardless of physical location.
-
Benefits: Security (isolate groups), reduced broadcast traffic, flexible administration.
-
VLAN Tagging (IEEE 802.1Q):
-
Inserts 4-byte VLAN tag between source MAC and EtherType.
-
TPID (Tag Protocol Identifier,
0x8100), TCI (Tag Control Information: PCP, DEI, VID). -
VID (12 bits) supports 4094 VLANs (1–4094, 0 and 4095 reserved).
-
-
Trunk Port: Carries multiple VLANs (tagged); Access Port: single VLAN (untagged).
8.5 Cryptography Basics
-
Symmetric Encryption: Same key for encrypt/decrypt (AES, DES). Fast, key distribution problem.
-
Asymmetric Encryption: Public/private key pair (RSA, ECC). Slow, solves key distribution.
-
Digital Signature: Hash of message encrypted with sender's private key → authenticity, integrity.
-
Certificates: Bind public key to entity (X.509), issued by CA (Certificate Authority).
-
Role in Security:
-
Confidentiality: Encryption.
-
Integrity: Hash functions (SHA-256), digital signatures.
-
Authentication: Digital signatures, certificates.
-
Non-repudiation: Digital signatures.
-
8.6 Broadcast & Multicast Routing
-
Broadcast: To all nodes in network (e.g., ARP). Flooding (TTL=1 in IPv4) but wasteful.
-
Multicast: To group of interested nodes (e.g., video streaming).
-
IGMP (Internet Group Management Protocol): Hosts join/leave multicast groups on local network.
-
Multicast Routing Protocols:
-
DVMRP (Distance Vector Multicast Routing Protocol): Reverse path forwarding, prune/graft.
-
PIM (Protocol Independent Multicast): Sparse Mode (RP, shared tree), Dense Mode (flood & prune).
-
-
Source-Specific Multicast (SSM): Receiver specifies source.
-
8.7 Network Topology Design
| Topology | Advantages | Disadvantages | Use Case |
|---|---|---|---|
| Star | Easy to manage, single link failure doesn't affect others | Hub/switch failure fatal | Ethernet LANs |
| Bus | Simple, cheap | Collisions, single failure fatal | Legacy Ethernet (10BASE2) |
| Ring | Deterministic access, no collisions | Single failure breaks ring | Token Ring, FDDI |
| Mesh | High reliability, multiple paths | Expensive, complex | Backbone networks, Internet |
| Tree (hierarchical) | Scalable, easy to expand | Root node failure critical | Large LANs, hierarchical networks |
| Hybrid | Flexible, combines benefits | Complex design | Enterprise networks |
Design Considerations:
-
Cost: Cabling, devices.
-
Reliability: Redundancy (mesh, dual-homed star).
-
Scalability: Ease of adding nodes.
-
Performance: Latency, bandwidth, collision domains.
-
Maintainability: Troubleshooting, modularity.
8.8 Internet Standards & RFCs
-
RFC (Request for Comments): IETF documents Internet standards.
-
Categories:
Informational,Experimental,Best Current Practice (BCP),Internet Standard (STD). -
Process: Internet Draft → RFC (after review).
-
-
TCP/IP Standardization:
-
IETF (Internet Engineering Task Force): Develops standards (working groups).
-
IESG (Internet Engineering Steering Group): Approves standards.
-
IAB (Internet Architecture Board): Oversees architecture.
-
IRTF (Internet Research Task Force): Long-term research.
-
-
Key RFCs: RFC 791 (IP), RFC 793 (TCP), RFC 768 (UDP), RFC 2460 (IPv6), RFC 1034/1035 (DNS).
[!TIP] Final Exam Strategy:
- Definitions first: Always start with clear definition (e.g., "CRC is...").
- Formulas boxed: Nyquist, Shannon, throughput calculations.
- Diagrams in mind: OSI/TCP/IP layers, TCP header, IPv4 header, Ethernet frame, sliding window.
- Compare/contrast: OSI vs TCP/IP, DVR vs LSR, TCP vs UDP, hub/switch/router, circuit/packet switching.
- Numerical practice: Subnetting, CRC, Nyquist/Shannon, TDM frame size, min Ethernet frame, ALOHA throughput.
- Protocol operations: ARP request/reply, DNS iterative/recursive, TCP handshake, CSMA/CD steps.
- Real-world examples: Mention Ethernet (802.3), Wi-Fi (802.11), OSPF, BGP, HTTP/2, QUIC where relevant.
Key Formulas Summary:
-
Nyquist: $$\displaystyle \boxed{R_{\max} = 2B \log_2 M} $$
-
Shannon: $$\displaystyle \boxed{C = B \log_2(1 + \text{SNR})} $$
-
Stop-and-Wait Efficiency: $$\displaystyle \boxed{U = \frac{1}{1 + 2a}} $$, $$\displaystyle a = \frac{\text{prop delay}}{\text{frame tx time}} $$
-
Slotted ALOHA Throughput: $$\displaystyle \boxed{S = G e^{-G}} $$, max $0.368$ at $$\displaystyle G=1 $$
-
Pure ALOHA Throughput: $$\displaystyle \boxed{S = G e^{-2G}} $$, max $0.184$ at $$\displaystyle G=0.5 $$
-
CSMA/CD Minimum Frame: $$\displaystyle \boxed{\text{Min Frame} \ge 2 \times \text{Prop Delay} \times \text{Bandwidth}} $$
-
GBN Utilization: $$\displaystyle \boxed{U = \frac{W_s}{1 + 2a}} $$ (if $$\displaystyle W_s \le 1+2a $$)