Skip to content

Apply a dApp's PRB block in the gNB's scheduler - #17

Merged
aferaudo merged 7 commits into
mainfrom
feat/prb-block
Nov 11, 2026
Merged

aferaudo merged 7 commits into
mainfrom
feat/prb-block

Conversation

@aferaudo

@aferaudo aferaudo commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • PRB block (prb_block.enabled, off by default): a dApp's Spectrum SM PRB blacklist control (RAN function 1, control 1) now reaches ocudu's scheduler. The scheduler keeps every PDSCH and PUSCH allocation off those PRBs, in every slot, DL and UL, until the next control replaces the list, as OAI's gNB does, so the same dApp works with both gNBs. PUCCH, PDCCH, SSB, PRACH, SRS and CSI-RS keep their PRBs (docs/known-limitations.md).
  • The first RAN function 1 subscription loads the new prb_block codelet on ocudu's sched_prb_block hook, instead of the eCPRI IQ pipeline; the last one unloads it, which clears the block. PrbBlockRelay hands the newest block to the gNB from the main loop and ACKs it then, as OAI ACKs on install; the codelet reports the first scheduler slot that applies it. A PRB outside the carrier, a full queue or no codelet is a NACK.
  • Spectrum SM grammar: OAI's current e3sm_spectrum.asn (c2fc976521), plus the legacy Spectrum-IQDataIndication section, whose bytes do not change. Includes Send dApp reports to the xApps through the gNB's E2SM-DAPP #14's two Spectrum commits, now the same commits in both PRs (9ec5cae, b1ba0e9): whichever PR merges second only replays its own.
  • Closed-loop stage records with OAI's stage names, and tools/latrec_closed_loop.py, which joins the controller's and the dApp's rings (docs/stage-records.md).
  • Rebased onto main on 2026-11-09, after Publish only the uplink slots no UE transmits in, on the L1-KPM v2 grammar #16 merged. The only conflicts were in two lists, in src/e3sm/asn/CMakeLists.txt and docs/architecture.md.

Tested (x86 gNB with the ocudu PR, Foxconn RU, no UE; the adaptive_cpu dApp with its detector off, sending blocks of PRBs 100–149, then 150–199, then [], every 200 ms):

  • 2 runs × 300 blocks, with slot_filter.ue_free_only true and false: received = sent to the gNB = applied = 300, 0 NACKs, and the gNB logged 200 blocks and 100 clears with the same ids. Stopping the dApp unloaded the codelet, and the gNB cleared the block in force.

  • From the gNB's capture of the slot the dApp decided on to the first scheduler slot that applies the block, in µs, run 1 / run 2:

    Segment p50 p99 max
    gNB capture → dApp decision 146.5 / 145.4 194.7 / 208.3 316.3 / 539.2
    dApp encode + send 24.9 / 25.8 30.1 / 30.0 37.9 / 40.2
    dApp → controller 14.8 / 14.8 21.3 / 20.2 27.6 / 25.3
    controller decode (E3AP + E3SM) 29.1 / 29.2 35.7 / 35.7 65.8 / 62.5
    queue + hand-off to the gNB (jbpf) 1.4 / 1.5 5.8 / 5.6 77.7 / 193.2
    wait for the next scheduler slot 215.2 / 214.3 270.3 / 278.1 279.3 / 471.7
    Loop 431.9 / 431.0 479.9 / 489.6 487.8 / 931.0

    Run 2's two maxima are the first control and one slow dApp IQ read. The dApp gets its ACK 92.0 / 98.5 µs (p50) after sending. On air, DL is under the block 7 slots (3.5 ms) after the slot the dApp read (8 slots for 3 of run 2's blocks); UL 11 slots (5.5 ms) for about 90 % of the blocks and 19–20 slots for the rest, when the dApp read the second of the two UL slots (k2 = 4).

  • Each commit builds on its own (x86, latrec on) and passes test_l1_kpm_sm and test_spectrum_sm. New cases: a PRB list → the gNB's mask (word edges, a repeated PRB, [] = clear, PRBs past the mask), and OAI's controls 3 and 4 → unsupported. Codelets verified (prb_block within 645 instructions). CI builds the head with latrec off and on.

  • Not run: prb_block.enabled: false with a dApp, a UE with traffic under a block, an APER control from a dApp (test vectors only), arm64, OAI's gNB.

  • After the rebase, on x86 (Ubuntu 22.04, GCC 11.4, Release): the controller and the gNB of the rebased wineslab/ocudu-e3-private#8 build, the three codelets pass the verifier and are byte-identical to the committed objects, and test_l1_kpm_sm (59) and test_spectrum_sm (47) pass. The runs above were not repeated.

Type of change

  • Bug fix
  • New feature / enhancement
  • New Service Model
  • Refactor (no behavior change)
  • Documentation
  • Test / CI / packaging
  • Other (explain):

Linked issue

None.

Twin-repo coordination

  • This PR does not change the E3 wire protocol or public ABI, OR a paired PR exists in each affected twin repo (link below).

Paired PR(s): https://github.com/wineslab/ocudu-e3-private/pull/8 (the scheduler hook, same jbpf_e3_prb_block_api.h, byte-identical). The dApp needs no change: it already sends OAI's control.

