# Networks 2027 Rank-Decider: Token Bucket Burst Math, TCP Wrap-Around, BGP Policies & DNS RTTs
Exam: GATE Computer Science & Information Technology (GATE CS)
Subject: Computer Networks
Canonical URL: https://gateandnet.com/exams/gate-cs/computer-networks/token-bucket-bgp-ospf-dns-and-tcp-wraparound

> Token Bucket vs Leaky Bucket maximum burst duration formula, 32-bit TCP sequence wrap-around time on high-speed fiber, Distance-Vector 3-node count-to-infinity, BGP AS valley-free routing, and DNS + HTTP RTTs.

## 1. Traffic Shaping: Leaky Bucket vs Token Bucket (GATE NAT Classic)

- **Leaky Bucket:** Smooths bursty traffic into a **strictly constant output rate** $\rho$ regardless of how full the bucket is (cannot send bursts faster than $\rho$!).
- **Token Bucket (Capacity $C$, Token Rate $\rho$, Peak Output Link $M > \rho$):** Starts full with $C$ tokens. Draining at peak rate $M$ while refilling at $\rho$ exhausts the bucket at $S = \frac{C}{M - \rho}$ seconds!
  - *Quick Example:* $C = 1\text{ MB},\; \rho = 2\text{ MB/s},\; M = 10\text{ MB/s} \implies S = \frac{1}{10 - 2} = \mathbf{0.125\text{ s}}$, transmitting $10 \times 0.125 = \mathbf{1.25\text{ MB}}$ at peak speed before throttling to $2\text{ MB/s}$!

## 2. Routing Nuances: OSPF vs RIP vs BGP-4

| Protocol | Scope & Algorithm | Transport Carrier | Metric & Critical Exam Nuance |
| :--- | :--- | :---: | :--- |
| **RIP** | Intra-AS (IGP) • Distance Vector | **UDP Port 520** | Hop count (max $15$; $16 = \infty$); **Poisoned Reverse fails on $\ge 3$-node cycles!** |
| **OSPF** | Intra-AS (IGP) • Link-State (Dijkstra) | **Directly over IP (Proto 89)** | Bandwidth/cost; floods LSAs to all routers in area |
| **BGP-4** | Inter-AS (EGP) • **Path-Vector** | **TCP Port 179** | Policy + `AS-PATH` attribute (prevents loops in $\mathcal{O}(1)$ by checking own ASN!) |

## 3. End-to-End Web Page Load RTT Formula (DNS + TCP + HTTP)

Suppose visiting a page requires $k$ uncached iterative DNS lookups ($\text{RTT}_1, \dots, \text{RTT}_k$), followed by fetching a base HTML file + $m$ embedded images from an origin server at $\text{RTT}_0$ (ignoring transmission delay):
- **Non-Persistent HTTP/1.0 (Serial):** $\sum_{i=1}^k \text{RTT}_i + 2\,\text{RTT}_0\text{ (HTML)} + m \cdot (2\,\text{RTT}_0)$!
- **Persistent HTTP/1.1 without Pipelining:** $\sum \text{RTT}_i + \underbrace{\text{RTT}_0}_{\text{TCP SYN}} + \underbrace{\text{RTT}_0}_{\text{HTML}} + m \cdot \text{RTT}_0$.
- **Persistent HTTP/1.1 WITH Pipelining (or HTTP/2 Multiplexing):** $\sum \text{RTT}_i + \text{RTT}_0\text{ (TCP)} + \text{RTT}_0\text{ (HTML)} + \mathbf{1 \cdot \text{RTT}_0}\text{ (all } m \text{ objects together!)}$.

## Solved Practice Questions & PYQs

### [GATE CS 2027 Expected NAT | NAT]
A **Token Bucket** shaper has bucket capacity $C = 500\text{ KB}$, token refill rate $\rho = 4\text{ MB/s}$, and maximum output link rate $M = 24\text{ MB/s}$. Starting with a **full bucket**, what is the **maximum burst duration $S$ in milliseconds** during which the output can transmit continuously at $24\text{ MB/s}$?
**Correct Answer:** 25
**Solution:** $C = 0.5\text{ MB}$. Solving $C + \rho S = M S \implies S = \frac{C}{M - \rho} = \frac{0.5\text{ MB}}{(24 - 4)\text{ MB/s}} = \frac{0.5}{20} = 0.025\text{ s} = \mathbf{25\text{ ms}}$.

### [GATE CS 2026–27 Expected | NAT]
A high-speed TCP connection transmits continuously at $1\text{ GigaByte/sec}$ ($2^{30}\text{ bytes/sec}$). In how many **seconds** does the $32$-bit TCP sequence number space ($2^{32}\text{ bytes}$) wrap around completely?
**Correct Answer:** 4
**Solution:** $$T_{\text{wrap}} = \frac{2^{32}\text{ bytes}}{2^{30}\text{ bytes/s}} = 2^2 = \mathbf{4\text{ seconds}}$$ (far shorter than $\text{MSL} = 60\text{s}$, which is why Gigabit TCP requires the PAWS timestamp option!).
