25-Comp-B10 Distributed Systems · May 2014
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
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 500 bytes, response message 8000 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 | 500 bytes |
| Response size | 8000 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.
| Case | Estimated total time |
|---|---|
| (i) UDP (connectionless) | 33.80 ms |
| (ii) TCP (connection-oriented) | 38.80 ms |
| (iii) Client and server on the same machine | 12.00 ms |
(b) UDP vs. TCP by application. 1. Mail access protocols (POP3, 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. File transfer. TCP is used: transferring a file (e.g. an ftp data connection) requires the destination copy to be byte-for-byte identical to the source and of arbitrary size, so reliable, in-order delivery is essential — any silently dropped or reordered byte corrupts the file. Unlike a real-time stream, a file transfer is not time-critical in the same way, so TCP's retransmission-driven latency variance is an acceptable price for guaranteed correctness; ftp itself splits the reliable TCP control connection (negotiating the transfer) from a separate TCP data connection carrying the bulk bytes. 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.