Skip to content

Computer Networks: Complete MCQ Revision Notes ​

Legend: ⭐ = asked very often · ⚠️ = trap · All numerical examples were checked by running code. (Cryptography and network security are in the separate file 04_Crypto_Network_Security_Revision.md.)

Contents

  1. Basics (types, topologies, switching, delays)
  2. OSI and TCP/IP models, devices
  3. Physical layer
  4. Data link layer (framing, errors, ARQ, MAC protocols, Ethernet, Wi-Fi, ARP)
  5. Network layer (IPv4, subnetting, header, fragmentation, IPv6, ICMP, NAT, DHCP, routing)
  6. Transport layer (UDP, TCP, congestion control)
  7. Application layer (ports, DNS, HTTP, email, FTP, SNMP)
  8. Rapid-fire trap list

1. Basics ​

  • By scale: PAN (~10 m; Bluetooth), LAN (building/campus; Ethernet, Wi-Fi), MAN (city; cable TV, WiMAX), WAN (country/global; the Internet). Also CAN (campus), SAN (storage).

1.1 Topologies ⭐⭐ ​

TopologyLinks for n devicesNotes
Mesh (full)n(n βˆ’ 1)/2 links; n βˆ’ 1 ports per deviceMost robust, most expensive
Starn links (to a hub/switch)Central device failure kills the network; easy to install and troubleshoot
Bus1 backbone + n drop linesCheap; backbone failure kills everything; collisions
Ringn linksToken passing; one break can stop the ring (dual ring in FDDI)
Tree, hybrid
  • Transmission modes: simplex (one way: keyboard, TV broadcast), half-duplex (both ways, one at a time: walkie-talkie), full-duplex (both ways at once: telephone).

1.2 Switching ⭐⭐ ​

Circuit switchingPacket switching (datagram)Virtual circuit
Dedicated path reserved; setup phase; telephone networkEach packet routed independently; no setup; the Internet (IP)Setup phase, then all packets follow the same path; VCI labels; ATM, Frame Relay, MPLS
Guaranteed bandwidth, wasted when idleEfficient; packets may be reordered or lost; store-and-forwardIn-order delivery

Message switching = store-and-forward of whole messages (old telegraph networks).

1.3 Delays ⭐⭐⭐ ​

  • Transmission delay = L / R (packet size in bits / link bandwidth).
  • Propagation delay = d / s (distance / signal speed β‰ˆ 2 Γ— 10⁸ m/s in cable and fiber, 3 Γ— 10⁸ m/s in air).
  • Plus queuing delay and processing delay. Store-and-forward over N links: end-to-end β‰ˆ NΒ·(L/R) + NΒ·d_prop (ignoring queuing and processing).
  • RTT β‰ˆ 2 Γ— propagation delay (plus other delays). Bandwidth–delay product = bandwidth Γ— propagation delay = the most bits that can be "in the pipe".
  • Throughput = actual data rate (≀ bandwidth); the bottleneck link sets end-to-end throughput.
  • Standards bodies: IEEE (802.x LANs), IETF (RFCs, Internet protocols), ISO (OSI model), ITU-T (telecom), ANSI, W3C (web), IANA/ICANN (IP addresses, port numbers, domain names), regional registries (APNIC for Asia-Pacific).

2. OSI and TCP/IP Models ⭐⭐⭐ ​

OSI (ISO, 7 layers). Bottom-up mnemonic: "Please Do Not Throw Sausage Pizza Away".

#LayerPDUKey functionsProtocols / devices
7ApplicationData / messageNetwork services for user applicationsHTTP, FTP, SMTP, DNS, Telnet, SSH, SNMP, DHCP
6PresentationDataTranslation (formats, ASCII ↔ EBCDIC), encryption/decryption, compressionSSL/TLS (often mapped here), JPEG, MPEG, GIF, MIME
5SessionDataDialog control (half/full duplex), synchronization (checkpoints), session setup/teardown, token managementNetBIOS, RPC
4TransportSegment (TCP) / datagram (UDP)Process-to-process (end-to-end) delivery, port addressing, segmentation and reassembly, end-to-end flow and error control, connection controlTCP, UDP, SCTP
3NetworkPacket (datagram)Logical (IP) addressing, routing, host-to-host delivery, fragmentationIP, ICMP, IGMP, OSPF; router, L3 switch
2Data linkFrameFraming, physical (MAC) addressing, hop-to-hop flow and error control (CRC trailer), media access control. Sublayers: LLC (802.2) + MACEthernet, PPP, HDLC, 802.11; switch, bridge, NIC
1PhysicalBitBit transmission, encoding/signaling, data rate, bit synchronization, physical topology, transmission mode, connectorsCables, RJ-45, hub, repeater, modem

Quick "which layer?" answers ⭐⭐:

  • Routing β†’ Network Β· framing β†’ Data link Β· dialog control / synchronization / token management β†’ Session Β· encryption, compression, translation β†’ Presentation Β· end-to-end delivery and port numbers β†’ Transport Β· MAC address β†’ Data link Β· IP address β†’ Network Β· voltages / bit encoding β†’ Physical.

  • Error detection: data link (CRC trailer) and transport (TCP/UDP checksum). Congestion control: transport (TCP), also network. Only the data link layer adds a trailer.

  • TCP/IP model: Application (= OSI 5–7) | Transport | Internet | Network access / link (= OSI 1–2). Kurose and Forouzan teach a 5-layer version: Application, Transport, Network, Link, Physical. TCP/IP came first (ARPANET/DoD); OSI is a reference model.

  • Encapsulation: each layer adds a header (data link adds header + trailer); the receiver decapsulates.

  • Addresses: physical/MAC (48-bit, L2, changes at every hop), logical/IP (32-bit IPv4, 128-bit IPv6, L3, end-to-end except with NAT), port (16-bit, L4, identifies the process), application-specific (URL, email).

2.1 Devices ⭐⭐⭐ ​

