RFC 2348

TFTP Blocksize Option

๐Ÿ“… published May 1998, from ietf

RFC 2348: TFTP Blocksize Option ๐ŸŽ€

  • Network Working Group ๐ŸŒธ
  • RFC number: 2348
  • Authors: G. Malkin (Bay Networks) and A. Harkin (Hewlett Packard Co.) ๐Ÿซถ
  • Category: Standards Track โœจ
  • Date: May 1998 ๐Ÿ“…
  • Updates: RFC 1350 ๐Ÿ”ง
  • Obsoletes: RFC 1783 ๐Ÿ’…

Status of This Memo ๐Ÿ’–

okay so this doc is a standards track protocol for the whole Internet community, and it's basically inviting everyone to discuss it and suggest improvements ๐Ÿ™Œ. If you want the current standardization state of this protocol, check the latest edition of the "Internet Official Protocol Standards" (STD 1) ๐Ÿ“š. Distribution of this memo is unlimited, so share it with everyone ๐Ÿฆ‹.

Copyright (C) The Internet Society (1998). All Rights Reserved.

Abstract โœจ

okay so TFTP, the Trivial File Transfer Protocol [1], is a super simple, lock-step file transfer protocol that lets a client get a file from a remote host or put one onto it ๐Ÿ“. One of its main jobs is booting diskless nodes on a Local Area Network ๐Ÿ’ป. It's built this simple on purpose so it fits in a small node's limited ROM space ๐Ÿงš. BUT the 512-octet blocksize is not the most efficient choice on a LAN where the MTU may be 1500 octets or greater ๐Ÿ˜ญ.

So this document describes a TFTP option that lets the client and server negotiate a blocksize that actually suits the network medium ๐Ÿ”ฅ. The TFTP Option Extension mechanism is described in [2] ๐Ÿ’œ.

Blocksize Option Specification ๐ŸŽ€

The TFTP Read Request or Write Request packet gets a makeover to include the blocksize option, and it looks like this (note: everything except "opc" is NULL-terminated ๐Ÿ’…):

   +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+
   |  opc  |filename| 0 |  mode  | 0 | blksize| 0 | #octets| 0 |
   +-------+---~~---+---+---~~---+---+---~~---+---+---~~---+---+

Here's what each field does, bestie ๐Ÿซถ:

  • opc: the opcode. It's a 1 for Read Requests or a 2 for Write Requests, as defined in [1] ๐Ÿ”ข.
  • filename: the name of the file being read or written, as defined in [1] ๐Ÿ“„.
  • mode: the transfer mode, which is "netascii", "octet", or "mail", as defined in [1] ๐ŸŒธ.
  • blksize: the Blocksize option itself, written as "blksize" (case in-sensitive) ๐Ÿ“.
  • #octets: the number of octets in a block, written in ASCII. Valid values range between "8" and "65464" octets, inclusive ๐Ÿฆ‹. The blocksize counts only the data octets, so it does NOT include the four octets of TFTP header ๐Ÿ™ˆ.

Here's an example packet ๐Ÿงš:

   +-------+--------+---+--------+---+--------+---+--------+---+
   |   1   | foobar | 0 | octet  | 0 | blksize| 0 |  1428  | 0 |
   +-------+--------+---+--------+---+--------+---+--------+---+

This is a Read Request for the file named "foobar", in octet (binary) transfer mode, with a block size of 1428 octets. That's the Ethernet MTU minus the TFTP, UDP and IP header lengths, so it's giving perfectly sized ๐Ÿ’…โœจ.

If the server is cool with the blocksize option, it sends an Option Acknowledgment (OACK) back to the client ๐Ÿค. The value it specifies must be less than or equal to the value the client asked for ๐Ÿ™Œ. The client then has to either use the size from the OACK, or send an ERROR packet with error code 8 to end the transfer ๐Ÿ’€.

