home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / ien / ien-45 < prev    next >
Text File  |  1988-12-02  |  29KB  |  741 lines

  1. IEN 45
  2. Section 2.4.4.5
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.                   TCP Checksum Function Design
  20.  
  21.  
  22.  
  23.                        William W. Plummer
  24.  
  25.  
  26.                   Bolt Beranek and Newman, Inc.
  27.                         50 Moulton Street
  28.                       Cambridge MA   02138
  29.  
  30.  
  31.                            5 June 1978
  32.  
  33.  
  34.  
  35.  
  36. Internet Experiment Note  45                          5 June 1978
  37. TCP Checksum Function Design                   William W. Plummer
  38.  
  39.  
  40.  
  41.  
  42. 1.      Introduction
  43.  
  44. Checksums  are  included  in  packets  in   order   that   errors
  45. encountered  during  transmission  may be detected.  For Internet
  46. protocols such as TCP [1,9] this is especially important  because
  47. packets  may  have  to cross wireless networks such as the Packet
  48. Radio Network  [2]  and  Atlantic  Satellite  Network  [3]  where
  49. packets  may  be  corrupted.  Internet protocols (e.g., those for
  50. real time speech transmission) can tolerate a  certain  level  of
  51. transmission  errors  and  forward error correction techniques or
  52. possibly no checksum at all might be better.  The focus  in  this
  53. paper  is  on  checksum functions for protocols such as TCP where
  54. the required reliable delivery is achieved by retransmission.
  55.  
  56. Even if the checksum appears good on a  message  which  has  been
  57. received, the message may still contain an undetected error.  The
  58. probability of this is bounded by 2**(-C) where  C  is the number
  59. of  checksum bits.  Errors can arise from hardware (and software)
  60. malfunctions as well as transmission  errors.   Hardware  induced
  61. errors  are  usually manifested in certain well known ways and it
  62. is desirable to account for this in the design  of  the  checksum
  63. function.  Ideally no error of the "common hardware failure" type
  64. would go undetected.
  65.  
  66. An  example  of  a  failure  that  the  current checksum function
  67. handles successfully is picking up a bit in the network interface
  68. (or I/O buss, memory channel, etc.).  This will always render the
  69. checksum bad.  For an example of  how  the  current  function  is
  70. inadequate, assume that a control signal stops functioning in the
  71. network  interface and the interface stores zeros in place of the
  72. real data.  These  "all  zero"  messages  appear  to  have  valid
  73. checksums.   Noise  on the "There's Your Bit" line of the ARPANET
  74. Interface [4] may go undetected because the extra bits input  may
  75. cause  the  checksum  to be perturbed (i.e., shifted) in the same
  76. way as the data was.
  77.  
  78. Although messages containing undetected errors will  occasionally
  79. be  passed  to  higher levels of protocol, it is likely that they
  80. will not make sense at that level.  In the case of TCP most  such
  81. messages will be ignored, but some could cause a connection to be
  82. aborted.   Garbled  data could be viewed as a problem for a layer
  83. of protocol above TCP which itself may have a checksuming scheme.
  84.  
  85. This paper is the first step in design of a new checksum function
  86. for TCP  and  some  other  Internet  protocols.   Several  useful
  87. properties  of  the current function are identified.  If possible
  88.  
  89.  
  90.                               - 1 -
  91.  
  92.  
  93.  
  94.  
  95. Internet Experiment Note  45                          5 June 1978
  96. TCP Checksum Function Design                   William W. Plummer
  97.  
  98.  
  99. these should be retained  in  any  new  function.   A  number  of
  100. plausible  checksum  schemes are investigated.  Of these only the
  101. "product code" seems to be simple enough for consideration.
  102.  
  103.  
  104. 2.      The Current TCP Checksum Function
  105.  
  106. The current function is  oriented  towards  sixteen-bit  machines
  107. such  as  the PDP-11 but can be computed easily on other machines
  108. (e.g., PDP-10).  A packet is thought of as  a  string  of  16-bit
  109. bytes  and the checksum function is the one's complement sum (add
  110. with  end-around  carry)  of  those  bytes.   It  is  the   one's
  111. complement  of  this sum which is stored in the checksum field of
  112. the TCP header.  Before computing the checksum value, the  sender
  113. places  a  zero  in  the  checksum  field  of the packet.  If the
  114. checksum value computed by a receiver of the packet is zero,  the
  115. packet  is  assumed  to  be  valid.  This is a consequence of the
  116. "negative" number in the checksum field  exactly  cancelling  the
  117. contribution of the rest of the packet.
  118.  
  119. Ignoring  the  difficulty  of  actually  evaluating  the checksum
  120. function for a given  packet,  the  way  of  using  the  checksum
  121. described  above  is quite simple, but it assumes some properties
  122. of the checksum operator (one's complement addition, "+" in  what
  123. follows):
  124.  
  125.  
  126.   (P1)    +  is commutative.  Thus, the  order  in  which
  127.         the   16-bit   bytes   are  "added"  together  is
  128.         unimportant.
  129.  
  130.   (P2)    +  has  at  least  one  identity  element  (The
  131.         current  function  has  two:  +0  and  -0).  This
  132.         allows  the  sender  to  compute   the   checksum
  133.         function by placing a zero in the packet checksum
  134.         field before computing the value.
  135.  
  136.   (P3)    +  has an  inverse.   Thus,  the  receiver  may
  137.         evaluate the checksum function and expect a zero.
  138.  
  139.   (P4)    +  is associative, allowing the checksum  field
  140.         to be anywhere in the packet and the 16-bit bytes
  141.         to be scanned sequentially.
  142.  
  143. Mathematically, these properties of the binary operation "+" over
  144. the set of 16-bit numbers forms an Abelian group [5].  Of course,
  145. there  are  many Abelian groups but not all would be satisfactory
  146. for  use  as  checksum  operators.   (Another  operator   readily
  147.  
  148.  
  149.                               - 2 -
  150.  
  151.  
  152.  
  153.  
  154. Internet Experiment Note  45                          5 June 1978
  155. TCP Checksum Function Design                   William W. Plummer
  156.  
  157.  
  158. available  in  the  PDP-11  instruction set that has all of these
  159. properties is exclusive-OR, but XOR is unsatisfactory  for  other
  160. reasons.)
  161.  
  162. Albeit imprecise, another property which must be preserved in any
  163. future checksum scheme is:
  164.  
  165.   (P5)    +  is fast to compute on a variety of  machines
  166.         with limited storage requirements.
  167.  
  168. The  current  function  is  quite  good  in this respect.  On the
  169. PDP-11 the inner loop looks like:
  170.  
  171.         LOOP:   ADD (R1)+,R0    ; Add the next 16-bit byte
  172.                 ADC R0          ; Make carry be end-around
  173.                 SOB R2,LOOP     ; Loop over entire packet.
  174.  
  175.          ( 4 memory cycles per 16-bit byte )
  176.  
  177.  
  178. On the PDP-10 properties  P1-4  are  exploited  further  and  two
  179. 16-bit bytes per loop are processed:
  180.  
  181.  
  182.         LOOP:   ILDB THIS,PTR   ; Get 2 16-bit bytes
  183.                 ADD SUM,THIS    ; Add into current sum
  184.                 JUMPGE SUM,CHKSU2       ; Jump if fewer than 8 carries
  185.                 LDB THIS,[POINT 20,SUM,19] ; Get left 16 and carries
  186.                 ANDI SUM,177777 ; Save just low 16 here
  187.                 ADD SUM,THIS    ; Fold in carries
  188.         CHKSU2: SOJG COUNT,LOOP ; Loop over entire packet
  189.  
  190.         ( 3.1 memory cycles per 16-bit byte )
  191.  
  192. The  "extra"  instruction  in  the  loops  above  are required to
  193. convert the two's complement  ADD  instruction(s)  into  a  one's
  194. complement  add  by  making  the  carries  be  end-around.  One's
  195. complement arithmetic is better than two's complement because  it
  196. is  equally  sensitive  to errors in all bit positions.  If two's
  197. complement addition were used, an even number  of  1's  could  be
  198. dropped  (or  picked  up)  in  the  most  significant bit channel
  199. without affecting the value of the checksum.   It  is  just  this
  200. property  that makes some sort of addition preferable to a simple
  201. exclusive-OR which is frequently used but permits an even  number
  202. of drops (pick ups) in any bit channel.  RIM10B paper tape format
  203. used  on PDP-10s [10] uses two's complement add because space for
  204. the loader program is extremely limited.
  205.  
  206.  
  207.  
  208.                               - 3 -
  209.  
  210.  
  211.  
  212.  
  213. Internet Experiment Note  45                          5 June 1978
  214. TCP Checksum Function Design                   William W. Plummer
  215.  
  216.  
  217. Another property of the current checksum scheme is:
  218.  
  219.   (P6)    Adding the checksum to a packet does not change
  220.         the information bytes.  Peterson [6] calls this a
  221.         "systematic" code.
  222.  
  223.  
  224. This property  allows  intermediate  computers  such  as  gateway
  225. machines  to  act  on  fields  (i.e.,  the  Internet  Destination
  226. Address) without having to first  decode  the  packet.   Cyclical
  227. Redundancy  Checks  used  for error correction are not systematic
  228. either.  However, most applications of  CRCs  tend  to  emphasize
  229. error  detection rather than correction and consequently can send
  230. the message unchanged, with the CRC check bits being appended  to
  231. the  end.   The  24-bit CRC used by ARPANET IMPs and Very Distant
  232. Host Interfaces [4] and the ANSI standards for 800 and 6250  bits
  233. per inch magnetic tapes (described in [11]) use this mode.
  234.  
  235. Note  that  the  operation  of higher level protocols are not (by
  236. design) affected by anything that may be done by a gateway acting
  237. on possibly invalid packets.  It is permissible for  gateways  to
  238. validate  the  checksum  on  incoming  packets,  but  in  general
  239. gateways will not know how to  do  this  if  the  checksum  is  a
  240. protocol-specific feature.
  241.  
  242. A final property of the current checksum scheme which is actually
  243. a consequence of P1 and P4 is:
  244.  
  245.   (P7)    The checksum may be incrementally modified.
  246.  
  247. This  property permits an intermediate gateway to add information
  248. to a packet, for instance a timestamp, and "add"  an  appropriate
  249. change  to  the  checksum  field  of  the  packet.  Note that the
  250. checksum  will  still  be  end-to-end  since  it  was  not  fully
  251. recomputed.
  252.  
  253.  
  254. 3.      Product Codes
  255.  
  256. Certain  "product  codes"  are potentially useful for checksuming
  257. purposes.  The following is a brief description of product  codes
  258. in  the  context  of TCP.  More general treatment can be found in
  259. Avizienis [7] and probably other more recent works.
  260.  
  261. The basic concept of this coding is that the message (packet)  to
  262. be sent is formed by transforming the original source message and
  263. adding  some  "check"  bits.   By  reading  this  and  applying a
  264. (possibly different) transformation, a receiver  can  reconstruct
  265.  
  266.  
  267.                               - 4 -
  268.  
  269.  
  270.  
  271.  
  272. Internet Experiment Note  45                          5 June 1978
  273. TCP Checksum Function Design                   William W. Plummer
  274.  
  275.  
  276. the  original  message  and  determine  if  it has been corrupted
  277. during transmission.
  278.  
  279.          Mo              Ms              Mr
  280.  
  281.         -----           -----           -----
  282.         | A |  code     | 7 |   decode  | A |
  283.         | B |    ==>    | 1 |     ==>   | B |
  284.         | C |           | 4 |           | C |
  285.         -----           |...|           -----
  286.                         | 2 | check     plus "valid" flag
  287.                         ----- info
  288.  
  289.         Original        Sent            Reconstructed
  290.  
  291.  
  292. With product codes the transformation is  Ms = K * Mo .  That is,
  293. the message sent is simply the product of  the  original  message
  294. Mo   and  some  well known constant  K .  To decode, the received
  295. Ms  is divided by  K  which will yield  Mr  as the  quotient  and
  296. 0   as the remainder if  Mr is to be considered the same as  Mo .
  297.  
  298. The first problem is selecting a "good" value for  K, the  "check
  299. factor".   K  must  be  relatively  prime  to  the base chosen to
  300. express  the  message.   (Example:  Binary   messages   with    K
  301. incorrectly  chosen  to be 8.  This means that  Ms  looks exactly
  302. like  Mo  except that three zeros have been appended.   The  only
  303. way  the message could look bad to a receiver dividing by 8 is if
  304. the error occurred in one of those three bits.)
  305.  
  306. For TCP the base  R  will be chosen to be 2**16.  That is,  every
  307. 16-bit byte (word on the PDP-11) will be considered as a digit of
  308. a big number and that number is the message.  Thus,
  309.  
  310.                 Mo =  SIGMA [ Bi * (R**i)]   ,   Bi is i-th byte
  311.                      i=0 to N
  312.  
  313.                 Ms = K * Mo
  314.  
  315.  
  316. Corrupting a single digit  of   Ms   will  yield   Ms' =  Ms +or-
  317. C*(R**j)  for some radix position  j .  The receiver will compute
  318. Ms'/K = Mo +or- C(R**j)/K. Since R  and  K  are relatively prime,
  319. C*(R**j) cannot be any exact  multiple  of   K.   Therefore,  the
  320. division will result in a non-zero remainder which indicates that
  321. Ms'   is  a  corrupted  version  of  Ms.  As will be seen, a good
  322. choice for  K  is (R**b - 1), for some  b  which  is  the  "check
  323. length"  which  controls  the  degree  of detection to be had for
  324.  
  325.  
  326.                               - 5 -
  327.  
  328.  
  329.  
  330.  
  331. Internet Experiment Note  45                          5 June 1978
  332. TCP Checksum Function Design                   William W. Plummer
  333.  
  334.  
  335. burst errors which affect a string of digits (i.e., 16-bit bytes)
  336. in the message.  In fact  b  will be chosen to be  1, so  K  will
  337. be  2**16 - 1 so that arithmetic operations will be simple.  This
  338. means  that  all  bursts  of  15  or fewer bits will be detected.
  339. According to [7] this choice for  b   results  in  the  following
  340. expression for the fraction of undetected weight 2 errors:
  341.  
  342.    f =  16(k-1)/[32(16k-3) + (6/k)]  where k is the message length.
  343.  
  344. For  large messages  f  approaches  3.125 per cent as  k  goes to
  345. infinity.
  346.  
  347. Multiple precision multiplication and division are normally quite
  348. complex operations, especially on small machines which  typically
  349. lack  even  single precision multiply and divide operations.  The
  350. exception to this is exactly the case being dealt  with  here  --
  351. the  factor  is  2**16  - 1  on machines with a word length of 16
  352. bits.  The reason for this is due to the following identity:
  353.  
  354.         Q*(R**j)  =  Q, mod (R-1)     0 <= Q < R
  355.  
  356. That is, any digit  Q  in the selected  radix  (0,  1,  ...  R-1)
  357. multiplied  by any power of the radix will have a remainder of  Q
  358. when divided by the radix minus 1.
  359.  
  360. Example:  In decimal R = 10.  Pick  Q = 6.
  361.  
  362.                 6  =   0 * 9  +  6  =  6, mod 9
  363.                60  =   6 * 9  +  6  =  6, mod 9
  364.               600  =  66 * 9  +  6  =  6, mod 9   etc.
  365.  
  366.         More to the point,
  367.  
  368.  rem(31415/9) = rem((30000+1000+400+10+5)/9)
  369.               = (3 mod 9) + (1 mod 9) + (4 mod 9) + (1 mod 9) + (5 mod 9)
  370.               = (3+1+4+1+5) mod 9
  371.               = 14 mod 9
  372.               = 5
  373.  
  374. So, the remainder of a number divided by the radix minus one  can
  375. be  found  by simply summing the digits of the number.  Since the
  376. radix in the TCP case has been chosen to be  2**16 and the  check
  377. factor is  2**16 - 1, a message can quickly be checked by summing
  378. all  of  the  16-bit  words  (on  a  PDP-11),  with carries being
  379. end-around.  If zero is the result, the message can be considered
  380. valid.  Thus, checking a product coded  message  is  exactly  the
  381. same complexity as with the current TCP checksum!
  382.  
  383.  
  384.  
  385.                               - 6 -
  386.  
  387.  
  388.  
  389.  
  390. Internet Experiment Note  45                          5 June 1978
  391. TCP Checksum Function Design                   William W. Plummer
  392.  
  393.  
  394. In  order  to  form   Ms,  the  sender must multiply the multiple
  395. precision "number"  Mo  by  2**16 - 1.  Or,  Ms = (2**16)Mo - Mo.
  396. This is performed by shifting  Mo   one  whole  word's  worth  of
  397. precision  and  subtracting   Mo.   Since  carries must propagate
  398. between digits, but it is only the  current  digit  which  is  of
  399. interest, one's complement arithmetic is used.
  400.  
  401.         (2**16)Mo =  Mo0 + Mo1 + Mo2 + ... + MoX +  0
  402.             -  Mo =    - ( Mo0 + Mo1 + ......... + MoX)
  403.         ---------    ----------------------------------
  404.            Ms     =  Ms0 + Ms1 + ...             - MoX
  405.  
  406. A  loop  which  implements  this  function on a PDP-11 might look
  407. like:
  408.  
  409.         LOOP:   MOV -2(R2),R0   ; Next byte of (2**16)Mo
  410.                 SBC R0          ; Propagate carries from last SUB
  411.                 SUB (R2)+,R0    ; Subtract byte of  Mo
  412.                 MOV R0,(R3)+    ; Store in Ms
  413.                 SOB R1,LOOP     ; Loop over entire message
  414.  
  415.                 ( 8 memory cycles per 16-bit byte)
  416.  
  417. Note that the coding procedure is not done in-place since  it  is
  418. not  systematic.   In general the original copy, Mo, will have to
  419. be  retained  by  the  sender  for  retransmission  purposes  and
  420. therefore  must  remain  readable.   Thus  the  MOV  R0,(R3)+  is
  421. required which accounts for 2 of the  8  memory cycles per  loop.
  422.  
  423. The  coding  procedure  will  add  exactly one 16-bit word to the
  424. message since  Ms <  (2**16)Mo .  This additional 16 bits will be
  425. at the tail of the message, but may be  moved  into  the  defined
  426. location  in the TCP header immediately before transmission.  The
  427. receiver will have to undo this to put  Ms   back  into  standard
  428. format before decoding the message.
  429.  
  430. The  code  in  the receiver for fully decoding the message may be
  431. inferred  by  observing  that  any  word  in   Ms   contains  the
  432. difference between two successive words of  Mo  minus the carries
  433. from the previous word, and the low order word contains minus the
  434. low word of Mo.  So the low order (i.e., rightmost) word of Mr is
  435. just  the negative of the low order byte of Ms.  The next word of
  436. Mr is the next word of  Ms  plus the just computed  word  of   Mr
  437. plus the carry from that previous computation.
  438.  
  439. A  slight  refinement  of  the  procedure is required in order to
  440. protect against an all-zero message passing to  the  destination.
  441. This  will  appear to have a valid checksum because Ms'/K  =  0/K
  442.  
  443.  
  444.                               - 7 -
  445.  
  446.  
  447.  
  448.  
  449. Internet Experiment Note  45                          5 June 1978
  450. TCP Checksum Function Design                   William W. Plummer
  451.  
  452.  
  453. = 0 with 0 remainder.  The refinement is to make  the  coding  be
  454. Ms  =  K*Mo + C where  C  is some arbitrary, well-known constant.
  455. Adding this constant requires a second pass over the message, but
  456. this will typically be very short since it can stop  as  soon  as
  457. carries  stop propagating.  Chosing  C = 1  is sufficient in most
  458. cases.
  459.  
  460. The product code checksum must  be  evaluated  in  terms  of  the
  461. desired  properties  P1 - P7.  It has been shown that a factor of
  462. two more machine cycles are consumed in computing or verifying  a
  463. product code checksum (P5 satisfied?).
  464.  
  465. Although the code is not systematic, the checksum can be verified
  466. quickly   without   decoding   the   message.   If  the  Internet
  467. Destination Address is located at the least  significant  end  of
  468. the packet (where the product code computation begins) then it is
  469. possible  for  a  gateway to decode only enough of the message to
  470. see this field without  having  to  decode  the  entire  message.
  471. Thus,   P6  is  at  least  partially  satisfied.   The  algebraic
  472. properties P1 through P4 are not  satisfied,  but  only  a  small
  473. amount  of  computation  is  needed  to  account  for this -- the
  474. message needs to be reformatted as previously mentioned.
  475.  
  476. P7  is  satisfied  since  the  product  code  checksum   can   be
  477. incrementally  updated to account for an added word, although the
  478. procedure is  somewhat  involved.    Imagine  that  the  original
  479. message  has two halves, H1 and  H2.  Thus,  Mo = H1*(R**j) + H2.
  480. The timestamp word is to be inserted between these halves to form
  481. a modified  Mo' = H1*(R**(j+1)) + T*(R**j) + H2.  Since   K   has
  482. been  chosen to be  R-1, the transmitted message  Ms' = Mo'(R-1).
  483. Then,
  484.  
  485.  Ms' =  Ms*R + T(R-1)(R**j) + P2((R-1)**2)
  486.  
  487.      =  Ms*R + T*(R**(j+1))  + T*(R**j) + P2*(R**2) - 2*P2*R - P2
  488.  
  489. Recalling that  R   is  2**16,  the  word  size  on  the  PDP-11,
  490. multiplying  by   R   means copying down one word in memory.  So,
  491. the first term of  Ms' is simply the  unmodified  message  copied
  492. down  one word.  The next term is the new data  T  added into the
  493. Ms' being formed beginning at the (j+1)th word.  The addition  is
  494. fairly  easy  here  since  after adding in T  all that is left is
  495. propagating the carry, and that can stop as soon as no  carry  is
  496. produced.  The other terms can be handle similarly.
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.                               - 8 -
  504.  
  505.  
  506.  
  507.  
  508. Internet Experiment Note  45                          5 June 1978
  509. TCP Checksum Function Design                   William W. Plummer
  510.  
  511.  
  512.  
  513.  
  514. 4.      More Complicated Codes
  515.  
  516. There exists a wealth of theory on error detecting and correcting
  517. codes.   Peterson  [6]  is an excellent reference.  Most of these
  518. "CRC" schemes are  designed  to  be  implemented  using  a  shift
  519. register  with  a  feedback  network  composed  of exclusive-ORs.
  520. Simulating such a logic circuit with a program would be too  slow
  521. to be useful unless some programming trick is discovered.
  522.  
  523. One  such  trick has been proposed by Kirstein [8].  Basically, a
  524. few bits (four or eight) of the current shift register state  are
  525. combined with bits from the input stream (from Mo) and the result
  526. is  used  as  an  index  to  a  table  which yields the new shift
  527. register state and, if the code is not systematic, bits  for  the
  528. output  stream  (Ms).  A trial coding of an especially "good" CRC
  529. function using four-bit bytes showed showed this technique to  be
  530. about  four times as slow as the current checksum function.  This
  531. was true for  both  the  PDP-10  and  PDP-11  machines.   Of  the
  532. desirable  properties  listed  above, CRC schemes satisfy only P3
  533. (It has an inverse.), and P6 (It is systematic.).   Placement  of
  534. the  checksum  field in the packet is critical and the CRC cannot
  535. be incrementally modified.
  536.  
  537.  
  538. Although the bulk of coding theory deals with binary codes,  most
  539. of  the theory works if the alphabet contains   q  symbols, where
  540. q is a power of a prime number.  For instance  q  taken as  2**16
  541. should  make  a great deal of the theory useful on a word-by-word
  542. basis.
  543.  
  544.  
  545. 5.      Outboard Processing
  546.  
  547. When a function such as computing an involved  checksum  requires
  548. extensive processing, one solution is to put that processing into
  549. an  outboard processor.  In this way "encode message" and "decode
  550. message" become single instructions which do  not  tax  the  main
  551. host   processor.   The  Digital  Equipment  Corporation  VAX/780
  552. computer is equipped with special  hardware  for  generating  and
  553. checking  CRCs [13].  In general this is not a very good solution
  554. since such a processor must be constructed  for  every  different
  555. host machine which uses TCP messages.
  556.  
  557. It is conceivable that the gateway functions for a large host may
  558. be  performed  entirely  in an "Internet Frontend Machine".  This
  559. machine would be  responsible  for  forwarding  packets  received
  560.  
  561.  
  562.                               - 9 -
  563.  
  564.  
  565.  
  566.  
  567. Internet Experiment Note  45                          5 June 1978
  568. TCP Checksum Function Design                   William W. Plummer
  569.  
  570.  
  571. either  from the network(s) or from the Internet protocol modules
  572. in the connected host, and for  reassembling  Internet  fragments
  573. into  segments and passing these to the host.  Another capability
  574. of this machine would be  to  check  the  checksum  so  that  the
  575. segments given to the host are known to be valid at the time they
  576. leave the frontend.  Since computer cycles are assumed to be both
  577. inexpensive and available in the frontend, this seems reasonable.
  578.  
  579. The problem with attempting to validate checksums in the frontend
  580. is that it destroys the end-to-end character of the checksum.  If
  581. anything,  this is the most powerful feature of the TCP checksum!
  582. There is a way to make the host-to-frontend link  be  covered  by
  583. the  end-to-end  checksum.   A  separate,  small protocol must be
  584. developed to cover this link.  After having validated an incoming
  585. packet from the network, the frontend would pass it to  the  host
  586. saying "here is an Internet segment for you.  Call it #123".  The
  587. host  would  save  this  segment,  and  send  a  copy back to the
  588. frontend saying, "Here is what you gave me as #123.  Is it  OK?".
  589. The  frontend  would  then  do a word-by-word comparison with the
  590. first transmission, and  tell  the  host  either  "Here  is  #123
  591. again",  or "You did indeed receive #123 properly.  Release it to
  592. the appropriate module for further processing."
  593.  
  594. The headers on the messages crossing the host-frontend link would
  595. most likely be covered  by  a  fairly  strong  checksum  so  that
  596. information  like  which  function  is  being  performed  and the
  597. message reference numbers are reliable.  These headers  would  be
  598. quite  short,  maybe  only sixteen bits, so the checksum could be
  599. quite strong.  The bulk of the message would not be checksumed of
  600. course.
  601.  
  602. The reason this scheme reduces the computing burden on  the  host
  603. is  that  all  that  is required in order to validate the message
  604. using the end-to-end checksum is to send it back to the  frontend
  605. machine.   In  the  case  of  the PDP-10, this requires only  0.5
  606. memory cycles per 16-bit byte of Internet message, and only a few
  607. processor cycles to setup the required transfers.
  608.  
  609.  
  610. 6.      Conclusions
  611.  
  612. There is an ordering of checksum functions: first and simplest is
  613. none at all which provides  no  error  detection  or  correction.
  614. Second,  is  sending a constant which is checked by the receiver.
  615. This also is extremely weak.  Third, the exclusive-OR of the data
  616. may be sent.  XOR takes the minimal amount of  computer  time  to
  617. generate  and  check,  but  is  not  a  good  checksum.   A two's
  618. complement sum of the data is somewhat better and takes  no  more
  619.  
  620.  
  621.                              - 10 -
  622.  
  623.  
  624.  
  625.  
  626. Internet Experiment Note  45                          5 June 1978
  627. TCP Checksum Function Design                   William W. Plummer
  628.  
  629.  
  630. computer  time  to  compute.   Fifth, is the one's complement sum
  631. which is what is currently used by  TCP.   It  is  slightly  more
  632. expensive  in terms of computer time.  The next step is a product
  633. code.  The product code is strongly related to  one's  complement
  634. sum,  takes  still more computer time to use, provides a bit more
  635. protection  against  common  hardware  failures,  but  has   some
  636. objectionable properties.  Next is a genuine CRC polynomial code,
  637. used  for  checking  purposes only.  This is very expensive for a
  638. program to implement.  Finally, a full CRC error  correcting  and
  639. detecting scheme may be used.
  640.  
  641.  
  642. For  TCP  and  Internet  applications  the product code scheme is
  643. viable.  It suffers mainly in that messages  must  be  (at  least
  644. partially)  decoded  by  intermediate gateways in order that they
  645. can be forwarded.  Should product  codes  not  be  chosen  as  an
  646. improved  checksum,  some  slight  modification  to  the existing
  647. scheme might be possible.  For  instance  the  "add  and  rotate"
  648. function  used  for  paper  tape  by  the  PDP-6/10  group at the
  649. Artificial Intelligence Laboratory at  M.I.T.  Project  MAC  [12]
  650. could  be  useful  if it can be proved that it is better than the
  651. current scheme and that it  can  be  computed  efficiently  on  a
  652. variety of machines.
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.                              - 11 -
  681.  
  682.  
  683.  
  684.  
  685. Internet Experiment Note  45                          5 June 1978
  686. TCP Checksum Function Design                   William W. Plummer
  687.  
  688.  
  689. References
  690.  
  691.  
  692. [1]     Cerf, V.G. and Kahn, Robert E., "A Protocol for Packet
  693.         Network Communications," IEEE Transactions on Com-              
  694.         munications, vol. COM-22, No. 5, May 1974.
  695.  
  696. [2]     Kahn, Robert E., "The Organization of Computer Resources
  697.         into a Packet Radio Network", IEEE Transactions on                      
  698.         Communications, vol. COM-25, no. 1, pp. 169-178, January 1977.
  699.  
  700. [3]     Jacobs, Irwin, et al., "CPODA - A Demand Assignment                    
  701.         Protocol for SatNet", Fifth Data Communications
  702.         Symposium, September 27-9, 1977, Snowbird, Utah
  703.  
  704. [4]     Bolt Beranek and Newman, Inc.  "Specifications for the
  705.         Interconnection of a Host and an IMP", Report 1822, January
  706.         1976 edition.
  707.  
  708. [5]     Dean, Richard A., "Elements of Abstract Algebra",
  709.         John Wyley and Sons, Inc., 1966
  710.  
  711. [6]     Peterson, W. Wesley, "Error Correcting Codes", M.I.T. Press
  712.         Cambridge MA, 4th edition, 1968.
  713.  
  714. [7]     Avizienis, Algirdas, "A Study of the Effectiveness of
  715.         Fault-Detecting Codes for Binary Arithmetic", Jet
  716.         Propulsion Laboratory Technical Report No. 32-711,
  717.         September 1, 1965.
  718.  
  719. [8]     Kirstein, Peter, private communication
  720.  
  721. [9]     Cerf, V. G. and Postel, Jonathan B., "Specification
  722.         of Internetwork Transmission Control Program Version 3",
  723.         University of Southern California Information Sciences
  724.         Institute, January 1978.
  725.  
  726. [10]    Digital Equipment Corporation, "PDP-10 Reference Handbook",
  727.         1970, pp. 114-5.
  728.  
  729. [11]    Swanson, Robert, "Understanding Cyclic Redundancy Codes",
  730.         Computer Design, November, 1975, pp. 93-99.
  731.  
  732. [12]    Clements, Robert C., private communication.
  733.  
  734. [13]    Conklin, Peter F., and Rodgers, David P., "Advanced Minicomputer
  735.         Designed by Team Evaluation of Hardware/Software Tradeoffs",
  736.         Computer Design, April 1978, pp. 136-7.
  737.  
  738.  
  739.                              - 12 -
  740.  
  741.