Skip to content

fix(transport): optionally accept reordered best-effort frames - #2701

Open
samconsidine wants to merge 1 commit into
eclipse-zenoh:mainfrom
samconsidine:fix/unordered-sequence-window
Open

fix(transport): optionally accept reordered best-effort frames#2701
samconsidine wants to merge 1 commit into
eclipse-zenoh:mainfrom
samconsidine:fix/unordered-sequence-window

Conversation

@samconsidine

@samconsidine samconsidine commented Jul 23, 2026

Copy link
Copy Markdown

Description

What does this PR do?

Adds an optional receive-side sequence-number window for unfragmented BestEffort Frames arriving over non-streamed links.

When transport.link.rx.best_effort_reorder_window is non-zero, Zenoh keeps a bounded bitmap of recently observed sequence numbers. A reordered Frame inside the window is delivered once, while duplicates and Frames older than the window are dropped. Frames are delivered immediately; this does not buffer packets or restore their original delivery order.

The default is 0, which preserves the existing strict monotonic validation. Reliable Frames, streamed links, multicast, and fragments retain their existing behavior.

Example:

{
  transport: {
    link: {
      rx: {
        best_effort_reorder_window: 1024,
      },
    },
  },
}

Why is this change needed?

Unordered transports such as QUIC DATAGRAM can deliver valid Frames out of sequence. The current receive path advances its sequence-number high-water mark when a later Frame arrives, then treats subsequently arriving earlier Frames as invalid. Forward batching or other network-induced reordering can therefore be amplified into substantial application-visible loss even when the packets reach the receiver.

In a controlled A/B reproduction using the same sender workload and network profile:

Mode Sent Received Application loss Invalid SN RX qdisc drops
Strict/default 21,871 9,509 56.5% 10,024 0
Window = 1024 21,871 21,871 0% 0 0

With the window enabled, 9,603 late reordered Frames were accepted. The maximum observed reorder distance was 29 sequence numbers (mean 16.05).

The implementation also handles sequence-number rollover and suppresses duplicate delivery. Reordered fragments are deliberately excluded because the current defragmenter tracks a single sequential message.

Validation

  • cargo test -p zenoh-config test_best_effort_reorder_window_config --lib
  • cargo test -p zenoh-transport common::seq_num::tests --lib
  • cargo test -p zenoh-transport --lib (30 passed, 1 ignored)
  • cargo clippy -p zenoh-config -p zenoh-transport --lib -- -D warnings

The full local zenoh-config test suite has one unrelated existing failure: the TOML-format test runs although that local feature set reports only JSON, JSON5, and YAML support. The new configuration test passes both independently and within that suite.

Related Issues

No matching existing issue was found.


🏷️ Label-Based Checklist

Based on the labels applied to this PR, please complete these additional requirements:

Labels: enhancement

✨ Enhancement Requirements

Since this PR enhances existing functionality:

  • Enhancement scope documented - Clear description of what is being improved
  • Minimum necessary code - Implementation is as simple as possible, doesn't overcomplicate the system
  • Backwards compatible - Existing code/APIs still work unchanged
  • No new APIs added - Only improving existing functionality
  • Tests updated - Existing tests pass, new test cases added if needed
  • Performance improvement measured - If applicable, before/after metrics provided
  • Documentation updated - Existing docs updated to reflect improvements
  • User impact documented - How users benefit from this enhancement

Remember: Enhancements should not introduce new APIs or breaking changes.

Instructions:

  1. Check off items as you complete them (change - [ ] to - [x])
  2. The PR checklist CI will verify these are completed

This checklist updates automatically when labels change, but preserves your checked boxes.

Signed-off-by: Sam Considine <sambconsidine@gmail.com>
@diogomatsubara diogomatsubara added the enhancement Existing things could work better label Jul 24, 2026
@diogomatsubara

Copy link
Copy Markdown
Contributor

@samconsidine Please, sign the Eclipse Contributor Agreement so we're able to consider this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Existing things could work better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants