1

I'm writing a small TFTP client and server for class, and I have to send TFTP ERROR packets when things go wrong. Here is the TFTP RFC for reference.

So, error code 4 is "Illegal TFTP operation", in which cases would you send that ERROR packet?

For example, if the Server is listening on port 69 for RRQ/WRQ packets, but it instead receives a random DATA packet, should it send an ERROR (error code 4) packet in response?

Community
  • 1
  • 1
pepers
  • 315
  • 3
  • 15

1 Answers1

1

Anything that does not follow the flow and semantics of the spec is "illegal". A packet with an unknown opcode, a packet with a malformed payload, or a packet that is out of sequence with the normal flow of commands/responses would all be considered "illegal". So an unexpected DATA packet for a non-existent transfer could be considered "illegal" and use error code 4, though error code 5 (Unknown Transfer ID) would be more appropriate.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Great, thank you! Although for my stray DATA packet example, are you saying to use error code 5 because that would more likely be useful for whomever sent the packet (they most likely sent the right type of packet to the wrong place, as opposed to the wrong type of packet to the right place)? – pepers May 22 '15 at 23:31
  • 1
    That would fall in line with Section 4: "*In the next step, and in all succeeding steps, the hosts should make sure that the source TID matches the value that was agreed on in steps 1 and 2. **If a source TID does not match, the packet should be discarded as erroneously sent from somewhere else.** An error packet should be sent to the source of the incorrect packet, while not disturbing the transfer.*" – Remy Lebeau May 23 '15 at 00:58