Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Part II: TCP/IP Protocols > TFTP: Trivial File Transfer Protocol

Chapter 28. TFTP: Trivial File Transfer Protocol

Protocol Description Trivial File Transfer Protocol (TFTP) is a simple protocol to transfer files. It has been implemented on top of the User Datagram Protocol (UDP) using port number 69. TFTP is designed to be small and easy to implement and, therefore, lacks most of the features of a regular FTP. TFTP only reads and writes files (or mail) from/to a remote server. It cannot list directories, and currently has no provisions for user authentication.

Three modes of transfer are currently supported by TFPT: netASCII, that is 8 bit ASCII; octet (this replaces the “binary” mode of previous versions of this document.) i.e. raw 8-bit bytes; mail, netASCII characters sent to a user rather than a file. Additional modes can be defined by pairs of cooperating hosts.

In TFTP, any transfer begins with a request to read or write a file, which also serves to request a connection. If the server grants the request, the connection is opened and the file is sent in fixed length blocks of 512 bytes. Each data packet contains one block of data and must be acknowledged by an acknowledgment packet before the next packet can be sent. A data packet of less than 512 bytes signals termination of a transfer. If a packet gets lost in the network, the intended recipient will timeout and may retransmit his last packet (which may be data or an acknowledgment), 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 received. Notice that both machines involved in a transfer are considered senders and receivers. One sends data and receives acknowledgments, the other sends acknowledgments and receives data.

The current version of TFTP is version 2.

Protocol Structure The header structures of the TFTP messages/packets:

RRQ/WRQ packet:

2 bytesString1 byteString1 byte
OpcodeFilename0Mode0


Opcode -- Operation code or commands. The following are TFTP commands:

OpcodeCommandDescription
1Read RequestRequest to read a file.
2Write RequestRequest to write to a file.
3File DataTransfer of file data.
4Data AcknowledgeAcknowledgement of file data.
5ErrorError indication.


Filename -- the name of file to be transferred.

Mode -- Datamode. The format of the file data that the protocol is to transfer. It could be NetASCII Standard ASCII, Octet Eight-bit binary data, or Mail Standard ASCII.

Data packet:

2 bytes2 bytes0 - 512 bytes
OpcodeBlock #Data


The opcode is 3.

Block # -- Block numbers on data packets begin with one and increase by one for each new block of data.

Data -- Data field range from 0 to 512 bytes.

ACK packet:

2 bytes2 bytes
OpcodeBlock #


The Opcode is 4.

Block# -- Block number echoes the block number of the DATA packet being acknowledged.

A WRQ is acknowledged with an ACK packet having a block number of zero.

Error Packet:

2 bytes2 bytesString1 byte


The Opcode is 5.

Error code -- an integer indicating the nature of the error.

0 -- Not defined, see error message (if any).
1 -- File not found.
2 -- Access violation.
3 -- Disk full or allocation exceeded.
4 -- Illegal TFTP operation.
5 -- Unknown transfer ID.
6 -- File already exists.
7 -- No such user.

ErrMSG -- Error message is intended for human consumption, and should be in netascii. It is terminated with a zero byte.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial