Unit 8 of 1012 min read

Computer Networks

OSI / TCP-IP, MAC, routing, IPv4 / CIDR, transport, application layer, security.

Share:WhatsAppLinkedIn

Why this unit matters

Computer Networks in ISRO CS has a strong numerical component. Subnetting calculations, sliding window protocol throughput analysis, TCP sequence numbers, and routing table computations are recurring question types. The conceptual questions focus on differences between protocols (TCP vs UDP, distance vector vs link state) and network layer mechanisms (ARP, DHCP, NAT). ISRO also tests security basics at a definitional level.

Understanding this unit also supports application-level questions about specific protocols (DNS, HTTP, SMTP), which appear as 1-mark fact questions.

Syllabus map

  • Network models

    • OSI 7-layer model: physical, data link, network, transport, session, presentation, application
    • TCP/IP 4-layer model: network access, internet, transport, application
    • Layer functions and encapsulation (segments, packets, frames, bits)
  • Physical layer

    • Bandwidth, throughput, latency
    • Nyquist and Shannon capacity formulas
    • Signal encoding: NRZ-L, NRZ-I, Manchester, differential Manchester, 4B/5B
  • Data link layer

    • Framing: character stuffing, bit stuffing
    • Error detection: parity (even/odd), checksum, CRC
    • Error correction: Hamming codes
    • Flow control and error control: Stop-and-Wait, Go-Back-N (GBN), Selective Repeat (SR)
    • Efficiency and window size calculations
  • MAC sublayer

    • Random access: ALOHA (pure, slotted), CSMA, CSMA/CD, CSMA/CA
    • Controlled access: token ring, token bus
    • LAN: Ethernet (IEEE 802.3), switches, hubs, bridges
    • Wireless LAN: IEEE 802.11, hidden node problem
  • Network layer

    • IPv4: address structure, classful addressing (A, B, C, D, E)
    • Subnetting: subnet mask, CIDR notation, hosts per subnet
    • IPv6: 128-bit addressing, address notation, key differences from IPv4
    • ARP, RARP, ICMP
    • Routing: static vs dynamic, intra-domain (RIP, OSPF), inter-domain (BGP)
    • Distance vector routing, Bellman-Ford update
    • Link state routing, Dijkstra
    • NAT
  • Transport layer

    • UDP: connectionless, no reliability, used for DNS, streaming
    • TCP: connection setup (3-way handshake), segment structure, sequence and acknowledgment numbers
    • TCP flow control: sliding window, receive window (rwnd)
    • TCP congestion control: slow start, congestion avoidance (AIMD), fast retransmit, fast recovery
    • Port numbers: well-known (0-1023), registered, dynamic
  • Application layer

    • DNS: hierarchy, resolution process (recursive vs iterative), record types (A, MX, CNAME, NS)
    • HTTP: stateless, request/response, methods (GET, POST, PUT, DELETE), status codes
    • SMTP, POP3, IMAP: email protocols
    • FTP: control and data connections
    • DHCP: address assignment process (DORA: Discover, Offer, Request, Acknowledge)
    • Telnet, SSH
  • Network security basics

    • Symmetric encryption: AES, DES (key distribution problem)
    • Asymmetric encryption: RSA (public and private keys)
    • Message Authentication Code (MAC) and HMAC
    • Digital signatures and certificates
    • SSL/TLS: HTTPS

Physical layer

Channel capacity

Nyquist formula (noiseless channel): C = 2 * B * log2(L), where B is bandwidth (Hz) and L is number of signal levels.

Shannon's theorem (noisy channel): C = B * log2(1 + S/N), where S/N is signal-to-noise ratio (linear, not dB).

ISRO trap: Shannon gives the theoretical maximum. Nyquist applies only to noiseless channels. In practice, both constraints apply and the minimum of the two gives the achievable rate.

Data link layer

Error detection

Parity: append a bit such that total number of 1s is even (even parity) or odd (odd parity). Detects single-bit errors. Cannot detect two-bit errors that cancel out.