🤖 Generated with Claude Code

Base automatically changed from feat/ul-ue-free-slots to main November 9, 2026 19:07
Two problems in how the SM types were generated, both hidden so far:

- asn1c generated BER and JER code for our types, while libe3's runtime
  is built without them. asn_config.h sets the layout of the type tables
  from that codec set, so our tables could be laid out differently from
  the runtime they link against. Generate with -no-gen-OER -no-gen-BER
  -no-gen-JER, like libe3.
- cleanup_asn1c.cmake runs with -P, where CMAKE_BINARY_DIR is the working
  directory (<build>/src/e3sm/asn), not the build root. It looked for a
  directory that does not exist and returned, so the whole asn1c runtime
  stayed next to our types, asn_config.h included, and could shadow
  libe3's. The directory is now passed in, and a missing one is an error.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
The dApp, the controller and the xApp all encode Spectrum types, and the
xApp decodes the dApp's reports with OAI's grammar. Ours was an older one.
e3sm_spectrum.asn is now the copy in wineslab/spear-flexric
(src/sm/dapp_sm/e3/service_models/spectrum_sm/asn/defs/e3sm_spectrum.asn),
unchanged, plus a marked section at the end with Spectrum-IQDataIndication,
which only the legacy eCPRI IQ path uses. Its bytes do not change.

- RAN function data goes out in the agent's encoding: APER, or in JSON
  the same fields as an object, as OAI's Spectrum SM sends it.
- A dApp control is Spectrum-DAppControlData in APER, or OAI's JSON
  envelope ({"controlType":"prbBlacklist","controlPayload":{...}}).
  Only control id 1 (PRB blacklist) is accepted; the other ids and payloads
  get a NACK. The blacklist is still only logged and acknowledged.
- Spectrum-SensingPolicyControl has a BOOLEAN and libe3 ships no BOOLEAN
  runtime, so asn1c's is compiled with libe3's codec set, only while
  libe3 has none.
- tests/test_spectrum_sm.cpp (E3C_BUILD_TESTS=ON): the legacy IQ
  indication against bytes from the previous grammar, APER controls
  against vectors encoded by hand, and the JSON controls the dApp builds.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
A spectrum-sharing dApp sends a Spectrum SM PRB blacklist control (RAN
function 1, control 1) with the PRBs where it detected an incumbent. OAI's
gNB keeps every data allocation off them, in every slot, UL and DL, until
the next control replaces the list. The controller only logged and
acknowledged it. With prb_block.enabled it now reaches ocudu's scheduler,
so the same dApp works with both gNBs.

- e3sm_spectrum.asn is OAI's current grammar (c2fc976521). It adds
  Spectrum-CellConfigIndication and two dApp control alternatives; the
  PRB blacklist control is unchanged and the legacy
  Spectrum-IQDataIndication section stays. Only control 1 is applied,
  the others still get a NACK.
- The first RAN function 1 subscription loads the prb_block codelet on
  ocudu's sched_prb_block hook, instead of the eCPRI IQ pipeline; the
  last one unloads it, which clears the block. A PRB index outside the
  radio's carrier, a full queue or a missing codelet is a NACK.
- PrbBlockRelay hands the newest queued block to the codelet from the
  main loop and ACKs it, superseded ones too, once it is in the gNB, as
  OAI ACKs on install. The codelet reports the first scheduler slot that
  applies each block.
- jbpf_e3_prb_block_api.h is a new shared header, byte-identical with
  ocudu's copy.
- Stage records for the closed loop, from the gNB's capture of the slot
  the dApp decided on to the scheduler slot that applies the block, with
  OAI's stage names; tools/latrec_closed_loop.py joins the controller's
  and the dApp's rings.
- prb_block.enabled defaults to false, which keeps today's behaviour.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
aferaudo and others added 4 commits November 11, 2026 17:26
Describe what this code does rather than what another gNB does. Where a
comparison carried information, keep the information: the ACK means the
block is in the RAN, and a block lasts until the next one replaces it.
Spell out the JSON form of the dApp control instead of calling it an
envelope.

jbpf_e3_prb_block_api.h is shared with ocudu, which changes its copy the
same way: the two copies must stay byte-identical.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
ocudu sends a Msg3 retransmission on the RBs of the first transmission
whenever no other channel uses them, so a block that starts in between
does not move it.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
libe3 0.2.5 deletes every SM inside agent.stop(), but main() still used
two of them afterwards: spectrum_ptr->stop(), so every Ctrl-C ended in a
segfault, and layer1_ptr->drops_summary(), a read of freed memory. Stop
the slot pipeline first, take the summary, then stop the agent; the
prb_block codelet is unloaded through main's own relay, which outlives
the SM.

With slot_filter.ue_free_only every UL slot a UE transmits in is a
ue_busy drop, so the per-second drop line printed for as long as a UE
was attached. The counters stay: the shutdown summary prints them by
reason, and logging.drops_log_path still writes one CSV row per second.

Fixes #19.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
@aferaudo
aferaudo merged commit 39b1a8c into main Nov 11, 2026
2 checks passed
@aferaudo
aferaudo deleted the feat/prb-block branch November 11, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant