UDP / RECEIVE COMPLETENESS
Can a complete capture still produce a truncated application result?
Yes. In ordinary Linux UDP reception, a call that supplies less space than the datagram payload can obtain only its beginning; the remaining bytes are discarded. The next receive reads the next datagram, not that missing tail. Compare payload length, supplied capacity, interface status and stored bytes. Queue overflow and later parsing losses are separate mechanisms. The diagrams are conceptual examples, not measurements.
01 · Copy capacity
For an ordinary Linux UDP receive, capacity eight cannot store a twelve-byte payload. The remaining four bytes are discarded.
02 · Next datagram
Once truncated A is consumed, the next queued B is a separate datagram. B does not supply the missing tail of A.
03 · Controlled comparison
Change only the supplied receive capacity, then compare raw contents and truncation status. Larger capacity does not create more payload.
Match the payload
Compare UDP payload bytes, excluding network headers and capture truncation.
Log each call
Record capacity, return value, truncation indication and raw stored bytes.
Separate the layers
Distinguish per-call truncation, queue drops and application parsing.
Selection and verification checklist — expand
| Check | What to confirm | How to verify |
|---|---|---|
| Receive API | Platform-specific length and truncation semantics | Read the actual API documentation and log its status |
| Capacity | Space supplied for this receive call | Compare eight and sixteen with the same twelve-byte test payload |
| Datagram boundary | Next receive is independent B | Use distinct agreed payload markers and retain raw logs |
| Serial server | Ordered model, firmware and packetization | Match delivery documents and actual business framing |
A serial server sends data to a computer over UDP. The capture contains the complete payload, yet the application log shows only its beginning. Before blaming a switch for removing the tail, separate two observations: a datagram reaching the host and the application obtaining its whole payload. This article follows ordinary Linux UDP reception through the network interface, kernel queue and application copy. Return values and error reporting on other systems or through other APIs must be checked separately. All test data here are hypothetical, not product specifications or customer measurements.

Arrival at the host still leaves an application receive operation
UDP means User Datagram Protocol. Network endpoints exchange datagrams, while an application uses a receive interface to copy available data into its own memory. After the network interface receives an Ethernet frame, the host protocol stack performs further processing before delivering UDP data to the appropriate socket receive queue. A socket is the software endpoint where an application exchanges data with the network stack; it is not a physical connector on the computer.
When the application calls a receive API, it tells the system where to write and how many bytes this call may write. That length limits this particular copy. It differs from the network interface’s receiving capability, a serial device’s internal cache capacity and the capacity of the entire socket queue. Calling all of them a buffer without identifying the layer can send diagnosis in the wrong direction.
A capture tool records packets visible at its selected observation point. It helps establish which bytes were seen there. It does not directly prove how much space a business thread later supplied, how many bytes its receive call obtained or how it parsed those bytes. Pairing network evidence with application receive logs is what reveals the handoff between them.
Follow a twelve-byte payload through truncation
Suppose a test sender transmits datagram A with a twelve-byte UDP payload, represented in hexadecimal as 01 through 0C. This receive call supplies space for only eight bytes. Under ordinary Linux UDP receive semantics, the system can copy only the first eight bytes into that region. The remaining four do not become a tail that a later ordinary call can continue reading. This is datagram truncation at reception.
The comparison is between twelve bytes of UDP payload and eight bytes of application receive space. It is not a comparison with the Ethernet frame length or the UDP Length field, which includes the eight-byte UDP header. Comparing a capture’s frame length directly with the application’s byte count mixes link and network headers into the result. First compare the same object at both observation points.
How a receive call reports truncation also depends on its API and options. Linux recvmsg can report MSG_TRUNC in its output message flags. Specific input flags can also change the meaning of the returned length. A returned number alone therefore does not establish that the same number of bytes were copied. Never pass a length larger than the actual stored region to a parser for access.
Record the capacity supplied to the call, its return value, any available truncation flag and the bytes actually stored in the buffer. There is no single error-code rule in this article intended for every operating system. A Linux description must not silently become a Windows or framework-wide convention. A wrapper may translate the underlying status into an exception or a different group of result fields.

