2
1
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?
Why?
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?
1
"Unlike the UDP checksum (see Section 4.1.3.4), the TCP checksum is never optional. The sender MUST generate it and the receiver MUST check it. " - quote from http://www.freesoft.org/CIE/RFC/1122/93.htm
– Lorenzo Von Matterhorn – 2013-03-18T23:28:24.933so you mean 1 UDP checksum can't be offloaded or usually not offloaded? 2 routers can modify UDP and TCP checksum? 3 if I randomly set the TCP checksum value, the NIC can modify it to a correct value if checksum offloading is enabled? – user138126 – 2013-03-18T23:31:11.987
1For (1) and (2) see the modified answer. For (3) I don't know. I've always let the IP stack take care of this for me. – Wayne Johnston – 2013-03-18T23:41:25.577