Skip to main content

CLI flags

The simulator binary is driven entirely by command-line flags. This page is the authoritative catalog — new flags land here first.

Run the simulator with:

sudo ./nl6 [options]

Root is required because the simulator creates TUN interfaces and manages the opensim network namespace. See Network namespace for the namespace details and Quick start for a minimal invocation.

Core flags

FlagTypeDefaultPurpose
-auto-start-ipstringAuto-create devices starting from this IP (e.g. 192.168.100.1).
-auto-countint0Number of devices to auto-create. Requires -auto-start-ip.
-auto-netmaskstring24Netmask for auto-created devices.
-portstring8080HTTP API server port.
-snmp-portint161UDP port for the SNMP listener on each device. Use 1161 to avoid requiring CAP_NET_BIND_SERVICE.
-no-namespaceboolfalseDisable network namespace isolation (run in the root namespace).
-helpShow the help message and exit.
-versionPrint the simulator version string to stdout and exit 0. Runs before any startup side effects (no TUN, no netns, no port binds) so it works from unprivileged shells and inside minimal containers.

SNMPv3 flags

Omit the engine-id flag to run in v2c-only mode.

FlagValuesDefaultPurpose
-snmpv3-engine-idstringEnable SNMPv3 with the specified engine ID (e.g. 0x80001234).
-snmpv3-authnone | md5 | sha1md5SNMPv3 auth protocol.
-snmpv3-privnone | des | aes128noneSNMPv3 privacy protocol.

See SNMP reference for the auth/priv compatibility matrix.

Interface-state scenarios

The -if-scenario flag controls the SNMP admin/oper status reported for all simulated interfaces, so you can reproduce common network conditions without editing resource files.

FlagTypeDefaultPurpose
-if-scenarioint2Interface state scenario: 1=all-shutdown, 2=all-normal, 3=all-failure, 4=pct-failure.
-if-failure-pctint10Percentage of interfaces with oper-down (used with -if-scenario 4, 0–100).
ScenarioNameifAdminStatusifOperStatusUse case
1all-shutdowndown (2)down (2)Planned maintenance, device decommission
2all-normal (default)up (1)up (1)Normal steady-state operations
3all-failureup (1)down (2)Link failures, SFP issues, cable pull
4pct-failureup (1)down for n%Partial outage, staged rollout testing

Scenario 4 uses a deterministic rule (ifIndex % 100 < n) so test runs are reproducible across restarts.

Error / discard scenario

-if-scenario governs which interfaces are up. A companion flag, -if-error-scenario, governs how clean the interfaces that are up behave — the ppm ranges used to derive ifInErrors, ifOutErrors, ifInDiscards, and ifOutDiscards from the live packet counters.

FlagValuesDefaultPurpose
-if-error-scenarioclean | typical | degraded | failingcleanAuto-start-batch default for per-device error / discard counter cycling. REST-created devices default to clean independently (they opt in via if_error_scenario in the POST body).
ScenarioerrPpm rangediscPpm rangeUse case
clean (default)00Pristine lab gear — counters stay at the pre-seeded baseline
typical10 – 10020 – 200Good production gear; faint error/discard growth visible in long-period polls
degraded1 000 – 10 0002 000 – 20 000Congested / faulty optics; 0.1 – 1 % error rate
failing10 000 – 100 00020 000 – 200 000Link-flap / bad cable; 1 – 10 % error rate

Each interface within a device draws its per-direction ppm deterministically from the scenario's band at device creation — so repeated runs with the same auto-start layout produce the same per-interface values. clean (0/0) is the backwards-compatible default and leaves all error/discard counters at their pre-seeded zero.

Unlike -if-scenario, this setting is per-device: every device carries its own scenario, so one simulator can host 100 clean lab devices alongside 5 degraded ones for alert-threshold testing. See if-counters reference.

-if-flap-scenario drives Poisson-distributed link flaps per (device, ifIndex). Mutations go through the interface state engine that powers SNMP ifOperStatus / ifAdminStatus / ifLastChange and gNMI ON_CHANGE subscribers, so all three surfaces see the same value at the same instant.

FlagValuesDefaultScopePurpose
-if-flap-scenarioclean | rare | typical | aggressivecleanseedAuto-start-batch per-device link-flap scenario. REST devices default to clean; opt in via if_flap_scenario POST body.
-if-flap-global-capint (events/sec)0globalSimulator-wide rate ceiling on flap events. 0 is unlimited.
ScenarioMean inter-flapDown durationUse case
clean (default)∞ (no flaps)n/aSteady-state regression testing
rare~6 hours / interfaceuniform 1–10 sLong-running fleets, background variance
typical~15 minutes / interfaceuniform 1–30 sCollector alarm-pipeline stress
aggressive~1 minute / interfaceuniform 1–5 sChaos / churn measurement

See interface state engine reference for the REST control plane (POST /api/v1/devices/{ip}/interfaces/{ifIndex}/{oper,admin}-status), auto-revert semantics, and the cross-protocol consistency contract.

Export flag scope

Export flags (flow / trap / syslog) fall into two categories:

  • seed — applies only to devices created by the -auto-start-ip batch at startup. Devices subsequently created via POST /api/v1/devices do NOT inherit these values; they must opt in by including a flow / traps / syslog block in the request body.
  • global — applies simulator-wide regardless of how the device was created. Shared sockets, catalogs, rate-limiter, and network-namespace bind policy sit here.

Duration units differ between CLI and REST: CLI flags that express a duration take integer seconds (e.g. -flow-tick-interval 5, -trap-interval 30), while the REST per-device blocks require Go duration strings ("tick_interval": "5s", "interval": "30s"). Passing an integer in the REST body ("interval": 30) is rejected with 400 by design — the two forms are not interchangeable.

