+8618758069661 [email protected]
Product Search Guide: space = AND, | = OR, ! = NOT

Why Does a UDP Checksum Include IP Addresses? The Pseudo-Header and End-to-End Error Detection

Got any Questions? Call us Today!

+8618758069661

Or leave us a message

Online Message

Why Does a UDP Checksum Include IP Addresses? The Pseudo-Header and End-to-End Error Detection

Views: 26 +3Original by FCTELEAuthor: FCTELE Technical Team

UDP / END-TO-END ERROR DETECTION

Why include IP addresses in a UDP checksum?

The ordinary IPv4 UDP checksum includes endpoint context as well as the UDP header and payload. Both ends construct the same pseudo-header for calculation. That links error detection to the intended network context without transmitting an extra header. A valid checksum does not guarantee delivery, freshness or trusted origin; applications still need their own validity and security checks.

01 · Include endpoint context

Ordinary IPv4 UDP teaching example, no measured traffic or product implementation.IPUDPDATA

The IPv4 pseudo-header contributes addresses, protocol and length locally. It is not an extra UDP header on the wire.

02 · Complement the sum

Ordinary IPv4 UDP teaching example, no measured traffic or product implementation.8FE2701D

The complete hypothetical example produces sum 8FE2. Complementing its bits yields checksum 701D.

03 · Compare at the receiver

Ordinary IPv4 UDP teaching example, no measured traffic or product implementation.INTACT: FFFFCHANGED: 0001

Retain 701D and change payload 0001 to 0002: the verification sum is 0001. This demonstrates one detectable change, not all possible errors.

Preserve the inputs

Record bytes, addresses, ports, length and capture direction.

Check the observation point

Account for NIC offload before diagnosing a local capture.

Verify application meaning

Check sequence, age and outcome separately from checksum validity.

Selection and verification checklist — expand
Check What to confirm How to verify
Coverage Context, header and complete payload Pseudo-header-aware calculation
Offload Local versus on-wire fields Tool settings and remote observation
Validity Fresh, nonduplicate application result Sequence, age and outcome records

A serial server sends acquisition data to a computer over UDP. Ethernet already has a frame check, so why does UDP need a separate checksum—and why include IP addresses? Each layer checks a different object across a different boundary. Follow an ordinary IPv4 UDP datagram from endpoint context, header and payload to receiver verification. The examples exclude UDP extension options and do not depict any particular product’s implementation.

What UDP hands to the application

UDP, the User Datagram Protocol, delivers datagrams. Receiving a datagram does not necessarily mean receiving one complete instrument message: a serial server may packetize according to length or waiting time, while the application protocol has its own addressing, function and length rules. Here the focus is consistency checking between network endpoints.

An ordinary UDP header contains eight bytes: source port, destination port, length and checksum. Ports help identify processes or services. UDP length includes the eight-byte header and payload. Source and destination IP addresses belong to the surrounding IP information, not these four UDP fields. Nevertheless, UDP checking includes more than the information physically inside its own header.

Feichang serial-server documentation lists UDP modes and can establish the relevant equipment category. UDP support alone does not establish a model’s checksum offload, packet-capture display or error-counter capabilities. An ordinary Layer 2 switch generally forwards Ethernet frames; UDP verification must not automatically be assigned to every switch forwarding chip.

Sender combines pseudo-header context with UDP header and payload
Figure 1. The sender checks IP context, UDP header and payload together. The dashed ribbon is local calculation context, not an extra transmitted pseudo-header or a product interior. Original FCTELE illustration with AI assistance.

Why the pseudo-header is not another transmitted header

For checksum computation, the sender assembles source address, destination address, protocol and UDP length into a calculation context called the pseudo-header. In this IPv4 example it contains the two addresses, a zero byte, protocol number 17 and UDP length. This context participates alongside the UDP header and payload. It is not sent as an additional duplicate header immediately before UDP.

The receiver reconstructs the context from the received IP information and checks it together with UDP. Even when ports and payload look identical, changing endpoint addresses can change the expected checksum. This associates the data with its network context and helps detect some misdelivery or corruption. It does not encrypt data using IP addresses.

The pseudo-header does not include the complete IPv4 header. TTL, for example, is absent from the context listed here. A network device that legitimately changes relevant addresses or ports must handle the affected checksums accordingly. Such processed modifications differ from the damage example below, which deliberately retains the old checksum.

Return the carry before taking the complement

Pair adjacent bytes into 16-bit words, add them using one’s-complement arithmetic, then complement every result bit to obtain the 16-bit checksum. A key difference from truncated ordinary addition is that a carry beyond 16 bits returns to the low end instead of being discarded. For an odd payload length, append a zero byte for calculation only; that padding does not increase UDP length.

When generating the checksum, treat its header field as zero. During verification, include the transmitted checksum and sum the same range again. For a valid datagram using a checksum, the resulting one’s-complement sum is all ones: hexadecimal FFFF. A change that makes the result differ from FFFF provides grounds for rejecting the datagram.

Hexadecimal is simply compact byte notation; a field reader need not calculate every packet manually. The important requirements are matching coverage, byte pairing and carry rules. An ordinary byte sum that omits the pseudo-header can incorrectly reject a valid UDP packet in a home-built checking tool.

Complementing an example sum 8FE2 yields checksum 701D
Figure 2. The complete example has a ones-complement sum of 8FE2; complementing yields 701D. Functional overlay, not a silicon layout or measurement; input words are listed in the text. Original FCTELE illustration with AI assistance.

