Level 5 — MasteryComputer Networks

Computer Networks

90 minutes60 marksprintable — key stays hidden on paper

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 B=4 MHzB = 4\text{ MHz} with a signal-to-noise ratio of SNRdB=30 dB\text{SNR}_{\text{dB}} = 30\text{ dB}.

(a) Convert the SNR from decibels to a linear ratio, then compute the Shannon–Hartley capacity CC 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 MM-ary encoding at the maximum Nyquist signalling rate for this bandwidth. Derive the required number of levels MM (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 R=10 Mbit/sR = 10\text{ Mbit/s} 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 hh host bits provides 2h22^{h}-2 usable host addresses, and explain precisely which two addresses are excluded and why. Then state the special case where the "2-2" rule does not apply and justify it. (5 marks)

(c) Compute the CRC remainder (Frame Check Sequence) for the data bit-string

D=1101011011D = 1101011011

using the generator polynomial

G(x)=x4+x+1G=10011.G(x) = x^{4} + x + 1 \quad\Rightarrow\quad G = 10011.

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 GG. (6 marks)


Question 3 — Transport reliability, congestion, and a socket build (20 marks)

(a) A TCP connection has round-trip time RTT=20 ms\text{RTT} = 20\text{ ms} and runs over a link of capacity 1 Gbit/s1\text{ Gbit/s}. 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: 30 dB=1030/10=103=100030\text{ dB} = 10^{30/10} = 10^{3} = 1000. (1) Shannon–Hartley: C=Blog2(1+SNR)C = B\log_2(1+\text{SNR}). (1) C=4×106log2(1001).C = 4\times10^{6}\cdot\log_2(1001). log2(1001)=ln(1001)/ln29.9672\log_2(1001) = \ln(1001)/\ln 2 \approx 9.9672. (1) C4×106×9.9672=39.87×106 bit/s39.87 Mbit/s.C \approx 4\times10^{6}\times 9.9672 = 39.87\times10^{6}\text{ bit/s} \approx 39.87\text{ Mbit/s}. (2) (Accept 39.9\approx 39.9 Mbit/s; using log21000=9.966\log_2 1000 = 9.966 gives essentially the same.)

(b) Nyquist M-ary (6 marks)

Nyquist noiseless capacity: C=2Blog2MC = 2B\log_2 M. (1) Max signalling (Nyquist) rate =2B=8×106= 2B = 8\times10^{6} symbols/s. (1) Set 2Blog2M=CShannon2B\log_2 M = C_{\text{Shannon}}: log2M=C2B=39.87×1068×1064.984.\log_2 M = \frac{C}{2B} = \frac{39.87\times10^{6}}{8\times10^{6}} \approx 4.984. (2) So M24.98431.6M \approx 2^{4.984} \approx 31.6. Round up to smallest usable power of two \ge this that keeps log2M\log_2 M integer for clean encoding: M=32M = 32 (=25=2^5). (1) Bounding explanation: Nyquist assumes a noiseless channel and lets MM 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 R=10R = 10 Mbit/s the transition rate is 2020 Mbaud. (2) Minimum bandwidth \approx baud rate: Manchester needs 10\approx 10 MHz whereas NRZ needs 5\approx 5 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 2h22^h - 2 \ge hosts.

Dept Hosts Host bits hh Prefix Network Mask Usable
Engineering 4000 12 (2122=40942^{12}-2=4094) /20 172.16.0.0 255.255.240.0 4094
Sales 2000 11 (2112=20462^{11}-2=2046) /21 172.16.16.0 255.255.248.0 2046
Support 1000 10 (2102=10222^{10}-2=1022) /22 172.16.24.0 255.255.252.0 1022
WAN link 2 2 (222=22^{2}-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 2h22^h-2 (5 marks)

With hh host bits, the host portion ranges over all 2h2^{h} bit patterns → 2h2^{h} 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 =2h2= 2^{h} - 2. (0.5) Exception: For a /31 (h=1h=1, point-to-point link, RFC 3021) the "2-2" 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 GG is 4 → append 4 zeros: dividend =11010110110000= 1101011011\,0000. Divide by 1001110011 (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:

R=1110\boxed{R = 1110}

Transmitted frame =DR=11010110111110= D \,\|\, R = 1101011011\,1110. (4)

Verification: the transmitted frame 110101101111101101011011\,1110 divided by 1001110011 gives remainder 00000000 → divisible, confirming FCS. (2)

(Standard textbook result: D=1101011011D=1101011011, G=10011G=10011 ⇒ remainder 11101110.)


Question 3

(a) Bandwidth–delay product (5 marks)

BDP=capacity×RTT=109 bit/s×0.02 s=2×107 bit=2.5×106 bytes=2.5 MB.\text{BDP} = \text{capacity}\times\text{RTT} = 10^{9}\text{ bit/s}\times 0.02\text{ s} = 2\times10^{7}\text{ bit} = 2.5\times10^{6}\text{ bytes} = 2.5\text{ MB}. (3) The receive window must be 2.5\ge 2.5 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): ssthresh=14/2=7\text{ssthresh} = 14/2 = 7, cwnd=7\text{cwnd} = 7 (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)"}
]