Topic 313 Key Rules
Computer Networks High-Yield Revision
# Computer Networks Master Revision Cheat Sheet
## High-Yield Exam Guide for RPSC Computer Instructor
> **Target Exam**: RPSC Computer Instructor (Senior & Basic) / Computer Science Competitive Exams
> **Subject**: Computer Networks (CN)
> **Page URL**: `https://upscorer.in/topics/computer-networks`
---
## 🌟 Priority 1 (Must Master) ⭐⭐⭐⭐⭐
### 1. OSI 7-Layer Reference Model (Open Systems Interconnection)
*Developed by ISO in 1984. Conceptual 7-layer framework.*
| Layer # | Layer Name | Primary Function / Responsibilities | PDU (Protocol Data Unit) | Hardware Devices | Protocols & Standards |
| :---: | :--- | :--- | :--- | :--- | :--- |
| **7** | **Application** | Network services to end-user applications, UI interface. | Data / Message | Gateway | HTTP, HTTPS, FTP, SMTP, DNS, SSH, Telnet, DHCP, SNMP, POP3, IMAP |
| **6** | **Presentation** | Data formatting, Syntax/Semantics, Encryption/Decryption, Compression (JPEG, ASCII, TLS/SSL). | Data | Gateway | TLS/SSL, JPEG, MPEG, ASCII, EBCDIC |
| **5** | **Session** | Session setup, maintenance, synchronization (checkpoints), dialog control (half/full duplex). | Data | Gateway | NetBIOS, PPTP, RPC, SOCKS |
| **4** | **Transport** | End-to-End (Host-to-Host) process communication, Port addressing, Segmentation, Flow/Error control. | **Segment** (TCP) / **Datagram** (UDP) | Gateway, Layer 4 Switch | TCP, UDP, SCTP, RTP |
| **3** | **Network** | Logical Addressing (IP), Routing, Packet forwarding, Subnetting, Fragmentation. | **Packet** | **Router**, Layer 3 Switch | IPv4, IPv6, ARP, RARP, ICMP, IGMP, OSPF, BGP, RIP |
| **2** | **Data Link** | Node-to-Node framing, Physical (MAC) addressing, Error detection (CRC), Flow control (Sliding Window), MAC access. | **Frame** | **Switch**, **Bridge**, NIC | Ethernet (802.3), Wi-Fi (802.11), PPP, HDLC, ATM, ARP |
| **1** | **Physical** | Transmission of raw bits over physical medium, bit synchronization, signal encoding, topology, data rate. | **Bits** | **Hub**, **Repeater**, Modem, Cable | RS-232, RJ-45, Coaxial, Fiber Optics, Manchester Encoding |
* **Memory Trick (Top-to-Bottom)**: **A**ll **P**eople **S**eem **T**o **N**eed **D**ata **P**rocessing.
* **Memory Trick (Bottom-to-Top)**: **P**lease **D**o **N**ot **T**hrow **S**ausage **P**izza **A**way.
---
### 2. TCP/IP Model (Internet Protocol Suite)
*Developed by DoD (Department of Defense). Practical 4-layer (or 5-layer) operational model.*
```
OSI Model (7 Layers) TCP/IP 5-Layer Model TCP/IP 4-Layer Model
+--------------------+ +--------------------+ +--------------------+
| 7. Application | | 5. Application | | |
| 6. Presentation | ---> | | ---> | 4. Application |
| 5. Session | | | | |
+--------------------+ +--------------------+ +--------------------+
| 4. Transport | ---> | 4. Transport | ---> | 3. Transport |
+--------------------+ +--------------------+ +--------------------+
| 3. Network | ---> | 3. Network (Internet)| ---> | 2. Internet |
+--------------------+ +--------------------+ +--------------------+
| 2. Data Link | ---> | 2. Data Link | \ | 1. Network Access /|
+--------------------+ | | |---->| Link Layer |
| 1. Physical | ---> | 1. Physical | / | |
+--------------------+ +--------------------+ +--------------------+
```
---
### 3. Data Link Layer (Layer 2)
#### Core Functions
1. **Framing**: Character Count, Byte Stuffing (Flag = 01111110), Bit Stuffing (Insert `0` after 5 consecutive `1`s).
2. **Error Detection**:
- **Parity Check**: Single bit error detection. (Odd/Even parity).
- **Checksum**: Internet Checksum uses 1's complement addition.
- **CRC (Cyclic Redundancy Check)**: Modulo-2 binary division using generator polynomial $G(x)$. Detects all single bit errors, double bit errors, odd number errors, and burst errors of length $\le k$.
3. **Flow Control & Sliding Window Protocols**:
| Protocol | Sender Window Size ($W_s$) | Receiver Window Size ($W_r$) | Efficiency Formula ($\eta$) | Sequence Numbers Required | Retransmission on Loss |
| :--- | :---: | :---: | :---: | :---: | :--- |
| **Stop-and-Wait** | $1$ | $1$ | $\frac{1}{1 + 2a}$ | $2$ ($0$ and $1$) | Resend lost frame |
| **Go-Back-N (GBN)** | $N$ | $1$ | $\frac{N}{1 + 2a}$ | $N + 1$ | Resend $N$ frames starting from lost frame |
| **Selective Repeat (SR)** | $N$ | $N$ ($W_s = W_r$) | $\frac{N}{1 + 2a}$ | $2N$ | Resend ONLY the specific lost frame |
*Where $a = \frac{T_p}{T_t} = \frac{\text{Propagation Delay}}{\text{Transmission Delay}}$.*
*Transmission Delay $T_t = \frac{L}{B}$ (Frame Size / Bandwidth).*
*Propagation Delay $T_p = \frac{d}{v}$ (Distance / Signal Speed).*
4. **Protocols & Devices**:
- **Ethernet (IEEE 802.3)**: Uses **CSMA/CD** (Carrier Sense Multiple Access with Collision Detection). Min frame size = $64$ bytes ($512$ bits).
- **Wi-Fi (IEEE 802.11)**: Uses **CSMA/CA** (Carrier Sense Multiple Access with Collision Avoidance) with RTS/CTS.
- **PPP (Point-to-Point Protocol)**: Byte-oriented protocol for direct 2-node connections.
- **HDLC (High-Level Data Link Control)**: Bit-oriented protocol using bit stuffing.
---
### 4. Network Layer (Layer 3)
#### IPv4 Addressing (32 bits / 4 Bytes)
Format: `X.X.X.X` (Dotted Decimal notation). Total address space = $2^{32} \approx 4.3 \text{ billion}$.
| Class | First Octet Range | Default Subnet Mask | CIDR Prefix | Network Bits | Host Bits | Max Networks | Usable Hosts per Network |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **Class A** | `1 – 126` | `255.0.0.0` | `/8` | 7 | 24 | $2^7 - 2 = 126$ | $2^{24} - 2 = 16,777,214$ |
| **Class B** | `128 – 191` | `255.255.0.0` | `/16` | 14 | 16 | $2^{14} = 16,384$ | $2^{16} - 2 = 65,534$ |
| **Class C** | `192 – 223` | `255.255.255.0` | `/24` | 21 | 8 | $2^{21} = 2,097,152$ | $2^8 - 2 = 254$ |
| **Class D** | `224 – 239` | Reserved for Multicasting | — | — | — | — | — |
| **Class E** | `240 – 255` | Reserved for Research & Experimental | — | — | — | — | — |
* **Loopback Address**: `127.0.0.0/8` (specifically `127.0.0.1` for local host self-testing).
* **Private IP Address Ranges (RFC 1918)**:
- Class A: `10.0.0.0` to `10.255.255.255`
- Class B: `172.16.0.0` to `172.31.255.255`
- Class C: `192.168.0.0` to `192.168.255.255`
#### IPv6 Addressing (128 bits / 16 Bytes)
* Formatted as 8 groups of 4 hexadecimal digits separated by colons (e.g., `2001:0db8:85a3:0000:0000:8a2e:0370:7334`).
* Address space = $2^{128}$.
* No broadcast address (uses Multicast instead). Includes built-in IPsec.
#### Key Network Layer Protocols & Routing
* **ARP (Address Resolution Protocol)**: Maps logical **IP address $\rightarrow$ MAC address** (Layer 2/3 boundary).
* **RARP (Reverse ARP)**: Maps physical **MAC address $\rightarrow$ IP address** (used by diskless workstations).
* **ICMP (Internet Control Message Protocol)**: Error reporting and diagnostics. Used by `ping` (Echo Request Type 8, Echo Reply Type 0) and `traceroute` (Time Exceeded Type 11).
* **Routing Algorithms**:
- **Distance Vector**: Uses Bellman-Ford algorithm. Metric = Hop count (Max 15 hops). Example: **RIP** (Routing Information Protocol, UDP Port 520). Suffers from Count-to-Infinity problem.
- **Link State**: Uses Dijkstra's Shortest Path First (SPF) algorithm. Metric = Cost / Bandwidth. Example: **OSPF** (Open Shortest Path First, IP Protocol 89).
- **Path Vector**: Inter-domain routing protocol. Example: **BGP** (Border Gateway Protocol, TCP Port 179).
---
### 5. Transport Layer (Layer 4)
#### TCP vs UDP Detailed Matrix
| Feature | TCP (Transmission Control Protocol) | UDP (User Datagram Protocol) |
| :--- | :--- | :--- |
| **Connection Type** | Connection-Oriented (3-Way Handshake) | Connectionless |
| **Reliability** | Reliable (ACKs, Retransmissions) | Unreliable (Best-effort delivery) |
| **Header Size** | **20 Bytes** minimum (up to 60 Bytes) | **8 Bytes** fixed |
| **Data Flow** | Byte Stream | Message / Datagram |
| **Flow & Congestion Control**| Yes (Sliding Window, AIMD, Slow Start) | None |
| **Speed** | Slower (Overhead due to state management) | Very Fast |
| **Usage** | Web (HTTP/S), Email (SMTP/POP3), File Transfer (FTP), Terminal (SSH) | Streaming, VoIP, DNS, DHCP, Online Gaming |
#### TCP Handshakes
* **3-Way Handshake (Connection Establishment)**:
1. Client $\rightarrow$ Server: `SYN` (Seq = $x$)
2. Server $\rightarrow$ Client: `SYN + ACK` (Seq = $y$, ACK = $x + 1$)
3. Client $\rightarrow$ Server: `ACK` (Seq = $x + 1$, ACK = $y + 1$)
* **4-Way Handshake (Connection Termination)**:
1. Client $\rightarrow$ Server: `FIN`
2. Server $\rightarrow$ Client: `ACK`
3. Server $\rightarrow$ Client: `FIN`
4. Client $\rightarrow$ Server: `ACK`
---
## 🥈 Priority 2 (Very Important) ⭐⭐⭐⭐
### Switching Techniques
1. **Circuit Switching**: Dedicated physical path set up before data transfer. Constant bandwidth, zero queueing delay once established. (e.g., Landline Telephone).
2. **Message Switching**: Store-and-Forward mechanism for entire messages. High latency, large memory requirement.
3. **Packet Switching**: Data broken into small packets (headers + payload). Dynamic routing.
- **Datagram Packet Switching**: Connectionless. Packets routed independently; may arrive out-of-order. (e.g., Internet IP).
- **Virtual Circuit Packet Switching**: Connection-oriented. Pre-planned route; packets arrive in-order. (e.g., ATM, Frame Relay).
### Transmission Media
* **Guided (Bounded)**:
- **Twisted Pair**: UTP (Unshielded) & STP (Shielded). Cat5e/Cat6. Reduces crosstalk.
- **Coaxial Cable**: Inner copper conductor surrounded by insulation & braided mesh. Used in cable TV.
- **Optical Fiber**: Transmits light signals via **Total Internal Reflection**. Ultra-high bandwidth, immune to Electromagnetic Interference (EMI).
* **Unguided (Unbounded)**:
- **Radio Waves**: Omnidirectional ($3 \text{ kHz} - 1 \text{ GHz}$). Penetrates walls.
- **Microwave**: Unidirectional Line-of-Sight ($1 \text{ GHz} - 300 \text{ GHz}$). Used in satellite links and cellular towers.
- **Infrared**: Short range ($300 \text{ GHz} - 400 \text{ THz}$). Cannot penetrate walls (TV remote).
### Network Topologies
| Topology | Formula for Links ($N$ nodes) | Fault Tolerance | Main Advantage / Disadvantage |
| :--- | :---: | :---: | :--- |
| **Mesh** | $\frac{N(N-1)}{2}$ links, $N-1$ I/O ports | Highest (Dedicated links) | Highly reliable & private / Extremely expensive cabling |
| **Star** | $N$ links (Connected to Central Hub/Switch) | Moderate (Central switch single point of failure) | Easy to install & reconfigure / Hub failure downs network |
| **Bus** | $1$ main backbone cable + $N$ drop lines | Low (Cable cut breaks entire net) | Simple & cheap / High collision rate, hard to troubleshoot |
| **Ring** | $N$ links (Token passing) | Low (Single break interrupts ring) | Equal access / Failure of 1 host affects all (unless dual-ring) |
| **Tree** | Hierarchical combination of Star & Bus | Moderate | Scalable / Heavy dependency on main backbone cable |
### Multiplexing & Error Correction
* **Multiplexing**:
- **FDM (Frequency Division Multiplexing)**: Analog technique. Total bandwidth divided into frequency channels separated by guard bands (Radio/TV).
- **TDM (Time Division Multiplexing)**: Digital technique. Entire bandwidth allocated to each user for fixed time slots (Synchronous/Asynchronous).
- **WDM (Wavelength Division Multiplexing)**: Optical fiber technique combining different light wavelengths (colors).
* **Hamming Code (Error Correction)**:
- Redundancy bits ($r$) formula: $2^r \ge m + r + 1$ (where $m$ is data bits).
- Can detect 2-bit errors and correct 1-bit error.
---
## 🥉 Priority 3 (Moderately Important) ⭐⭐⭐
### Application Layer Protocols & Port Numbers
| Protocol | Port Number | Transport Protocol | Description / Purpose |
| :--- | :---: | :---: | :--- |
| **FTP (File Transfer Protocol)** | **20** (Data), **21** (Control) | TCP | Transfer files between host and server (Active vs Passive mode) |
| **SSH (Secure Shell)** | **22** | TCP | Secure encrypted remote terminal login |
| **Telnet** | **23** | TCP | Unencrypted plaintext remote terminal login |
| **SMTP (Simple Mail Transfer Protocol)** | **25** | TCP | Sending email between servers (Push protocol) |
| **DNS (Domain Name System)** | **53** | UDP & TCP | Map domain names $\rightarrow$ IP addresses (UDP for queries < 512B, TCP for zone transfer) |
| **DHCP (Dynamic Host Config Protocol)** | **67** (Server), **68** (Client) | UDP | Automatically assigns IP, Subnet Mask, Gateway, DNS to hosts |
| **HTTP (Hypertext Transfer Protocol)** | **80** | TCP | Web page data transfer (unencrypted) |
| **POP3 (Post Office Protocol v3)** | **110** | TCP | Downloads email from server to client and deletes from server (Pull) |
| **IMAP (Internet Message Access Protocol)**| **143** | TCP | Syncs email across multiple devices while keeping emails on server (Pull) |
| **HTTPS (HTTP Secure)** | **443** | TCP | Encrypted web browsing over TLS/SSL |
---
## 🎖️ Priority 4 ⭐⭐
### Network Devices Layer Mapping
| Device Name | Layer of OSI Model | Key Function |
| :--- | :--- | :--- |
| **Hub** | Layer 1 (Physical) | Multi-port repeater. **Broadcasts** all incoming signals to all ports. Shares collision domain. |
| **Repeater** | Layer 1 (Physical) | Regenerates weak physical signals to extend cable reach. |
| **Modem** | Layer 1 (Physical) | Modulator-Demodulator (Converts Digital $\leftrightarrow$ Analog signals). |
| **Switch** | Layer 2 (Data Link) | Multi-port bridge. **Unicasts** frames using MAC address table (CAM table). Separate collision domains per port. |
| **Bridge** | Layer 2 (Data Link) | Connects 2 LAN segments filtering traffic based on MAC address. |
| **Router** | Layer 3 (Network) | Connects different networks. Routes packets using IP addresses and routing tables. Separate broadcast domain per interface. |
| **Gateway** | Upper Layers (4–7) | Protocol converter connecting networks with different protocol stacks. |
### Network Types & MAC vs IP Addressing
* **Network Types**:
- **PAN (Personal Area Network)**: Up to 10 meters (Bluetooth 802.15).
- **LAN (Local Area Network)**: Office/Building up to 1 km (Ethernet, Wi-Fi).
- **MAN (Metropolitan Area Network)**: City-wide up to 50 km (Cable TV net, WiMAX).
- **WAN (Wide Area Network)**: Country/Global (Internet).
* **Addressing Differences**:
- **MAC Address**: Physical/Hardware address. 48 bits (6 Bytes) hex format (e.g., `00:1A:2B:3C:4D:5E`). Burned into NIC card by manufacturer.
- **IP Address**: Logical network address. 32 bits (IPv4) or 128 bits (IPv6). Assigned dynamically (DHCP) or statically.
- **Port Number**: Process identifier address. 16 bits ($0 - 65535$).
---
## ⚖️ Very Important Comparisons (Exam Favorites)
1. **TCP vs UDP**: TCP is connection-oriented, reliable, 20B header, flow-controlled. UDP is connectionless, unreliable, 8B header, low overhead.
2. **OSI vs TCP/IP**: OSI is a theoretical 7-layer reference model. TCP/IP is a practical 4/5-layer implementation model.
3. **IPv4 vs IPv6**: IPv4 is 32-bit (numeric decimal), IPv6 is 128-bit (hexadecimal).
4. **Hub vs Switch**: Hub is Layer 1 broadcast device (single collision domain). Switch is Layer 2 unicast device (separate collision domain per port).
5. **Switch vs Router**: Switch works on MAC addresses (Layer 2). Router works on IP addresses (Layer 3).
6. **CSMA/CD vs CSMA/CA**: CSMA/CD detects collisions after they occur (Ethernet). CSMA/CA avoids collisions before transmitting (Wi-Fi).
7. **ARP vs RARP**: ARP converts IP $\rightarrow$ MAC. RARP converts MAC $\rightarrow$ IP.
---
## 🧮 High-Yield Numericals to Revise
### Numerical 1: TCP Header Length Scaling
* **Rule**: The Header Length field (`HLEN`) in a TCP header is 4 bits wide. Its value represents the length of the header in **4-byte words** (32-bit words).
* **Formula**: $\text{Actual TCP Header Size (Bytes)} = \text{HLEN Value} \times 4$.
* **Example Question**: If the HLEN value in a TCP segment header is binary `1010` (decimal 10), what is the size of the TCP header?
- *Solution*: $10 \times 4 = \mathbf{40 \text{ Bytes}}$. (20 Bytes options).
### Numerical 2: CIDR Usable Host Calculation
* **Rule**: For a prefix `/N`, Host bits $h = 32 - N$. Total IPs = $2^h$. Usable hosts = $2^h - 2$ (subtracting Network ID and Broadcast ID).
* **Example Question**: How many usable host IP addresses are in a `/27` network?
- *Solution*: Host bits $h = 32 - 27 = 5$. Total IPs = $2^5 = 32$. Usable hosts = $32 - 2 = \mathbf{30 \text{ Hosts}}$.
### Numerical 3: Sliding Window Efficiency & Throughput
* **Formulas**:
- Transmission time $T_t = \frac{\text{Frame Size}}{\text{Bandwidth}}$
- Propagation time $T_p = \frac{\text{Distance}}{\text{Speed}}$
- Efficiency $\eta = \frac{N}{1 + 2a}$, where $a = \frac{T_p}{T_t}$ and $N$ is sender window size.
- Throughput = $\eta \times \text{Bandwidth}$.
---
## 🕒 One-Day Rapid Revision Order
1. **OSI Model & 7 Layers** (20 min)
2. **Network Devices & PDU Mapping** (15 min)
3. **Data Link Layer & Flow Control Math** (40 min)
4. **Network Layer, IPv4 & CIDR Subnetting** (45 min)
5. **Transport Layer & TCP 3-Way Handshake** (45 min)
6. **TCP vs UDP Quick Comparison** (15 min)
7. **IP Classes & Special IPs** (30 min)
8. **Application Layer Port Numbers** (15 min)
9. **Switching Techniques** (20 min)
10. **Topologies & Media** (30 min)
11. **Solve High-Yield PYQs** (1–2 Hours)
---
## 📌 The 20 "Must-Remember" Facts
1. OSI has **7 layers**; TCP/IP model has **4 (or 5)** layers.
2. Physical Layer PDU = **Bits**.
3. Data Link Layer PDU = **Frame**.
4. Network Layer PDU = **Packet**.
5. Transport Layer PDU = **Segment (TCP)** or **Datagram (UDP)**.
6. Hub operates at **Layer 1 (Physical)**.
7. Switch operates at **Layer 2 (Data Link)**.
8. Router operates at **Layer 3 (Network)**.
9. TCP is **connection-oriented** and **reliable**.
10. UDP is **connectionless** and **unreliable**.
11. TCP uses **3-Way Handshake** (`SYN` $\rightarrow$ `SYN-ACK` $\rightarrow$ `ACK`) for connection setup.
12. Ethernet uses **CSMA/CD** (Collision Detection).
13. Wi-Fi uses **CSMA/CA** (Collision Avoidance).
14. IPv4 address is **32 bits** (4 bytes).
15. IPv6 address is **128 bits** (16 bytes).
16. ARP resolves **IP address to MAC address**.
17. ICMP is used by **ping** (Echo Request/Reply) and **traceroute**.
18. HTTP uses port **80**, HTTPS uses port **443**.
19. DNS uses port **53** (UDP/TCP).
20. DHCP automatically assigns IP addresses using **DISCOVER, OFFER, REQUEST, ACK** (DORA process).