RFC1141 Incremental updating of the Internet checksum

1141 Incremental updating of the Internet checksum. T. Mallory, A.Kullberg. January 1990. (Format: TXT=3587 bytes) (Updates RFC1071) (Updated by RFC1624) (Status: INFORMATIONAL)

日本語訳
RFC一覧

参照

Network Working Group                                         T. Mallory
Request for Comments: 1141                                   A. Kullberg
Obsoletes: RFC 1071                                   BBN Communications
                                                            January 1990


             Incremental Updating of the Internet Checksum

Status of this Memo

   This memo correctly describes the incremental update procedure for
   use with the standard Internet checksum.  It is intended to replace
   the description of Incremental Update in RFC 1071.  This is not a
   standard but rather, an implementation technique.  Distribution of
   this memo is unlimited.

Description

   In RFC 1071 on pages 4 and 5, there is a description of a method to
   update the IP checksum in the IP header without having to completely
   recompute the checksum.  In particular, the RFC recommends the
   following equation for computing the update checksum C' from the
   original checksum C, and the old and new values of byte m:

         C' = C + (-m) + m' = C + (m' - m)

   While the equation above is correct, it is not very useful for
   incremental updates since the equation above updates the checksum C,
   rather than the 1's complement of the checksum, ~C, which is the
   value stored in the checksum field.  In addition, it suffers because
   the notation does not clearly specify that all arithmetic, including
   the unary negation, must be performed one's complement, and so is
   difficult to use to build working code.  The useful calculation for
   2's complement machines is:

         ~C' = ~(C + (-m) + m') = ~C + (m - m') = ~C + m + ~m'

   In the oft-mentioned case of updating the IP TTL field, subtracting
   one from the TTL means ADDING 1 or 256 as appropriate to the checksum
   field in the packet, using one's complement addition.  One big-endian
   non-portable implementation in C looks like:

      unsigned long sum;
      ipptr->ttl--;                  /* decrement ttl */
      sum = ipptr->Checksum + 0x100;  /* increment checksum high byte*/
      ipptr->Checksum = (sum + (sum>>16)) /* add carry */

   This special case can be optimized in many ways: for instance, you



Mallory & Kullberg                                              [Page 1]

RFC 1141                  Incremental Updating              January 1990


   can bundle updating and checking the ttl.  Compiler mileage may vary.
   Here is a more general and possibly more helpful example which
   updates the ttl by n seconds:

      UpdateTTL(iph,n)
      struct ip_hdr *ipptr;
      unsigned char n;
      {
          unsigned long sum;
          unsigned short old;

          old = ntohs(*(unsigned short *)&ipptr->ttl);
          ipptr->ttl -= n;
          sum = old + (~ntohs(*(unsigned short *)&ipptr->ttl) & 0xffff);
          sum += ntohs(ipptr->Checksum);
          sum = (sum & 0xffff) + (sum>>16);
          ipptr->Checksum = htons(sum + (sum>>16));
      }

Security Considerations

   Security issues are not addressed in this memo.

Authors' Addresses

   Tracy Mallory
   BBN Communications Corporation
   50 Moulton Street
   Cambridge, MA 02238

   Phone: (617) 873-3193

   EMail: tmallory@CCV.BBN.COM


   A. Kullberg
   BBN Communications Corporation
   50 Moulton Street
   Cambridge, MA 02238

   Phone: (617) 873-4000

   EMail:  akullberg@BBN.COM








一覧

 RFC 1〜100  RFC 1401〜1500  RFC 2801〜2900  RFC 4201〜4300 
 RFC 101〜200  RFC 1501〜1600  RFC 2901〜3000  RFC 4301〜4400 
 RFC 201〜300  RFC 1601〜1700  RFC 3001〜3100  RFC 4401〜4500 
 RFC 301〜400  RFC 1701〜1800  RFC 3101〜3200  RFC 4501〜4600 
 RFC 401〜500  RFC 1801〜1900  RFC 3201〜3300  RFC 4601〜4700 
 RFC 501〜600  RFC 1901〜2000  RFC 3301〜3400  RFC 4701〜4800 
 RFC 601〜700  RFC 2001〜2100  RFC 3401〜3500  RFC 4801〜4900 
 RFC 701〜800  RFC 2101〜2200  RFC 3501〜3600  RFC 4901〜5000 
 RFC 801〜900  RFC 2201〜2300  RFC 3601〜3700  RFC 5001〜5100 
 RFC 901〜1000  RFC 2301〜2400  RFC 3701〜3800  RFC 5101〜5200 
 RFC 1001〜1100  RFC 2401〜2500  RFC 3801〜3900  RFC 5201〜5300 
 RFC 1101〜1200  RFC 2501〜2600  RFC 3901〜4000  RFC 5301〜5400 
 RFC 1201〜1300  RFC 2601〜2700  RFC 4001〜4100  RFC 5401〜5500 
 RFC 1301〜1400  RFC 2701〜2800  RFC 4101〜4200 

スポンサーリンク

left 左からの配置位置(距離)を指定する

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る