-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?

Bugs
  • 4,491
  • 9
  • 32
  • 41
  • 1
    This link should help with your question. [Link](https://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol) – Manav Dubey Mar 22 '17 at 01:56
  • 7
    why do you modify your question to add spam and remove all the question content? – phuclv Mar 27 '17 at 03: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 '17 at 06: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 '17 at 06: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 '17 at 07:16

1 Answers1

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.

Community
  • 1
  • 1
John Hascall
  • 9,176
  • 6
  • 48
  • 72
  • 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 – John Hascall Mar 24 '17 at 00: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. – John Hascall Mar 25 '17 at 22:36