Repository navigation
Runtime Control
FikoRE can be steered while it runs. A control plane accepts commands that change UE
parameters -priority, rate cap, SINR offset, position, speed, traffic target- and that
attach or detach UEs, both in fast mode (period: -1) and in real time (period: 1).
The same commands can come from a script on disk, from a socket, or from the REST API in
api/. There is no difference in behaviour between them: they all go through the same
code path.
Read this first if you are experimenting with priority. Under Round Robin (
metric_type: 5) the scheduler ignores priority altogether:phy_layer::get_metricderives to the round robin rotation before the priority is applied. Three of the shipped configs use RR. If you setpriorityand nothing changes, checkmetric_typebefore anything else. The emulator logs a warning the first time you do this.
Imperative, and the emulator is the source of truth. Every command is an order that is applied and forgotten. The emulator remembers nothing between runs and reapplies nothing after a restart; a restart is a new session. The API keeps no copy of the control state either: when you ask it for the state of a UE, it asks the emulator.
Everything is applied at a single point. control_manager::tick() runs as the first
statement of simulator::step(), before the MAC layer. At that instant every worker
thread of both pools is parked, which is what makes it safe to mutate UE state without
locks in the readers. Nothing is ever applied from the socket thread or from inside a
parallel phase.
Time is counted in TTIs. One step is one TTI, 1 ms of simulated time, in both modes.
A command can carry at_tti (an integer, canonical) or at_t (seconds, converted). A
command with neither is applied on the next tick.
[Control]
enabled: true
transport: unix ; unix | tcp | file | none
address: /tmp/fikore-control.sock
port: 0 ; tcp only
sync_mode: async ; async | barrier
credit_timeout_ms: 30000
on_timeout: abort ; abort | continue
on_peer_loss: abort ; abort | continue
timeline_file: none ; NDJSON script, for transport: file
journal_file: none ; every applied command, in the same format
max_cmds_per_tick: 256 ; async / real time only; barrier applies the whole TTI
max_object_events: 65536 ; replay log for incremental object feedbackWithout a [Control] section the control plane is off and the emulator behaves exactly
as it always has.
Fourteen knobs, and describe (or GET /schema) is the authoritative list at runtime.
| Name | Type | Unit | Range | Effect |
|---|---|---|---|---|
priority |
number | — | >= 0 | Scheduling priority. Absolute: replaces the .ini value |
enabled |
boolean | — | — | Attaches or detaches the UE |
dl.rmax_mbps |
number | Mbps | >= 0, 0 = no cap | Rate cap over the air |
ul.rmax_mbps |
number | Mbps | >= 0, 0 = no cap | Same, uplink |
dl.sinr_offset_db |
number | dB | -50..50 | Offset added to the derived SINR |
ul.sinr_offset_db |
number | dB | -50..50 | Same, uplink |
traffic.dl_target_mbps |
number | Mbps | >= 0 | Target rate of the traffic generator |
traffic.ul_target_mbps |
number | Mbps | >= 0 | Same, uplink |
mobility.pos_x_m |
number | m | clamped to the apothem | X coordinate |
mobility.pos_y_m |
number | m | clamped to the apothem | Y coordinate |
mobility.speed_kmh |
number | km/h | >= 0 | Target speed |
dl.inject_bytes |
number | bytes | >= 0 | Hands N bytes to the UE now. Incremental |
ul.inject_bytes |
number | bytes | >= 0 | Same, uplink |
pkt_delay_budget_s |
number | s | 0.001..60 | Delay budget of the PDCP buffers |
They are normative, not stylistic:
-
The unit is in the name, always, unless the knob is dimensionless (
priority) or boolean (enabled). -
The unit is the one of the
.ini, not the internal one.mobility.speed_kmhtakes km/h even though the state is in m/s; the conversion happens in the applier. One vocabulary for the user, no number that means two things. -
Directional knobs carry a
dl.orul.prefix, and there is no unprefixed form. Writing both directions takes two entries. More verbose, no ambiguity. -
Subsystem prefix (
mobility.,traffic.) when the parameter belongs to one. Parameters of the UE as such do not carry one.
priority is absolute. It replaces the .ini value; it does not multiply it. It is
initialized from ue_config::priority, so an emulator without a control plane behaves as
before. It is applied at the point of reading, in phy_layer::get_metric, rather than
inside the cached metric: otherwise a change would take up to cqi_period to be felt,
with a latency depending on each UE's position in its CQI cycle.
rmax is a token bucket in the scheduler. The bucket is refilled once per TTI with
rmax_bps * 1 ms and is one TTI deep, so an idle UE accumulates no burst credit. A UE
with an empty bucket is not a scheduling candidate at all; the RBGs it does not take go
to other UEs or stay empty. The cap counts the bits granted over the air,
retransmissions and padding included, so under errors the delivered throughput is
slightly below the cap. Tokens may go negative: the UE then waits until the refill brings
them back, which keeps the long run rate at rmax without having to split an RBG.
enabled: false removes the UE from the simulation, for all purposes. It drops every
live buffer on the spot, stops generating traffic, stops estimating its channel, emits no
telemetry -its series simply stop appearing, which shows up as a gap and not as a zero-
and stops taking a turn in the round robin rotation. Its source keeps being drained and
discarded, so a real UE does not back its netfilter queue up in the kernel. Re-enabling
it is like a terminal joining: empty buffers, last known position, and averaged
statistics carried over from before.
inject_bytes is client driven traffic, the runtime twin of the file based
generator: the client hands over bytes and decides the pacing, and the emulator
packetizes and queues them. It adds to the configured traffic rather than replacing it.
It is the only incremental knob in the catalogue, so its read returns the cumulative
total and a client that retries can tell whether its injection landed. Mind
pkt_delay_budget_s: whatever does not make it out in time is discarded as expired. See
Traffic Generator.
sinr_offset_db moves the reported RSRP too. It is added where the SINR is derived,
which is the consistent behaviour if the offset stands for power or losses.
A client moving more than one transfer over the same UE needs to know which of them
arrived. inject labels the bytes with a tag, an integer it chooses; the emulator
attaches it to the packets it generates, carries it through fragmentation and HARQ, and
counts what happened to each tag's bits:
{"id":1,"cmds":[{"op":"inject","target":"ue/3","tag":7,"dl.bytes":12000}]}
{"id":2,"cmds":[{"op":"forget","target":"ue/3","tag":7}]}Tag 0 is the generator's traffic and is not accounted for; dl.inject_bytes is the
untagged form and is equivalent to it. The counters appear in the objects block of
get, as delivered_bytes, dropped_bytes, expired_bytes and ce_bytes per tag.
What is in none of the first three is still in flight, which the client can work out
because it knows how much it injected. The emulator does not: it never learns how big an
object is, which is why forget exists rather than the counters expiring on their own.
expired_bytes and dropped_bytes are not two names for the same event, and
dropped_bytes is itself a sum, reported broken down as queue_dropped_bytes and
radio_dropped_bytes:
| Counter | What happened |
|---|---|
expired_bytes |
The packet sat longer than pkt_delay_budget_s. Deterministic, and about that packet's own age |
queue_dropped_bytes |
The AQM asked the sender to slow down, a full buffer tail-dropped, or the UE was detached and its queues emptied |
radio_dropped_bytes |
HARQ retransmissions exhausted |
expired_bytes and queue_dropped_bytes are the pair worth not confusing. An AQM drop
is not a late packet. The dual queue fires off its own target, 15 ms by default, while
the delay budget defaults to 350 ms; a packet dropped by the AQM would have gone out well
inside its budget. The drop is probabilistic and it looks at the head of the queue rather
than at the packet it sacrifices, so a freshly arrived packet can be the one that pays.
Raising pkt_delay_budget_s therefore does not stop AQM drops, and expired_bytes
staying at zero does not mean nothing was lost to congestion.
Only radio_dropped_bytes means the link itself is bad. A client asking "should I send
less, or is the radio bad?" reads those two and ignores the rest.
dropped_bytes remains the sum of the two, so delivered + dropped + expired still adds
up to what was injected. The same counters appear per direction in the state block,
suffixed _total.
The account is per object, but the queue is not. A UE has one FIFO, so an object that overfeeds it pushes its neighbours past the delay budget too, and they expire behind it. Whatever bounds the injection has to be per UE.
Transport models should use events instead of serialising the complete live-object
map every TTI:
{"id":7,"cmds":[{"op":"events","after":123,"include_state":false}]}The result carries only counter movements newer than after:
{"cursor":125,"events":[
{"seq":124,"at_tti":939,"target":"ue/0","dir":"dl","tag":8817,
"delivered_bytes":1500,"ce_bytes":1500},
{"seq":125,"at_tti":939,"target":"ue/1","dir":"dl","tag":730,
"expired_bytes":1500}
]}These are deltas, not terminal declarations: a tag may be injected more than once and
only its owner knows the total size. after means that the client consumed everything
through that cursor. Newer events stay in the replay log, so retrying the same cursor
does not lose feedback. The first call uses after: 0 and starts the subscription at
that quiescent point.
include_state: true adds compact cumulative queue, latency, SINR and per-UE counters
without knobs or the object map. A harness normally asks for it only at the end of its
telemetry window.
The replay log is bounded by max_object_events. Overflow aborts a barrier run before
feedback is lost. Async mode reports a gap and requires an atomic snapshot and reset:
{"id":8,"cmds":[{"op":"events","after":0,"resync":true}]}The snapshot is the same full UE/object state as get ue/*; collection restarts at the
same quiescent point, with no unobserved interval between the two.
inject takes an optional ecn, which is what the generated packets declare in the IP
header's ECN field: not-ect, ect0, ect1 (l4s is accepted as a synonym) or ce.
It defaults to not-ect, so a client that says nothing gets exactly what it got before.
{"id":1,"cmds":[{"op":"inject","target":"ue/3","tag":7,"dl.bytes":12000,"ecn":"ect1"}]}This is what the dual queue classifies on. Traffic declaring ECT(1) goes to the L4S queue and is marked with CE rather than dropped, so a scalable sender driving the emulator through the control plane has a congestion signal to react to. Without the field, injected traffic is not-ECT and can only ever be dropped, which limits what an external sender can be: classic, or nothing.
ce_bytes counts the marks, per object and in bytes of payload that arrived. A mark is
not a fate: delivered + dropped + expired still adds up to what was injected, and
ce_bytes is a subset of delivered_bytes. Marks are per object rather than per UE
because a sender needs the marks of its own flow, and one UE can carry several.
[Control]
enabled: true
transport: file
timeline_file: config/timelines/my_scenario.ndjsonOne JSON object per line, # for comments:
{"id":1,"at_t":5.0,"cmds":[{"target":"ue/0","set":{"priority":8.0}}]}
{"id":2,"at_tti":10000,"cmds":[{"target":"ue/1","set":{"enabled":false}}]}[Control]
enabled: true
transport: unix
address: /tmp/fikore-control.sock$ nc -U /tmp/fikore-control.sock
{"op":"hello","proto":"fikore-control-1"}
{"proto":"fikore-control-1"}
{"id":1,"cmds":[{"target":"ue/0","set":{"priority":4.0,"dl.rmax_mbps":25.0}}]}
{"id":1,"status":"ok","tti":12345,"t":12.345}The emulator greets with its protocol version and the client must answer with the same string. There is no negotiation and no backwards compatibility: the emulator and the API are built and deployed together, so a mismatch is a deployment error and the connection is closed with an explicit message.
One client at a time. A second connection is answered with
{"op":"error","reason":"control channel already in use"} and closed.
get returns, besides the knob values, a state block per direction with cumulative
counters: bytes injected, delivered, expired, dropped -with its three causes broken out-
and retransmitted, what is still queued, the age of the oldest packet, the recent
latency, the mean SINR and the live objects. It is resolved at the quiescent point and in simulated time, which makes it
exact, unlike the telemetry, whose aggregator flushes on wall clock.
The retransmission counter reads zero in this build: the BLER model behind
harq_handler::get_rtx is compiled out, so the radio never asks for a second attempt.
With it out, the delay budget and the AQM are the only ways a byte is lost.
Operations are set, get, describe, ping, grant, inject, forget and
events. Targets are ue/<id>, ue/* and cell; events is cell-wide and needs no
explicit target.
ue/<id> accepts either the numeric scheduler index or the textual ue_id from
the configuration. A single ue_id: car is ue/car; a section with n_ues: 2
creates ue/car_0 and ue/car_1. Replies keep the numeric target for backwards
compatibility and add the textual ue_id. Compact event state also reports
mobility.pos_x_m, mobility.pos_y_m and mobility.speed_kmh.
Three rules a client has to get right. A command carrying at_tti is applied when
the emulator reaches that TTI, so in barrier mode you must not wait for its
acknowledgement before granting the credit that takes you there: write the commands,
write the grant, then read. And grant is answered from the socket thread while
everything else is answered at the quiescent point, so replies do not come back in the
order they were sent.
The third is the one that will cost you a day if you get it wrong. A message of N
commands is answered N times, once per command, and every one of those replies carries
the id of the message, not of the command. So id identifies the message and cannot
tell two commands of the same message apart: a client demultiplexes by counting
replies, in the order the commands were written, and must drain all N before writing
again. Read one reply per message and the unread ones stay in the socket, the stream
desynchronises, and the symptom is not an error but plausible-looking answers belonging
to earlier commands.
A message is validated whole before anything is applied, so a ue/* carrying one bad
value does not leave half the UEs updated. There is no deduplication by id and there
are no incremental operators: a correct client is assumed.
See api/README.md. In short:
$ ./run_scripts/run_api.sh
$ curl -X POST localhost:8100/control/ue/0 -H 'content-type: application/json' \
-d '{"priority": 8, "dl.rmax_mbps": 25}'
$ curl localhost:8100/ue/0/stateIn async mode -the default- the emulator never waits. That is what you want in real
time and usually what you want in fast mode too.
In barrier mode the emulator only runs TTI n if n <= credit_until_tti, and credit
is granted by the controller:
{"id":7,"op":"grant","until_tti":1500}Credit is absolute and monotonic. Granting into the past is a no-op answered with
ok and the credit in force, which is exactly what a client retrying after a timeout
needs. The reply always carries credit_until_tti, so a controller can tell what
happened without decoding error codes.
Three things worth knowing:
-
Barrier is refused in real time. With
period > 0it degrades toasyncwith a warning at startup: blocking the wall clock defeats the mode. -
Losing the peer ends the run, unless you say otherwise. If a controller that had
connected goes away,
on_peer_loss: abort-the default- stops the run: nothing would drive it any more. Withcontinuethe emulator switches toasyncfor the rest of the run instead, so an unattended session finishes rather than hanging, and does not pretend to be synchronised if someone reconnects. -
credit_timeout_msandon_timeoutdecide what happens when no credit arrives. The default isabort;continueexplicitly accepts an unsynchronised result.
An aborted process is not a successful process: lost peer returns 74, credit timeout 75, and event-backlog/protocol integrity failure 76. Normal completion alone returns 0.
Set journal_file and every applied command is written down with its at_tti:
{"id":1,"at_tti":5000,"at_t":5.0,"wall_ns":...,"cmds":[{"op":"set","target":"ue/0","set":{"priority":8.0}}]}A journal line is a valid script line. Feed the journal back as timeline_file on a run
with the same seed and you get the same output byte for byte, with every command
applied on the same step. An interactive session becomes a repeatable experiment with no
conversion in between.
With monitoring enabled, the control measurement carries, per window:
| Field | Meaning |
|---|---|
applied_sum |
commands applied |
rejected_sum |
commands rejected |
blocked_ttis_sum |
TTIs held by the barrier |
blocked_ms_sum |
time spent blocked |
last_applied_tti_last |
TTI of the last command applied |
credit_until_tti_last |
credit in force |
It is emitted only on TTIs where something happened, so an idle control plane costs nothing. Together with the journal, it is what lets you line up "what changed" with "what happened" in the same data.
With the control plane enabled and an empty inbox, the step time is indistinguishable from the baseline. The reading points are one scalar comparison each and the write side -the registry, the JSON parser, the mutexes- never runs inside the scheduling loop.