22-Elec-B4 Information Technology Networks · December 2015
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Paper format. Professional Engineers of Ontario, Annual Examinations — December 2015, 07-Elec-B4 Information Technology Networks. Three hours, closed book, a PEO-approved non-programmable calculator permitted. Five questions; any four constitute a complete paper worth 100 marks, and marks are printed in the left margin against each sub-part. All five questions are solved here, because the set is a study resource rather than an exam attempt.
Reference texts.
Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.
Given. An initial congestion window $\mathrm{cwnd}_{1}=1$ MSS and a congestion threshold $\mathrm{ssthresh}=32$ MSS; in part (c) every segment is acknowledged, and in part (d) a segment in the third window is not. Find. The major behavioural differences between TCP and UDP with an application suited to each, and the congestion window used in each transmission round for both the loss-free and the lossy case.
Both protocols sit on IP and both multiplex applications by port number, and there the resemblance stops. The differences that matter fall into four groups.
| Aspect | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented: a three-way handshake establishes state at both ends before any data flows, and a four-way exchange tears it down | Connectionless: a datagram is sent with no prior exchange and no per-peer state |
| Service model | Reliable, in-order byte stream; segment boundaries are not preserved | Best-effort message service; datagram boundaries are preserved, delivery is not |
| Error recovery | Sequence numbers, cumulative acknowledgements, timeouts, fast retransmit and duplicate detection | An optional checksum, which discards a corrupt datagram; nothing is retransmitted |
| Flow control | Receiver-advertised window prevents a fast sender overrunning a slow receiver | None |
| Congestion control | Slow start and AIMD congestion avoidance; the sender slows down when the network signals loss | None — the sender transmits at whatever rate the application chooses |
| Header | 20 bytes minimum, more with options | 8 bytes fixed |
| Addressing | Strictly unicast, point-to-point | Supports unicast, multicast and broadcast |
| Delay behaviour | Variable: retransmission and head-of-line blocking add unbounded jitter | Low and predictable: a datagram is delivered once or not at all |
The single sentence that captures it: TCP trades latency and complexity for reliability and network friendliness, while UDP trades reliability away to keep latency and overhead minimal, leaving any recovery to the application.
Better with TCP: bulk file transfer — for example, nightly upload of a plant historian archive over SFTP. Every byte must arrive and arrive in order, because a single missing block corrupts the archive; the transfer has no deadline, so the delay introduced by a retransmission costs nothing; and the file is large enough that TCP's congestion control is doing genuinely useful work in sharing the link fairly with other traffic. Web pages, email and remote login belong to the same class for the same reasons.
Better with UDP: real-time voice — for example, a VoIP call carried in RTP over UDP. Here a retransmitted packet is worse than useless: by the time it arrives the play-out instant for that 20 ms of speech has passed, so it can only be discarded, having consumed bandwidth and possibly delayed the packets behind it. The codec conceals an isolated lost packet far better than the listener tolerates a gap, so a small loss rate is preferable to variable delay. UDP's absence of congestion control is also the point: a voice codec produces a constant rate and cannot usefully be slowed down. DNS is a second good example for a different reason — a single short request and reply would spend three round trips on a TCP handshake for one round trip of useful work, so the application retries instead.
It is worth noting that QUIC now blurs this line by rebuilding reliability, congestion control and encryption on top of UDP in user space, precisely so that it can keep UDP's freedom from head-of-line blocking while regaining TCP's guarantees.
Approach. TCP grows the congestion window in two regimes: exponentially in slow start while $\mathrm{cwnd}\lt\mathrm{ssthresh}$, and linearly in congestion avoidance once the threshold is reached.
| Transmission round | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| cwnd (MSS) | 1 | 2 | 4 | 8 | 16 | 32 | 33 | 34 | 35 | 36 |
| Phase | slow start (doubling) | congestion avoidance (+1 per RTT) | ||||||||
The third window carries $\mathrm{cwnd}_{3}=4$ segments, and one of them goes unacknowledged. TCP treats the loss as the network's congestion signal and responds in two parts: it remembers half the window that was in flight as the new threshold, and it restarts growth from the bottom.
Had the loss instead been signalled by three duplicate acknowledgements, TCP Reno would have used fast retransmit and fast recovery: it would set both the threshold and the window to 2 MSS and continue in congestion avoidance without a slow-start restart, giving 1, 2, 4, 2, 3, 4, 5, 6. Either answer is defensible provided the variant is stated; the Tahoe sequence above is the one implied by a course that introduces a single “congestion threshold” and a reset to one segment.
| Quantity | Value |
|---|---|
| Rounds of slow start before the threshold | 6 (cwnd = 1, 2, 4, 8, 16, 32) |
| Segments delivered during slow start | 63 |
| Windows beyond the threshold | 33, 34, 35, 36, … (+1 MSS per RTT) |
| New threshold after the loss | 2 MSS |
| First eight windows, loss in window 3 (Tahoe) | 1, 2, 4, 1, 2, 3, 4, 5 MSS |
| Same case under Reno fast recovery | 1, 2, 4, 2, 3, 4, 5, 6 MSS |
| Application better on TCP / UDP | bulk file transfer / real-time voice over RTP |