feat: hold a packet that runs ahead of the sequence, and deliver a late one flagged

This commit is contained in:
Martino Ferrari committed 2026-10-08 17:34:26 +02:00
1 parent 57e2f6aa8b
commit 6e79a67252
2 files changed
+276 -29

No files matched your search

+26
View File
@@ -150,6 +150,13 @@ typedef struct {
* range the next frame claims.
*/
uint32_t lost;
/**
* 1 when this frame's counter is behind the sequence already delivered: it lost
* the race past the reorder window and the consumer has a hole where it belongs.
* @c lost is 0 for such a frame -- it is not missing anything, it *is* what was
* missing -- so a consumer sizes its backfill from @c counter, not from @c lost.
*/
uint8_t late;
uint64_t hrt; /**< Producer's high-resolution timer at send. */
double recv_time; /**< Wall-clock seconds (CLOCK_REALTIME) at arrival. */
uint8_t publish_mode; /**< UDPS_PUBLISH_*. */
@@ -180,6 +187,17 @@ typedef struct {
* time base older than data already handed over.
*/
uint64_t stale_packets;
/**
* DATA packets that arrived out of order and were put *back* in order inside
* the reorder window, so the consumer never saw a gap for them.
*/
uint64_t late_resequenced;
/**
* DATA packets delivered behind the sequence because the reorder window had
* already closed on them. The consumer has a hole for these and may fill it;
* before the window existed they were counted in @c stale_packets and dropped.
*/
uint64_t late_delivered;
uint64_t reconnects;
} udps_stats_t;
@@ -226,6 +244,14 @@ typedef struct {
double keepalive_interval_s;/**< Unicast ACK period. 0 disables. */
uint32_t recv_buffer_bytes; /**< SO_RCVBUF; large bursts need a large value. */
uint32_t max_packet_bytes; /**< Ceiling on one reassembled payload. */
/**
* How long a packet may be held waiting for an earlier counter, in seconds.
*
* A *contiguous* arrival is never held, so this is the latency a gap costs and
* not a latency the stream pays. 0 disables resequencing entirely and restores
* the drop-on-late behaviour. Default 0.020.
*/
double reorder_window_s;
} udps_client_config_t;
/** Fills @p cfg with the defaults documented in Docs/UDPS-C-Client.md. */