IPv4/IPv6 TCP/UDP Checksum

Raghavendra Hiremath
3 min readSep 15, 2021

I’ve learned that I still have a lot to learn!

Hello Everyone, hope you are doing well! It has been ages that I haven’t uploaded any articles online.

Today, I would be teaching some of the basics of NIC data checksum that most of us get confused about.

What is TCP/UDP Checksum? Where can I find it?

Checksum determine the integrity of the data transmitted over a network. You can find it under NIC Card properties:

What is TCP/UDP? -> Transmission Control Protocol/User datagram protocol, simple terms TCP doesn’t loss the data however, you can expect data loss in UDP Protocol.

TCP performs three way handshake during establishing the connection with client. However UDP does not provide any reliability on the connection ( You can think this like a television broadcast, if you see any noise on the movie/series. That means there is a loss of data during data transmission.) TCP is a connection which make sure each data being transmitted over a network is not lost.)

https://www.educative.io/edpresso/tcp-vs-udp

Oh! UDP is considered not sure which using it over the public because it is prone to security data risk.

Now, let us understand what is TCP/UDP checksum. When our computer receives or sends data the NIC (Network Interface Card) keeps track on the data frame that is being transmitted from it, those frames are being checked before/after data is being received/sent to check if the data is not being lost or tampered.

https://www.synopsys.com/dw/dwtb/ethernet_mac/ethernet_mac.html

For example, consider the above TCP IP datagram which has a checksum value placeholder, sender make sure that there is a checksum value mentioned in the header details which is a 2 byte value. Data-corruption is determined and the error is reported to the host.

“The received frame could be a TCP or a UDP segment, encapsulated in IPv4 or IPv6, as indicated by the “type” field in the MAC frame. Further, TCP vs. UDP is indicated by the “protocol” field in the IP frame. The checksum-calculator module will decode this and based on the protocol, the frame is parsed suitably to compute the checksum.

The IPv4 header checksum error is reported to the host through a register bit. Any TCP/UDP segment checksum error is reported through a common status bit as well. The errors also include the mismatch between the values as indicated in the length field in the IP header vs. the actual number of bytes received. In case of the IPv6 datagram, any extension field other than hop-by-hop or routing header or destination header is considered as non-supported field. In this case the payload checksum appending is automatically disabled.”

Final conclusion

Checksum in layer 3 (IP) and layer 4(TCP/UDP) is an essential function to ensure data integrity across a network. To keep up with network speeds of 1Gbps and higher, the checksum computation function is being offloaded to hardware, completely or partially to improve system performance and decrease the CPU load. Synopsys’ DesignWare Ethernet MAC 10/100/1000-Universal IP enables SOC developers to easily incorporate this feature by configuring the core to include the IP checksum block option.

However, in the production system those values would be disabled locally to avoid any TCP/UDP inconsistency, we have been observed it is mostly on the database queries where the SQL statements are being transmitted over by the application and at times it causes spikes in the database/you may call it has database contention

Hope you all have a good day ahead!

--

--

Raghavendra Hiremath

WE BELIEVE IN FREE AND OPEN SOURCE. My mission is to constantly learn and share the knowledge I gain so that you can use it to empower you.