CRC: treat the data as a polynomial, divide by a generator polynomial, append the remainder. The receiver performs the same division; a non-zero remainder indicates an error. Detects all single-bit errors, all burst errors of length <= degree of generator, and many others.

Hamming code: can detect up to 2-bit errors and correct 1-bit errors. Number of parity bits r satisfies 2^r >= m + r + 1 where m is the number of data bits.

Sliding window protocols

Stop-and-Wait: send one frame, wait for ACK. Efficiency = T_propagation / (T_frame + 2 * T_propagation) when propagation dominates... more precisely:

Efficiency = 1 / (1 + 2a) where a = propagation delay / transmission time.

Go-Back-N (GBN): sender window size Ws (sequence numbers from 0 to 2^n - 1, window <= 2^n - 1). On a timeout or NAK, retransmit all frames from the erroneous one onward.

Selective Repeat (SR): window size <= 2^(n-1). Only the errored frame is retransmitted.

Efficiency:

  • GBN with error probability p: efficiency = (1-p) / (1 + 2a * (1-p)... ) approximately (1-p) / ((1-p) + 2a * p * Ws).

Simpler form for the ideal case (no errors):

  • Stop-and-Wait: eta = 1 if 2a < 1, else eta = 1/(2a+1).
  • GBN: eta = Ws / (2a+1) if Ws < 2a+1, else eta = 1. (Ws = window size)
  • SR: same as GBN in the no-error case.

Ethernet and CSMA/CD

Ethernet uses CSMA/CD (Carrier Sense Multiple Access with Collision Detection). Before transmitting, a station listens for an idle channel (carrier sense). If two stations transmit simultaneously, a collision is detected, both stop, send a jam signal, and back off for a random time (binary exponential backoff).

Minimum frame size in Ethernet: ensures the sender is still transmitting when it detects the collision. Minimum frame size = 2 * propagation delay * data rate = 64 bytes for 10 Mbps Ethernet with 500 m cable.

Network layer

IPv4 addressing

Classes:

  • Class A: 0xxxxxxx first octet, 1 network byte, 3 host bytes. Range 0-127. Default mask: /8.
  • Class B: 10xxxxxx first octet. Range 128-191. Default mask: /16.
  • Class C: 110xxxxx first octet. Range 192-223. Default mask: /24.
  • Class D: multicast (224-239). Class E: reserved (240-255).

Private address ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.

Subnetting

Given a Class C address 192.168.1.0 and requirement for 4 subnets:

4 subnets needs 2 bits of borrowing from host. Subnet mask: /26 (255.255.255.192). Hosts per subnet: 2^6 - 2 = 62 (subtract network and broadcast addresses).

Subnets: 192.168.1.0/26, 192.168.1.64/26, 192.168.1.128/26, 192.168.1.192/26.

CIDR (classless inter-domain routing): addresses specified as a.b.c.d/prefix. Supernetting: aggregate multiple class C blocks into one route. Example: 200.1.0.0/22 covers 200.1.0.0 through 200.1.3.255 (four /24 blocks).

IPv6

128-bit addresses written as 8 groups of 4 hex digits separated by colons. Double colon (::) replaces the longest consecutive run of zero groups.

Key differences from IPv4: no broadcast (multicast instead), no fragmentation by routers (only by source), integrated IPSec support, no checksum in IP header (moved to transport), larger address space eliminates need for NAT.

Routing protocols

RIP (Routing Information Protocol): distance vector, metric = hop count (max 15), updates every 30 seconds, uses Bellman-Ford. Suffers from slow convergence and count-to-infinity problem. Uses split horizon and poison reverse to mitigate.

OSPF (Open Shortest Path First): link state, each router knows the complete topology, uses Dijkstra to compute shortest paths, hierarchical (backbone area 0 + other areas). Converges faster than RIP.

BGP (Border Gateway Protocol): path vector protocol used between autonomous systems (inter-domain routing). Policy-based routing. Uses TCP for reliable transport.

