-7

I keep hearing about "conversion" of data into octet mode, how does it happen?

Is data in "netascii" bydefault? If I make a TFTP server in C, is it necessary for my packet/buffer variables to be exactly 512 bytes? I mean there are a plethora of functions allowing me to use only 512 bytes of the n bytes of any variable, but for the tftp server does the variable size itself matter?

5
  • 1
    This link should help with your question. Link Mar 22, 2017 at 1:56
  • 7
    why do you modify your question to add spam and remove all the question content?
    – phuclv
    Mar 27, 2017 at 3:57
  • 4
    the fact that it's your question doesn't mean that you have the right to remove important information and add junks like that
    – phuclv
    Mar 27, 2017 at 6:11
  • 9
    The question isn't yours, as per the terms you accepted when you signed up for your account here. You'll find a link to the license agreement in the footer of every page.
    – tripleee
    Mar 27, 2017 at 6:18
  • 12
    Do not vandalise posts please. Together with the answers this is a combined work under the terms of the CC wiki license; altering the question materially is not something we allow.
    – Martijn Pieters
    Mar 27, 2017 at 7:16

1 Answer 1

15

In octet mode, data is transferred and stored exactly as-is. In netascii mode, line endings are converted (if needed) on the receiving end to its preferred line-ending (i.e. Newline on Unixes). There is no default as the mode string is always included in the ReadReQuest or WriteReQuest packet.

[edit] Every packet (except the last) sent must contain exactly 512 bytes of data. If a packet contains less (0..511) it signals the end of the file. The protocol was designed to able to be implemented with a minimum amount of code, so using a fixed-size buffer was anticipated. You could probably come up with a more complicated scheme, but why?

RFC 1350* defines the protocol.

[more]

The "Sorcerer's Apprentice Syndrome" is protected against by only sending the next block upon timeout or the receipt of the first acknowledgment for a block (any further acknowledgments are silently ignored).

The RFC (see section 7) requires an ERROR packet upon error (including malformed request).

*RFC = "Request for Comments". RFC 1350 is the latest and official description and standard for the TFTP protocol.

2
  • 1
    No, if you have sent DATA[n] then you must have previously received ACK[n-1], therefore any further ACK[n-1] is ignored (any ACK[m], where m<n is ignored). It is a general principle to "be conservative in what you send and liberal in what you accept", however this particular protocol is designed to be simple and small to implement -- in fact, the RFC says "Most errors cause termination of the connection" -- so adding a bunch error recovery code is probably counterproductive. Mar 24, 2017 at 0:19
  • 1
    No, you resend each time the previous DATA send times out without an ACK. All you need to do to prevent S.A.S. is ignore ACKs for previously ACKed DATA's. Mar 25, 2017 at 22:36

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.