DeviceLayerCollision domainsBroadcast domainsNotes
Repeater1Doesn't splitDoesn't splitRegenerates the signal (an amplifier also boosts noise)
Hub1One for all portsOneMultiport repeater; half duplex
Bridge2Splits (one per port)OneFilters by MAC; joins LAN segments
Switch2 (L3 switches exist)One per portOne (unless VLANs)Multiport bridge; MAC/CAM table; full duplex
Router3One per interfaceOne per interface (stops broadcasts)Routes by IP; joins different networks
GatewayUp to 7Protocol converter between different architectures
Modem1Modulator–demodulator: digital ↔ analog
NIC1 and 2Holds the MAC address
Brouter2 and 3Bridge + router
Firewall3 / 4 / 7Filters traffic

Example: a router with 2 interfaces, each to a switch with 5 hosts β†’ 2 broadcast domains, 12 collision domains (each switch: 5 host ports + 1 uplink). With hubs instead of switches β†’ 2 collision domains.


3. Physical Layer ​

  • Guided media: twisted pair (UTP/STP; twisting reduces crosstalk/EMI; RJ-45; Cat5e β†’ 1 Gbps, Cat6 β†’ 10 Gbps up to ~55 m, Cat6a β†’ 10 Gbps at 100 m), coaxial (BNC; cable TV, old 10Base2/10Base5 Ethernet), fiber optic (light by total internal reflection; single-mode: thin core, laser, long distance; multimode: LED, shorter runs; immune to EMI, highest bandwidth, lowest attenuation, hard to tap).
  • Unguided media: radio waves (3 kHz–1 GHz; omnidirectional; pass through walls), microwaves (1–300 GHz; unidirectional, line of sight; satellite and cellular), infrared (300 GHz–400 THz; short range; blocked by walls; remotes).
  • Impairments: attenuation (loss of energy, in dB; fixed with amplifiers/repeaters), distortion (frequency components arrive at different times), noise (thermal, induced, crosstalk, impulse).
  • dB = 10Β·log₁₀(P2/P1). SNR_dB = 10Β·log₁₀(SNR).

3.1 Capacity formulas ⭐⭐⭐ ​

  • Nyquist (noiseless channel): max bit rate = 2Β·BΒ·logβ‚‚(L) (B = bandwidth in Hz, L = signal levels). 3 kHz with 2 levels β†’ 6 kbps; with 4 levels β†’ 12 kbps.
  • Shannon (noisy channel): capacity C = BΒ·logβ‚‚(1 + SNR) (SNR as a ratio, not dB). B = 3,000 Hz, SNR = 3,162 (β‰ˆ 35 dB) β†’ β‰ˆ 34.9 kbps. B = 4 kHz, SNR = 63 β†’ 4,000 Γ— 6 = 24 kbps. SNR = 0 β†’ C = 0.
  • Shannon gives the upper limit; Nyquist tells how many levels you need.
  • Bit rate = baud rate Γ— logβ‚‚(L) (baud = signal elements per second).

3.2 Encoding, modulation, multiplexing ​

  • Line coding: NRZ-L, NRZ-I, RZ, Manchester (a transition in the middle of every bit β†’ self-clocking; 10 Mbps Ethernet; needs twice the bandwidth), Differential Manchester (Token Ring), AMI (bipolar), B8ZS/HDB3 (scrambling). Block coding: 4B/5B (Fast Ethernet), 8B/10B (Gigabit over fiber), 64B/66B (10 GbE).
  • Digital β†’ analog modulation: ASK, FSK, PSK, QAM (amplitude + phase; most bandwidth-efficient). Analog β†’ analog: AM, FM, PM. Analog β†’ digital: PCM (sample at β‰₯ 2 Γ— the highest frequency, the Nyquist sampling theorem), delta modulation.
  • Multiplexing: FDM (analog; radio/TV), WDM (optical FDM), TDM (synchronous = fixed slots; statistical = slots on demand), CDMA (codes).
  • Spread spectrum: FHSS (Bluetooth), DSSS (802.11b).

4.1 Framing ​

  • Character count; byte stuffing (flag + ESC byte; PPP); bit stuffing (HDLC flag 01111110; after five consecutive 1s insert a 0); physical-layer coding violations.
  • Bit-stuffing example (checked): 011111110 β†’ 0111110110.

4.2 Error detection and correction ⭐⭐⭐ ​

  • Single-bit error vs burst error (length = first to last corrupted bit).
  • Parity: simple even/odd parity detects all odd numbers of bit errors and misses even numbers. 2-D parity detects all 1-, 2- and 3-bit errors and can correct single-bit errors; misses some 4-bit patterns.
  • Internet checksum: 16-bit one's-complement sum, then complemented. Used by the IPv4 header, TCP, UDP, ICMP. The receiver's sum including the checksum must be all 1s.
  • CRC ⭐⭐: generator polynomial of degree r (r + 1 bits). The sender appends r zeros, divides by the generator using mod-2 (XOR) division, and sends the r-bit remainder (the CRC) after the data. The receiver divides the codeword; remainder 0 β†’ no error detected.
    • Detects all single-bit errors; all double-bit errors (with a suitable generator); all odd-numbered errors if (x + 1) is a factor; all bursts of length ≀ r. Ethernet uses CRC-32.
    • Example (checked): data 1101011111, generator 10011 (x⁴ + x + 1) β†’ CRC 0010 β†’ send 11010111110010.
    • Example: data 1101, generator 1011 (xΒ³ + x + 1) β†’ CRC 001 β†’ send 1101001.
  • Hamming distance rules ⭐⭐: to detect s errors you need d_min β‰₯ s + 1; to correct t errors you need d_min β‰₯ 2t + 1.
  • Hamming code: check bits r for m data bits satisfy 2^r β‰₯ m + r + 1 (m = 4 β†’ r = 3, giving Hamming(7,4); m = 7 β†’ 4; m = 8 β†’ 4; m = 16 β†’ 5; m = 32 β†’ 6). Parity bits sit at positions 1, 2, 4, 8, …; parity bit p covers positions whose binary index includes p. The syndrome gives the error position. Example (even parity): data 1011 β†’ codeword 0110011. Single-error correction (SEC); SEC-DED with one extra parity bit.
  • Forward error correction (FEC) vs retransmission (ARQ).

4.3 Flow and error control (ARQ) ⭐⭐⭐ ​

Let Tt = transmission time = L/B, Tp = propagation delay, a = Tp/Tt, k = sequence-number bits.