A reproducible hypothetical datagram

Use source address 192.0.2.1, destination 192.0.2.2, source port 1000, destination port 2000 and two payload bytes 00 01. These documentation addresses are not field-configuration recommendations. UDP length is ten bytes: eight header bytes plus two payload bytes. This teaching example has no IP options, fragmentation or UDP extension options.

In network byte order the pseudo-header words are C000, 0201, C000, 0202, 0011 and 000A. Append UDP header words 03E8, 07D0, 000A and 0000, followed by payload word 0001. The 0011 word combines the zero byte and decimal protocol 17; 0000 is the checksum field cleared for generation. UDP length appears in both the pseudo-header and UDP header intentionally, serving its role in each.

One’s-complement addition with end-around carry gives 8FE2. Complementing the bits gives 701D, which the sender writes into the UDP checksum field. A receiver with the same context and content obtains FFFF. The figures’ values apply only to this complete hypothetical datagram, not a capture or a device performance measurement.

Now change only the payload from 00 01 to 00 02, retaining all other fields and checksum 701D. The verification sum becomes 0001 rather than FFFF. This single-word change demonstrates the error-detection path. It does not prove that every possible error is detectable: a 16-bit checksum has collisions, and some multiple changes can cancel.

Receiver verification compares intact and deliberately changed test datagrams
Figure 3. With 701D retained, changing payload 0001 to 0002 changes the verification sum from FFFF to 0001. Two rows represent separate test cases, not a requirement for two physical ports. Original FCTELE illustration with AI assistance.

A valid checksum does not establish fresh, reliable data

UDP checking does not guarantee delivery or automatically provide retransmission, duplicate suppression or ordering. An intact duplicate can pass. A cached reading from yesterday can be resent with a perfectly correct checksum. Applications still need business-specific sequence numbers, time information, validity states, timeouts and execution confirmation.

For periodic acquisition, check which point a reading represents, its sample sequence and whether it exceeds its permitted age. Commands also require consideration of duplicate execution and outcome confirmation. Passing the checksum does not establish device health, fresh information or successful command execution. These conclusions require different evidence.

Nor is the checksum an identity check or tamper-resistant signature. A party able to modify content may also generate a matching checksum. Trusted origin and resistance to malicious modification require planned authentication, encryption and access controls. A UDP checksum field does not turn an ordinary acquisition path into a secure channel.

Separate zero values, IPv6 and observation points

In traditional IPv4 UDP, an all-zero transmitted checksum field means no checksum was generated. If computation produces zero, transmit all ones to avoid that ambiguity. Do not apply this rule directly to ordinary IPv6 UDP: IPv6 has different checksum requirements and a different pseudo-header. Specific tunnel exceptions are outside this article’s scope.

Distinguish a local capture on the sending host from the packet actually sent on the wire. NIC checksum offload can make a local capture appear to contain an unfilled or mismatching checksum. Check tool documentation, offload settings and a remote or independent observation point before diagnosing actual corrupted packets. One red warning is insufficient reason to change a production configuration.

For acceptance, preserve a known payload and endpoint configuration, check UDP length and byte order, then recompute using a pseudo-header-aware tool. Perform deliberate-corruption comparisons only on a controlled bench. Separately verify loss, duplication, timeouts and application recovery. This establishes checksum coverage without confusing end-to-end error detection, Ethernet FCS and application reliability.

Ethernet FCS checks the current Ethernet frame. Across multiple links, a transfer cannot simply be treated as one unchanged frame travelling from beginning to end: network-layer forwarding may build a new Layer 2 frame for the next segment. UDP checks the complete UDP portion with the appropriate endpoint context. The place that detects an error is not necessarily where it arose. Interpret switch-port counters, endpoint captures and application records at their respective layers.

If IPv4 fragmentation occurs, UDP coverage still concerns the complete UDP datagram. Do not treat the local bytes in every fragment as an independent UDP datagram. Receiving the complete relevant content is necessary; a missing fragment introduces another problem. This example deliberately avoids fragmentation so every word can be checked. Observation methods for longer field packets must follow their actual encapsulation conditions.

Preserve original bytes, endpoint addresses, ports, UDP length, capture direction and offload state with a checking result. A screenshot saying only “correct” makes it difficult to reproduce whether coverage was complete. Reproducible evidence includes both the computed value and its input conditions, rather than one isolated checksum number.

Sources and scope

RFC768 — UDP · RFC1071 — Internet checksum · RFC8200 — IPv6 · Feichang serial-server reference (Chinese)

The example concerns ordinary IPv4 UDP without UDP extension options. IPv6 rules and special tunnel exceptions cannot be inferred from it. Verify product modes in model-specific documentation.

Translated from the Chinese technical article: Read the original Chinese article.

Common questions

Is the pseudo-header transmitted as an extra header?

No. Endpoints reconstruct calculation inputs from IP context. It participates with the UDP header and payload rather than adding another UDP wire header.

Does a valid UDP checksum establish fresh data?

No. Duplicate or old data can have a correct checksum. Applications need sample sequence, time and validity checks.

Can IPv4 zero-checksum rules be applied directly to IPv6?

No. Ordinary IPv6 UDP has different requirements and a different pseudo-header. This example covers ordinary IPv4; tunnel exceptions require separate review.

Further reading

Ethernet CRC and FCS · Modbus TCP and RTU framing

Share this article