Skip to main content

TFTP

The Trivial File Transfer Protocol is a minimal lock-step file transfer protocol over UDP, defined by RFC 1350. DataStream also implements the option-negotiation extension of RFC 2347, which is what makes block sizes above 512 bytes available.

The tftp device receives files only. Read requests are refused.

Binary Layout

FieldInternal NameDescriptionType / FormatExample / Values
OpcodeopcodeOperation typeuint161 = RRQ, 2 = WRQ, 3 = DATA, 4 = ACK, 5 = ERROR
FilenamefilenameFile path (RRQ/WRQ only)Null-terminated stringconfig.txt\0
ModemodeTransfer mode (RRQ/WRQ only)Null-terminated stringoctet\0, netascii\0
Block Numberblock_numData block sequence (DATA/ACK)uint16e.g. 1, 2, 3
DatadataFile content (DATA only)Binary512 bytes by default, up to 65464 when negotiated
Error Codeerror_codeError type (ERROR only)uint160 = Not defined, 1 = File not found
Error Messageerror_msgError description (ERROR only)Null-terminated stringFile not found\0

Opcodes

OpcodeNamePurpose
1RRQRead Request. Not accepted—the tftp device receives files only
2WRQWrite Request
3DATAData packet
4ACKAcknowledgment
5ERRORError packet
6OACKOption Acknowledgment

Options

Options are appended to a read or write request as null-terminated name-value pairs, and the server confirms the ones it accepts in an OACK packet.

OptionDescription
blksizeData block size, from 512 to 65464 bytes
tsizeTotal transfer size

Other options are ignored.

Transfer Modes

Only netascii receives special handling, which translates line endings. Every other mode string, including octet, is treated as raw binary and passed through unchanged.