Transport layer

TCP

TCP provides: reliable, ordered, error-checked delivery of a stream of bytes between applications.

3-way handshake for connection setup:

  1. Client sends SYN (sequence number = x).
  2. Server sends SYN-ACK (server sequence number = y, ACK number = x+1).
  3. Client sends ACK (ACK number = y+1).

TCP segment header fields: source port, destination port, sequence number, acknowledgment number, flags (SYN, ACK, FIN, RST, PSH, URG), receive window, checksum, urgent pointer.

Flow control: the receiver advertises its receive window (rwnd) in each ACK. The sender cannot send more unacknowledged bytes than rwnd.

TCP congestion control

Slow start: begin with cwnd (congestion window) = 1 MSS. Double cwnd each RTT until a threshold (ssthresh) is reached. Exponential growth.

Congestion avoidance: after ssthresh, increase cwnd by 1 MSS per RTT (linear growth). AIMD: additive increase (by 1 MSS per RTT), multiplicative decrease (halve cwnd on congestion event).

On timeout: ssthresh = cwnd/2, cwnd = 1 MSS, restart slow start. On triple duplicate ACK (fast retransmit): ssthresh = cwnd/2, cwnd = ssthresh + 3 MSS, continue in congestion avoidance (fast recovery).

ISRO trap: after a timeout, TCP goes back to slow start (cwnd = 1). After triple duplicate ACK, TCP uses fast recovery (cwnd is not reset to 1).

UDP

Connectionless, unreliable, no flow control, no congestion control. Header: 8 bytes (source port, dest port, length, checksum). Used where speed matters more than reliability: DNS, DHCP, VoIP, video streaming, online games.

Application layer

DNS resolution

A client queries a local DNS resolver. If not cached, the resolver contacts the root name server (for the TLD), then the TLD name server (for the authoritative server), then the authoritative name server for the final IP address. This is iterative resolution.

In recursive resolution, each server queries the next on behalf of the client and returns the final answer.

Record types: A (IPv4 address), AAAA (IPv6), MX (mail exchange), CNAME (canonical name alias), NS (name server), PTR (reverse lookup), SOA (start of authority).

HTTP

HTTP is stateless. Each request-response is independent. Cookies provide state across requests.

HTTP/1.1: persistent connections (keep-alive). HTTP/2: multiplexing (multiple streams over one connection). HTTP/3: uses QUIC (over UDP) instead of TCP.

Common status codes: 200 OK, 301 Moved Permanently, 302 Found (redirect), 400 Bad Request, 401 Unauthorised, 403 Forbidden, 404 Not Found, 500 Internal Server Error.

Worked examples

Example 1: Subnetting

IP: 172.16.0.0/16. Divide into subnets of at most 30 hosts each.

30 hosts + 2 (network + broadcast) = 32 = 2^5. So 5 host bits. Subnet prefix = /27 (32 - 5 = 27). Subnets available: 2^(27-16) = 2^11 = 2048 subnets.

First few subnets: 172.16.0.0/27 (hosts .1 to .30, broadcast .31), 172.16.0.32/27 (hosts .33 to .62, broadcast .63), etc.

Example 2: Go-Back-N window and efficiency

n = 3 bit sequence number. Window size for GBN <= 2^3 - 1 = 7. Propagation delay = 200 ms, transmission time per frame = 20 ms. a = 200/20 = 10. Bandwidth delay product: 2a + 1 = 21.

Efficiency with window 7: Ws = 7 < 21. Efficiency = 7/21 = 1/3 = 33.3%.

For efficiency = 1 (full utilisation), need Ws >= 2a+1 = 21. With 3-bit sequence numbers, max window is 7. Not achievable.

Example 3: Hamming code

Data bits: 1011 (4 bits). Add parity bits at positions 1, 2, 4 (powers of 2).

Positions: 1(p1) 2(p2) 3(d1=1) 4(p4) 5(d2=0) 6(d3=1) 7(d4=1).

