TCPIP : UDP / TCP 체크섬

UDP / TCP 체크섬

1Content 표

인터넷 체크섬

1의 보수 합

UDP / TCP 체크섬

 

2Internet 검사

(1) 쌍으로 체크섬 될 인접 옥텟 16 비트를 형성

정수, 이들 16 비트 정수의 1의 보수 합을 형성한다.

(2) 검사를 생성하려면 체크섬 필드 자체는 삭제됩니다,

16 비트 1의 보수 합 관련 옥텟을 통해 계산되고,이 총합의 1의 보수는 체크섬 필드에 배치된다.

(3) 체크섬을 확인하기 위해, 하나의 보수 합 체크섬 필드를 포함 옥텟들의 동일한 세트를 통해 연산된다. 결과는 모두 1 비트 (1의 보수 연산에서 -0) 인 경우 검사가 성공합니다.



31의 보수 합

데이터 블록의 체크섬 블록의 16 비트 합계의 1의 보수의 보수이다. 체크섬은 데이터 블록에 포함되어있는 경우, 데이터의 새로운 블록의 체크섬 제로가됩니다. 이 검사는 데이터 그램 전송에 오류 검출에 사용되는 방법이다.

예로서, 데이터 블록을 고려

0x23fb

+ 0x34c0

+ 0xa090

+ 0xbcaf

+ 0xfc05

-----------

0x2b1ff

16 비트 1의 보수 합이 개 필요 최하위 16 비트에 다시 추가 할 수있는 여분의 자리를 계산하려면 :

0xb1ff

+ 0x2로

-----------

0xb201

이것의 보완 0x4dfe입니다. 이 데이터 블록의 체크섬이다.

체크섬 (+ 데이터 체크섬) = 0 :이 참고

우리는 체크섬 필드를 포함하는 데이터 블록을 전송하는 경우에는 비트 오류가없는 경우에 따라서, 수신기는 0의 체크섬을 볼 수 있습니다.



4UDP / TCP 체크섬

 

Although the basics for calculating the UDP checksum are similar to the general Internet checksum (the one’s complement of the one’s complement sum of 16-bit words), there are two small special details.

First, the length of the UDP datagram can be an odd number of bytes, whereas the checksum algorithm adds 16-bit words (always an even number of bytes). The procedure for UDP is to append a (virtual) pad byte of 0 to the end of odd-length datagrams, just for the checksum computation and verification.

The second detail is that UDP (as well as TCP) computes its checksum over a 12-byte pseudo-header derived from fields in the IPv4 header or a 40-byte pseudo-header derived from fields in the IPv6 header. This pseudo-header is also virtual and is used only for purposes of the checksum computation (at both the sender and the receiver). Its purpose is to let the UDP layer verify that the data has arrived at the correct destination (i.e., that IP has not accepted a misaddressed datagram, and that IP has not given UDP a datagram that is for another transport protocol).


The TCP Checksum field covers the TCP header and data and some fields in the IP header, using a pseudo-header computation similar to the one used with UDP. It is mandatory for this field to be calculated and stored by the sender, and then verified by the receiver.



5Reference

  1. https://tools.ietf.org/html/rfc1071

  2. http://www.cs.newpaltz.edu/~easwaran/CCN/Week5/Checksum.pdf

  3. Vol 1. TCP/IP Illustrated

 

추천

출처www.cnblogs.com/wordchao/p/11127637.html