ProtocolSender windowReceiver windowRetransmitsEfficiency (no errors)
Stop-and-wait11The same frame on timeout; 1-bit sequence numbers (0/1)Ξ· = 1 / (1 + 2a)
Go-Back-N≀ 2^k βˆ’ 11The lost frame and everything after it; cumulative ACKsΞ· = N / (1 + 2a) (max 1)
Selective Repeat≀ 2^(kβˆ’1)= sender windowOnly lost/corrupted frames; NAKs; receiver buffers and reordersΞ· = W / (1 + 2a) (max 1)
  • Throughput = Ξ· Γ— bandwidth. Full utilization needs W β‰₯ 1 + 2a. Bits needed: GBN 2^k β‰₯ W + 1; SR 2^k β‰₯ 2W.
  • Example (checked): 1 Mbps, 1,000-bit frames (Tt = 1 ms), Tp = 2 ms β†’ a = 2 β†’ stop-and-wait Ξ· = 1/5 = 20% (200 kbps); full use needs a window of 5.
  • Piggybacking: ACKs carried inside data frames (full duplex).

4.4 Multiple access ⭐⭐⭐ ​

Random access

  • Pure ALOHA: send any time; vulnerable time = 2Β·T_fr; S = GΒ·e^(βˆ’2G); max 18.4% at G = 0.5.
  • Slotted ALOHA: send only at slot boundaries; vulnerable time = T_fr; S = GΒ·e^(βˆ’G); max 36.8% at G = 1.
  • CSMA (listen before talking): 1-persistent (send as soon as idle; used by Ethernet; most collisions), non-persistent (wait a random time if busy), p-persistent (slotted; send with probability p).
  • CSMA/CD (wired Ethernet, 802.3): detect the collision while sending β†’ jam signal β†’ binary exponential backoff. Requirement Tt β‰₯ 2Β·Tp, so minimum frame size = 2Β·TpΒ·B. Classic Ethernet: 512 bits = 64 bytes (slot time 51.2 Β΅s at 10 Mbps). Efficiency β‰ˆ 1/(1 + 6.44a) (Kurose approximates 1/(1 + 5a)).
    • Example (checked): 10 Mbps, 2 km cable, 2 Γ— 10⁸ m/s β†’ Tp = 10 Β΅s β†’ L_min = 2 Γ— 10 Β΅s Γ— 10 Mbps = 200 bits.
  • Binary exponential backoff: after the nth collision pick K from {0, …, 2^n βˆ’ 1} (n capped at 10, so K ≀ 1023) and wait K Γ— slot time; give up after 16 attempts.
  • CSMA/CA (wireless 802.11): collisions can't be detected reliably (hidden-station problem, half-duplex radios), so they are avoided: IFS (DIFS/SIFS), random backoff (contention window), ACKs, optional RTS/CTS with NAV (virtual carrier sensing).

Controlled access: reservation, polling (primary/secondary; poll and select), token passing (Token Ring 802.5, Token Bus 802.4, FDDI). Channelization: FDMA, TDMA, CDMA.

4.5 Ethernet (IEEE 802.3) ⭐⭐⭐ ​

  • Frame: Preamble 7 B + SFD 1 B | Destination MAC 6 | Source MAC 6 | Type/Length 2 | Data 46–1500 | CRC 4. Frame size excluding preamble/SFD = 64 to 1,518 bytes (1,522 with an 802.1Q tag). MTU = 1,500 bytes. Jumbo frames β‰ˆ 9,000.
  • Connectionless and unreliable at L2 (no ACKs).
  • Variants: 10Base5 (thick coax, 500 m), 10Base2 (thin coax, 185 m), 10Base-T (twisted pair, 100 m), 10Base-F (fiber); Fast Ethernet 100Base-TX; Gigabit 1000Base-T (Cat5e), 1000Base-SX/LX (fiber); 10GBase-T. "10Base-T" = 10 Mbps, baseband, twisted pair. Classic 5-4-3 rule: ≀ 5 segments, 4 repeaters, 3 populated segments.
  • MAC address: 48 bits (6 bytes, hex, e.g., 00:1A:2B:3C:4D:5E). First 24 bits = OUI (vendor). Broadcast = FF:FF:FF:FF:FF:FF. Least significant bit of the first byte: 0 = unicast, 1 = multicast.
  • Switches: learn source MACs into the MAC (CAM) table; forward/filter by destination; flood unknown unicast and broadcast frames. Store-and-forward vs cut-through vs fragment-free switching.
  • STP (802.1D Spanning Tree Protocol): stops loops and broadcast storms in redundant switched networks; elects the root bridge (lowest bridge ID = priority + MAC); blocks redundant ports. RSTP (802.1w) converges faster.
  • VLAN (802.1Q): logical broadcast domains on one switch; 4-byte tag with a 12-bit VLAN ID (4,094 usable). Trunk vs access ports. Traffic between VLANs needs a router or L3 switch.
  • IEEE numbers: 802.1 (bridging: 802.1Q VLAN, 802.1D STP, 802.1X port-based authentication/EAP), 802.2 LLC, 802.3 Ethernet, 802.4 Token Bus, 802.5 Token Ring, 802.11 Wi-Fi, 802.15.1 Bluetooth, 802.15.4 Zigbee, 802.16 WiMAX.

4.6 Wireless LAN (802.11) ⭐ ​

StandardBandMax rate
802.11b2.4 GHz11 Mbps
802.11a5 GHz54 Mbps
802.11g2.4 GHz54 Mbps
802.11n (Wi-Fi 4)2.4 / 5 GHz600 Mbps (MIMO)
802.11ac (Wi-Fi 5)5 GHz~6.9 Gbps (MU-MIMO)
802.11ax (Wi-Fi 6/6E)2.4 / 5 (+ 6 GHz for 6E)~9.6 Gbps (OFDMA)
802.11be (Wi-Fi 7)2.4 / 5 / 6 GHz~46 Gbps
  • BSS (stations + access point), IBSS (ad hoc), ESS (several BSSs joined by a distribution system), SSID. MAC: CSMA/CA (DCF) or polling (PCF). An 802.11 frame can carry up to 4 address fields.
  • Bluetooth (802.15.1): piconet = 1 master (primary) + up to 7 active slaves (up to 255 parked); scatternet = connected piconets; 2.4 GHz with FHSS.

