home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / drafts / draft_n_r / draft-newman-protocol-design-00.txt < prev    next >
Text File  |  1997-06-24  |  17KB  |  449 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Network Working Group                                          C. Newman
  8. Internet Draft: Application Protocol Design Principles          Innosoft
  9. Document: draft-newman-protocol-design-00.txt                  June 1997
  10.                                                    Expires in six months
  11.  
  12.  
  13.                  Application Protocol Design Principles
  14.  
  15.  
  16. Status of this memo
  17.  
  18.      This document is an Internet-Draft.  Internet-Drafts are working
  19.      documents of the Internet Engineering Task Force (IETF), its areas,
  20.      and its working groups.  Note that other groups may also distribute
  21.      working documents as Internet-Drafts.
  22.  
  23.      Internet-Drafts are draft documents valid for a maximum of six
  24.      months and may be updated, replaced, or obsoleted by other
  25.      documents at any time.  It is inappropriate to use Internet-Drafts
  26.      as reference material or to cite them other than as "work in
  27.      progress."
  28.  
  29.      To view the entire list of current Internet-Drafts, please check
  30.      the "1id-abstracts.txt" listing contained in the Internet-Drafts
  31.      Shadow Directories on ftp.is.co.za (Africa), ftp.nordu.net
  32.      (Europe), munnari.oz.au (Pacific Rim), ds.internic.net (US East
  33.      Coast), or ftp.isi.edu (US West Coast).
  34.  
  35. Abstract
  36.  
  37.      There are a number of design principles which come into play over
  38.      and over again when designing application protocols.  Many of these
  39.      are entrenched in IETF lore and spread by word of mouth.  Most have
  40.      been learned the hard way many times.
  41.  
  42.      This is an attempt to codify some of these principles so they can
  43.      be referenced rather than spread by word of mouth.  The author has
  44.      not invented any of these ideas and while the exercise of finding
  45.      the originator of the ideas would be interesting, it is not deemed
  46.      necessary for this project.
  47.  
  48.      Many of these principles have a much wider scope than application
  49.      protocol design.  However, the author's primary experience is with
  50.      application protocols and examples provided usually involve
  51.      application protocols or elements.
  52.  
  53.      [Disclaimer: this is a preliminary draft.  Some of the case studies
  54.      and exceptions need tuning.  Suggestions welcome.]
  55.  
  56.  
  57.  
  58. Newman                                                          [Page i]
  59.  
  60. Internet Draft   Application Protocol Design Principles    June 21, 1997
  61.  
  62.  
  63.  
  64.  
  65.  
  66.                            Table of Contents
  67.  
  68.  
  69.  
  70. Status of this memo ...............................................    i
  71. Abstract ..........................................................    i
  72. 1.   K.I.S.S.  ....................................................    1
  73. 2.   Make the Common Case Simple & Uncommon Case Possible .........    1
  74. 3.   0, 1, N Principle ............................................    1
  75. 4.   Be Liberal/Conservative ......................................    2
  76. 5.   Avoid Silly States ...........................................    3
  77. 6.   Text Not Numbers .............................................    3
  78. 7.   Avoid Alternative Representations ............................    4
  79. 8.   Announce Features, Not Version ...............................    4
  80. 9.   Avoid Unnecessary Layers .....................................    5
  81. 10.  Conclusions Based on Design Principles .......................    5
  82. 11.  Security Considerations ......................................    6
  83. 12.  References ...................................................    6
  84. 13.  Author's Address .............................................    6
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. Newman                                                         [Page ii]
  115.  
  116. 1.   K.I.S.S.
  117.  
  118.      The "Keep It Simple, Stupid" principle or "KISS" principle is well
  119.      known.  The basic idea is not to add complexity if there is any way
  120.      to avoid it.  Sometimes this also involves a decision of where the
  121.      complexity should live (e.g. client implementation, server
  122.      implementation, protocol itself, external layers).  This is a very
  123.      difficult principle to follow in practice.
  124.  
  125.      Consequences of Violation: design errors, implementation bugs, poor
  126.      deployment, poor maintainability, interoperability problems, poor
  127.      usability, less peer review, protocol has to be "profiled" to
  128.      interoperate.
  129.  
  130.      Case Study: X.400 vs. SMTP/MIME.  X.400 is very complex and is
  131.      losing ground steadily in the marketplace.  SMTP/MIME is much
  132.      simpler and is gaining ground in the marketplace.
  133.  
  134. 2.   Make the Common Case Simple & Uncommon Case Possible
  135.  
  136.      This is largely a corollary of the KISS principle.  Sometimes
  137.      phrased as "design for the common case."  The idea is to make the
  138.      common case very simple without disallowing the useful uncommon
  139.      cases.
  140.  
  141.      Consequences of Violation: Same as KISS.  If useful uncommon case
  142.      is not possible, then a potentially complex protocol extension is
  143.      necessary which results in more complexity than if the uncommon
  144.      case was considered from the start.
  145.  
  146.      Case Study (common case too complex): ASN.1 makes the common case
  147.      far too complex.  While it does provide for unlimited
  148.      extensibility, in practice implementations can't deal with many
  149.      legal structures due to the complexity.
  150.  
  151.      Case Study (uncommon case not possible): Internet Mail originally
  152.      didn't allow non-text data.  MIME is more complex than it would
  153.      have been if designed in from the beginning.
  154.  
  155. 3.   0, 1, N Principle
  156.  
  157.      The "0, 1, N principle" is not an obvious principle but is true
  158.      surprisingly often.  In general, any protocol element or object
  159.      should come in quantities of 0, 1, or N where N is an arbitrary
  160.      number.  If a limit is picked, it is likely to be too small.  This
  161.      is especially true of hierarchy, and often true of names.
  162.  
  163.      Consequences of Violation: System has to be extended to allow
  164.  
  165.  
  166.  
  167. Newman                                                          [Page 1]
  168.  
  169. Internet Draft   Application Protocol Design Principles    June 21, 1997
  170.  
  171.  
  172.      larger values.  This causes a transition with severe
  173.      interoperability problems or a semantic overload of existing
  174.      structure which adds complexity and confusion.
  175.  
  176.      Case Study: 640K
  177.  
  178.      Case Study: MIME media types.  Two levels of hierarchy were defined
  179.      in the initial MIME specification.  This proved inadequate, so a
  180.      new hierarchy delimiter had to be introduced to allow more naming
  181.      hierarchy.
  182.  
  183.      Case Study: SMTP error codes have 3 levels of hierarchy with 10
  184.      settings each.  This has proved to be insufficent and inflexible
  185.      requiring the addition of ESMTP ENHANCEDSTATUSCODES.
  186.  
  187.      Exception: A quantity of two is permitted for clearly binary
  188.      situations.
  189.  
  190.      Exception: Has to be balanced with the KISS principle.  For
  191.      example, current practice limits most numbers in protocols to
  192.      32-bit values.
  193.  
  194. 4.   Be Liberal/Conservative
  195.  
  196.      The "Be Liberal in What You Accept, and Conservative in What You
  197.      Generate" principle is well known in the IETF, but controversial in
  198.      some cases.  The intention is to interoperability.  The basic idea
  199.      is that on generation one should follow the standard strictly as
  200.      that will work with all other compliant software.  On acceptance if
  201.      one tolerates minor protocol or format violations, it helps work
  202.      around known bugs in other software.  This principle would work
  203.      great if everyone followed it.  However, when there are mixtures of
  204.      systems which follow this rule and others which don't the
  205.      exceptions below need to be considered.
  206.  
  207.      Consequences of Violation: decreased interoperability, customers
  208.      blaming the violator of this principle for bugs in other vendor's
  209.      software.
  210.  
  211.      Case Study: TBD
  212.  
  213.      Exception: Don't accept ambiguous interactive input with
  214.      potentially vastly different meanings.  If the user ends up seeing
  215.      the data in an indecipherable context, severe consequences result.
  216.      It's often better to reject the data so the problem can be fixed at
  217.      the source.
  218.  
  219.      Exception: Don't accept clearly illegal interactive input when
  220.  
  221.  
  222.  
  223. Newman                                                          [Page 2]
  224.  
  225. Internet Draft   Application Protocol Design Principles    June 21, 1997
  226.  
  227.  
  228.      there are no known sources of it.  If client vendors notice their
  229.      illegal behavior before deploying, it gets fixed before it's
  230.      deployed, and overall interoperability is increased.
  231.  
  232.      Exception Case Study: When netnews was initially deployed, a number
  233.      of clients generated date headers in a variety of illegal formats.
  234.      Fairly early in the deployment, a major implementation was modified
  235.      to discard news messages which had missing or improperly formatted
  236.      date headers.  Very soon after this was deployed, all date headers
  237.      in news were interoperable.
  238.  
  239. 5.   Avoid Silly States
  240.  
  241.      Whenever possible, design the system so no silly states are
  242.      possible.  A silly state is a combination of options or values
  243.      which contradict each other or are nonsensical.
  244.  
  245.      Consequences of Violation: Increased complexity to deal with the
  246.      possibility of the silly states occurring.
  247.  
  248.      Case Study: TBD
  249.  
  250. 6.   Text Not Numbers
  251.  
  252.      Whenever possible, text should be used instead of numbers.  Numbers
  253.      almost always have to be looked up in order for humans to interpret
  254.      them.  Text can be read and debugged by a mere mortal.  One common
  255.      counter argument is that numbers are more compact, but if size is a
  256.      serious concern, a general purpose compression layer is usually a
  257.      better solution.  Another counter argument is that the mapping
  258.      tables and parsers to convert to internal numbers add complexity.
  259.      In practice the complexity of debugging a non-text protocol is
  260.      usually greater than the complexity of the parser and tables.
  261.  
  262.      Consequences of Violation: Protocol is difficult to debug, protocol
  263.      is difficult to understand, examples are hard to provide.  Previous
  264.      three consequences make this equivalent to a KISS violation.
  265.      Results in poor user interface.  Endian problems.
  266.  
  267.      Case Study: X.400 problems are very hard to diagnose.  The protocol
  268.      trace has to be recorded and run through an ASN.1 interpretor to
  269.      debug.  SMTP can be debugged by observing the original protocol
  270.      trace.
  271.  
  272.      Case Study: Whenever numeric error codes are used unqualified by
  273.      text, humans are invariably presented with these error codes,
  274.      resulting in a poor user interface and debugging difficulties.
  275.  
  276.  
  277.  
  278.  
  279. Newman                                                          [Page 3]
  280.  
  281. Internet Draft   Application Protocol Design Principles    June 21, 1997
  282.  
  283.  
  284.      Case Study: The telnet ENVIRON option had to be replaced with
  285.      NEW-ENVIRON due to endian problems.
  286.  
  287.      Exceptions: Compression or Encrytion layers (which make things
  288.      unreadable anyway).  Low-level protocols with high performance
  289.      requirements.  Encapsulated non-text objects.
  290.  
  291. 7.   Avoid Alternative Representations
  292.  
  293.      Having several ways to represent the same thing results in
  294.      interoperability problems.  In general, implementors will only test
  295.      the representation format they use.  The less often used
  296.      representations will fail to work.  In a worst case scenario, two
  297.      or more representions are widely used, but systems which use one
  298.      often can't talk to systems which use another.
  299.  
  300.      Consequences of Violation: Serious interoperability problems, more
  301.      bugs, conversion support necessary to interoperate.
  302.  
  303.      Case Study: The TIFF image format permits both a "big endian"
  304.      version and a "little endian" version.  Some implementations can
  305.      only read one or the other.  Many TIFF applications now have a
  306.      "Macintosh format TIFF" vs "IBM format TIFF" option when saving
  307.      TIFF files.
  308.  
  309.      Case Study: ASN.1 provides many ways of representing the same
  310.      thing.  This has caused numerous interoperability problems as not
  311.      all systems support all representations of a given field.  Profiles
  312.      of ASN.1 are usually necessary to interoperate at all.
  313.  
  314.      Case Study: RFC 822 allows several different ways to quote the same
  315.      address.  The useless ones like: "foo"."bar"@do.main rarely work.
  316.  
  317.      Exceptions: An alternative representation may be necessary for a
  318.      more expressive case.  For example, quoted strings and literals in
  319.      IMAP.  Rare alternative representations should be avoided.
  320.  
  321. 8.   Announce Features, Not Version
  322.  
  323.      While version numbers are fine to inform the user of what
  324.      implementation or conformance level they are at, they are usually a
  325.      bad idea in protocols.  A system where the server announces
  326.      available features and the client activates the features it wants
  327.      results in a far better protocol.  If a protocol needs to be
  328.      redesigned from scratch, use of a different port number for the new
  329.      version will allow a parallel transition period -- otherwise when a
  330.      major version number is increased on the server, the old clients
  331.      cease to interoperate with it.
  332.  
  333.  
  334.  
  335. Newman                                                          [Page 4]
  336.  
  337. Internet Draft   Application Protocol Design Principles    June 21, 1997
  338.  
  339.  
  340.      Consequences of Violation: Useless version number fields, painful
  341.      version transition, complexity due to need to support older
  342.      versions, meaning of version number sometimes ambiguous.
  343.  
  344.      Case Study: MIME has the MIME-Version header.  Since MIME also has
  345.      feature announcement via headers, the version number is useless and
  346.      will never change.
  347.  
  348.      Case Study: X.400:1988 fails to interoperate with X.400:1993 due to
  349.      certain body part types.  [XXX: need to confirm]
  350.  
  351. 9.   Avoid Unnecessary Layers
  352.  
  353.      Whenever two layered services can be combined into a single service
  354.      without a significant increase in complexity, it should be done.
  355.      Unnecessary layers result in implementor confusion and more
  356.      complexity.
  357.  
  358.      Consequences of Violation: same as KISS violations
  359.  
  360.      Case Study: RFC 822 has a multi-layer parsing model which includes
  361.      unfolding lines, lexing, removal of linear-white-space, and
  362.      parsing.  This has resulted in endless confusion and serious
  363.      interoperability problems.  The DRUMS WG is folding these into a
  364.      single formal syntax and the result looks promising.
  365.  
  366. 10.  Conclusions Based on Design Principles
  367.  
  368.      KISS: Every protocol should go through a "feature cut review"
  369.      before going on the standards track.
  370.  
  371.      KISS/Text not Binary/Alternate Representations: Use of ASN.1 in new
  372.      protocols should be strongly discouraged.
  373.  
  374.      0,1,N Principle/Text not Numbers: Use of 3 digit SMTP-style error
  375.      codes in new protocols should be forbidden.
  376.  
  377.      Announce Features, Not Version: Server feature announcement should
  378.      be required in most standards track protocols.
  379.  
  380.      Alternate Representations: CRLF line separators should be required.
  381.      Big endian should be required in new binary protocols and formats.
  382.      Use of UTF-8 should be preferred over labelled character sets in
  383.      new protocols.
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391. Newman                                                          [Page 5]
  392.  
  393. Internet Draft   Application Protocol Design Principles    June 21, 1997
  394.  
  395.  
  396. 11.  Security Considerations
  397.  
  398.      Many of these can have profound security implications.  Violation
  399.      of KISS makes a security bug more likely.  Alternate
  400.      Representations makes a security bug more likely in a less
  401.      frequently used representation.  A silly state could introduce a
  402.      security bug if special handling isn't included.  Failure to follow
  403.      the 0,1,N principle when implementing makes buffer overrun problems
  404.      more likely.
  405.  
  406.      While it's harder to fix a security bug in a binary protocol due to
  407.      the debugging complexity, text protocols tend to be more
  408.      susceptible to buffer overrun security problems.  These two factors
  409.      probably offset each other.
  410.  
  411. 12.  References
  412.  
  413.  
  414.      [IMAP4] Crispin, M., "Internet Message Access Protocol - Version
  415.      4rev1", RFC 2060, University of Washington, December 1996.
  416.  
  417.          <ftp://ds.internic.net/rfc/rfc2060.txt>
  418.  
  419.      [TBD]
  420.  
  421.  
  422.  
  423.  
  424. 13.  Author's Address
  425.  
  426.      Chris Newman
  427.      Innosoft International, Inc.
  428.      1050 Lakes Drive
  429.      West Covina, CA 91790 USA
  430.  
  431.      Email: chris.newman@innosoft.com
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447. Newman                                                          [Page 6]
  448.  
  449.