# IPv4 CIDR Subnetting, CSMA/CD Minimum Frame & Sliding Window Math
Exam: GATE Computer Science & Information Technology (GATE CS)
Subject: Computer Networks
Canonical URL: https://gateandnet.com/exams/gate-cs/computer-networks/ipv4-cidr-csma-and-sliding-window

> Host count, subnet mask binary math, L >= 2Tp*B efficiency formula, Go-Back-N vs Selective Repeat window sizes, and TCP AIMD.

## Sliding Window Sequence Number Bits ($k$ bits $\implies 2^k$ Seq Numbers)

| Protocol | Sender Window $W_s$ | Receiver Window $W_r$ | Min Seq Numbers Required ($W_s + W_r \le 2^k$) |
| :--- | :---: | :---: | :---: |
| **Stop-and-Wait ARQ** | $1$ | $1$ | $2$ ($1$-bit sequence: `0, 1`) |
| **Go-Back-N (GBN)** | $2^k - 1$ | $1$ | $W_s + 1 \le 2^k$ |
| **Selective Repeat (SR)** | $2^{k-1}$ | $2^{k-1}$ | $2 \cdot W_s \le 2^k$ |

## IPv4 CIDR Block Calculations

Given prefix `A.B.C.D / n` ($0 \le n \le 32$):
- **Host bits:** $h = 32 - n$
- **Total IP addresses in block:** $2^{32 - n}$
- **Usable Host IPs:** $2^{32 - n} - 2$ *(subtract Network ID all-0s & Directed Broadcast all-1s; exception `/31` point-to-point RFC 3021)*.


## Solved Practice Questions & PYQs

### [GATE CS Networks NAT | NAT]
An Ethernet LAN operating at $100\text{ Mbps}$ uses CSMA/CD over a cable of length $2\text{ km}$ where signal propagation speed is $2 \times 10^8\text{ m/s}$. What is the **minimum frame size** required (in **bytes**)?
**Correct Answer:** 250
**Solution:** - Propagation delay $T_p = \frac{d}{v} = \frac{2000\text{ m}}{2 \times 10^8\text{ m/s}} = 10^{-5}\text{ s}$.
- Minimum frame bits $L_{\min} = 2 \times T_p \times B = 2 \times 10^{-5} \times 10^8 = 2000\text{ bits}$.
- In bytes: $\frac{2000}{8} = \mathbf{250\text{ bytes}}$.

### [GATE CS Networks | MCQ]
In a **Selective Repeat** sliding window protocol using $k = 4$ bits for frame sequence numbers, what is the maximum permissible sender window size $W_s$ to avoid sequence ambiguity?
**Correct Answer:** C
**Solution:** In Selective Repeat ARQ, $W_s + W_r \le 2^k$ with $W_s = W_r$, giving $W_{s,\max} = 2^{k-1} = 2^{4-1} = \mathbf{8}$ (whereas Go-Back-N allows $2^k - 1 = 15$).

### [GATE CS Networks | MCQ]
How many **usable host IPv4 addresses** are available in a `/26` CIDR subnet (subnet mask `255.255.255.192`)?
**Correct Answer:** B
**Solution:** Host bits $= 32 - 26 = 6$ bits. Subtracting the network address (all 0s) and directed broadcast address (all 1s) leaves $2^6 - 2 = 64 - 2 = \mathbf{62}$ usable host addresses.

### [GATE CS Networks | MCQ]
In CRC error detection, if the generator polynomial is $G(x) = x^4 + x + 1$, how many **CRC redundant check bits** are appended to the dataword?
**Correct Answer:** B
**Solution:** A generator polynomial $G(x)$ of **degree $r$** has an $(r+1)$-bit binary divisor (`10011`, 5 bits) and appends exactly **$r = 4$** CRC remainder bits to the frame.
