Network data packet-tested and (checksum) Calculation

  In the transmission network to ensure that data packets are transmitted with an effective post-mortem right field, IP, arp, such as every tcp 

  Data has its own validity of the post-mortem and. 
  - Tested the calculation is not complicated.    The corresponding data of all data packets as a byte array 
  (A, b, c, d, e), they were divided into a group of 16 bit 
  ([Ab], [cd], [e0]) 
  And calculated: 
  [Ab] 
  [Cd] 
  [E0] 
——–
  [Xy] 
  Calculated using binary cycle, the highest lowest Add to rounding, 
  If the calculation of the [xy] are all for a bit (ie 1111 1111)-tested through. 

  If [cd]-tested and it has already completed all other byte, to how the [cd] 

  (Checksum) values?    We first filled with 0 [cd], and then calculated [xy], right [cd] should include 

  Calculated by the [xy] for the anti-bit results.    This will ensure that the entire data packet through the validity of the post-mortem. 

  Actual procedures, because the machines are now 32, so modifications to the algorithms used: 
  Byte-by-byte "Normal" Swapped 
  Order Order 

  Byte 0 / 1: 00 01 0001 0100 
  Byte 2 / 3: f2 03 f203 03f2 
  Byte 4 / 5: f4 f5 f4f5 f5f4 
  Byte 6 / 7: f6 f7 f6f7 f7f6 
  — — —– —– 
  Sum1: 2dc 1f0 2ddf0 1f2dc 

  Dc f0 ddf0 f2dc 
  Carrys: 1 2 2 1 
  — - —- —- 
  Sum2: dd f2 ddf2 f2dd 

  Final Swap: dd f2 ddf2 ddf2 
  —————————— 
  Byte 0/1/2/3: 0001f203 010003f2 03f20100 
  Byte 4/5/6/7: f4f5f6f7 f5f4f7f6 f7f6f5f4 
  ——– ——– ——– 
  Sum1: 0f4f7e8fa 0f6f4fbe8 0fbe8f6f4 

  Carries: 0 0 0 

  Top half: f4f7 f6f4 fbe8 
  Bottom half: e8fa fbe8 f6f4 
  —– —– —– 
  Sum2: 1ddf1 1f2dc 1f2dc 

  Ddf1 f2dc f2dc 
  Carrys: 1 1 1 
  —- —- —- 
  Sum3: ddf2 f2dd f2dd 

  Final Swap: ddf2 ddf2 ddf2 

  Can be seen for 32 to the checksum, and then the low and high eight eight together, and ultimately sought 

  Checksum is the same. 
  Is a section of the C + + algorithm: 
  In 6 
  ( 
  / * Compute Internet Checksum for "count" bytes 
  * Beginning at location "addr." 
  * / 
  Register long sum = 0; 

  While (count> 1) ( 
  / * This is the inner loop * / 
  Sum + = * (unsigned short) addr + +; 
  Count -= 2; 
  ) 

  / * Add left-over byte, if any * / 
  If (count> 0) 
  Sum + = * (unsigned char *) addr; 

  / * Fold 32-bit sum to 16 bits * / 
  While (sum>> 16) 
  Sum = (sum & 0xffff) + (sum>> 16); 

  Checksum = ~ sum; 
  ) 

  References: RFC1071 Website: http://www.faqs.org/rfcs/rfc1071.html 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags:

Releated Articles


0 Comments to “Network data packet-tested and (checksum) Calculation”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.