Skip to content

cell M6: a handover arrival's DL — the UE's DL status report - #562

Merged
josephnef merged 1 commit into
masterfrom
feat/m6-arrival-harq
Nov 12, 2026
Merged

josephnef merged 1 commit into
masterfrom
feat/m6-arrival-harq

Conversation

@josephnef

Copy link
Copy Markdown
Collaborator

Part of #260 (M6, "shared sequence handling … and state cleanup during handover"), epic #254. Follows #561.

The crossing's return switch (same channel) had 392 ms of DL gap where a plain same-channel switch had 112 ms. The UE's first frames from the target were HARQ retransmissions (attempts 2–3) of PDUs it already had: the target airs to an arriving UE from the handover's effective superframe, but the UE switches 2–200 ms after that instant, and a due retransmission goes before new data.

Pre-arrival HARQ (src/cell/Harq.h, examples/cell)

  • Until the target hears the arriving UE, every DL frame to it is a new one. Frames aired before it switched are given up (HarqSender::abandon_all, seqs never reused) and their PDUs go back in the queue.
  • At the UE's first uplink (cell.ho.arrival_heard) its HARQ feedback is applied first, so a frame it caught is ACKed, and the rest are given up.

DL status report (protocol v5)

  • The UE's uplink beacon carries its DL stream status: the stream, the newest sn delivered, and which of the 32 below it are pending (DlStreamRx::status, UeDlStatus, under the cell and area tags). This is 3GPP's PDCP status report.
  • The target prunes its queue by it (prune_dl_queue, cell.dl.status_prune): every sn the UE has goes, and so does anything older than the reorder window. It learns the status from the UE's own uplinks, and before the switch from the UE's beacons to its source, heard on one channel or as a visit copy across channels (area tag).
  • Without this the target can't know what the source delivered. Two attempts on the rig failed. Guessing it with an offered mark made the plain switch worse (214–317 ms). Abandoning only at the first uplink left the return switch at 183–187 ms, because in the arrival superframe the DL slot comes before the UE's first uplink.

Rig (testrig m6_daps_dl.sh, DL gap across each switch, DAPS):

case (runs) before now
plain, same channel (3) 112, 112, 112 112, 112, 112
crossing: the switch there (2) 111, 214 111, 112
crossing: the return switch (2) 392, 392 84, 94
source killed (3) 1444–1648 1349–1750
crossing, longest DL silence (2) 392, 1031 213, 316
  • In every DAPS run the first target frame was a first attempt carrying new PDUs. Killed source: it carried the 13–18 PDUs the UE lacked; the gap is the dead source's time.
  • 0 DL / 0 UL lost with DAPS.
  • Pruning came mostly from the source-identity beacons before the switch (12–39 per run).

m6_daps_xch: 122–123 ms, 166 where the source had the newest PDU; visit copies pruned the target 122 times. Full M6 regression passes: measgap, three_ho, crossing3, handover, daps, daps_dl, crossing.

🤖 Generated with Claude Code

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Reduce handover DL gaps with UE status and pre-arrival HARQ cleanup

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add UE DL status to protocol v5 beacons so targets can avoid sending already-delivered PDUs.
• Abandon pre-arrival HARQ frames and requeue their PDUs, prioritizing new data after handover.
• Add regression coverage and document improved DAPS handover gaps.
Diagram

graph TD
  RX["UE DL receiver"] --> ST["Status beacon"] --> SRC["Source identity"] --> DU["Target DU"] --> Q["DL queue"] --> HARQ["HARQ sender"] --> AIR["DL frames"]
  ST -->|own uplink| DU
  DU -->|arrival state| HARQ
  HARQ -->|requeue abandoned PDUs| Q
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Transfer source DL delivery state through the CU
  • ➕ Could avoid relying on the target hearing pre-switch UE beacons.
  • ➖ Would require coordinating delivery state across the source, CU, and target.
  • ➖ Transferred state could become stale while the source continues transmitting.

