GATE-Style Numericals
By the end of this lesson you will be able to recognise the common types of numerical question in computer networks, apply a fixed method to each one, and check your answer with a few lines of Python before you trust it.
Numerical questions reward a calm, step-by-step habit more than clever tricks. For every question below, we first write the known values with units, then pick the formula, then calculate. All the problems are original practice problems in the style of GATE, not copies of past papers.
The habit that prevents most mistakes
- Write the givens with units. "1 Gbps", "2,000 km", "1,000 bytes".
- Convert everything to bits, metres and seconds before using a formula.
- Choose the formula and write it down.
- Calculate, and sanity-check the size of the answer.
- Answer in the unit asked (ms, bytes, number of bits).
Most wrong answers come from step 2: bytes left as bytes, km left as km, or Mbps treated as MBps. The table below collects the formulas from this course.
| Topic | Formula |
|---|---|
| Transmission delay | Tt = L / R |
| Propagation delay | Tp = d / v |
| Stop-and-wait efficiency | 1 / (1 + 2a), where a = Tp / Tt |
| Sliding window efficiency | min(1, W / (1 + 2a)) |
| Window bits | GBN: 2^n - 1 ≥ W; SR: 2^(n-1) ≥ W |
| CSMA/CD minimum frame | Lmin = 2 × Tp × R |
| Usable hosts | 2^h - 2 |
| TCP sequence wrap time | 2^32 bytes / bandwidth in bytes per second |
| Throughput limit by window | window / RTT |
Problem 1: subnet facts
Question. A host has address 172.29.150.77/21. Find the network address, broadcast address, number of usable hosts and the 100th usable host.
Method.
- A /21 leaves 3 network bits in the third octet: mask 248, block size 8.
- 150 lies between 144 and 151, so the network is
172.29.144.0and the broadcast172.29.151.255. - Host bits = 32 - 21 = 11, so 2^11 - 2 = 2,046 hosts.
- The 100th usable host is the network address plus 100:
172.29.144.100.
import ipaddress
net = ipaddress.ip_interface("172.29.150.77/21").network
print("Network:", net.network_address, " Broadcast:", net.broadcast_address)
print("Usable hosts:", net.num_addresses - 2)
print("100th host:", net.network_address + 100)Network: 172.29.144.0 Broadcast: 172.29.151.255 Usable hosts: 2046 100th host: 172.29.144.100
Problem 2: sliding window and sequence bits
Question. A 100 Mbps link is 3,000 km long, with signal speed 2 × 10^8 m/s. Frames are 1,250 bytes. Find (a) the stop-and-wait efficiency, (b) the window size for 100% utilisation, and (c) the minimum sequence number bits for Go-Back-N and for Selective Repeat with that window.
Method.
- Tt = 1,250 × 8 / 10^8 = 0.1 ms. Tp = 3 × 10^6 / (2 × 10^8) = 15 ms.
- a = Tp / Tt = 150.
- Efficiency = 1 / (1 + 300) ≈ 0.33%.
- W = 1 + 2a = 301 frames.
- GBN: smallest n with 2^n - 1 ≥ 301 is n = 9 (511). SR: 2^(n-1) ≥ 301 gives n = 10.
import math
R, L, d, v = 100e6, 1250 * 8, 3000e3, 2e8
tt, tp = L / R, d / v
a = tp / tt
w = math.ceil(1 + 2 * a)
print(f"Tt = {tt * 1e3:.1f} ms, Tp = {tp * 1e3:.0f} ms, a = {a:.0f}")
print(f"Stop-and-wait efficiency = {1 / (1 + 2 * a):.2%}")
print("Window for full use =", w)
print("GBN bits =", math.ceil(math.log2(w + 1)), " SR bits =", math.ceil(math.log2(w)) + 1)Tt = 0.1 ms, Tp = 15 ms, a = 150 Stop-and-wait efficiency = 0.33% Window for full use = 301 GBN bits = 9 SR bits = 10
Problem 3: CSMA/CD minimum frame size
Question. A shared 1 Gbps CSMA/CD bus is 200 m long, with signal speed 2 × 10^8 m/s. What is the minimum frame size in bytes?
Method.
- Tp = 200 / (2 × 10^8) = 1 µs.
- Lmin = 2 × Tp × R = 2 × 10^-6 × 10^9 = 2,000 bits.
- 2,000 / 8 = 250 bytes.
The answer grows with speed: at 1 Gbps the same cable needs frames ten times longer than at 100 Mbps. That is one reason gigabit Ethernet dropped shared half-duplex cables in practice.
Problem 4: when do TCP sequence numbers wrap?
Question. TCP sequence numbers are 32 bits and count bytes. On a 10 Gbps link, how long until they wrap around? Why does this matter?
Method.
- Sequence space = 2^32 bytes.
- Bytes per second = 10 × 10^9 / 8 = 1.25 × 10^9.
- Wrap time = 2^32 / (1.25 × 10^9) ≈ 3.44 seconds.
Old segments delayed in the network for more than about 3 seconds could then be confused with new data. That is why high-speed TCP uses the timestamps option (PAWS, "protection against wrapped sequence numbers").
for gbps in [0.1, 1, 10, 100]:
seconds = 2 ** 32 / (gbps * 1e9 / 8)
print(f"{gbps:>5} Gbps: wraps in {seconds:,.2f} s")
print("CSMA/CD Lmin:", 2 * (200 / 2e8) * 1e9 / 8, "bytes") 0.1 Gbps: wraps in 343.60 s
1 Gbps: wraps in 34.36 s
10 Gbps: wraps in 3.44 s
100 Gbps: wraps in 0.34 s
CSMA/CD Lmin: 250.0 bytesThe last line checks Problem 3.
Problem 5: congestion window
Question. A TCP connection starts in slow start with cwnd = 1 MSS and ssthresh = 32 MSS. There are no losses. After how many RTTs does cwnd first reach 40 MSS? (Count the window used in each RTT, starting with RTT 1 at cwnd = 1.)
Method.
- Slow start doubles: 1, 2, 4, 8, 16, 32 (RTTs 1 to 6).
- At ssthresh, congestion avoidance adds 1 per RTT: 33 at RTT 7, 34 at RTT 8, and so on.
- 40 = 32 + 8, so RTT 6 + 8 = RTT 14.
cwnd, ssthresh, rtt = 1, 32, 1
while cwnd < 40:
cwnd = min(cwnd * 2, ssthresh) if cwnd < ssthresh else cwnd + 1
rtt += 1
print("cwnd reaches 40 MSS in RTT", rtt)cwnd reaches 40 MSS in RTT 14
Read the question's counting rule carefully. Some questions count "after n RTTs" starting from 0; the answer then shifts by one.
Problem 6: throughput limited by the window
Question. A TCP receiver advertises a fixed window of 64 KiB (65,535 bytes, no window scaling). The RTT is 50 ms and the link is 1 Gbps. What is the maximum throughput?
Method.
- At most one window is sent per RTT.
- Throughput ≤ window / RTT = 65,535 × 8 / 0.05 ≈ 10.5 Mbps.
- The link could do 1,000 Mbps, so the window is the bottleneck. The window needed is bandwidth × RTT = 6.25 MB, which is why the window scale option exists.
window, rtt, link = 65535, 0.05, 1e9
print(f"Max throughput: {window * 8 / rtt / 1e6:.1f} Mbps")
print(f"Window needed for 1 Gbps: {link * rtt / 8 / 1e6:.2f} MB")Max throughput: 10.5 Mbps Window needed for 1 Gbps: 6.25 MB
Problem 7: fragmentation and CRC, quick checks
Two more question types you have already solved in earlier lessons:
- Fragmentation (IPv4 Header & Fragmentation): data per fragment = MTU - 20, rounded down to a multiple of 8; offsets in 8-byte units; MF = 0 only on the last.
- CRC (Error Detection): append (generator length - 1) zeros, divide with XOR, send the remainder.
Common mistakes
- Forgetting the factor 8. Convert bytes to bits before dividing by a bit rate.
- Using 1 / (1 + a) for stop-and-wait. The ACK has to return: use 1 + 2a.
- Mixing up GBN and SR limits. GBN: 2^n - 1. SR: 2^(n-1).
- Miscounting RTTs in congestion questions. Write out the window for each RTT in a small table.
Key points
- Write givens with units, convert to bits, metres and seconds, then apply one formula.
- Subnet questions use block size and 2^h - 2.
- Efficiency questions depend on a = Tp / Tt; full use needs W ≥ 1 + 2a.
- CSMA/CD needs frames of at least 2 × Tp × R bits.
- TCP throughput is limited by window / RTT; the sequence space wraps after 2^32 bytes.
- Check every answer with a quick calculation; Python makes that easy.
Exercise
Solve by hand, then check with Python: a 20 Mbps link has RTT 80 ms and frames of 2,000 bytes. (a) What is the stop-and-wait efficiency? (b) What window gives full use? (c) How many sequence bits does Selective Repeat need for that window? (d) How many RTTs does slow start take to go from cwnd 1 to cwnd 64 if ssthresh is 128?
Show solution
import math
tt = 2000 * 8 / 20e6 # 0.8 ms
tp = 0.080 / 2 # one-way 40 ms
a = tp / tt
w = math.ceil(1 + 2 * a)
print(f"a = {a:.0f}, efficiency = {1 / (1 + 2 * a):.2%}")
print("Window =", w, " SR bits =", math.ceil(math.log2(w)) + 1)
cwnd, rtt = 1, 1
while cwnd < 64:
cwnd *= 2
rtt += 1
print("cwnd is 64 in RTT", rtt)a = 50, efficiency = 0.99% Window = 101 SR bits = 8 cwnd is 64 in RTT 7
Tt is 0.8 ms and the one-way delay is half the RTT, 40 ms, so a = 50 and efficiency is 1/101. Selective Repeat needs 2^(n-1) ≥ 101, so n = 8. Slow start goes 1, 2, 4, 8, 16, 32, 64, which is the seventh RTT.
Quick Quiz
1. A 1 Gbps link carries 1,000-byte frames. What is the transmission delay?
1,000 × 8 bits / 10^9 bits per second = 8 × 10^-6 s.
2. With a = 4.5, what window gives 100% utilisation?
W = 1 + 2a = 10.
3. Roughly how long do TCP sequence numbers take to wrap at 1 Gbps?
2^32 bytes / 1.25 × 10^8 bytes per second ≈ 34 seconds.
4. A fixed 32 KiB window and a 100 ms RTT limit throughput to about:
32,768 × 8 / 0.1 ≈ 2.6 million bits per second.
Learn Computer Networks with a mentor
Free lessons get you started. Our Computer Science Fundamentals training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
