The calculation of the TCP control amount explained in more than 128 words

The TCP (checksum) control sum, intended for package integrity control, uses a pseudo-header that consists of the source IP of origin, destination, reserved file name (identified by 0000,0000), protocol (x06) and the length of the header Tcp.

Pseudo header TCP (source wikipedia)
TCP header (source wikipedia)
Consider the TCP package:
IP source 192.168.0.1
IP destination 192.168.0.2
Reserved/TCP Control 0 / 6
Padding/Lenght 0 / 10
TCP source port 20
TCP port destination 10
Sequence number11
ACK Acknowledgement Number 0
Offset / Reserved / Flag 5/0/2 (Flag SYN)
Window (c) 8192
Checksum (c) 0
Urgent pointer 0
Data "Ah" (41 68 unicode converts to hexadecimal)
We convert to binary:
Source IP (32-bit) 11000000.10101000.
00000000.00000001
IP destination (32 bits) 11000000.10101000.
00000000.00000010
Reserved/TCP Control (16 bts) 00000000.00000110
Padding/Lenght – 0/10 (16 bts) 00000000.00001010
TCP source port – 20 (16 bit) 00000000.00010100
TCP port destination – $10 00000000.00001010
Sequence number – 11 (32 bits) 00000000.00000000
00000000.00001011
ACK Acknowledgement Number 00000000.00000000
Offset / Reserved / Flag
5 / 0 / 2 (Flag SYN) 01010000.00000010
Window – 8192 01010000.00000010
Checksum – 0 00100000.00000000
Urgent Pointer – 0 00000000.00000000
Data – "Ah"
(41 68 unicode
converts to hexadecimal) 01000001.01101000
SOMME DE CONTROLE
Step 1 (addition) 10.10000010.00001110

The binary addition is based on the rules:

  • Rule 1: 0 – 0 – 0;
  • Rule 2: 1 – 0 – 1;
  • Rule 3: 1 – 1 – 0 with carry of 1;
  • Rule 4: 1 – 1 – 1 – 1 with carry of 1.

To add up several binary numbers you have to proceed in pairs and carry out postponements.

The TCP (checksum) control sum, intended for package integrity control, uses a pseudo-header that consists of the source IP of origin, destination, reserved file name (identified by 0000,0000), protocol (x06) and the length of the header Tcp.
Source https://fr.wikihow.com/additionner-des-nombres-binaires

CONTROLE SOMME (step 1) 00000000.00000010.10000010.00001110

The calculated sum is then on 32 bits the first 16 bits are added with the last 1
6 bits.

CONTROLE SOMME (step 2) 00000000.00000010
10000010.00001110
10000010.00010000

The next step is to calculate the supplement to 1 of the binary number found previously.
The complement to one of a binary number is the value obtained by reversing all the bits of that number (by swapping the 0 by 1 and vice versa).

CONTROLE SOMME – 01111101.1110111 1 I.e.
7D EF in hexadecimal

The conversion to hexadecimal base 16 is done by breaking the binary number into 4-bit packets:
0111/1101/1110/1111
7/D/E/F