Commands
Command reference
The command layer turns text lines into configuration, operator commands and show views. erpsd, erpsctl and erps-sim all use it, and it embeds into any CLI.
Commands
Configuration keywords can be combined on one line. Durations take ms, s, m or h; a bare number is milliseconds. Blank lines and lines starting with # or ! are ignored.
| Command | Effect |
|---|---|
erps ring <name> ring-id <1-239> raps-vid <1-4094> port0 <port> port1 <port> | Create or configure a ring instance |
erps ring <name> role owner|neighbour|none [rpl-port <0|1>] | RPL role of this node |
erps ring <name> node-id <mac>|auto | Node ID; auto takes the platform's system MAC |
erps ring <name> mel <0-7> · pcp <0-7> | Ring MEG level; 802.1Q priority of R-APS |
erps ring <name> revertive|non-revertive | Reversion mode (live) |
erps ring <name> compat-version <1|2> | Interworking with 2008-only nodes |
erps ring <name> timers [wtr <dur>] [guard <dur>] [holdoff <dur>] | WTR 1–12 min, guard 10 ms–2 s, hold-off 0–10 s (live) |
erps ring <name> init-timer wtr|wtb | Owner's timer at start-up; wtb converges faster after a cold start |
erps ring <name> protected-vlans [add|remove] <list> | VLANs the instance protects, e.g. 10-20,30 |
erps ring <name> sw-forwarding on|off | Forward R-APS between ring ports in software |
erps ring <name> fop-pm on|off · fop-to on|off · fop-timeout <dur> | Failure-of-protocol alarms |
erps ring <name> relaxed-timers on|off | Allow out-of-range timers (lab use) |
erps ring <name> enable|disable | Start or stop the instance; disable leaves both ring ports blocked |
no erps ring <name> | Delete a ring |
erps ring <name> force-switch port <0|1> | Operator forced switch |
erps ring <name> manual-switch port <0|1> | Operator manual switch |
erps ring <name> clear | Clear a local FS or MS, or revert at the RPL owner |
erps ring <name> flush-event | Send an R-APS flush event burst |
show erps [summary] [json] | One line per ring |
show erps ring <name> [detail|status|config|counters|history] [json] | Ring details |
show running-config erps | The configuration as commands |
clear erps [ring <name>] counters | Reset counters |
debug erps [ring <name>] level <error|warning|notice|info|debug|trace> | Log level; debug logs every executed row |
While a ring is enabled, timers and the revertive mode change live. Ports, role, ring ID and the other identity settings need disable first, and the command says so.
Show output
From the simulator: a four-node ring two seconds after link 1 failed. The detail view is shortened here.
> show erps
Ring ID VID Role State Port0 Port1 Top request
n0 1 100 rpl-neighbour Protection n0.p0:F n0.p1:F R-APS(SF) 02:00:00:00:00:03 bpr0 @p0
n1 1 100 none Protection n1.p0:F n1.p1:B local-SF p1
n2 1 100 none Protection n2.p0:B n2.p1:F local-SF p0
n3 1 100 rpl-owner Protection n3.p0:F n3.p1:F R-APS(SF) 02:00:00:00:00:02 bpr1 @p1
> show erps ring n3 detail
ERP instance n3
Ring ID 1, R-APS VID 100, MEL 7, node ID 02:00:00:00:00:04
Role: rpl-owner, RPL port 1 (n3.p1)
Mode: revertive, compatible-version 2, software R-APS forwarding
Timers: WTR 5m00s, WTB 5.500s, guard 500ms, hold-off 0ms
State: Protection (B), since t=301.001050, last row 21
Top request: R-APS(SF) 02:00:00:00:00:02 bpr1 @p1
Port 0 n3.p0 Forwarding SF:no last rx R-APS(SF) 02:00:00:00:00:03 bpr0 (0ms ago)
Port 1 n3.p1 Forwarding SF:no last rx R-APS(SF) 02:00:00:00:00:02 bpr1 (0ms ago)
Counters: port0 port1
rx NR 63 62
rx SF 3 2
forwarded 2 2
...
History (5):
#1 t=0.000000 init->E row 1 init [block-p1 tx start-wtr] ports --->-B tx=R-APS(NR) 02:00:00:00:00:04 bpr1
#3 t=300.000000 E->A row 66 WTR-expires [tx] ports -B->-B tx=R-APS(NR,RB,DNF) 02:00:00:00:00:04 bpr1
#4 t=301.001050 A->B row 7 R-APS(SF) 02:00:00:00:00:03 bpr0 @p0 [unblock-p1 stop-tx] ports -B->--
#5 t=301.004383 B->B row 21 R-APS(SF) 02:00:00:00:00:03 bpr0 @p0 [] ports --->-- (x3 more, last t=301.007766)
Add json to any view for machine-readable output:
> show erps ring n3 status json
{"status":{"state":"Protection","state_letter":"B","running":true,"last_row":21,
"last_change_us":301001050,"top_request":"R-APS(SF) 02:00:00:00:00:02 bpr1 @p1",
"ports":[{"blocked":false,"sf":false,"ssf":false,"holdoff":false,"fop_to":false,
"last_rx_us":301007716,"last_rx":{"text":"R-APS(SF) 02:00:00:00:00:03 bpr0","req":11,
"rb":false,"dnf":false,"bpr":0,"node_id":"02:00:00:00:00:03"}}, ...],
"tx":null,"timers":{"wtr_us":0,"wtb_us":0,"guard_us":0},"command":null,"fop_pm":false}}
Configuration files
A configuration file is a command script, and show running-config erps prints one that recreates the current configuration exactly. Replaying it on a fresh instance produces the same running-config; a test checks that.
erps ring R1 ring-id 3 raps-vid 200 mel 5 port0 eth1 port1 eth2 erps ring R1 node-id 02:00:00:00:00:42 erps ring R1 role neighbour rpl-port 0 erps ring R1 timers wtr 7m guard 1s holdoff 300ms erps ring R1 non-revertive erps ring R1 protected-vlans 1-5,7,9-10 erps ring R1 sw-forwarding on erps ring R1 enable !
Long VLAN lists are split over several protected-vlans add lines so every line stays within the parser's limit.
Embedding the command layer
A host supplies the current time and, to create rings, a way to bind a ring to its dataplane. Everything else is in the library.
#include <erps/erps_cli.h>
erps_cli_platform_t p = {
.ctx = my,
.now = my_now, /* required */
.port_lookup = my_port_lookup, /* "eth1" -> handle (+ MAC); optional */
.system_mac = my_system_mac, /* for node-id auto; optional */
.instance_bind = my_bind, /* fill erps_ops_t + user for a ring being enabled */
.instance_unbind = my_unbind,
};
erps_cli_t *cli = erps_cli_create(&p);
erps_cli_exec(cli, "erps ring R1 enable", out_fn, out_ctx); /* errors print as "% ..." */
size_t n;
const erps_cli_cmd_t *cmds = erps_cli_commands(&n); /* syntax + help, for host grammars */
instance_bind may adjust the configuration before the instance is created; the Linux platform uses this to turn on software R-APS forwarding and set port MACs. erps_cli_attach() exposes instances you created yourself to show and the operator commands.
Simulator commands
In erps-sim, every command above works on the rings n0…n<N-1>, plus these:
| Command | Effect |
|---|---|
sim create <nodes> [owner <n>] [no-neighbour] [non-revertive] [compat <1|2>] [wtr|guard|holdoff <dur>] [delay <us>] [jitter <us>] [loss <0..1>] [seed <n>] [id <node> <octet>] | Build a ring and start every node |
run <dur> | Advance virtual time |
link <i> down|up [cw|ccw] | Fail or restore a link, both directions or one |
node <i> down|up | Node failure, and recovery as a fresh restart |
node <i> fs <0|1> · ms <0|1> · clear | Operator commands on a node |
show | One-line ring summary, e.g. n2:B[-B] = Protection, port 1 blocked |
events on|off · log <level>|off | Print protocol events or node logs |
pcap <file>|off | Capture all R-APS frames |
expect state <node> <A-E> · expect blocked <node> <port> yes|no · expect no-loops | Assertions for scripts |