Architecture
How liberps is put together
One erps_t is one ERP control process: one ERP instance on one node, as in Figure 10-1 of G.8032. Everything around it is a layer you can replace.
Layers
erpsd and erpsctl on Linux, the erps-sim shell, or your NOS CLI
Data flow inside the control process
The receive path follows Figure 10-1. The flush logic sees every valid message, including those the guard timer then discards, and only the priority logic is shielded by the guard.
erps_rx_frame ─► Ethernet / VID / EtherType ─► R-APS DA ─► MEL ≥ ring MEL ─► [software R-APS_FF]
│
validity check: ring ID, MEL, opcode, TLV offset, request
│
┌─── Event flush indication (10 ms) ─────────────────┤
▼ ▼
flush logic ◄─────────────────── (node ID, BPR) pairs, every valid message
│
own node ID? ─► ignored
guard running? ─► discarded, counted
▼
erps_set_signal_fail ─► hold-off ─► local SF ───────► PRIORITY LOGIC ◄─── WTR / WTB running, expires
erps_command ─► compat filter ─► local priority ────► (Table 10-1)
│ top-priority request
▼
R-APS REQUEST PROCESSING (Table 10-2)
block / unblock │ Tx R-APS │ timers │ flush
▼
set_port_state ◄── port_set tx ◄── scheduler flush_fdb ◄── once, at the end of the input
Modules
| File | G.8032 | Responsibility |
|---|---|---|
fsm.c | §10.1.2, Table 10-2 | fsm_table[state][request] = {row, action, next} with the spec's row numbers; action helpers mirror actions a) to r) |
priority.c | §10.1.1, §10.1.9, §10.1.13 | Table 10-1 ordering, persistent requests versus events, command validity, compatible-version filtering |
erps.c | §10.1.5–10.1.8 | Lifecycle, receive pipeline, local defect logic and hold-off, timer expiry, software R-APS forwarding |
tx.c | §10.1.3 | Continuous transmission (burst of three, then every 5 s), event bursts, holding new information until blocks are confirmed |
flush.c | §10.1.10, §9.6 | (node ID, BPR) pairs per port, DNF, coalesced FDB flush with retry |
fop.c | §10.4 | FOP-PM and optional FOP-TO |
pdu.c | §10.3 | R-APS PDU and frame encode / decode |
trace.c | — | Transition history, status and counters, text and JSON rendering |
mgr.c | — | Several instances: receive demultiplexing, signal-fail fan-out, aggregated deadlines |
config.c, names.c | §10.1.4, §10.1.5, §10.1.8 | Defaults, range validation, enum names |
Design decisions
- Table-driven state machine
- The table is the Recommendation's table. Conditionals inside a row are written as the table nests them ("if requested ring port is already blocked", "if RPL owner node and revertive"). A unit test re-derives the (state, request) to row mapping independently and compares it with the table.
- Persistent requests and events
- Latched FS and MS, local SF, and WTR or WTB running hold until cleared. Commands, clear SF, timer expiry and R-APS messages are one-shot. The top request is the higher of the two. An R-APS message that loses to an already-signalled persistent request does not re-run its row, and persistent requests are re-evaluated after every state change.
- Caller-supplied time
- Every input carries
nowin microseconds. Deadlines are absolute and saturate instead of wrapping. The host callserps_poll()aterps_next_deadline(). Hours of ring time therefore simulate in milliseconds, and tests are exact. - Fail-safe dataplane
- The state machine records the port state it wants and whether the platform confirmed it. New R-APS information is held until every requested block is confirmed, because peers unblock when they receive it. Failed blocks and failed flushes are retried every 100 ms.
- One flush per input
- A row's "Flush FDB" and the flush logic's request for the same message become a single
flush_fdb()call, issued after all port changes for that input. - History that keeps what matters
- Each executed row is stored in a ring buffer (128 entries by default). Repeated no-action rows, such as a periodic R-APS(SF) on row 21, fold into one entry with a repeat count.
- Safe callbacks
- Callbacks run inside the call that caused them. A nested call into the same instance returns
ERPS_E_BUSY, anderps_destroy()from a callback is deferred until the outer call returns. - Small and static
- An instance is about 12 KB, most of it history. Nothing is allocated after
erps_create(), anderps_init_static()allows fully static allocation.
The simulator
A discrete-event simulation drives N instances wired as a ring. It keeps a heap of frame deliveries and signal-fail changes and polls each node at its own deadline. Links have per-direction state, delay, jitter and loss; FIFO order per direction is preserved. A failed node stops processing, but frames already on the wire are still delivered. After every simulated instant the simulator checks both ring directions for a forwarding loop, meaning every link up in that direction with both end ports unblocked on live nodes, and records the first violation with a description of the ring.
Extension points
- Sub-rings and interconnection.
ERPS_BLOCK_TRAFFICandERPS_BLOCK_RAPSare already separate bits for the §10.1.14 R-APS block logic; the flush logic needs its sub-ring variant, and the manager would carry topology-change propagation. - Appendix VIII flush optimisation. Needs an RPL next-neighbour port in the configuration, a DNF status bit and per-port transmit masks. Its faster cold start is already available as
init_wtb. - CCM-based signal fail. Any CFM implementation can feed
erps_set_signal_fail().