See Web API for the per-device block schema and Migration for converting pre-per-device-config invocations.

Flow export flags

See Flow export (operator guide) for prerequisites and collector setup, and Flow export reference for protocol details.

FlagTypeDefaultScopePurpose
-flow-collectorstringseedEnable flow export to this UDP collector (e.g. 192.168.1.10:2055) for the auto-start batch.
-flow-protocolnetflow9 | ipfix | netflow5 | sflownetflow9seedFlow export protocol (alias: sflow5).
-flow-tick-intervalint (seconds)5seedFlow ticker interval.
-flow-active-timeoutint (seconds)30seedActive flow timeout.
-flow-inactive-timeoutint (seconds)15seedInactive flow timeout.
-flow-template-intervalint (seconds)60globalTemplate retransmission interval (NetFlow v9 / IPFIX only).
-flow-source-per-devicebooltrueglobalUse each device's IP as the UDP source address.

SNMP trap / INFORM export flags

See SNMP trap / INFORM export (operator guide) for prerequisites and snmptrapd smoke-test, and SNMP trap reference for wire format and catalog JSON.

FlagTypeDefaultScopePurpose
-trap-collectorstringseedEnable trap export to this UDP collector (e.g. 192.168.1.10:162) for the auto-start batch. Empty disables seeding; REST-created devices can still opt in via the traps block.
-trap-modetrap | informtrapseedNotification mode. TRAP is fire-and-forget; INFORM is acknowledged and retried.
-trap-intervalduration30sseedPer-device mean firing interval (Poisson-distributed, not periodic).
-trap-global-capint (tps)0globalSimulator-wide rate ceiling across fires + INFORM retries. 0 is unlimited.
-trap-catalogstringglobalPath to a JSON catalog; empty uses the embedded universal 5-trap catalog + per-type overlays from resources/<slug>/traps.json. Setting this flag disables per-type overlays — the file becomes the sole catalog for every device.
-trap-communitystringpublicseedSNMPv2c community string.
-trap-source-per-devicebooltrueglobalUse each device's IP as the UDP source address. Required when a device is configured mode=inform — enforced at device-attach time: the attach fails per-device and the device's trapConfig is cleared.
-trap-inform-timeoutduration5sseedPer-retry timeout in INFORM mode.
-trap-inform-retriesint2seedMaximum retransmissions per INFORM before it's declared failed.

gNMI target flags

The gNMI subsystem is always-on by default and serves a read-only OpenConfig interfaces subset over gRPC + TLS on every device. See gNMI target reference for path coverage, subscribe semantics, and gnmic invocation examples.

FlagTypeDefaultScopePurpose
-gnmi-portint9339globalTCP port for the gNMI listener on each device.
-gnmi-disableboolfalseglobalDisable the subsystem; no device listens on the gNMI port.

UDP syslog export flags

See UDP syslog export (operator guide) for prerequisites and netcat smoke-test, and UDP syslog reference for wire format and catalog JSON.

FlagTypeDefaultScopePurpose
-syslog-collectorstringseedEnable syslog export to this UDP collector (e.g. 192.168.1.10:514) for the auto-start batch. Empty disables seeding; REST-created devices can still opt in via the syslog block.
-syslog-format5424 | 31645424seedWire format. RFC 5424 is structured (recommended); RFC 3164 is legacy BSD. Per-device as of phase 5 — different devices can emit different formats to the same collector; the shared-socket pool is keyed by (collector, format) so streams never interleave.
-syslog-intervalduration10sseedPer-device mean firing interval (Poisson-distributed, not periodic).
-syslog-global-capint (rate)0globalSimulator-wide rate ceiling across scheduled fires. On-demand HTTP fires bypass the cap. 0 is unlimited.
-syslog-catalogstringglobalPath to a JSON catalog; empty uses the embedded universal 6-entry catalog + per-type overlays from resources/<slug>/syslog.json. Setting this flag disables per-type overlays — the file becomes the sole catalog for every device.
-syslog-source-per-devicebooltrueglobalUse each device's IP as the UDP source address. Per-device bind failures are non-fatal (unlike INFORM mode on the trap side) — the exporter falls back to the shared socket with a warning.

Examples

# Start server only (all interfaces up/up by default)
sudo ./nl6

# Auto-create 5 devices starting from 192.168.100.1
sudo ./nl6 -auto-start-ip 192.168.100.1 -auto-count 5

# Custom API port and subnet
sudo ./nl6 -auto-start-ip 10.10.10.1 -auto-count 100 -port 9090

# Non-privileged SNMP port (no CAP_NET_BIND_SERVICE needed)
sudo ./nl6 -auto-start-ip 10.10.10.1 -auto-count 10 -snmp-port 1161

# SNMPv3 with MD5 auth and AES128 privacy
sudo ./nl6 -snmpv3-engine-id 0x80001234 -snmpv3-auth md5 -snmpv3-priv aes128

# Disable network namespace isolation
sudo ./nl6 -no-namespace -auto-start-ip 192.168.100.1 -auto-count 10

# Maintenance window — all interfaces admin-shutdown
sudo ./nl6 -auto-start-ip 192.168.100.1 -auto-count 10 -if-scenario 1

# Link failure — all interfaces admin-up but oper-down
sudo ./nl6 -auto-start-ip 192.168.100.1 -auto-count 10 -if-scenario 3

# Partial outage — 30% of interfaces oper-down
sudo ./nl6 -auto-start-ip 192.168.100.1 -auto-count 10 \
-if-scenario 4 -if-failure-pct 30