Mock protocol implementations for industrial gateway testing
- rust 1.93+
rectangle industrial_gateway
rectangle fixtures #line.dashed {
rectangle mock_modbus_server
rectangle mock_snmp_agent
rectangle mock_redfish_service
rectangle mock_dnp3_outstation
rectangle mock_canbus_node
}
industrial_gateway --> mock_modbus_server: Modbus TCP
industrial_gateway --> mock_snmp_agent: SNMP
industrial_gateway --> mock_redfish_service: Redfish HTTPS
industrial_gateway --> mock_dnp3_outstation: DNP3
industrial_gateway --> mock_canbus_node: CANbus| Protocol | Port | Description |
|---|---|---|
| Modbus TCP | 502 | Mock modbus server |
| SNMP | 161 | Mock snmp agent |
| Redfish | 8443 | Mock redfish service |
| DNP3 | 20000 | Mock dnp3 outstation |
| CANbus | - | Mock canbus node |
Three mocks expose an out-of-band HTTP control endpoint (CONTROL_PORT,
default 8080) so the digital-twin service can drive protocol values
with coherent plant physics instead of the built-in sawtooths:
| Mock | Endpoint | Body |
|---|---|---|
| mock-modbus-server | PUT /registers |
{"registers": {"4000": 15, "4001": 16960}} — raw 16-bit words |
| mock-dnp3-outstation | PUT /points |
{"analog_inputs": {"0": 5000000.0}} — engineering f64, unseeded indices added on demand |
| mock-snmp-agent | PUT /oids |
{"values": {"1.3.6.1.4.1.1718.4.1.3.3.1.7": 32}} — raw i64 |
Batch writes apply atomically under one lock (multi-word values can't tear mid-poll; a malformed OID rejects its whole batch). Driven addresses/points/OIDs are excluded from the sawtooth simulators from then on; untouched channels keep drifting. The protocol surfaces stay read-only (TLS authz denies protocol writes by design). Sim fixtures only — never expose the control port beyond the deployment network.
Each fixture runs in its own container for isolated testing:
# Build all fixture containers
docker-compose build
# Run all fixtures
docker-compose up
# Run specific fixture
docker-compose up mock-modbus-server# Run specific fixture locally
cargo run --bin mock-modbus-server
cargo run --bin mock-snmp-agent
# Test all fixtures
cargo test├── Cargo.toml # Workspace configuration
├── mock-modbus-server/ # Modbus TCP/RTU mock
├── mock-snmp-agent/ # SNMP agent mock
├── mock-redfish-service/ # Redfish HTTPS/JSON service mock
├── mock-dnp3-outstation/ # DNP3 outstation mock
└── mock-canbus-node/ # CANbus node mock