Why Does TFTP Use UDP Instead of TCP?
The Trivial File Transfer Protocol (TFTP) uses the User Datagram Protocol (UDP) instead of a reliable transport protocol like TCP to prioritize simplicity, minimal resource consumption, and rapid execution. Designed primarily for bootstrapping devices across local networks, TFTP relies on UDP because it requires very little code to implement in hardware with constrained memory. Despite UDP being a connectionless and inherently unreliable protocol, TFTP compensates by implementing its own lightweight reliability mechanisms at the application layer.
1. Minimal Code Footprint for Firmware and ROM
TFTP was originally developed for diskless workstations, embedded systems, and network hardware (such as routers and switches) during early boot stages, such as Preboot Execution Environment (PXE) booting. In these scenarios, the client system operates with very limited memory (ROM or small flash chips) and cannot support a complete, complex TCP/IP stack. A UDP implementation requires significantly fewer lines of code and less processing power, allowing low-level firmware to initiate simple network transfers.
2. Elimination of Connection Overhead
TCP relies on a three-way handshake (SYN,
SYN-ACK, ACK) to establish a connection,
maintains complex state machines for windowing and flow control, and
requires a four-way handshake for termination. For transferring small
files—such as boot images, system configurations, or firmware
updates—this overhead creates unnecessary latency. UDP eliminates
connection states entirely, allowing the transfer process to begin
immediately.
3. Application-Layer Reliability (Stop-and-Wait Mechanism)
TFTP does not ignore reliability; rather, it handles it at the application layer using a basic “Stop-and-Wait” Acknowledgement (ACK) protocol: * The sender divides the file into fixed-size blocks (traditionally 512 bytes). * The sender transmits one data packet and waits for an explicit ACK containing the correct block number from the receiver. * The receiver must acknowledge the current block before the sender transmits the next one. * If an ACK is not received within a specified timeout period, the sender retransmits the lost block.
This mechanism provides the necessary reliability without the complexity of TCP features like dynamic sliding windows, selective acknowledgments, and congestion control algorithms.
4. Designed for Controlled Local Networks
TFTP was intended primarily for Local Area Networks (LANs) where packet loss, high latency, and network congestion are minimal. In a reliable physical environment, the advanced congestion avoidance algorithms of TCP provide little benefit, making UDP’s raw transport approach ideal for quick and straightforward transfers.