1
votes

(Using Linux)

Creating TCP packets using raw sockets - it turns out that calculating the checksum is the bottleneck for me, in high performance networks. Since the NIC's would support checksum offloading, and ethtool also says that it is enabled, I hoped that I could use checksum offloading.

But it seems that the checksum is not calculated, when I use raw sockets. Is there a way to enable tcp checksum offloading using raw sockets?

Edit:

Actually the behaviour of my machine/NIC (Thinkpad x201) does not seem to be too logical: when sending packets with normal tcp sockets, all checksums are wrong, on the loopback interface as well as between machines. Funnily the other machine silently delivers the packets though ?

Edit2: Ok now I just looked at the packets on the wrong machine, the offloading works. But when I leave the tcp_checksum field 0, it does not get filled in, it simply stays 0.

1

1 Answers

0
votes

I have the same problem here: sent TCP or UDP packet in raw socket but can't take advantage the NIC whose checksuming-offloading is on. Wish there is a setsockopt() or ioctl() type of function that enable checksuming-offloading on the raw socket.

For the question why wireshark shows packets to have checksum errors but destination host accepts all the packets anyway, the reason is that wireshark (through winpcap etc if on windows) captures packets before the packets reached the NIC from OS. The packets don't have the checksum fields filled correctly by OS or application --- this is what checksum offloading feature on NIC is for.

The question is, how to enable NIC to do checksum offloading on a raw socket.