4.7 HDLC and PPP ​

  • HDLC: bit-oriented. Frame types: I-frames (information), S-frames (supervisory: RR, RNR, REJ, SREJ), U-frames (unnumbered: link management). Modes NRM, ABM, ARM.
  • PPP: byte-oriented, point-to-point (dial-up, DSL via PPPoE). LCP (link setup and negotiation), NCP (network-layer configuration, e.g., IPCP). Authentication PAP (plaintext, 2-way) and CHAP (challenge–response, 3-way, repeated periodically). No flow control or sequence numbers by default.

4.8 ARP family ⭐⭐ ​

  • ARP: IP address β†’ MAC address inside a LAN. Request is broadcast, reply is unicast; results cached (with timeout). Carried directly in an Ethernet frame (EtherType 0x0806).
  • Gratuitous ARP (announce your own IP/MAC, detect conflicts); proxy ARP (a router answers for hosts on another network); ARP spoofing/poisoning attack.
  • RARP (MAC β†’ IP; obsolete) β†’ BOOTP β†’ DHCP. IPv6 replaces ARP with NDP (Neighbor Discovery, over ICMPv6).
  • Layer: Forouzan treats ARP as a network-layer helper protocol; many MCQs accept "data link" or "between L2 and L3". Go by the options given.

5. Network Layer ⭐⭐⭐ ​

5.1 IPv4 addressing ​

  • 32 bits, dotted decimal, 2^32 β‰ˆ 4.3 billion addresses; network part + host part.
ClassLeading bitsFirst octetDefault maskNetworksHosts per network
A00–127 (1–126 usable)/8 (255.0.0.0)2^7 = 128 (126 usable)2^24 βˆ’ 2 = 16,777,214
B10128–191/16 (255.255.0.0)2^14 = 16,3842^16 βˆ’ 2 = 65,534
C110192–223/24 (255.255.255.0)2^21 = 2,097,1522^8 βˆ’ 2 = 254
D1110224–239n/aMulticastn/a
E1111240–255n/aReserved / experimentaln/a

