Trivial File Transfer Protocol (TFTP)

From MattWiki
Jump to: navigation, search
TFTP [-i] host [GET | PUT] source [destination]
 -i              Specifies binary image transfer mode (also called
                 octet). In binary image mode the file is moved
                 literally, byte by byte. Use this mode when
                 transferring binary files.
 host            Specifies the local or remote host.
 GET             Transfers the file destination on the remote host to
                 the file source on the local host.
 PUT             Transfers the file source on the local host to
                 the file destination on the remote host.
 source          Specifies the file to transfer.
 destination     Specifies where to transfer the file.

Some details of TFTP

  • It uses UDP port 69 as its transport protocol (unlike FTP which uses TCP port 21).
  • It cannot list directory contents.
  • It has no authentication or encryption mechanisms.
  • It is used to read files from, or write files to, a remote server.
  • It supports three different transfer modes, "netascii", "octet" and "mail", with the first two corresponding to the "ASCII" and "image" (binary) modes of the FTP protocol; the third is obsoleted by RFC1350.
  • The original protocol has a file size limit of 32 MB, although this was extended when RFC 2347 introduced option negotiation, which was used in RFC 2348 to introduce block-size negotiation in 1998 (allowing a maximum of 4 GB and potentially higher throughput). If the server and client support block number wraparound, file size is essentially unlimited.
  • Since TFTP utilizes UDP, it has to supply its own transport and session support. Each file transferred via TFTP constitutes an independent exchange. That transfer is performed in lock-step, with only one packet (either a block of data, or an 'acknowledgement') ever in flight on the network at any time. Due to this lack of windowing, TFTP provides low throughput over high latency links.
  • Due to the lack of security, it is dangerous over the open Internet. Thus, TFTP is generally only used on private, local networks.

Example of a TFTP session

  • The initiating host A sends an RRQ (read request) or WRQ (write request) packet to host B at the well-known port number 69, containing the filename and transfer mode.
  • B replies with an ACK (acknowledgement) packet to WRQ and directly with a DATA packet to RRQ. Packet is sent from a freshly allocated ephemeral port, and all future packets to host B should be 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