Protocol Layering & Network Delays
OSI vs TCP/IP Models & Packet Encapsulation
Open Full Lesson →OSI is a 7-layer reference model; TCP/IP is the practical 4/5-layer implementation. As data descends the stack, each layer encapsulates headers (Application: Messages, Transport: Segments/Datagrams, Network: Packets, Data Link: Frames, Physical: Bits). Total nodal delay is d_nodal = d_proc + d_queue + d_trans + d_prop.
Must-Remember Principles:- —Transmission Delay: d_trans = L / R (depends strictly on packet length L and link bandwidth R).
- —Propagation Delay: d_prop = d / s (depends strictly on distance d and signal velocity s in medium).
- —Bandwidth-Delay Product (BDP): BDP = R * d_prop (measures maximum in-flight bits filling the pipe).
- —Store-and-Forward Pipelined Delay: For M packets across N links, Total Time = N * d_trans + N * d_prop + (M - 1) * d_trans.
- —Traffic Intensity: I = (L * a) / R. If I > 1, queue grows without bound and packet loss occurs.
Critical Pitfalls & Exam Traps:- ×Bandwidth does NOT affect signal propagation speed; higher bandwidth only reduces transmission delay L/R.
- ×In store-and-forward routing, intermediate routers cannot forward a packet until all bits of that packet have been completely received.
- ×PDU nomenclature: Application = Messages, Transport = Segments/Datagrams, Network = Packets, Data Link = Frames.
Protocol Layering & Network Delays
Physical Layer: Channel Capacity, Nyquist-Shannon Bounds & Switching
Open Full Lesson →Nyquist formula defines the maximum theoretical bit rate on a noiseless channel: C = 2B log2(M). Shannon-Hartley capacity theorem defines the absolute upper bound on a noisy Gaussian channel: C = B log2(1 + SNR). In real systems, the actual achievable bit rate is min(Nyquist, Shannon).
Must-Remember Principles:- —Nyquist Bit Rate (Noiseless): C = 2 * B * log2(M) bps, where B = bandwidth (Hz) and M = discrete signaling levels.
- —Shannon-Hartley Capacity (Noisy): C = B * log2(1 + SNR) bps, where SNR = S / N (linear power ratio, NOT dB).
- —SNR in Decibels: SNR_dB = 10 * log10(SNR) <=> SNR = 10^(SNR_dB / 10).
- —Circuit Switching: Dedicated end-to-end path established before data transfer. Constant bit rate, zero queuing delay after setup, low link utilization during idle bursts.
- —Packet Switching: Data broken into independent packets multiplexed statistically across shared links. High utilization, variable queuing delays, jitter, packet drop under congestion.
Critical Pitfalls & Exam Traps:- ×Never plug SNR_dB directly into the Shannon formula! You must first convert decibels to linear SNR: SNR = 10^(SNR_dB / 10).
- ×If a question asks for the minimum number of signal levels M needed on a noisy channel, first calculate Shannon capacity C, then equate C = 2B log2(M) to solve for M = ceil(2^(C / (2B))).
- ×Virtual Circuit (VC) packet switching maintains a connection state table in routers and preserves packet order, but packets still experience queuing delays and store-and-forward transmission.
Data Link Layer, Error Detection & Correction
Framing, Bit Stuffing & Cyclic Redundancy Check (CRC)
Open Full Lesson →Data Link framing delimits frames using byte stuffing (character-oriented) or bit stuffing (inserting 0 after five consecutive 1s in HDLC). CRC uses modulo-2 polynomial division (XOR without borrow); generator of degree r appends r zeros, generating an r-bit remainder. Minimum Hamming distance d_min >= e + 1 detects e errors; d_min >= 2t + 1 corrects t errors.
Must-Remember Principles:- —HDLC Bit Stuffing: Transmitter inserts '0' after five consecutive '1's. Receiver strips '0' after five '1's.
- —CRC Codeword: Transmit T = D * 2^r XOR R, where R = (D * 2^r) mod_2 G.
- —CRC Error Detection Capability: If G(x) has x^0 = 1, detects all single-bit errors; if (x+1) is a factor of G(x), detects all odd numbers of bit errors; detects all burst errors of length <= r.
- —Hamming Distance Bounds: Error detection: d_min >= e + 1; Error correction: d_min >= 2t + 1; Simultaneous detection & correction: d_min >= e + t + 1 (e > t).
Critical Pitfalls & Exam Traps:- ×A polynomial of degree r has r + 1 coefficients/bits! For example, x^4 + x + 1 has degree 4, represented as 10011 (5 bits), appending 4 zeros.
- ×In bit stuffing, never count the stuffed 0 as part of the next sequence of five 1s.
- ×CRC division uses XOR arithmetic (no carries and no borrows); 1 XOR 1 = 0, 0 XOR 0 = 0, 1 XOR 0 = 1.
Flow Control & Sliding Window Protocols
Sliding Window: Stop-and-Wait, Go-Back-N & Selective Repeat
Open Full Lesson →Flow control manages sender transmission rates to avoid overflowing receiver buffers. Stop-and-Wait has W_S = 1, W_R = 1 with eta = 1 / (1 + 2a). Go-Back-N has W_S = 2^k - 1, W_R = 1 with cumulative ACKs and go-back retransmissions. Selective Repeat has W_S = 2^(k-1), W_R = 2^(k-1) with independent ACKs and individual retransmissions. Pipelined efficiency is eta = min(1, W_S / (1 + 2a)).
Must-Remember Principles:- —Normalized Propagation Parameter: a = T_p / T_t = (d / s) / (L / R).
- —Total Round-Trip Cycle Time: T_cycle = T_t + 2 * T_p + T_ack (if T_ack is negligible, T_cycle = T_t + 2 * T_p).
- —Stop-and-Wait Efficiency & Throughput: eta = 1 / (1 + 2a); Throughput = eta * Bandwidth = L / (T_t + 2 * T_p).
- —Pipelined Window Efficiency: eta = min(1, W_S / (1 + 2a)). For 100% utilization: W_S >= 1 + 2a.
- —Sequence Number Bounds for k Bits: Stop-and-Wait: k >= 1; Go-Back-N: W_S + W_R <= 2^k => W_S <= 2^k - 1 (since W_R = 1); Selective Repeat: W_S + W_R <= 2^k => W_S <= 2^(k-1) and W_R <= 2^(k-1).
Critical Pitfalls & Exam Traps:- ×If ACK transmission time T_ack is NOT negligible, Cycle Time = T_t + 2 * T_p + T_ack.
- ×In Go-Back-N, receiver window W_R = 1, so out-of-order error-free frames are unconditionally discarded!
- ×In Selective Repeat, if sequence numbers are not at least 2 * W_S, duplicate frames from the preceding window wrap around and overlap with the new window, corrupting data.
Medium Access Control (MAC) & Ethernet
CSMA/CD Collision Detection & Minimum Frame Size
Open Full Lesson →CSMA/CD enforces 'listen before talk, listen while talk'. To detect collisions before transmission completes, transmission time must satisfy T_t >= 2 * T_p, yielding minimum frame size L_min = 2 * T_p * Bandwidth. Binary exponential backoff chooses an integer slot r in [0, 2^min(n, 10) - 1] after collision n.
Must-Remember Principles:- —CSMA/CD Condition: T_t >= 2 * T_p <=> L_min / R >= 2 * (d / s) => L_min >= 2 * (d / s) * R.
- —Maximum Network Cable Span: d_max = (L_min * s) / (2 * R).
- —Pure ALOHA Throughput: S = G * e^(-2G); Maximum S_max = 1 / (2e) ≈ 18.4% at G = 0.5.
- —Slotted ALOHA Throughput: S = G * e^(-G); Maximum S_max = 1 / e ≈ 36.8% at G = 1.0.
- —IEEE 802.3 Standard Bounds: Minimum frame size = 64 bytes (46B payload + 18B header/trailer); Slot time = 512 bit times (51.2 μs at 10 Mbps).
- —Binary Exponential Backoff: Backoff slot r drawn uniformly from [0, 2^k - 1], where k = min(n, 10) for 1 <= n <= 15. Collision count drops after 16 failed attempts.
Critical Pitfalls & Exam Traps:- ×If bandwidth R doubles while cable length stays constant, L_min must double to retain collision detection!
- ×Repeaters and Hubs extend the physical collision domain; Bridges and Switches divide the collision domain into distinct collision segments.
- ×CSMA/CA (used in Wi-Fi IEEE 802.11) uses RTS/CTS (Request to Send / Clear to Send) handshakes and NAV timers because wireless stations cannot detect collisions while transmitting (Hidden Terminal Problem).
Medium Access Control (MAC) & Ethernet
Connecting Devices, Transparent Bridges & Spanning Tree Protocol (STP)
Open Full Lesson →Connecting devices operate at different layers: Hubs/Repeaters operate at Layer 1 (single collision domain, single broadcast domain). Bridges/Switches operate at Layer 2 (each switch port is its own collision domain; all ports share one broadcast domain). Routers operate at Layer 3 (each router interface is its own collision domain AND its own broadcast domain). STP eliminates Layer 2 bridging loops.
Must-Remember Principles:- —Collision Domain Count: Hubs/Repeaters = 1 collision domain for all connected ports; Switches/Bridges = 1 collision domain per connected active port; Routers = 1 collision domain per interface.
- —Broadcast Domain Count: Hubs and Switches do NOT isolate broadcasts = 1 broadcast domain across all interconnected switches/hubs (unless VLANs are configured); Routers isolate broadcasts = 1 broadcast domain per router interface.
- —Transparent Bridge Learning Algorithm: Upon receiving frame with source MAC S on port P: Add or update entry (MAC=S, Port=P, Timer=0). If destination MAC D is in forwarding table on port Q != P, forward to port Q. If D is on port P, filter (drop). If D is unknown or broadcast (FF:FF:FF:FF:FF:FF), flood to all ports except P.
- —Spanning Tree Protocol (STP IEEE 802.1D): Bridge ID = 2-byte Priority (default 32768) + 6-byte MAC. Root Bridge = Bridge with smallest Bridge ID. Root Port = Port with lowest path cost to Root Bridge. Designated Port = Port with lowest path cost on each segment. Blocked Port = All remaining alternate ports.
Critical Pitfalls & Exam Traps:- ×A Hub does NOT break up collision domains! If 8 computers connect to a single 8-port Hub, there is exactly 1 collision domain.
- ×A Switch breaks up collision domains, but NOT broadcast domains! An 8-port switch has 8 collision domains, but only 1 broadcast domain.
- ×In STP, the bridge with the LOWEST (smallest numerical) Bridge ID becomes the Root Bridge, NOT the highest!
Network Layer, IPv4 Addressing & CIDR Subnetting
IPv4 Header, Packet Fragmentation & CIDR Subnetting
Open Full Lesson →IPv4 header is 20 to 60 bytes (HLEN scaled by 4). Fragmentation occurs when datagram size > MTU; Fragment Offset is measured in 8-byte blocks of payload data. CIDR uses variable-length /n prefix with Longest Prefix Matching (LPM). Subnet ID = IP AND Mask; Direct Broadcast Address (DBA) sets all host bits to 1; Usable hosts = 2^(32-n) - 2.
Must-Remember Principles:- —Header Length (HLEN): Expressed in 4-byte words (range 5 to 15, corresponding to 20 to 60 bytes).
- —Total Length: 16-bit field spanning header + payload (maximum 65,535 bytes).
- —Fragmentation Offsets: Fragment Offset = (Payload bytes transmitted prior to this fragment) / 8.
- —Flags: DF = 1 (Don't Fragment); MF = 1 (More Fragments follow); MF = 0 (Last fragment).
- —Usable Host IP Addresses in /n Subnet: 2^(32 - n) - 2 (excludes Network Address and Direct Broadcast Address).
- —Private IP Blocks (RFC 1918): Class A: 10.0.0.0/8; Class B: 172.16.0.0/12; Class C: 192.168.0.0/16.
Critical Pitfalls & Exam Traps:- ×Fragment Offset counts PAYLOAD bytes only, NEVER including the 20-byte IP header!
- ×Every fragment (except possibly the very last fragment) MUST carry a payload size that is an exact integer multiple of 8 bytes.
- ×Don't forget to subtract 2 for the Network ID and Direct Broadcast Address when calculating usable host addresses.
Network Layer, IPv4 Addressing & CIDR Subnetting
NAT, and the Helpers Around IP: ARP, DHCP & ICMP
Open Full Lesson →NAT (in its common port-translating form, NAPT) rewrites the source IP and port of outgoing packets to the router's public IP and a chosen port, remembers the mapping in a translation table, and uses that table to rewrite the destination of replies.
Must-Remember Principles:- —Private IPv4 ranges (RFC 1918): 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
- —NAPT table entry: (private IP, private port) ↔ (public IP, public port), per transport protocol.
- —Outbound: rewrite SOURCE IP:port. Inbound reply: rewrite DESTINATION IP:port using the table.
- —After rewriting, NAT must recompute the IP header checksum and the TCP/UDP checksum (its pseudo-header includes the IP addresses).
- —ARP: resolves an IPv4 address to a MAC address on the same link. Request is broadcast, reply is unicast.
- —DHCP: Discover → Offer → Request → Acknowledge (DORA), over UDP (server port 67, client port 68).
- —ICMP: carried inside IP (protocol number 1). Echo request/reply = types 8/0, destination unreachable = 3, time exceeded = 11.
Critical Pitfalls & Exam Traps:- ×A host sending to a remote network ARPs for its default gateway's MAC, not the remote host's MAC.
- ×Across hops the MAC addresses change at every router; the IP addresses stay the same unless NAT rewrites them.
- ×NAT alone does not let outside hosts start connections to inside hosts; that needs a static mapping (port forwarding).
- ×A 16-bit port field limits how many simultaneous mappings one public IP can hold per protocol.
Routing Protocols & Algorithms
Distance Vector vs Link State Routing: Algorithms & Traps
Open Full Lesson →Routing algorithms determine paths through the network. Distance Vector (RIP, Bellman-Ford) shares entire routing table with immediate neighbors only; prone to slow convergence and Count-to-Infinity. Link State (OSPF, Dijkstra) floods local link states to all routers in the domain; every router builds an identical global topology graph and executes Dijkstra SPF. Path Vector (BGP) advertises complete AS-PATH lists to prevent inter-domain loops.
Must-Remember Principles:- —Bellman-Ford Equation: D_x(y) = min_v { c(x, v) + D_v(y) } over all neighbors v of x.
- —RIP Protocol Bounds: Metric is hop count; Maximum valid path length is 15 hops; 16 hops represents infinity (unreachable).
- —Count-to-Infinity Mitigations: Split Horizon (do not re-advertise route to the interface from which it was learned); Poison Reverse (advertise cost = infinity back to next hop).
- —OSPF Hierarchy: Area 0 (Backbone Area) interconnects standard areas; Area Border Routers (ABR) connect standard areas to Area 0; Autonomous System Boundary Routers (ASBR) connect OSPF to external routing domains.
- —BGP Loop Detection: A BGP router discards any routing update if its own Autonomous System Number (ASN) already appears in the AS-PATH attribute list.
Critical Pitfalls & Exam Traps:- ×Split Horizon with Poison Reverse does NOT completely prevent loops involving three or more routers!
- ×Link State Packets (LSPs) are flooded to ALL routers, but each LSP only lists the costs to IMMEDIATE neighbors.
- ×Distance Vector updates are sent ONLY to immediate neighbors, but contain distance estimates to ALL routers in the entire network.
Transport Layer, TCP Flow & Congestion Control
TCP Handshake, Flow Control & Congestion Control
Open Full Lesson →TCP provides reliable, in-order, byte-stream delivery with 3-way handshake and 4-way teardown (TIME_WAIT = 2MSL). Transmission window is W = min(cwnd, rwnd). Slow Start doubles cwnd every RTT; Congestion Avoidance adds 1 MSS every RTT (AIMD). On Timeout: ssthresh = cwnd / 2, cwnd = 1 MSS (Tahoe & Reno). On 3 Duplicate ACKs: Reno sets ssthresh = cwnd / 2, cwnd = ssthresh + 3 MSS, continuing linear growth without dropping to 1.
Must-Remember Principles:- —Effective Transmission Window: W = min(cwnd, rwnd).
- —Slow Start Growth: cwnd = cwnd + 1 MSS per ACK received (doubles cwnd each RTT) until cwnd >= ssthresh.
- —Congestion Avoidance Growth: cwnd = cwnd + (1 / cwnd) MSS per ACK received (increases by 1 MSS each RTT).
- —Timeout Event (Tahoe & Reno): ssthresh = max(cwnd / 2, 2 MSS); cwnd = 1 MSS; enters Slow Start.
- —3 Duplicate ACKs (Reno Fast Recovery): ssthresh = max(cwnd / 2, 2 MSS); cwnd = ssthresh + 3 MSS; continues Congestion Avoidance.
- —TCP Header: 20 to 60 bytes; Sequence number counts bytes, not packets; SYN and FIN flags each consume 1 sequence number (ACK with no data consumes 0).
- —Karn's Algorithm: Do not measure RTT for retransmitted segments; double timeout timer (exponential backoff) upon every retransmission.
Critical Pitfalls & Exam Traps:- ×SYN and FIN consume exactly 1 sequence number each, even when they carry 0 payload bytes! ACK segments without data consume 0 sequence numbers.
- ×In Slow Start, cwnd increases by 1 MSS for EACH individual ACK received, which doubles cwnd in one RTT if all segments are ACKed individually.
- ×Do not confuse Tahoe and Reno: On 3 duplicate ACKs, Tahoe drops cwnd to 1, while Reno enters Fast Recovery and drops cwnd to ssthresh + 3.
Transport Layer, TCP Flow & Congestion Control
TCP Socket API: From socket() to accept()
Open Full Lesson →A TCP server creates, binds, listens, then accepts a connection; a client creates a socket and connects to the server endpoint.
Must-Remember Principles:- —`socket()` creates an endpoint descriptor.
- —`bind()` associates a local address and port; `listen()` makes a stream socket passive.
- —`accept()` returns a new connected socket; the listening socket remains available for more clients.
- —A TCP byte stream preserves byte order, not application message boundaries.
Critical Pitfalls & Exam Traps:- ×`accept()` blocks until a connection is pending unless configured otherwise.
- ×The connected socket returned by `accept()` is distinct from the listening socket.
- ×TCP does not preserve the size of each individual `send()` call as a message boundary.
Application protocols provide user network services. DNS resolves hostnames to IPs via hierarchical servers (Root -> TLD -> Authoritative); Iterative gives referrals while Recursive queries on behalf of client. HTTP/1.0 uses non-persistent connections (2 RTT per object); HTTP/1.1 uses persistent connections (1 RTT per object); HTTP/2 uses binary multiplexed streams; HTTP/3 uses QUIC over UDP. Email uses SMTP (push, port 25), POP3 (pull, port 110), IMAP (pull with server sync, port 143).
Must-Remember Principles:- —Non-Persistent HTTP RTT Total: For base HTML + N objects, Total RTTs = (1 + N) * 2 RTT = 2(N + 1) RTTs (without parallel connections).
- —Persistent HTTP Without Pipelining: 2 RTT (base HTML) + N * 1 RTT = N + 2 RTTs.
- —Persistent HTTP With Pipelining: 2 RTT (base HTML) + 1 RTT (burst of all N objects) = 3 RTTs.
- —DNS Ports: UDP Port 53 (standard lookups <= 512 bytes); TCP Port 53 (zone transfers and responses > 512 bytes).
- —Email Ports: SMTP (TCP 25, 587 submission); POP3 (TCP 110, 995 SSL); IMAP (TCP 143, 993 SSL).
Critical Pitfalls & Exam Traps:- ×Non-persistent HTTP requires a BRAND NEW TCP handshake (1 RTT) PLUS 1 RTT for HTTP get/response for EACH referenced image, resulting in 2 RTT per image!
- ×Do not confuse SMTP and POP3: SMTP is a push protocol used to send mail from client to server and between servers; POP3 and IMAP are pull protocols used to retrieve mail from the mailbox server to the client.
Network Security, Cryptography & Firewalls
Network Security: Cryptography, RSA Math, Diffie-Hellman & Firewalls
Open Full Lesson →Network Security provides confidentiality, integrity, authentication, and non-repudiation. Symmetric ciphers (DES, AES) use 1 shared key for encryption and decryption. Asymmetric ciphers (RSA) use key pairs (Public/Private); security rests on prime factorization. Diffie-Hellman establishes a shared key over an insecure channel. Digital signatures encrypt message digest (SHA) with the sender's Private Key. Firewalls inspect packets (stateless vs stateful).
Must-Remember Principles:- —RSA Key Generation: Select primes p, q. n = p * q. phi(n) = (p - 1)(q - 1). Choose e coprime to phi(n). Compute d = e^(-1) mod phi(n) via e * d = 1 (mod phi(n)).
- —RSA Encryption & Decryption: Ciphertext c = m^e mod n; Plaintext m = c^d mod n (requires 0 <= m < n).
- —Diffie-Hellman Shared Secret: Alice sends A = g^a mod p; Bob sends B = g^b mod p; Shared Key K = B^a mod p = A^b mod p = g^(ab) mod p.
- —Digital Signature Generation & Verification: Signature S = D_Kpriv_sender(Hash(M)); Verification: Valid if E_Kpub_sender(S) == Hash(M).
- —Firewall Types: Stateless Packet Filter (Layer 3/4 header: IP, Port, TCP flags SYN/ACK); Stateful Inspection (tracks TCP 3-way handshake state table); Application Gateway / Proxy (Layer 7 payload inspection).
Critical Pitfalls & Exam Traps:- ×In RSA, private exponent d is computed modulo phi(n) = (p - 1)(q - 1), NOT modulo n!
- ×Diffie-Hellman key exchange is vulnerable to active Man-in-the-Middle (MitM) attacks unless combined with digital signatures or certificates for authentication.
- ×To sign a message for authentication/non-repudiation, the sender uses their own PRIVATE key. To encrypt for confidentiality, the sender uses the recipient's PUBLIC key.