Special addresses ⭐⭐:

  • Network address: host bits all 0 (not assignable). Directed broadcast: host bits all 1 (all hosts on that network). Limited broadcast: 255.255.255.255 (local network only; routers don't forward it).
  • 0.0.0.0: "this host" / unspecified (source address in DHCP Discover) or the default route 0.0.0.0/0.
  • Loopback 127.0.0.0/8 (127.0.0.1 = localhost). Link-local / APIPA 169.254.0.0/16 (self-assigned when DHCP fails).
  • Multicast 224.0.0.0/4 (224.0.0.1 all hosts, 224.0.0.5/.6 OSPF, 224.0.0.9 RIPv2).
  • Private (RFC 1918) ⭐: 10.0.0.0/8, 172.16.0.0/12 (172.16.0.0–172.31.255.255), 192.168.0.0/16. CGNAT shared space: 100.64.0.0/10.

5.2 Subnetting and CIDR ⭐⭐⭐ ​

  • Mask /n = n network bits. Usable hosts = 2^(32 βˆ’ n) βˆ’ 2 (exceptions: /31 point-to-point links have 2 usable (RFC 3021); /32 = a single host).
  • Borrowing s bits creates 2^s subnets (very old texts used 2^s βˆ’ 2, excluding "subnet zero").
  • Block size (magic number) = 256 βˆ’ mask value in the interesting octet.
CIDRMaskBlock sizeUsable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
/23255.255.254.02 (3rd octet)510
/22255.255.252.04 (3rd octet)1,022
/20255.255.240.016 (3rd octet)4,094
  • Network address = IP AND mask. Broadcast = network OR (NOT mask). First host = network + 1; last host = broadcast βˆ’ 1.

Examples (checked):

  • 192.168.10.77/27 β†’ network 192.168.10.64, broadcast .95, hosts .65–.94 (30 hosts).
  • 172.16.45.200/20 β†’ network 172.16.32.0, broadcast 172.16.47.255.
  • At least 50 subnets from 172.16.0.0/16 with the most hosts per subnet β†’ borrow 6 bits (64 subnets) β†’ /22 = 255.255.252.0, 1,022 hosts each.
  • A class C network split into β‰₯ 5 subnets β†’ borrow 3 bits β†’ /27 β†’ 8 subnets Γ— 30 hosts.
  • 500 hosts per subnet β†’ 2^9 βˆ’ 2 = 510 β†’ /23 (255.255.254.0).
  • Supernetting / route aggregation: 192.168.0.0/24 + .1.0 + .2.0 + .3.0 β†’ 192.168.0.0/22 (the blocks must be contiguous, aligned, and a power of 2 in number).
  • VLSM: give the largest subnets out first. Longest prefix match: a router uses the most specific matching route.
  • Wildcard mask (Cisco ACLs/OSPF) = inverted subnet mask (/24 β†’ 0.0.0.255).

5.3 IPv4 header (20–60 bytes) ⭐⭐⭐ ​

FieldBitsNotes
Version44
HLEN (IHL)4Header length in 4-byte words: 5 (20 B) to 15 (60 B)
DSCP/ECN (ToS)8QoS
Total length16Header + data; max 65,535 bytes
Identification16Same value in every fragment of one datagram
Flags3Reserved, DF (don't fragment), MF (more fragments)
Fragment offset13In units of 8 bytes
TTL8Decremented at each hop; at 0 β†’ discard + ICMP Time Exceeded. Typical starting values: 64 (Linux/macOS), 128 (Windows), 255 (routers)
Protocol81 ICMP, 2 IGMP, 6 TCP, 17 UDP, 41 IPv6-in-IPv4, 50 ESP, 51 AH, 88 EIGRP, 89 OSPF
Header checksum16Header only; recomputed at every router (TTL changes)
Source / destination IP32 + 32
Options0–40 BRecord route, timestamp, source routing

5.4 Fragmentation ⭐⭐⭐ ​

  • Needed when a datagram is larger than the next link's MTU. In IPv4, routers or the source may fragment; reassembly happens only at the final destination. DF = 1 and too big β†’ drop + ICMP "fragmentation needed" (used by Path MTU Discovery).
  • Each fragment gets its own IP header. Data in every fragment except the last must be a multiple of 8 bytes. Offset = (byte position of the fragment's data in the original payload) / 8. MF = 1 on every fragment except the last.
  • Example (checked) ⭐: a 4,000-byte datagram (20 B header + 3,980 B data) over MTU 1,500 β†’ max 1,480 data bytes per fragment β†’ 3 fragments:
FragmentData bytesTotal lengthOffsetMF
11,4801,50001
21,4801,5001851
31,0201,0403700

5.5 IPv6 ⭐⭐⭐ ​

  • 128-bit addresses (2^128): 8 groups of 4 hex digits. Leading zeros in a group can be dropped, and one run of consecutive zero groups can be replaced by "::" (only once). 2001:0db8:0000:0000:0000:ff00:0042:8329 β†’ 2001:db8::ff00:42:8329.
  • Fixed 40-byte base header: Version (4), Traffic class (8), Flow label (20), Payload length (16), Next header (8), Hop limit (8), Source (128), Destination (128). Options go in extension headers (hop-by-hop, routing, fragment, AH, ESP, destination options).
  • Differences from IPv4 ⭐⭐: no header checksum; routers never fragment (only the source does, using the fragment extension header and Path MTU discovery; minimum MTU 1,280 B); no broadcast (multicast and anycast instead); IPsec support built in; auto-configuration (SLAAC, EUI-64 interface IDs); NDP (ICMPv6) replaces ARP; hop limit replaces TTL; flow label for QoS.
  • Address types: unicast (global 2000::/3, link-local fe80::/10, unique local fc00::/7), multicast ff00::/8 (ff02::1 = all nodes), anycast (delivered to the nearest member). Loopback ::1; unspecified ::; IPv4-mapped ::ffff:a.b.c.d.
  • Transition: dual stack, tunneling (6to4, Teredo), translation (NAT64/DNS64).

5.6 ICMP ⭐⭐ ​

  • Error reporting and diagnostics for IP; carried inside IP (protocol 1); no port numbers.
  • Types: 0 Echo Reply, 3 Destination Unreachable (net, host, protocol, port unreachable; fragmentation needed), 4 Source Quench (deprecated), 5 Redirect, 8 Echo Request, 11 Time Exceeded (TTL hit 0 or reassembly timeout), 12 Parameter Problem.
  • No ICMP error is generated for: an ICMP error message, a non-first fragment, datagrams to multicast/broadcast addresses, special addresses (127.x, 0.0.0.0).
  • ping = echo request/reply. traceroute (UNIX: UDP probes to high ports with TTL 1, 2, 3, …; routers return Time Exceeded, the destination returns Port Unreachable). tracert (Windows: ICMP echo).
  • IGMP (protocol 2): hosts report multicast group membership to local routers.

5.7 NAT and DHCP ⭐⭐ ​

  • NAT translates private ↔ public addresses at the border router. Static NAT (1:1), dynamic NAT (pool), PAT / NAPT / NAT overload (many private hosts share one public IP using port numbers, as in home routers). Saves IPv4 addresses and hides internal hosts; breaks the end-to-end principle and causes trouble for P2P, IPsec AH and inbound connections (needs port forwarding).
  • DHCP gives automatic IP configuration (IP, mask, gateway, DNS, lease). Runs over UDP: server port 67, client port 68. DORA: Discover (client broadcast, from 0.0.0.0 to 255.255.255.255) β†’ Offer (server) β†’ Request (client broadcast naming the chosen server) β†’ Ack (server).
    • Renewal at T1 = 50% of the lease (unicast to the server); rebinding at T2 = 87.5% (broadcast). A DHCP relay agent forwards across subnets. Successor of BOOTP. Attacks: DHCP starvation, rogue DHCP server (defense: DHCP snooping).

5.8 Routing ⭐⭐⭐ ​

  • Routing (control plane: build routing tables) vs forwarding (data plane: send each packet to an output port using the forwarding table). SDN moves the control plane into a central controller.
  • Static (manual) vs dynamic (protocols); default route 0.0.0.0/0.
  • Link state: every router learns the whole topology by flooding LSAs and runs Dijkstra; fast convergence; more CPU and memory.
  • Distance vector: each router knows only its neighbors' vectors; Bellman–Ford; periodically sends its whole table to neighbors; slow convergence; count-to-infinity problem.
  • Path vector (BGP): carries the full AS path β†’ loop prevention; policy-based. Flooding: send on every link; robust; used to spread link-state advertisements.
  • Count-to-infinity fixes: split horizon, poison reverse (advertise ∞ back to the neighbor you learned the route from), hold-down timers, triggered updates, route poisoning, maximum hop count.
ProtocolTypeMetricRuns overFacts
RIP v1/v2Distance vectorHop count; max 15, 16 = infinityUDP 520Updates every 30 s; v2 is classless (CIDR), multicasts to 224.0.0.9, supports authentication; RIPng for IPv6
OSPFLink stateCost (∝ 1/bandwidth)IP protocol 89 (no TCP/UDP)Dijkstra; areas with backbone area 0; DR/BDR on multi-access links; hello packets; 224.0.0.5/.6; fast convergence; OSPFv3 for IPv6
IS-ISLink stateCostDirectly over L2Used by ISPs
EIGRPAdvanced distance vector ("hybrid")Bandwidth + delayIP protocol 88Cisco-originated (published as RFC 7868); DUAL algorithm; loop-free
BGP-4Path vectorPath attributes / policyTCP 179Between autonomous systems (the Internet's routing protocol); eBGP between ASes, iBGP inside one
  • Interior gateway protocols (IGP: RIP, OSPF, IS-IS, EIGRP) work inside one AS; exterior (EGP: BGP) between ASes.
  • Administrative distance (Cisco; lower = more trusted): connected 0, static 1, eBGP 20, EIGRP 90, OSPF 110, IS-IS 115, RIP 120, iBGP 200.
  • Autonomous system (AS) = networks under one administration, identified by an ASN (16-bit, now 32-bit).
  • Multicast routing: DVMRP, MOSPF, PIM-DM/SM. MPLS: label switching between L2 and L3 ("layer 2.5"), used by ISPs for traffic engineering and VPNs.

6. Transport Layer ⭐⭐⭐ ​

  • Process-to-process delivery. Port numbers are 16 bits (0–65535): well-known 0–1023, registered 1024–49151, dynamic/ephemeral 49152–65535. Socket = IP address + port.
  • Demultiplexing: a UDP socket is identified by (destination IP, destination port); a TCP socket by the 4-tuple (source IP, source port, destination IP, destination port), which is why one web server has many sockets on port 443.

6.1 UDP ⭐⭐ ​

  • Connectionless, unreliable (no ACK/retransmission), no flow or congestion control, no ordering, message-oriented (keeps message boundaries), low overhead, supports broadcast and multicast.
  • 8-byte header: source port, destination port, length (header + data), checksum. The checksum is optional in IPv4 (0 = unused) and mandatory in IPv6; it covers a pseudo-header (source/destination IP, protocol, length) + header + data.
  • Max UDP payload over IPv4 = 65,535 βˆ’ 20 βˆ’ 8 = 65,507 bytes.
  • Used by DNS (queries), DHCP, TFTP, SNMP, RIP, NTP, Syslog, VoIP/RTP, video streaming, online games, QUIC/HTTP/3.

6.2 TCP ⭐⭐⭐ ​

  • Connection-oriented, reliable, in-order byte stream, full duplex, point-to-point only (no broadcast/multicast), flow control, congestion control, error control (checksum, ACKs, retransmission). Sequence numbers count bytes, not segments.
  • Header 20–60 bytes: source port 16 | destination port 16 | sequence number 32 | acknowledgment number 32 (= next byte expected; cumulative) | HLEN 4 (in 4-byte words) | reserved | flags URG, ACK, PSH, RST, SYN, FIN (+ ECE, CWR) | window size 16 (receive window; max 65,535, or up to ~1 GB with the window-scale option) | checksum 16 (mandatory) | urgent pointer 16 | options (MSS, window scale, SACK, timestamps, NOP).
  • MSS = max TCP payload per segment: typically 1,460 on Ethernet (1,500 βˆ’ 20 βˆ’ 20); 536 by default if not negotiated.
  • Three-way handshake ⭐⭐⭐: client β†’ SYN (seq = x) β†’ server β†’ SYN+ACK (seq = y, ack = x + 1) β†’ client β†’ ACK (seq = x + 1, ack = y + 1). SYN and FIN each consume one sequence number; a pure ACK consumes none. ISNs are random (for security). The client's first data byte has seq = x + 1.
  • Termination: FIN β†’ ACK β†’ FIN β†’ ACK (4-way; or 3-way using FIN+ACK); half-close is possible. The side that closes first (active closer) waits in TIME_WAIT for 2 Γ— MSL, so the last ACK gets through and old duplicates expire.
  • States: CLOSED, LISTEN, SYN_SENT, SYN_RCVD, ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, CLOSE_WAIT, CLOSING, LAST_ACK, TIME_WAIT.
  • RST aborts a connection or refuses one (closed port). SYN flood: attacker sends many SYNs and leaves half-open connections β†’ defenses: SYN cookies, backlog limits.
  • Sequence-number wrap-around time = 2^32 bytes Γ· bandwidth in bytes/s (1 Gbps β†’ ~34 s; timestamps/PAWS protect against old segments).
  • Flow control: the receiver advertises rwnd; data in flight ≀ min(rwnd, cwnd). Zero window β†’ persist timer sends probes. Silly window syndrome: sender-side fix = Nagle's algorithm (hold small data until an ACK arrives or a full MSS is ready); receiver-side fix = Clark's solution (advertise 0 until a useful window opens) / delayed ACK.
  • Max throughput β‰ˆ window / RTT (64 KB window, 100 ms RTT β†’ ~5.24 Mbps).
  • Error control: cumulative ACKs; retransmit on timeout or after 3 duplicate ACKs (fast retransmit); SACK option; out-of-order segments are usually buffered.
  • RTO estimation (Jacobson/Karels): EstimatedRTT = (1 βˆ’ Ξ±)Β·EstimatedRTT + Ξ±Β·SampleRTT (Ξ± = 0.125); DevRTT = (1 βˆ’ Ξ²)Β·DevRTT + Ξ²Β·|SampleRTT βˆ’ EstimatedRTT| (Ξ² = 0.25); RTO = EstimatedRTT + 4Β·DevRTT. Karn's algorithm: ignore RTT samples from retransmitted segments and double the RTO after each timeout (exponential backoff).
  • Timers: retransmission, persistence, keepalive, TIME_WAIT (2MSL).

6.3 TCP congestion control ⭐⭐⭐ ​

  • cwnd = sender's congestion window; ssthresh = slow-start threshold.
  • Slow start: cwnd starts at 1 MSS (modern stacks up to 10) and grows by 1 MSS per ACK, i.e., it doubles every RTT (exponential), until ssthresh.
  • Congestion avoidance: once cwnd β‰₯ ssthresh, +1 MSS per RTT (linear, additive increase).
  • Timeout (Tahoe and Reno): ssthresh = cwnd / 2, cwnd = 1 MSS, back to slow start.
  • 3 duplicate ACKs: Tahoe β†’ same as a timeout (cwnd = 1). Reno β†’ fast retransmit + fast recovery: ssthresh = cwnd / 2, cwnd = ssthresh (+3), continue in congestion avoidance.
  • AIMD (additive increase, multiplicative decrease) gives the sawtooth. Modern algorithms: CUBIC (Linux default), BBR (model-based). ECN marks packets instead of dropping them.
  • Example (checked): ssthresh = 16, cwnd per RTT = 1, 2, 4, 8, 16, 17, 18, 19, 20 β†’ timeout β†’ ssthresh = 10, cwnd = 1, 2, 4, 8, 10, 11, … (exponential growth is capped at ssthresh).
  • Other congestion control: choke packets, backpressure, RED (random early detection), admission control.
  • Traffic shaping ⭐: leaky bucket (output at a constant rate, smooths bursts; overflow discarded) vs token bucket (tokens arrive at rate ρ into a bucket of size C; allows bursts up to C). Max burst duration S = C / (M βˆ’ ρ), M = max output rate. Example: C = 500 KB, M = 12 MB/s, ρ = 2 MB/s β†’ S = 50 ms.
  • QoS: IntServ (RSVP, per-flow reservation) vs DiffServ (DSCP classes, per-hop behavior).

6.4 TCP vs UDP ⭐⭐⭐ ​

TCPUDP
ConnectionConnection-oriented (handshake)Connectionless
ReliabilityReliable, ordered, ACKedBest effort, unordered
Flow / congestion controlYesNo
Header20–60 bytes8 bytes
Data unitByte stream (segments)Messages (datagrams), boundaries kept
Broadcast / multicastNoYes
SpeedSlowerFaster, lower latency
Used byHTTP/1.1, HTTP/2, HTTPS, FTP, SMTP, SSH, Telnet, POP3, IMAP, BGPDNS, DHCP, TFTP, SNMP, RIP, NTP, VoIP, streaming, games, QUIC
  • SCTP: message-oriented and reliable; multi-homing and multi-streaming; 4-way handshake with a cookie; used for telephony signaling and WebRTC data channels.
  • QUIC: runs over UDP (port 443); built-in TLS 1.3; 0-RTT/1-RTT setup; independent streams, so no head-of-line blocking between streams; connection migration; the basis of HTTP/3.

7. Application Layer ⭐⭐⭐ ​

7.1 Port numbers (memorize) ⭐⭐⭐ ​

PortProtocolTransport
20 / 21FTP data / controlTCP
22SSH, SCP, SFTPTCP
23TelnetTCP
25SMTP (relay); 587 submission; 465 SMTPSTCP
53DNSUDP for queries; TCP for zone transfers and large responses
67 / 68DHCP server / clientUDP
69TFTPUDP
80HTTPTCP
88KerberosUDP/TCP
110POP3 (995 = POP3S)TCP
123NTPUDP
143IMAP (993 = IMAPS)TCP
161 / 162SNMP agent / trapUDP
179BGPTCP
389LDAP (636 = LDAPS)TCP/UDP
443HTTPS (TCP); HTTP/3 (UDP via QUIC)TCP/UDP
445SMBTCP
514SyslogUDP
520RIPUDP
853DNS over TLSTCP
1433 / 1521 / 3306 / 5432SQL Server / Oracle / MySQL / PostgreSQLTCP
3389RDPTCP
5060 / 5061SIP / SIP over TLSUDP/TCP
6379 / 27017Redis / MongoDBTCP
8080Alternate HTTP / proxyTCP

7.2 DNS ⭐⭐⭐ ​

  • A distributed, hierarchical database mapping names ↔ IP addresses. Hierarchy: root (.) β†’ TLDs (generic: .com, .org, .net, .edu; country-code: .in, .uk; infrastructure: .arpa) β†’ second-level domains (example.com) β†’ subdomains.
  • Servers: root servers (13 named identities, a–m.root-servers.net, with hundreds of anycast instances), TLD servers, authoritative servers (primary/secondary hold the zones), local recursive resolver (ISP, 8.8.8.8, 1.1.1.1). Answers are cached for their TTL.
  • Recursive query: the server must return the final answer (typically host β†’ local resolver). Iterative query: the server returns its best referral (typically resolver β†’ root β†’ TLD β†’ authoritative).
  • Resource records ⭐⭐: A (name β†’ IPv4), AAAA (β†’ IPv6), CNAME (alias β†’ canonical name), MX (mail exchanger, with preference), NS (authoritative name server), PTR (IP β†’ name; reverse lookup in in-addr.arpa / ip6.arpa), SOA (start of authority: serial, refresh, …), TXT (SPF, DKIM, verification), SRV (service location), CAA.
  • Message = header + question + answer + authority + additional (same format for query and reply). UDP 53 (classic limit 512 bytes, larger with EDNS0), else TCP; zone transfers (AXFR/IXFR) use TCP.
  • Limits: a label ≀ 63 characters; a full name ≀ 253 characters.
  • Attacks: DNS spoofing / cache poisoning (Kaminsky), DNS amplification DDoS, DNS tunneling. Protection: DNSSEC (authenticity and integrity via signatures; no confidentiality), DoT (853), DoH (443).
  • Tools: nslookup, dig, host.

7.3 HTTP ⭐⭐⭐ ​

  • The web's protocol: client–server, request/response, stateless (state via cookies, sessions, tokens). URL = scheme://host:port/path?query#fragment.
  • Versions: HTTP/1.0 (non-persistent by default: one object per TCP connection); HTTP/1.1 (persistent connections by default, pipelining, mandatory Host header, chunked transfer); HTTP/2 (binary framing, multiplexed streams over one TCP connection, HPACK header compression, server push); HTTP/3 (over QUIC/UDP).
  • Response time: non-persistent β‰ˆ 2Β·RTT + transmission time per object (one RTT for TCP setup, one for request/response); persistent β‰ˆ 1 RTT per object after the first.
  • Methods: GET (retrieve; safe and idempotent; parameters in the URL), HEAD (headers only), POST (submit/create; not idempotent), PUT (replace/create at a URI; idempotent), PATCH (partial update; not necessarily idempotent), DELETE (idempotent), OPTIONS (allowed methods; CORS preflight), TRACE (loop-back), CONNECT (tunnel, e.g., HTTPS through a proxy).
  • Status codes ⭐⭐⭐:
    • 1xx informational: 100 Continue, 101 Switching Protocols (e.g., WebSocket upgrade).
    • 2xx success: 200 OK, 201 Created, 202 Accepted, 204 No Content.
    • 3xx redirection: 301 Moved Permanently, 302 Found, 303 See Other, 304 Not Modified, 307 Temporary Redirect, 308 Permanent Redirect.
    • 4xx client error: 400 Bad Request, 401 Unauthorized (= not authenticated), 403 Forbidden (authenticated but not allowed), 404 Not Found, 405 Method Not Allowed, 408 Request Timeout, 409 Conflict, 413 Payload Too Large, 429 Too Many Requests.
    • 5xx server error: 500 Internal Server Error, 501 Not Implemented, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout.
  • Cookies: Set-Cookie header in the response β†’ stored by the browser β†’ Cookie header in later requests. Attributes: Expires/Max-Age, Domain, Path, Secure, HttpOnly, SameSite. Kurose's four components: header in the response, header in the request, cookie file on the client, back-end database at the server.
  • Web caching / proxy servers cut response time and access-link traffic. Conditional GET (If-Modified-Since / If-None-Match + ETag) β†’ 304 Not Modified.
  • HTTPS = HTTP over TLS (port 443). WebSocket: full-duplex over one TCP connection (ws:// on 80, wss:// on 443) after an HTTP Upgrade.
  • REST: stateless, resources identified by URIs, standard methods. CORS relaxes the browser's same-origin policy.

7.4 Email ⭐⭐ ​

  • Parts: user agents (Outlook, Gmail web), mail servers (MTAs) with mailboxes and queues. SMTP pushes mail (user agent β†’ server and server β†’ server). Access protocols pull mail: POP3, IMAP, or HTTP (webmail).
  • SMTP: TCP 25 (relay), 587 (submission with authentication); persistent connections; commands HELO/EHLO, MAIL FROM, RCPT TO, DATA (ends with a line containing "."), QUIT; reply codes (220, 250, 354, 550, …); originally 7-bit ASCII only.
  • MIME extends email to non-ASCII text, attachments, images, audio (Content-Type: text/html, image/jpeg, multipart/mixed; Content-Transfer-Encoding: base64, which adds ~33% size, or quoted-printable).
  • POP3 (110): download-and-delete or download-and-keep; stateless across sessions; simple. IMAP (143): mail stays on the server; folders; partial fetch; sync across devices.
  • Email security: SPF, DKIM, DMARC (anti-spoofing); PGP and S/MIME (end-to-end); STARTTLS.

7.5 FTP and other protocols ⭐⭐ ​

  • FTP uses two TCP connections: control on port 21 (persistent; control is "out-of-band") and data on port 20 in active mode (a new data connection for each file). FTP is stateful (remembers the user and current directory). ASCII vs binary transfer modes. Active mode: server opens the data connection from port 20 to the client. Passive mode: client connects to a port the server chooses (firewall-friendly). Credentials travel in plaintext β†’ use SFTP (over SSH) or FTPS (over TLS).
  • TFTP: UDP 69, no authentication, very simple (boot images, router configs).
  • Telnet (23): remote login in plaintext using an NVT (Network Virtual Terminal). SSH (22): encrypted remote login, tunneling and port forwarding.
  • SNMP: manager–agent model; MIB (Management Information Base), SMI; operations Get, GetNext, GetBulk, Set, Trap/Inform; UDP 161 (agent) / 162 (trap). v1/v2c use plaintext community strings; v3 adds authentication and encryption.
  • NTP (UDP 123, stratum levels), LDAP (directory, 389), SIP (VoIP signaling) + RTP/RTCP (media), DHCP (section 5.7).
  • P2P: BitTorrent (tracker, .torrent file, chunks, rarest-first, tit-for-tat), DHTs. CDNs cache content close to users (often via DNS redirection).
  • Socket API: TCP server: socket() β†’ bind() β†’ listen() β†’ accept() β†’ recv()/send() β†’ close(). TCP client: socket() β†’ connect() β†’ send()/recv() β†’ close(). UDP: socket() β†’ bind() (server) β†’ sendto()/recvfrom(); no listen/accept/connect needed.
  • Tools: ping (ICMP echo), traceroute/tracert (TTL), nslookup/dig (DNS), ipconfig/ifconfig/ip addr, netstat/ss (connections and ports), arp -a (ARP cache), route / ip route, nmap (port scanning), tcpdump/Wireshark (packet capture), curl/wget.

8. Rapid-fire trap list ⭐⭐⭐ ​

  1. Physical β†’ bits; data link β†’ frames; network β†’ packets; transport β†’ segments/datagrams.
  2. A router splits broadcast domains; a switch splits collision domains; a hub splits nothing.
  3. Repeater/hub = L1; bridge/switch = L2; router = L3; gateway = up to L7.
  4. Encryption, compression, translation β†’ presentation; dialog control and synchronization β†’ session.
  5. MAC 48 bits; IPv4 32; IPv6 128; port 16.
  6. Pure ALOHA 18.4%; slotted ALOHA 36.8%.
  7. CSMA/CD for wired, CSMA/CA for wireless.
  8. Ethernet frame 64–1,518 bytes; payload 46–1,500.
  9. GBN window ≀ 2^k βˆ’ 1; SR ≀ 2^(kβˆ’1).
  10. Stop-and-wait Ξ· = 1/(1 + 2a).
  11. Hamming: 2^r β‰₯ m + r + 1. Detect d errors β†’ distance d + 1; correct t β†’ 2t + 1.
  12. CRC: append (degree of generator) zeros before dividing.
  13. Usable hosts = 2^h βˆ’ 2.
  14. 127.x loopback; 169.254.x APIPA; 10/8, 172.16/12, 192.168/16 private.
  15. IPv4 header 20–60 bytes; IPv6 fixed 40 bytes; IPv6 has no checksum and no broadcast.
  16. Fragment offset in 8-byte units; reassembly only at the destination; IPv6 routers never fragment.
  17. TTL drops by 1 per hop; traceroute relies on it.
  18. RIP: hop count, max 15, UDP 520. OSPF: Dijkstra, IP protocol 89. BGP: path vector, TCP 179.
  19. Link state = Dijkstra; distance vector = Bellman–Ford (count-to-infinity).
  20. TCP header 20–60 bytes; UDP 8 bytes.
  21. SYN and FIN each consume a sequence number.
  22. TIME_WAIT = 2 MSL, at the active closer.
  23. Timeout β†’ cwnd = 1; 3 duplicate ACKs (Reno) β†’ cwnd halves.
  24. DNS: UDP 53 (TCP for zone transfers). DHCP: UDP 67/68. FTP: TCP 20/21.
  25. HTTP is stateless (cookies add state); HTTP/1.1 persistent by default; HTTP/3 runs over QUIC/UDP.
  26. SMTP pushes; POP3/IMAP pull.
  27. 401 = not authenticated; 403 = authenticated but forbidden.
  28. ARP: IP β†’ MAC (broadcast request, unicast reply).
  29. NAT/PAT shares one public IP using ports.
  30. Shannon for noisy channels; Nyquist for noiseless ones.