Recommendation: Use the UE-reported status: it reflects what the UE actually received while the source remains active. Pairing it with pre-arrival HARQ abandonment addresses both redundant queued PDUs and retransmissions that would otherwise take precedence over new data.

Files changed (7) +287 / -12

Enhancement (3) +88 / -4
cell.hEncode UE DL status in protocol v5 beacons +53/-4

Encode UE DL status in protocol v5 beacons

• Adds an optional, tagged DL stream status to UE beacon construction and parsing. Introduces queue pruning based on delivered, missing, and out-of-window sequence numbers.

examples/cell/cell.h

Handover.hExpose the UE receiver's DL reorder status +19/-0

Expose the UE receiver's DL reorder status

• Adds a status snapshot containing the stream epoch, newest delivered sequence number, and a bitmap of pending sequence numbers within the reorder window.

src/cell/Handover.h

Harq.hSupport abandoning all in-flight HARQ frames +16/-0

Support abandoning all in-flight HARQ frames

• Adds an operation that returns outstanding frame sequences, clears them without reusing sequence numbers, and counts abandoned frames.

src/cell/Harq.h

Bug fix (1) +102 / -4
main.cppPrune target DL queues and retire pre-arrival HARQ frames +102/-4

Prune target DL queues and retire pre-arrival HARQ frames

• Publishes UE receive status, applies it at the target from own uplinks and pre-switch source-identity beacons, and tracks staged arrival identities. Abandons unheard HARQ frames before scheduling further DL and after applying first-uplink feedback, requeues their PDUs, and adds arrival and pruning telemetry.

examples/cell/main.cpp

Tests (2) +43 / -4
cell_m2_selftest.cppTest HARQ abandonment after partial feedback +15/-0

Test HARQ abandonment after partial feedback

• Verifies that acknowledged frames are excluded, outstanding frames are abandoned, and the next transmission is new with a continuing sequence number.

tests/cell_m2_selftest.cpp

cell_node_selftest.cppTest beacon status and target queue pruning +28/-4

Test beacon status and target queue pruning

• Covers optional DL status encoding and decoding, adjusts beacon offset checks for protocol v5, and verifies that pruning retains missing and newer PDUs while removing delivered or settled ones.

tests/cell_node_selftest.cpp

Documentation (1) +54 / -0
cell-m6.mdDocument arrival behavior and DAPS rig results +54/-0

Document arrival behavior and DAPS rig results

• Explains why pre-switch target transmissions caused retransmissions after arrival, describes the status-report and abandonment strategy, and records before-and-after DL gap measurements.

docs/cell-m6.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. New arrivals can lose earlier downlinks 🐞 Bug ≡ Correctness
Description
DlStreamRx::status() reports no missing sequence numbers below the first PDU the UE receives, and
prune_dl_queue() treats those unreported numbers as delivered. If the first received PDU is 120
while the target still holds an undelivered PDU 119, the target erases 119 from its queue when it
processes the status beacon.
Code

examples/cell/cell.h[R439-440]

+      const uint32_t d = s.top - sn;
+      keep = d >= 1 && d <= window && ((s.missing >> (d - 1)) & 1u);
Evidence
The first accept() sets top_ without adding preceding numbers to missing_; only subsequent
forward jumps create missing entries. The new status serializes that list, and the new pruning loop
erases every number at or below top unless its missing bit is set. The target applies this
operation to its independently populated downlink queue on source-identity and own-identity beacons.

