Connect an eaxsim host to eaxScada's broker
Let an eaxsim host (the plant emulator) watch eaxScada’s broker safely. Before its PLCs publish on the UNS, eaxsim’s UNS prefix guard checks that no real PLC already uses their UNS prefix, so a simulated PLC never answers a command meant for a real PLC or mixes its values into a real PLC’s tags. To do that, the guard subscribes to plc.*.birth, plc.*.status and uns.telemetry.>.
eaxScada’s broker admits only identities it knows. The guard gets a watcher identity: it may subscribe to exactly those three subjects and publish nothing.
- Product
- Service or process
- Device or controller
- Data or telemetry
- Command to equipment
- Configuration or deploy
- Refusal
Read as text
The simulated PLCs of an eaxsim host connect to eaxScada's NATS broker with their own seeds, which eaxScada creates for the ids in --edge-plcs. The host's UNS prefix guard connects with its own watcher seed, known to eaxScada through --nats-watcher: it may subscribe to the PLC births, the PLC status and the UNS telemetry, and publishes nothing. When another PLC already uses a simulated PLC's prefix, or the guard cannot watch, the host refuses that PLC's UNS telemetry and commands.
Parts
- Simulated PLCs (device or controller, inside eaxsim host): each with its own seed <id>.nk
- UNS prefix guard (service or process, inside eaxsim host): seed eaxsim-guard.nk (eaxsim -nats-nkey)
- eaxScada (product, inside eaxScada server): --edge-plcs <ids> --nats-watcher eaxsim=U...
- NATS broker (service or process, inside eaxScada server): admits known identities only
Connections
- Simulated PLCs → NATS broker (data or telemetry): UNS telemetry, births
- NATS broker → Simulated PLCs (command to equipment): UNS commands. A simulated PLC that the guard refused handles no UNS command.
- NATS broker → UNS prefix guard (data or telemetry): subscribes only: plc.*.birth, plc.*.status, uns.telemetry.>. The watcher identity may subscribe to exactly these three subjects and publish nothing.
- UNS prefix guard → Simulated PLCs (refusal): UNS refused. When another PLC already uses a simulated PLC's prefix, or the guard cannot watch, the host refuses that PLC's UNS telemetry and commands; its API, births and heartbeats still go out. A guard that cannot connect refuses every hosted PLC.
- eaxScada → NATS broker (configuration or deploy): identities. eaxScada creates a seed for each id in --edge-plcs and registers the watcher's public key from --nats-watcher; the broker admits only these.
Before you start
Section titled “Before you start”- Access to the eaxScada server’s start options (command line, service definition or environment).
- The eaxsim host can reach eaxScada’s NATS port.
- The simulated PLCs have their own broker identities: eaxScada’s
--edge-plcslists their ids and creates a seed<id>.nkfor each underdata/security/nkeys(or--edge-plc-seed-dir); the scenario’snats.nkey_dirpoints eaxsim at those seeds.
1. Make a seed for the guard
Section titled “1. Make a seed for the guard”On the eaxsim host, with the eaxScada program:
eaxscada --gen-device-seed eaxsim-guard.nkIt writes a new seed (mode 0600, never over an existing file), prints device seed written to eaxsim-guard.nk (public key U...) and exits. Keep the seed on the eaxsim host. Use a new seed: a PLC’s seed is refused as a watcher key (one key, one role).
2. Start eaxScada with the watcher
Section titled “2. Start eaxScada with the watcher”Add the watcher with the public key the command printed:
eaxscada --nats-watcher eaxsim=U...or, in the environment, EAX_NATS_WATCHERS=eaxsim=U.... The value can also be the path of the seed file instead of the public key, when the file is on the eaxScada server; only its public key is kept.
- The server log shows
NATS watcher identitywith the name and the public key. - A bad value stops the start (
invalid --nats-watcher): a name given twice, a key that is already the server’s, a PLC’s or another watcher’s, or a seed file that cannot be read. - High availability: give both nodes the same watcher (the same public key, or the same seed file).
The rules are in NATS identities on the broker.
3. Start eaxsim with the seed
Section titled “3. Start eaxsim with the seed”eaxsim -scenario plant.json -nats nats://<eaxscada host>:4222 -nats-nkey eaxsim-guard.nk-nats-nkey is the seed file the UNS prefix guard connects with. eaxsim waits up to 60 s for the file to appear.
4. Check the connection
Section titled “4. Check the connection”- eaxScada’s log shows
watcher connectedwith the name and the client address. - Security > Access audit holds
NATS_WATCHER_CONNECTED, userwatcher-eaxsim.
Without a watcher identity
Section titled “Without a watcher identity”The guard fails closed. When it cannot connect (no -nats-nkey on a broker that requires NKeys, a seed it cannot read, a key eaxScada does not know: recorded NATS_AUTH_REJECTED) or the broker refuses its subscriptions, it cannot tell whether a real PLC uses the prefixes, so it refuses every hosted PLC’s UNS telemetry and commands. The PLCs’ API, births and heartbeats still go out; each PLC’s status gives the reason. Give the guard a watcher identity and restart eaxsim.
Result
Section titled “Result”The guard watches the broker with a read-only identity and lets the simulated PLCs publish on prefixes no real PLC uses. eaxScada still refuses the values of simulated PLCs by default: see Accept or refuse simulated PLCs.