liberps

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

Front ends erpsd and erpsctl on Linux, the erps-sim shell, or your NOS CLI
Command layer Configuration model, enable and disable, operator commands, show views in text or JSON, running-config. Transport-agnostic. erps_cli_exec(cli, line, out, ctx) · erps_cli_commands()
Protocol core State machine, priority logic, timers, R-APS scheduler, flush logic, validity check, FOP, history and counters, and a manager for several instances. Pure C11, deterministic. platform interface: tx · set_port_state · flush_fdb · notify · log
Platforms Linux (AF_PACKET, bridge netlink, epoll) and the discrete-event simulator. A switch SDK adapter plugs in the same way.

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

FileG.8032Responsibility
fsm.c§10.1.2, Table 10-2fsm_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.13Table 10-1 ordering, persistent requests versus events, command validity, compatible-version filtering
erps.c§10.1.5–10.1.8Lifecycle, receive pipeline, local defect logic and hold-off, timer expiry, software R-APS forwarding
tx.c§10.1.3Continuous 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.4FOP-PM and optional FOP-TO
pdu.c§10.3R-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.8Defaults, 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 now in microseconds. Deadlines are absolute and saturate instead of wrapping. The host calls erps_poll() at erps_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, and erps_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(), and erps_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