src/cell/Handover.h[298-316]
src/cell/Handover.h[331-340]
examples/cell/cell.h[433-446]
examples/cell/main.cpp[1848-1861]
examples/cell/main.cpp[1559-1561]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The UE cannot attest to delivery of sequence numbers preceding its first received PDU, but queue pruning currently discards them.
## Fix Focus Areas
- src/cell/Handover.h[298-316]
- src/cell/Handover.h[331-340]
- examples/cell/cell.h[433-446]
## Recommended Fix
Represent the lower bound of sequence numbers whose delivery status the UE actually knows, and preserve earlier queued PDUs unless delivery or expiration can be established. Add a test where the first received PDU has an older, undelivered predecessor in the target queue.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Queued arrival data can be dropped 🐞 Bug ☼ Reliability
Description
arrival_abandon() reinserts unacknowledged PDUs at the queue head without applying the queue's
size limit. If the queue is already full, subsequent downlink arrivals repeatedly remove those
reinserted PDUs from the head before a suspended or delayed DL slot can transmit them.
Code

examples/cell/main.cpp[R1276-1277]

+      sq.insert(sq.begin(), add.begin(), add.end());
+      requeued = add.size();
Evidence
The new insertion does not cap sq, whereas the F1 handler checks only after appending one new PDU
and removes exactly one entry from the front. Once reinsertion takes a full queue above 64, each
subsequent F1 arrival can therefore remove a reinserted entry; those entries came from abandoned
HARQ frames whose PDUs may not have reached the UE.

examples/cell/main.cpp[1257-1277]
examples/cell/main.cpp[1228-1232]
examples/cell/main.cpp[1848-1861]
examples/cell/main.cpp[1871-1876]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Reinserting abandoned PDUs can leave the queue above its 64-entry limit; later F1 arrivals evict its unacknowledged head entries.
## Fix Focus Areas
- examples/cell/main.cpp[1268-1277]
- examples/cell/main.cpp[1871-1876]
## Recommended Fix
Account for the queue limit when reinserting abandoned PDUs, and ensure overflow handling does not evict unacknowledged requeued entries before they can be sent. Test a full queue with reinserted PDUs and subsequent F1 arrivals before the next DL slot.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Handover target discards PDUs the UE could still recover ✓ Resolved
Description
prune_dl_queue drops every queued sn more than window (32) behind the reported top, and
DlStreamRx::status only encodes holes up to 32 back. But DlStreamRx::confirm keeps a whole
missing run pending as long as the run's *last* sn is within kReorder of top, so the earlier part of
the run can sit 33+ back while still pending. When a gap of that kind straddles the 32-sn boundary
at the switch (for example a long source outage followed by a few new PDUs), the target deletes PDUs
the UE would have taken as late copies, and they end up counted as lost instead of recovered.


Informational