The rules for finding the final packet are the same as in [1] ๐Ÿ“œ. The final packet is any data packet whose data length is less than the negotiated blocksize ๐Ÿ. If the blocksize is bigger than the amount of data being transferred, the first packet is already the final one ๐ŸŒˆ. And if the amount of data is an exact multiple of the blocksize, an extra data packet with no data gets sent to end the transfer ๐ŸŽ€.

Proof of Concept ๐Ÿ”ฅ

Okay the receipts! The team ran performance tests on the prototype implementation with a bunch of different block sizes ๐Ÿ“Š. The tests ran on a lightly loaded Ethernet, between two HP-UX 9000 machines, in "octet" mode, on 2.25MB files ๐Ÿ’ป. The average (5x) transfer times for paths with (g-time) and without (n-time) an intermediate gateway are graphed below ๐Ÿ“ˆ:

           |
        37 +      g
           |
        35 +
           |
        33 +
           |
        31 +
           |
        29 +
           |
        27 +
           |             g              blocksize   n-time   g-time
        25 +                            ---------   ------   ------
      s    |       n                      512       23.85    37.05
      e 23 +                g            1024       16.15    25.65
      c    |                             1428       13.70    23.10
      o 21 +                             2048       10.90    16.90
      n    |                             4096        6.85     9.65
      d 19 +                             8192        4.90     6.15
      s    |
        17 +                    g
           |             n
        15 +
           |                n
        13 +
           |
        11 +                    n
           |                           g
         9 +
           |
         7 +                           n
           |                                  g
         5 +                                  n
           "
         0 +------+------+--+---+------+------+---
                 512    1K  |  2K     4K     8K
                          1428
                    blocksize (octets)

Here's the comparison of transfer times (without a gateway) between the standard 512-octet blocksize and the negotiated ones ๐Ÿงฎ:

      1024     2x   -32%
      1428   2.8x   -42%
      2048     4x   -54%
      4096     8x   -71%
      8192    16x   -80%

As predicted, transfer time goes down as the blocksize goes up ๐Ÿ“‰โœจ. Why? Fewer packets get sent ๐Ÿฆ‹. For example, going from 512 to 1024 octets doesn't just halve the number of data packets, it also halves the number of acknowledgement packets, along with how many times the data sender has to wait for an ACK ๐Ÿ™ˆ. There's also a secondary win from reducing the per-packet framing and processing overhead ๐Ÿงš.

Okay but the catch: if the blocksize goes past the path MTU, IP fragmentation and reassembly start adding overhead ๐Ÿ˜ญ. That gets more noticable the more gateways are in the path ๐Ÿ’€.

Security Considerations ๐Ÿ”

The basic TFTP protocol has no security mechanism ๐Ÿšจ. That's exactly why it has no rename, delete, or file overwrite capabilities ๐Ÿ™…. This document does NOT add any security to TFTP ๐Ÿ˜ฌ. However, the specified extensions do not add any additional security risks ๐Ÿซถ, so we're at least not making things worse ๐Ÿ’œ.

References ๐Ÿ“š

[1] Sollins, K., "The TFTP Protocol (Revision 2)", STD 33, RFC 1350, October 1992.

[2] Malkin, G., and A. Harkin, "TFTP Option Extension", RFC 2347, May 1998.

Authors' Addresses ๐Ÿ’Œ

   Gary Scott Malkin
   Bay Networks
   8 Federal Street
   Billerica, MA  10821

   Phone:  (978) 916-4237
   EMail:  gmalkin@baynetworks.com


   Art Harkin
   Networked Computing Division
   Hewlett-Packard Company
   19420 Homestead Road MS 43LN
   Cupertino, CA  95014

   Phone: (408) 447-3755
   EMail: ash@cup.hp.com

Copyright (C) The Internet Society (1998). All Rights Reserved.

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.

The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.

This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. ๐Ÿ’…

๐Ÿ“ฆ where this page comes from