1

#Why is the Opcode for a TFTP packet 2 whole bytes?

The latest revision of the TFTP Standard, on the bottom of page 3, says that

The TFTP header consists of a 2 byte opcode field which indicates the packet's type (e.g., DATA, ERROR, etc.)

It later specifies that the Opcodes are 1-5:

TFTP supports five types of packets, all of which have been mentioned above:

opcode operation
1 Read request (RRQ)
2 Write request (WRQ)
3 Data (DATA)
4 Acknowledgment (ACK)
5 Error (ERROR)

Here's an example of a read request packet:

2 bytes     string    1 byte     string   1 byte
--------------------------------------------------
| Opcode |  Filename  |   0  |    Mode    |   0  |
--------------------------------------------------

Why is the Opcode 2 whole bytes? If my math is right, that means that you can put any number from 0 to 65536 65535 (2^16) in that slot, but there are only 5 Opcodes. 1 byte can get you 256 (2^8) slots. What is the point of all that space? Is there a more universal standard that specifies that they're following along with?

If I'm reading the standard correctly, the second byte will always be 0'd out?

Community
  • 1
  • 1
Isaiah Taylor
  • 345
  • 1
  • 2
  • 7

1 Answers1

1

Option 1: The Opcode was initially designed as a text field then you need the second byte as the classic "0" limiter, then later they decided to make that field numeric but they did not change the field length.

Option 2: Parsing a 2 bytes numeric field that always begins with 0 adds an extra layer of "format" security in times where the networks were far less reliable than today/

Pat
  • 2,670
  • 18
  • 27