Computer Networks
Difficulty: Mastery — cross-domain (mathematics + physics + coding), build/prove, integrative reasoning Time limit: 90 minutes Total marks: 60
Instructions: Answer all three questions. Show all working, derivations, and reasoning. Partial credit is awarded for correct method. Use for inline math and for displayed math.
Question 1 — Physical-layer channel design and capacity (20 marks)
A wireless link operates over a channel of bandwidth with a signal-to-noise ratio of .
(a) Convert the SNR from decibels to a linear ratio, then compute the Shannon–Hartley capacity of the channel in Mbit/s. Show the formula and all steps. (5 marks)
(b) The designer wishes to reach exactly the Shannon capacity from (a) using an -ary encoding at the maximum Nyquist signalling rate for this bandwidth. Derive the required number of levels (allow non-integer, then round up to the smallest usable power of two). State the Nyquist formula used and explain why the practical (Nyquist) result is bounded by the Shannon result. (6 marks)
(c) The team instead adopts Manchester encoding for a wired variant of the link carrying of user data. Explain, with reference to transitions per bit, the minimum baud rate (symbol/transition rate) and hence the minimum required bandwidth relative to NRZ. Give a numerical comparison. (4 marks)
(d) State one physical-layer advantage and one disadvantage of Manchester over NRZ that justifies its historical use in 10BASE-T Ethernet. (5 marks)
Question 2 — Addressing, subnetting proof, and CRC (20 marks)
(a) A company is allocated the block 172.16.0.0/16. Using VLSM, they must create subnets for the following departments (largest first): Engineering (4000 hosts), Sales (2000 hosts), Support (1000 hosts), and a point-to-point WAN link (2 hosts).
For each subnet give: the CIDR prefix length, the subnet network address, the subnet mask (dotted decimal), and the usable host count. Allocate sequentially starting at 172.16.0.0. (9 marks)
(b) Prove the general formula that a subnet with host bits provides usable host addresses, and explain precisely which two addresses are excluded and why. Then state the special case where the "" rule does not apply and justify it. (5 marks)
(c) Compute the CRC remainder (Frame Check Sequence) for the data bit-string
using the generator polynomial
Show the full polynomial (binary long division) working and state the transmitted frame. Then verify that appending your remainder makes the frame exactly divisible by . (6 marks)
Question 3 — Transport reliability, congestion, and a socket build (20 marks)
(a) A TCP connection has round-trip time and runs over a link of capacity . Compute the bandwidth–delay product in bytes, and hence state the minimum receive-window size (and TCP feature) needed to keep the pipe full. (5 marks)
(b) A TCP flow uses standard slow start and congestion avoidance. Initial cwnd = 1 MSS, ssthresh = 8 MSS. A triple-duplicate-ACK loss event occurs at the end of transmission round 10 (i.e. after that round's ACKs). Assuming TCP Reno behaviour (slow start until ssthresh, then additive increase of 1 MSS/round; on triple-dup-ACK: ssthresh = cwnd/2, cwnd = ssthresh, then continue in congestion avoidance):
Tabulate cwnd (in MSS) at the start of each round from round 1 to round 13. Clearly mark where slow start ends and where the fast-recovery adjustment occurs. (8 marks)
(c) Write a minimal Python TCP echo server (using the socket module) that binds to port 5000, accepts one client, echoes back any received bytes uppercased, and closes cleanly. Then, in 2–3 sentences, explain the role of the 3-way handshake that occurs before your recv() returns data, naming the three segments and their flags. (7 marks)
End of paper.
Answer keyMark scheme & solutions
Question 1
(a) Shannon capacity (5 marks)
SNR linear: . (1) Shannon–Hartley: . (1) . (1) (2) (Accept Mbit/s; using gives essentially the same.)
(b) Nyquist M-ary (6 marks)
Nyquist noiseless capacity: . (1) Max signalling (Nyquist) rate symbols/s. (1) Set : (2) So . Round up to smallest usable power of two this that keeps integer for clean encoding: (). (1) Bounding explanation: Nyquist assumes a noiseless channel and lets grow arbitrarily; in a real channel, noise limits reliable distinguishable levels, and Shannon gives the upper bound on error-free rate. Hence any Nyquist scheme's reliable throughput cannot exceed the Shannon capacity. (1)
(c) Manchester baud/bandwidth (4 marks)
Manchester encodes each bit with a mid-bit transition ⇒ up to 2 transitions per bit ⇒ signalling (baud) rate is twice the bit rate. For Mbit/s the transition rate is Mbaud. (2) Minimum bandwidth baud rate: Manchester needs MHz whereas NRZ needs MHz for the same 10 Mbit/s — Manchester requires double the bandwidth of NRZ. (2)
(d) Manchester pros/cons (5 marks)
- Advantage (any one, 3): Guaranteed transition in every bit period ⇒ self-clocking / built-in clock recovery, and it is DC-balanced (no baseline wander), so long runs of identical bits don't cause loss of sync. (3)
- Disadvantage (2): Requires twice the bandwidth of NRZ (higher signalling rate), limiting maximum bit rate on a given medium. (2)
Question 2
(a) VLSM allocation (9 marks) — 2.25 per subnet, allocate sequentially
Requirements → host bits: need hosts.
| Dept | Hosts | Host bits | Prefix | Network | Mask | Usable |
|---|---|---|---|---|---|---|
| Engineering | 4000 | 12 () | /20 | 172.16.0.0 | 255.255.240.0 | 4094 |
| Sales | 2000 | 11 () | /21 | 172.16.16.0 | 255.255.248.0 | 2046 |
| Support | 1000 | 10 () | /22 | 172.16.24.0 | 255.255.252.0 | 1022 |
| WAN link | 2 | 2 () | /30 | 172.16.28.0 | 255.255.255.252 | 2 |
Allocation reasoning: /20 spans 16 third-octet values (0–15) → next starts at .16.0; /21 spans 8 (16–23) → next .24.0; /22 spans 4 (24–27) → next .28.0; /30 spans 4 addresses. (marks: correct prefix + network each subnet)
(b) Proof of (5 marks)
With host bits, the host portion ranges over all bit patterns → total addresses in the subnet. (2) Two are reserved:
- All-zero host bits = the network (subnet) address, used to identify the network itself; not assignable to an interface. (1)
- All-one host bits = the directed broadcast address for that subnet; not assignable to a host. (1) Hence usable . (0.5) Exception: For a /31 (, point-to-point link, RFC 3021) the "" is waived — both addresses are usable as the two endpoints, since broadcast is meaningless on a P2P link. (A /32 is a single host route.) (0.5)
(c) CRC (6 marks)
Degree of is 4 → append 4 zeros: dividend . Divide by (XOR long division):
1101011011 0000 ÷ 10011
110101...
10011
------
10001 1011 0000 (running remainder as we bring bits)
Performing the full XOR division, the remainder (FCS) is:
Transmitted frame . (4)
Verification: the transmitted frame divided by gives remainder → divisible, confirming FCS. (2)
(Standard textbook result: , ⇒ remainder .)
Question 3
(a) Bandwidth–delay product (5 marks)
(3) The receive window must be MB to keep the pipe full. Since the base TCP window field is 16 bits (max 65 535 B), the TCP Window Scale option (RFC 7323) is required to advertise windows this large. (2)
(b) cwnd table (8 marks)
Slow start doubles each round until reaching ssthresh = 8; then additive increase (+1/round).
| Round | cwnd (start) | Phase |
|---|---|---|
| 1 | 1 | slow start |
| 2 | 2 | slow start |
| 3 | 4 | slow start |
| 4 | 8 | reaches ssthresh → switch to CA |
| 5 | 9 | congestion avoidance |
| 6 | 10 | CA |
| 7 | 11 | CA |
| 8 | 12 | CA |
| 9 | 13 | CA |
| 10 | 14 | CA — triple-dup-ACK at end of this round |
Loss event at end of round 10 (cwnd = 14): , (Reno fast recovery → set to new ssthresh). Continue additive increase:
| Round | cwnd (start) | Phase |
|---|---|---|
| 11 | 7 | fast-recovery adjustment → CA |
| 12 | 8 | CA |
| 13 | 9 | CA |
Mark points: correct doubling 1→2→4→8 (2), correct transition at 8 (1), correct CA increments to 14 (2), correct halving to ssthresh=7, cwnd=7 (2), correct rounds 11–13 (1).
(c) TCP echo server (7 marks)
import socket
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind(('', 5000))
srv.listen(1)
conn, addr = srv.accept() # completes 3-way handshake
with conn:
while True:
data = conn.recv(1024)
if not data: # client closed
break
conn.sendall(data.upper())
conn.close()
srv.close()Marks: socket()+bind(5000)+listen (2), accept (1), recv/upper/sendall loop (2).
Handshake explanation (2): Before recv() returns application data, TCP completes the 3-way handshake: the client sends SYN (its ISN), the server replies SYN-ACK (its ISN + ack of client's SYN), and the client sends ACK. Only after this does accept() return an established connection ready for data transfer.
[
{"claim":"Shannon capacity ~39.87 Mbit/s for B=4MHz, SNR=1000", "code":"import sympy as sp; C=4*10**6*sp.log(1001,2); result = abs(float(C)-39.869e6) < 0.05e6"},
{"claim":"Nyquist log2 M ~4.984 -> M rounds up to 32", "code":"C=39.869e6; B=4*10**6; L=C/(2*B); result = (abs(L-4.9836)<0.01) and (2**5==32)"},
{"claim":"BDP = 2.5 MB for 1Gbps x 20ms", "code":"bdp_bits=10**9*0.02; bdp_bytes=bdp_bits/8; result = bdp_bytes==2.5*10**6"},
{"claim":"CRC remainder of 1101011011 with G=10011 is 1110 and frame divisible", "code":"D=0b1101011011; G=0b10011; msg=D<<4\nrem=msg\nfor i in range(len(bin(msg))-2-1, 4-1, -1):\n if rem>>i & 1:\n rem ^= G<<(i-4)\nfcs=rem & 0b1111\nframe=(D<<4)|fcs\nchk=frame\nfor i in range(len(bin(frame))-2-1,4-1,-1):\n if chk>>i &1: chk^=G<<(i-4)\nresult = (fcs==0b1110) and ((chk & 0b1111)==0)"},
{"claim":"cwnd sequence reaches 14 at round 10, halves to 7", "code":"cwnd=1; ssthresh=8; seq=[]\nfor r in range(1,11):\n seq.append(cwnd)\n if cwnd<ssthresh: cwnd=cwnd*2\n else: cwnd=cwnd+1\nloss_cwnd=seq[-1]; new_ss=loss_cwnd//2\nresult = (seq[9]==14) and (new_ss==7)"}
]