Skip to main content
Drive a MikroTik router as a Lager net. This is the bench’s network fault-injection tool. It lets a test assert what firmware does when the network degrades — loses the internet, loses DNS, gets slow — rather than simply disappearing.

Handle

Methods

Types

RouterSystemInfo

Method Reference

connect() -> Result<serde_json::Value>

Verify connectivity by fetching the router’s identity.

system_info() -> Result<RouterSystemInfo>

Structured resource information.

block_internet() -> Result<()>

Drop all forwarded traffic, simulating an internet outage while leaving the local network — and the DUT’s association to it — intact.

remove_firewall_rules() -> Result<()>

Remove every firewall rule Lager added. This is the undo for block_internet and anything added through command().
Rules persist on the router until removed. A test that blocks the internet and then fails without cleaning up leaves the next test running on a broken network. Put remove_firewall_rules() in a teardown path that runs even on failure.

enable_interface(interface: &str) and disable_interface(interface: &str)

Enable or disable an interface by name — use these when you want the access point to vanish entirely, rather than to lose routing.

set_wireless_ssid(interface: &str, ssid: &str) -> Result<serde_json::Value>

Change the broadcast SSID.

command(action: &str, params: serde_json::Value) -> Result<serde_json::Value>

The generic escape hatch: invoke any other router action by name with raw JSON parameters. Every action this page lists has a typed method, so use this only for an action a newer box adds.

add_bandwidth_limit(target: &str, max_limit: &str, queue_name: Option<&str>) -> Result<serde_json::Value>

Limit a target’s bandwidth.

Examples

Assert firmware retries instead of rebooting when the internet goes away

Squeeze the bandwidth and check an OTA still completes

Supported Hardware

Notes

  • This net sends no role hint. A router net can be saved with role router or the legacy mikrotik. The box verifies a supplied hint exactly, so a hint will fail against whichever spelling the net does not use. A consequence you will see: a missing router net reports Net 'router1' not found without naming a role, where other net types report Net 'x (role adc)' not found.
  • Every router action gets a flat 60-second budget, because reboots and reset actions are slow and a busy router lags.
  • reboot() returns as soon as the router accepts the command, not when it is back.
  • Blocking the internet does not disconnect the DUT from WiFi. That distinction is the entire point of this net type.