From 854cb4d76e1b207f77621d1a2351091f6a40f51f Mon Sep 17 00:00:00 2001 From: Joseph <162703152+josephnef@users.noreply.github.com> Date: Sat, 14 Nov 2026 12:27:40 +0300 Subject: [PATCH] cell M6: a handover arrival placed on a position a staged schedule gives another UE (#566) The 'not reproduced' m6_daps_dl run (arrival DL ~111 us late, 13 uplinks lost) was a race: the CU's coordination schedule moved the target's own UE onto the position the CU then gave the arrival (from a report that predated the schedule), and the target's free-position check read a map snapshot refreshed once per pass. 13 % of handover commands on the rig were refused for it (the race caught); 14 DU logs show it missed. CU: no handover while either DU has a schedule pushed and not applied; the target id/position chosen against its own last schedule too. DU: a staged schedule's positions are taken; the check's view of the map refreshed at the commit. Rig after: 25 runs, 29 commands, 0 refused, no shared position. Co-Authored-By: Claude Opus 5.5 (1M context) --- docs/cell-m6.md | 30 ++++++++++++++++++++++++++++++ examples/cell/main.cpp | 10 ++++++++++ src/cell/F1.h | 3 +++ tools/ran-controller/main.cpp | 16 ++++++++++++++-- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/docs/cell-m6.md b/docs/cell-m6.md index 8aba3614..d17c1c96 100644 --- a/docs/cell-m6.md +++ b/docs/cell-m6.md @@ -1948,6 +1948,36 @@ replay checks caught it in the signed-list run: UE2 reported cell 1 in only - only a gap that ran consumes its suspend superframe; a failed one (late, the beacon would not stop) is left to that log. +**A handover arrival placed on a position a schedule was giving another +UE.** One `m6_daps_dl` run showed the target's DL to the arriving UE +~111 µs late (2–3 µs elsewhere) and 13 uplinks lost; it was recorded as not +reproduced. It was a race, and a frequent one. +- **What happened:** the CU's coordination schedule moved the target's own + UE from position 1 to 2. Before that schedule was on air, the CU issued + the handover with target position 2, taken free from the target's report + (which predated the schedule). +- **Why the target accepted it:** its free-position check read a snapshot + of the map that was refreshed once per main-loop pass, not at the commit. + Both UEs then sat on position 2: the arrival's DL frame queued behind the + other's in one slot (~110 µs, one frame's airtime), and their uplinks + collided. +- **How often:** in the saved rig logs, 201 of 1550 handover commands (13 %) + were refused by the target as `invalid`. That was the same race, caught + when the target's view was fresh, and the CU retried. 41–53 % of the + same-channel A3 handover runs had one, and 14 DU logs show the race + missed (two UEs on one position). Cross-channel runs never had it: the + coordination moves only co-channel positions. +- **The fix:** + - The CU holds a handover while either DU has a schedule pushed and not + yet applied (the reverse of the schedule's own in-flight guard). + - It chooses the target's id and position against its own last schedule + for that DU as well as the report. + - The DU counts a staged schedule's positions as taken. + - The DU refreshes its handover check's view of the map at the commit. +- **Rig, after:** 25 runs (`m6_handover.sh` 6 normal + 3 fault, + `m6_daps_dl.sh` all 16), 29 commands: 0 refused, no position shared, + the arrival's DL 2–3 µs late (p50) in every run. + **First attempts at execution, in order:** 1. The source's stale reports re-triggered the A3 for the UE that had just left, which issued a duplicate command. The CU now retires the old key. diff --git a/examples/cell/main.cpp b/examples/cell/main.cpp index de403fb6..d9c95270 100644 --- a/examples/cell/main.cpp +++ b/examples/cell/main.cpp @@ -2124,7 +2124,12 @@ int run_du(IRadio *dev, const Cfg &c) { last_ho_seq = cmd.seq; } net_now = f1_view.net_sf; + /* Taken: the map on air and a schedule staged to replace it (an + * arrival placed on a position the next schedule gives another UE + * collides with it from that instant: shared DL and UL slots). */ live = f1_view.ues; + if (const auto &sg = stager.staged()) + live.insert(live.end(), sg->ues.begin(), sg->ues.end()); again = (cmd.target == c.cell && ho_in.count(cmd.target_ue) && ho_in[cmd.target_ue].id == cmd.id) || (cmd.source == c.cell && ho_out.count(cmd.ue) && ho_out[cmd.ue].id == cmd.id); @@ -3110,6 +3115,11 @@ int run_du(IRadio *dev, const Cfg &c) { ta_report.clear(); for (const Grant &g : map.grants) ta_report[g.ue] = g.ta_us; + /* The positions the F1 thread checks a handover against: the map + * just committed, at once (not at the next pass). */ + f1_view.ues.clear(); + for (const Grant &g : map.grants) + f1_view.ues.push_back({g.ue, position_of(g)}); } if (f1_eff) { std::lock_guard lk(f1_mu); diff --git a/src/cell/F1.h b/src/cell/F1.h index 13caad85..e2f85ea9 100644 --- a/src/cell/F1.h +++ b/src/cell/F1.h @@ -1028,6 +1028,9 @@ class Stager { } uint32_t applied_version() const { return applied_ ? applied_->version : 0; } uint32_t staged_version() const { return staged_ ? staged_->version : 0; } + /* The staged schedule (not yet on air): its positions are already taken + * for anything else this DU is asked to place (a handover arrival). */ + const std::optional &staged() const { return staged_; } const std::optional &applied() const { return applied_; } private: diff --git a/tools/ran-controller/main.cpp b/tools/ran-controller/main.cpp index 889cea58..c895ab3f 100644 --- a/tools/ran-controller/main.cpp +++ b/tools/ran-controller/main.cpp @@ -1113,16 +1113,28 @@ int main() { for (const auto &fl : flights) busy = busy || fl.second.cmd.target == *act || fl.second.cmd.source == *act || fl.second.cmd.target == cell || fl.second.cmd.source == cell; + /* Nor while either DU has a schedule pushed and not yet applied: + * the positions in its report are about to change (the reverse + * of the schedule's own in-flight guard). */ + for (const uint16_t x : {cell, *act}) + if (auto xd = dus.find(x); xd != dus.end() && xd->second.sched && !xd->second.sched_refused && + xd->second.rep.applied_version < xd->second.sched->version) + busy = true; auto tit = dus.find(*act); /* The target's report must be current: its capacity, channel and * clock are what the command is built from. */ const bool tgt_fresh = tit != dus.end() && now - tit->second.at < std::chrono::seconds(3); if (!busy && tgt_fresh && tit->second.rep.net_sf > 0 && dit->second.rep.net_sf > 0) { const f1::Report &sr = dit->second.rep, &tr = tit->second.rep; + /* Taken at the target: what it reports, and what this CU last + * scheduled it (its report may predate that schedule). */ + std::vector taken = tr.ues; + if (tit->second.sched) + taken.insert(taken.end(), tit->second.sched->ues.begin(), tit->second.sched->ues.end()); uint16_t tue = 0; for (uint16_t u = 1; u <= tr.positions.size() && !tue; ++u) { bool used = false; - for (const auto &a : tr.ues) + for (const auto &a : taken) used = used || a.ue == u; if (!used) tue = u; @@ -1130,7 +1142,7 @@ int main() { uint8_t tpos = 0; for (uint8_t p = 1; p <= tr.positions.size() && !tpos; ++p) { bool used = false; - for (const auto &a : tr.ues) + for (const auto &a : taken) used = used || a.pos == p; if (!used) tpos = p;