Put bytes on the wire deliberately
The RTP transmitter encodes its 12-byte fixed header with shifts and masks rather than sending a C++ struct. This makes packet layout independent of host padding, bitfield allocation, and endianness. Each datagram carries up to 1400 binary payload bytes; timestamps and pacing simulate media timing rather than a codec-specific playback pipeline.
Treat each received datagram as untrusted input
The receiver uses recvmsg to detect truncation before parsing RTP. The shared parser checks the version, configured payload type, CSRC lengths, extension lengths, and padding. A valid fixed header does not by itself establish that the rest of the packet fits inside the received buffer.
Choose a policy for gaps
The receiver writes contiguous payload immediately and retains future packets in a 64-packet reorder window. A missing sequence is skipped after 500 ms. A packet beyond the configured window clears pending data and resynchronizes the receiver. These limits bound memory and waiting, while accepting that discarded bytes cannot be recovered without an additional reliability mechanism.
Observe the network separately
The libpcap analyzer watches traffic independently of the sender and receiver. It reports sequence-gap loss estimates, payload throughput, and interarrival jitter. Duplicate arrivals and mixed SSRCs can distort its simple single-stream model; offline throughput reflects replay processing speed. The documented loss-free loopback comparison demonstrates that run’s byte integrity, not a general UDP delivery guarantee.
Implementation reference
This note explains the documented architecture and separates suggested evaluations from measured results.
Custom RTP/UDP Video Streaming Server & Packet Analyzer — source repository ↗