I used raw socket to create some UDP packets and then send them to a UDP server
I notice that when I put a wrong UDP checksum number the UDP server doesn't accept it, but if I put all 0 on the checksum, the UDP server accepts it?
Also, I notice a pheonomenum: checksum offloading I checked my machine:
[root@kit temp]# ethtool --show-offload eth0 Offload parameters for eth0: rx-checksumming: on tx-checksumming: on scatter-gather: on tcp-segmentation-offload: off udp-fragmentation-offload: off generic-segmentation-offload: on generic-receive-offload: on large-receive-offload: off rx-vlan-offload: on tx-vlan-offload: on ntuple-filters: off receive-hashing: on
It seems there is checksum offloading on my machine. If I randomly set the TCP checksum value, the NIC can modify it to a correct value if checksum offloading is enabled?
Finally, packets may get modified when they are in transmission for example, TTL will decrease by number of hops NAT may also modify the source IP addresses, then the checksum will be obsolete, in these cases, how checksum works? The router will modify the checksum accordingly? Or the destination machine can smartly detect these and calculate the checksum accordingly?