25-Comp-B10 Distributed Systems · May 2013
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer) · Last updated
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. Request message 400 bytes, response message 6000 bytes; per-packet latency 5 ms (applies identically whether the two endpoints are local or remote, and is incurred once per packet transmitted); a one-time TCP connection-setup cost of 5 ms; a data transfer rate of 10 Mbps; an MTU of 2000 bytes (the maximum payload one packet can carry, so any message longer than this must be split into multiple packets); server request-processing time 2 ms; network lightly loaded (no queuing delay).
| Quantity | Value |
|---|---|
| Request size | 400 bytes |
| Response size | 6000 bytes |
| Per-packet latency (local or remote) | 5 ms |
| TCP connection setup (TCP only) | 5 ms |
| Data transfer rate | 10 Mbps |
| MTU | 2000 bytes |
| Server processing time | 2 ms |
Find. The total estimated elapsed time from the client issuing the request to it receiving the complete response, for (i) UDP, (ii) TCP, and (iii) client and server co-located on one machine.
Approach. Model the time to move an L-byte message across the network as k packet-latencies (one per MTU-sized packet the message is split into) plus the message's own transmission time at the link's data rate, add the server's fixed processing time between request and response, and add the one-time TCP handshake only for the connection-oriented case.
k = ⌈size/MTU⌉ packets pays the fixed 5 ms latency, while the data-rate term is charged once against the full message size (packets are assumed to stream back-to-back rather than each waiting for the previous one's latency to elapse) — is the simplest one consistent with all five given parameters and is used consistently across all three cases; the qualitative comparison (UDP fastest, TCP slower by the handshake, local fastest of all) is robust to the modelling choice even though the exact millisecond figures would shift under a different one.| Case | Estimated total time |
|---|---|
| (i) UDP (connectionless) | 27.12 ms |
| (ii) TCP (connection-oriented) | 32.12 ms |
| (iii) Client and server on the same machine | 12.00 ms |
(b) UDP vs. TCP by application. 1. Mail access protocols (IMAP). TCP is used: a mailbox session involves an extended, stateful sequence of commands (login, list folders, fetch specific messages) and every message must arrive complete and in order for the client to render it correctly — the reliability, ordering and flow control TCP provides are exactly what a multi-step, correctness-sensitive session needs, and the connection's setup cost is amortized over a long session. 2. Internet radio. UDP is preferred: the stream is a continuous sequence of audio samples where a late packet is worse than a lost one (a stalled TCP retransmission causes an audible gap, whereas dropping one UDP packet is a barely perceptible glitch), so the application favours low, steady latency over guaranteed delivery and tolerates loss with error concealment. 3. Information browsing (HTTP). TCP is used (as computed in part (a)): a Web page is a set of discrete resources (HTML, images, scripts) that must each arrive completely and correctly for the page to render, and modern HTTP/1.1–2 amortizes the connection-setup cost by reusing one TCP connection for many requests to the same server. 4. Remote procedure call. Either can be used depending on the semantics wanted: TCP-based RPC gives at-most-once/exactly-once-like guarantees for large or multi-part calls where retry logic would be complex to hand-roll, while UDP-based RPC (with the request-reply protocol adding its own lightweight retransmission-on-timeout and duplicate filtering) is common for small, idempotent, latency-sensitive calls (e.g. within a data-center) because it avoids the connection-setup overhead on every call.