p1 covers positions 1, 3, 5, 7: p1 XOR 1 XOR 0 XOR 1 = 0. So p1 = 0. p2 covers positions 2, 3, 6, 7: p2 XOR 1 XOR 1 XOR 1 = 0. p2 = 1. p4 covers positions 4, 5, 6, 7: p4 XOR 0 XOR 1 XOR 1 = 0. p4 = 0.

Codeword: 0 1 1 0 0 1 1 (positions 1-7).

If a single bit error occurs, recompute parities at receiver to find the error position (syndrome).

Example 4: TCP sequence numbers

TCP sends 3 segments of 1000 bytes each. Initial sequence number = 5000.

Segment 1: seq = 5000, data bytes 5000-5999. Segment 2: seq = 6000, data bytes 6000-6999. Segment 3: seq = 7000, data bytes 7000-7999.

ACK for segment 1: ack = 6000 (next expected byte). If segment 2 is lost, receiver buffers segment 3. Sender gets duplicate ACKs for 6000 (ack = 6000) three times, triggers fast retransmit of segment 2.

Example 5: CIDR aggregation

Routes: 200.23.16.0/24, 200.23.17.0/24, 200.23.18.0/24, 200.23.19.0/24.

In binary, the third octets: 16 = 0001 0000, 17 = 0001 0001, 18 = 0001 0010, 19 = 0001 0011.

Common prefix of third octet: 0001 00xx (first 6 bits identical). Combined with first 16 bits: 200.23.0001 00xx.xxxxxxxx. So the aggregated prefix is 200.23.16.0/22.

Quick-revision summary

  • OSI: 7 layers. TCP/IP: 4 layers. Encapsulation adds headers at each layer.
  • Shannon: C = B log2(1+SNR). Nyquist: C = 2B log2(L). Shannon is for noisy, Nyquist for noiseless.
  • GBN window <= 2^n - 1. SR window <= 2^(n-1).
  • CSMA/CD: wired (Ethernet). CSMA/CA: wireless (WiFi, to avoid, not detect, collision).
  • Class A: /8, Class B: /16, Class C: /24. Private: 10.x, 172.16-31.x, 192.168.x.x.
  • Subnetting: borrow host bits for subnets, hosts = 2^h - 2.
  • RIP: distance vector, max 15 hops. OSPF: link state, no hop limit, faster convergence.
  • TCP 3-way handshake: SYN, SYN-ACK, ACK. ACK number = received sequence number + 1.
  • TCP congestion: slow start (exponential), congestion avoidance (AIMD). Timeout resets cwnd to 1. Triple dup ACK triggers fast recovery.
  • DNS resolution: root -> TLD -> authoritative. A record: IPv4, MX: mail, CNAME: alias.

How to study this unit

  1. Practise subnetting on paper: given a network and a required number of subnets or hosts, compute mask, subnet addresses, broadcast, and valid host range. Do at least 10 problems.
  2. Derive Go-Back-N and Selective Repeat efficiency formulas from first principles. Know when to use which (given the number of sequence number bits).
  3. Trace TCP congestion control over 10-15 RTTs: starting from cwnd=1, simulate slow start, a timeout, congestion avoidance, and fast recovery. Draw the cwnd vs time graph.
  4. Know the port numbers for DNS (53), HTTP (80), HTTPS (443), FTP (21/20), SMTP (25), POP3 (110), IMAP (143), SSH (22), Telnet (23), DHCP (67/68).
  5. Understand Dijkstra used in OSPF and Bellman-Ford used in RIP at the algorithm level, not just name recognition.
  6. Revise the ARP/DHCP/DNS interaction for a host joining a network fresh: DHCP -> ARP -> DNS -> HTTP. This sequence is a classic conceptual question.

Test Your Knowledge

Quick MCQ check on this unit

Start Quiz →

Prefer watching over reading?

Subscribe for free.

Subscribe on YouTube