Trivial File Transfer Protocol
The Trivial File Transfer Protocol is a simple lockstep communication protocol for transmitting or receiving files in a client-server application. A primary use of TFTP is in the early stages of nodes booting on a local area network when the operating system or firmware images are stored on a file server.
TFTP was first standardized in 1981 and updated in.
Overview
Due to its simple design, TFTP can be easily implemented by code with a small memory footprint. It is, therefore, the protocol of choice for the initial stages of any network booting strategy like BOOTP, PXE, BSDP, etc., when targeting from highly resourced computers to very low resourced Single-board computers and System on a Chip. It is also used to transfer firmware images and configuration files to network appliances like routers, firewalls, IP phones, etc. Today, TFTP is virtually unused for Internet transfers.TFTP's design was influenced from the earlier protocol EFTP, which was part of the PARC Universal Packet protocol suite. TFTP was first defined in 1980 by IEN 133.
In June 1981 The TFTP Protocol was published as RFC 783 and later updated in July 1992 by RFC 1350 which fixed among other things the Sorcerer's Apprentice syndrome. In March 1995 the TFTP Option Extension RFC 1782 updated later in May 1998 by RFC 2347, defined the option negotiation mechanism which establishes the framework for file transfer options to be negotiated prior to the transfer using a mechanism that is consistent with TFTP's original specification.
TFTP is a simple protocol for transferring files, implemented on top of the UDP/IP protocols using well-known port number 69. TFTP was designed to be small and easy to implement, and therefore it lacks most of the advanced features offered by more robust file transfer protocols. TFTP only reads and writes files from or to a remote server. It cannot list, delete, or rename files or directories and it has no provisions for user authentication.
Today TFTP is generally only used on local area networks.
Operation
A TFTP transfer is initiated by the client issuing a request to read or write a particular file on the server. The request can optionally include a set of negotiated transfer parameters proposed by the client under the terms specified by RFC 2347. If the server grants the request, the file is sent in fixed-length blocks of 512 bytes by default or the number specified in the blocksize negotiated option defined by RFC 2348. Each block of transferred data, which is usually carried within a single IP packet in order to avoid IP fragmentation, must be acknowledged before the next block can be sent. A data packet of less than 512 bytes or the agreed blocksize option signals the termination of a transfer. If a packet gets lost in the network, the intended recipient will timeout and may retransmit their last packet, thus causing the sender of the lost packet to retransmit that lost packet. The sender has to keep just one packet on hand for retransmission since the lock step acknowledgment guarantees that all older packets have been correctly received. Notice that both devices involved in a transfer are considered senders and receivers. One sends data and receives acknowledgments, the other sends acknowledgments and receives data.TFTP defines three modes of transfer: netascii, octet, and mail.
- Netascii is a modified form of ASCII, defined in RFC 764. It consists of an 8-bit extension of the 7-bit ASCII character space from 0x20 to 0x7F and eight of the control characters. The allowed control characters include the null, the line feed, and the carriage return. Netascii also requires that the end of line marker on a host be translated to the character pair CR LF for transmission and that any CR must be followed by either a LF or the null.
- Octet allows for the transfer of arbitrary raw 8-bit bytes, with the received file resulting byte-per-byte identical to the one sent. More correctly, if a host receives an octet file and then returns it, the returned file must be identical to the original.
- Mail transfer mode uses Netascii transfer, but the file is sent to an email recipient by specifying that recipient's email address as the file name. RFC 1350 declared this mode of transfer obsolete.
- The initiating host A sends an RRQ or WRQ packet to host S at port number 69, containing the filename, transfer mode, and optionally any negotiated option under the terms of RFC 2347.
- S replies with an option ACK if options were used, and an ACK packet to WRQ and directly with a DATA packet to RRQ. The packet is sent from a randomly allocated ephemeral port, and all future packets to host S should be directed to this port.
- The source host sends numbered DATA packets to the destination host, all but the last containing a full-sized block of data. The destination host replies with numbered ACK packets for all DATA packets.
- The final DATA packet must contain less than a full-sized block of data to signal that it is the last. If the size of the transferred file is an exact multiple of the block size, the source sends a final DATA packet containing 0 bytes of data.
- Receiver responds to each DATA with associated numbered ACK. The sender responds to the first received ACK of a block with DATA of the next block.
- If an ACK is not eventually received, a retransmit timer re-sends DATA packet.
The original protocol has a transfer file size limit of 512 bytes/block x 65535 blocks = 32 MB. In 1998 this limit was extended to 65535 bytes/block x 65535 blocks = 4 GB by TFTP Blocksize Option RFC 2348. If the defined blocksize produces an IP packet size that exceeds the minimum MTU at any point of the network path, IP fragmentation and reassembly will occur not only adding more overhead but also leading to total transfer failure when the minimalist IP stack implementation in a host's BOOTP or PXE ROM does not implement IP fragmentation and reassembly. If TFTP packets should be kept within the standard Ethernet MTU, the blocksize value is calculated as 1500 minus headers of TFTP, UDP and IP = 1468 bytes/block, this gives a limit of 1468 bytes/block x 65535 blocks = 92 MB. Today most servers and clients support block number roll-over which gives an essentially unlimited transfer file size.
Since TFTP utilizes UDP, it has to supply its own transport and session support. Each file transferred via TFTP constitutes an independent exchange. Classically, this transfer is performed in lock-step, with only one packet alternatively in flight on the network at any time. Due to this single data block strategy instead of sending a larger amount of uninterrupted data blocks before pausing the transfer to wait for the corresponding acknowledge, TFTP provides low throughput especially over high latency links. Microsoft introduced windowed TFTP in Windows 2008 as part of their Windows Deployment Services, in January 2015 TFTP Windowsize Option RFC 7440 was published. This substantially improves performance for things like PXE booting without the IP fragmentation side effect sometimes observed on Blocksize Option RFC 2348