4. A doc comment sits above the wrong lambda 🐞 Bug ⚙ Maintainability
Description
The comment that describes arrival_abandon ("A handover arrival's DL frames in flight given up …
Returns (frames given up, PDUs re-queued)") sits directly above the status_prune comment and
lambda instead of above arrival_abandon. Someone reading status_prune sees two stacked
contracts, and the first one, about return values and re-queuing, does not apply to it.
Code

examples/cell/main.cpp[R1234-1243]

+  /* A handover arrival's DL frames in flight given up (mu held): aired
+   * before the UE switched (it switches up to ~2 superframes after the
+   * instant), their retransmissions would go before any new data. Their
+   * PDUs go back to the head of the queue; the UE's DL status (its beacons)
+   * then prunes what it has (status_prune). Returns (frames given up, PDUs
+   * re-queued). */
+  /* A UE's DL status against its queue here (mu held): what it has goes.
+   * Logged when anything went. `via`: its own uplink, or its source-identity
+   * beacon heard before the switch. */
+  auto status_prune = [&](uint16_t ue, const UeDlStatus &st, const char *via) {
Evidence
Lines 1234-1239 describe abandoning frames and a pair return value. They are followed straight away
by the status_prune comment (1240-1242) and the lambda (1243). arrival_abandon starts at 1257 with
no comment of its own.

examples/cell/main.cpp[1234-1258]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The arrival_abandon doc comment is placed above status_prune.
## Fix Focus Areas
- examples/cell/main.cpp[1234-1258]
## Recommended Fix
Move the comment block at lines 1234-1239 so it sits directly above `auto arrival_abandon = ...`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can open the rule or relationship behind a finding in one click

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…ival HARQ given up

- The UE beacon (protocol v5) carries its DL stream status: the stream, the
  newest sn delivered, which of the 32 below it are pending
  (DlStreamRx::status, UeDlStatus) — 3GPP's PDCP status report.
- A handover target prunes its queue for the UE by that status
  (prune_dl_queue, cell.dl.status_prune): from the UE's own uplinks, and
  before the switch from its beacons to the source (heard on one channel, or
  as a visit copy across channels; area tag).
- Until the target hears an arriving UE every frame to it is new: frames aired
  before it switched are given up (HarqSender::abandon_all, seqs never
  reused), their PDUs back in the queue; at its first uplink its feedback is
  applied first (cell.ho.arrival_heard).
- cell.dl.pdu_in also for staged and arriving queues.

Rig (m6_daps_dl): the crossing's return switch 84/94 ms (392/392 before),
plain same-channel switch 112 ms x3, first target frame new in every DAPS
run, 0 DL / 0 UL lost with DAPS. Full M6 regression passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@josephnef
josephnef force-pushed the feat/m6-arrival-harq branch from 16d3e5e to 2107483 Compare November 12, 2026 08:41
@josephnef

Copy link
Copy Markdown
Collaborator Author

Review fixes pushed:

  1. Predecessors of the first PDU — fixed. The status now carries floor, the first sn the UE tracked in this stream. prune_dl_queue keeps everything below it, since the UE can't vouch for it. Test: tracked from 100, with 95..99 in the queue → kept.
  2. Requeue past the bound — fixed. Giving PDUs back is now a pure helper, requeue_dl: once each, oldest first. A full queue drops the oldest, counted in dropped and logged as cell.dl.requeue_overflow, the same policy as an F1 arrival. It's a bounded buffer, so something must go; with the status pruning the queue holds only what the UE lacks. On the rig: 0 overflows in 16 runs. Test: a capped requeue.
  3. Pending runs past the bitmap — fixed. The status also carries low, the oldest still-pending sn; a run stays pending until its last sn leaves the window. Outside the bitmap, the target drops only what is tracked and older than low (settled), and keeps the rest. Test: 102..139 pending behind top 140 → 102..107 kept.
  4. Comment above the wrong lambda — moved.

The UE body is 8 bytes longer (still protocol v5, not released). Rig on the fixed build: m6_daps_dl passes. The crossing's return switch is 85/85 ms, the plain switch 111–112 ms, and nothing is lost with DAPS. m6_daps_xch passes at 122–123 ms, or 166 where the source had the newest PDU.

@josephnef

Copy link
Copy Markdown
Collaborator Author

Qodo's re-review marks #3 resolved. Findings 1, 2 and 4 are still listed, but the text quotes the pre-fix code; the pushed head (2107483) has the fixes:

  • 1: prune_dl_queue keeps every sn below the UE's tracked floor (examples/cell/cell.h:444). Test: tracked from 100, queue 95..99 → kept.
  • 4: the arrival_abandon comment sits directly above arrival_abandon (main.cpp:1251-1257), not above status_prune.
  • 2: the reinsertion applies the bound (requeue_dl, cell.h:466). What remains by design: a later F1 arrival into a full queue drops the oldest, requeued ones included. That's the queue's bounded-buffer policy, and only 64 PDUs the UE still lacks (~6.4 s of a UE that cannot be reached) fill it, because the status pruning removes everything else. 0 overflows in 16 rig runs.

Adding skip-qodo-gate.

@josephnef josephnef added the skip-qodo-gate Bypass the Qodo review gate (outage / maintainer decision) label Nov 12, 2026
@josephnef
josephnef merged commit 0561dc0 into master Nov 12, 2026
30 of 31 checks passed
@josephnef
josephnef deleted the feat/m6-arrival-harq branch November 12, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-qodo-gate Bypass the Qodo review gate (outage / maintainer decision)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant