Skip to content

Connect an eaxsim host to eaxScada's broker

eaxScadaHow-to guideStarterProEnterpriseView as Markdown

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.

System architectureAn eaxsim host on eaxScada's broker
An eaxsim host on eaxScada's brokerThe 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.EAXSIM HOSTEAXSCADA SERVERSimulated PLCseach with its ownseed <id>.nkUNS prefix guardseed eaxsim-guard.nk(eaxsim -nats-nkey)eaxScada--edge-plcs <ids>--nats-watcher eaxsim=U...NATS brokeradmits knownidentities onlyUNS telemetry, birthsCMDUNS commandssubscribes only: plc.*.birth,plc.*.status, uns.telemetry.>UNS refusedidentities
The guard only listens. Without a watcher identity it cannot tell whether a real PLC uses a prefix, so every hosted PLC's UNS telemetry and commands are refused.
  • 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.
  • 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-plcs lists their ids and creates a seed <id>.nk for each under data/security/nkeys (or --edge-plc-seed-dir); the scenario’s nats.nkey_dir points eaxsim at those seeds.

On the eaxsim host, with the eaxScada program:

Terminal window
eaxscada --gen-device-seed eaxsim-guard.nk

It 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).

Add the watcher with the public key the command printed:

Terminal window
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 identity with 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.

Terminal window
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.

  • eaxScada’s log shows watcher connected with the name and the client address.
  • Security > Access audit holds NATS_WATCHER_CONNECTED, user watcher-eaxsim.

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.

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.