The next receive does not normally recover that tail
Continue the example with another independent datagram B queued after A, this time carrying four bytes. Once an ordinary receive has consumed and truncated A, the next receive encounters B, not A’s missing four bytes. Appending those four bytes to the first eight may create an apparently twelve-byte message assembled from two different datagrams.
This differs from TCP stream parsing, where applications often retain parser state across reads. A TCP read boundary is not a send boundary. UDP preserves datagram boundaries, but this does not mean multiple ordinary receives can automatically reconstruct a datagram already truncated by a previous receive. A TCP routine that reads again until a desired length is reached cannot simply be reused for this UDP case.
A and B in the illustration are labels for datagrams, not instrument commands. A serial business message may also be packed into network units according to a device’s actual rules. The application must know its business framing agreement. First obtain complete datagrams as required, then check the real protocol’s length, sequence, address and checksum. Business validation does not replace truncation detection at reception.
Small copy space and a growing queue require different fixes
Another easily confused condition occurs when each call has enough copy space but the business thread cannot keep up. Datagrams accumulate in the socket receive queue. If queue resources run out, subsequent datagrams may fail to enter it. That resembles whole datagrams not reaching the application, rather than a current datagram losing everything after its first eight bytes. Available statistics and the exact discard point depend on the platform and observations.
Increasing the socket receive queue does not automatically change an eight-byte length passed to each receive call. Increasing an application array does not automatically fix a thread that stops reading for long periods. Queueing and scheduling capacity are one concern; per-call storage and the agreed maximum datagram size are another. Identify the layer being changed before changing a buffer setting.
Path MTU, the maximum transmission unit along a network path, is a separate boundary. It affects IP transmission and possible fragmentation. If the same complete datagram has already been established at a suitable observation point on the destination host, a partial application result warrants examining host delivery next. Do not attribute every symptom to an oversized packet. Capture location, reassembly display and capture length still need checking first.

Use a controlled comparison to answer one question
In an authorized test environment, fix A’s payload at twelve bytes and retain its complete contents. Run the same receive path with eight-byte and sixteen-byte application capacities. With eight bytes, check the truncation indication. With sixteen, check that the application gets all twelve bytes, rather than expecting sixteen merely because that much space was supplied. Keep the raw contents for each comparison.
Send B separately and confirm that it remains a separate datagram. Log the source address and port, payload identifier, supplied capacity, interface status and parsing outcome. When tools do not share comparable clocks, do not subtract their timestamps and call the result an accurate delay. The test establishes the completeness of a handoff; it does not manufacture a product performance figure.
For closer content comparison, a test payload can have explicit start and end markers and an independent sequence number. Both test participants must agree on those markers; they are not genuine instrument commands. Distinguish the raw received length from the business length retained after parsing. If a program receives twelve bytes and later keeps only eight during text conversion, terminator handling or validation, that is a different processing boundary. Do not report it as socket truncation. In particular, a string terminator is not the received length of a binary payload.
Finally, check the actual product documentation. FCTEL’s FCT-1500 series documentation lists UDP among its network modes, providing a basis for checking a serial device’s network connection against the ordered configuration. UDP support does not prove that host software handles truncation correctly. Confirm interfaces, packetization and firmware behavior against delivery documents; receive capacity, API semantics and business parsing depend on the corresponding software implementation as well.
Sources and product documentation
Linux man-pages: udp(7) · Linux man-pages: recv(2), recvmsg and MSG_TRUNC · FCT-1500 industrial serial server (Chinese product documentation)
Translated from the Chinese technical article: Read the original Chinese article.
Common questions
Can a second receive complete twelve bytes when capacity is eight?
Not in this ordinary Linux UDP example. A’s excess four bytes are discarded. The next receive reads separate B; it cannot supply A’s missing tail.
Does increasing SO_RCVBUF prevent truncation?
Not necessarily. Socket queue capacity and the copy space supplied to each call are different. Check per-call capacity, queueing and interface status separately.
How do I distinguish receive truncation from later parsing loss?
Log the UDP payload, supplied capacity, receive status and actually stored bytes. If reception is complete but parsing retains only a portion, inspect that later processing boundary.
Further reading
TCP stream parsing for serial servers (Chinese) · UDP pseudo-header checksum (Chinese)


