1. Summary
SNMP Trap Sender simulates a network device that sends SNMP notifications. It can send a periodic heartbeat, simulate a reboot, take a network interface down and up, and send free-text test messages or load-test bursts, as SNMPv1 traps, SNMPv2c traps or informs, or SNMPv3 traps or informs, to one or more trap receivers.
It ships with its own MIB, TRAPSIM-MIB. Uploaded to a trap receiver, it
lets the receiver show every simulated notification by name. Standard
events use SNMPv2-MIB (coldStart, warmStart) and IF-MIB (linkDown,
linkUp), which every receiver already knows.
It runs as a systemd service on Rocky Linux 9, either in a VM or in a Proxmox LXC container, is controlled from a web GUI in English or Norwegian, and installs from one file without internet access. It is the counterpart of SNMP Trap Receiver 2.0.
2. Purpose and scope
Simulates |
One network device with name, SNMPv1 agent address, SNMPv3 engine ID, |
Sends |
SNMPv1 Trap-PDU, SNMPv2c Trap and InformRequest, SNMPv3 Trap and InformRequest (USM: noAuthNoPriv, authNoPriv, authPriv; MD5, SHA-1, SHA-2; DES, 3DES, AES-128/192/256) over UDP/IPv4 and UDP/IPv6 |
Events |
Heartbeat, reboot (announced, cold/warm start, device up), interface down/up (IF-MIB and TRAPSIM-MIB), test message |
Scenarios |
Reboot with downtime, interface flap (repeated down/up), burst at a fixed rate |
Schedules |
Any event repeated every N seconds, for example a heartbeat every 60 s |
Does not |
Answer SNMP GET requests, act as a real agent, or receive traps |
3. Architecture
Rocky Linux 9 (VM or Proxmox LXC)
┌───────────────────────────────────────────────────────────────┐
│ snmp-trap-sender.service (user trapsender) │
│ │
│ ┌──────────────┐ ┌────────────────────────────────────────┐ │
│ │ Flask app on │ │ Engine: thread + asyncio event loop │ │
│ │ Waitress ├─►│ send() schedules scenarios │ │
│ │ (8 threads) │ │ one pysnmp SnmpEngine per target │ │
│ └──────▲───────┘ └──────────┬───────────────────┬─────────┘ │
│ │ │ │ │
│ state.json (device, │ history (2000) │ │
│ targets, schedules) │ + sent_traps.jsonl│ │
└─────────┼─────────────────────┼───────────────────┼───────────┘
│ HTTP 8082 │ UDP → 162 │ UDP → 162
┌────┴────┐ ┌───────┴────────┐ ┌───────┴────────┐
│ browser │ │ trap receiver 1│ │ trap receiver 2│
└─────────┘ └────────────────┘ └────────────────┘
One process contains everything. All SNMP traffic runs in one asyncio event
loop in its own thread. Web requests hand work to that loop with
run_coroutine_threadsafe and wait for the result. Schedules and
scenarios are asyncio tasks in the same loop, so they never block the GUI.
The engine keeps one pysnmp SnmpEngine per target. When several targets
share one engine, pysnmp’s high-level API also sends later notifications to
the targets of earlier calls. Separate engines avoid that, and they also
let a v3 target use the device’s own engine ID. An engine is rebuilt when
its target or the engine ID changes.
3.1. Modules
| Module | Responsibility |
|---|---|
|
The event catalogue: OID per event, parameters, validation, and how each event becomes variable bindings |
|
|
|
Simulated device, targets and schedules in |
|
|
|
Flask GUI and JSON API: login, CSRF, security headers |
|
GUI texts in English and Norwegian (196 keys; both languages must have the same keys) |
|
Shows the user manual ( |
|
End-to-end test with a temporary local receiver |
|
Command line: |
|
The simulator’s MIB |
4. Events
Every notification starts with sysUpTime.0 (the simulated device’s
uptime) and snmpTrapOID.0. For SNMPv1 targets, snmpTrapAddress.0 is
added when an agent address is set. pysnmp uses it as the agent-addr
field of the Trap-PDU (RFC 3584), and it converts the notification OID into
the v1 enterprise, generic-trap and specific-trap fields.
| Event | Notification | Variables |
|---|---|---|
Heartbeat |
|
tsimDeviceName, tsimSequence (1, 2, 3 … since the last reboot), tsimInterval |
Reboot announced |
|
tsimDeviceName, tsimRebootReason, tsimDowntime, tsimMessage |
Device up |
|
tsimDeviceName, tsimRebootReason, tsimDowntime |
Interface down / up |
|
tsimDeviceName, tsimIfIndex, tsimIfName, tsimIfAlias, tsimSeverity, tsimMessage |
Test message |
|
tsimDeviceName, tsimSeverity, tsimMessage |
coldStart / warmStart |
|
– |
linkDown / linkUp |
|
ifIndex.n, ifAdminStatus.n = up(1), ifOperStatus.n = down(2) / up(1), plus ifName.n and ifAlias.n as many vendors add them |
Parameters are validated on the server: ifIndex 1…2147483647, downtime 0…86400 s, severity and reason from the MIB enumerations, interface name and description up to 64 characters, message up to 255.
5. TRAPSIM-MIB
The MIB is SMIv2 and passes smilint -l 6 (libsmi’s strictest level)
without remarks. It sits under enterprise 32473, which IANA reserves for
documentation and examples (RFC 5612), so it never collides with a real
vendor’s OIDs.
1.3.6.1.4.1.32473 example (RFC 5612)
└─ .1 trapSimRoot
└─ .1 trapSimMIB (MODULE-IDENTITY)
├─ .0 trapSimNotifications
│ ├─ .1 tsimHeartbeat .4 tsimInterfaceDown
│ ├─ .2 tsimReboot .5 tsimInterfaceUp
│ ├─ .3 tsimDeviceUp .6 tsimTestMessage
├─ .1 trapSimObjects (accessible-for-notify)
│ ├─ .1 tsimDeviceName .5 tsimRebootReason .9 tsimIfAlias
│ ├─ .2 tsimSequence .6 tsimDowntime .10 tsimMessage
│ ├─ .3 tsimInterval .7 tsimIfIndex
│ └─ .4 tsimSeverity .8 tsimIfName
└─ .2 trapSimConformance (compliance and groups)
Enumerations: TrapSimSeverity = clear(1), info(2), warning(3), minor(4),
major(5), critical(6); TrapSimRebootReason = operatorRequest(1),
softwareUpgrade(2), powerFailure(3), watchdog(4), crash(5), scheduled(6).
The file is in Documentation/MIB/, in Offline-Installation/, in the
installed program (/opt/snmp-trap-sender/app/trapsender/mib/), and can be
downloaded from the Device tab.
6. Scenarios
Reboot |
Sends |
Interface flap |
For count times: interface down, wait down seconds, interface up, wait up seconds. The notifications are IF-MIB |
Burst |
count notifications of one event at rate per second. The pace follows a fixed timetable, so a slow send does not stretch the whole burst. Limits: |
Scenarios send to all enabled targets, run in the background, show their progress in the GUI, and can be cancelled. Cancelling a reboot ends the "down" state at once.
7. Schedules
A schedule repeats one event with fixed parameters every interval
seconds (1…86 400) to all enabled targets or to selected ones. The first
send happens when the schedule is started. On a fresh install, a disabled
Heartbeat schedule exists. The installer can enable it with
--heartbeat N. Schedules are saved in state.json and start again with
the service.
8. Targets
A target is one trap receiver: host name or IP address (IPv4 or IPv6), UDP port, SNMP version, trap or inform, community (v1/v2c) or USM user with protocols and keys (v3), timeout and retries (used by informs), and an enabled switch.
-
Traps are fire-and-forget. Sent means the packet left the sender, not that a receiver accepted it.
-
Informs are acknowledged by the receiver. A missing acknowledgement after the timeout and retries is shown as an error. Informs are the way to check that the receiver really got the notification.
-
SNMPv3 traps are sent with the simulated device’s engine ID as the authoritative engine. The receiver must have the same user for that engine ID. The GUI shows the line to put in SNMP Trap Receiver’s configuration (
[v3user:NAME]…engine_id = …).
Communities and v3 keys are stored in state.json (mode 0600, readable by
the service user only). They are never sent back to the browser. The edit
form shows "unchanged" and keeps the stored value when the field is left
empty.
9. Simulated device
Name |
Sent as |
Agent address |
Optional IPv4 address put into SNMPv1 traps as |
sysUpTime |
Counts from the last (simulated) reboot, in hundredths of a second, wraps at 232 |
Heartbeat sequence |
+1 per heartbeat (the same number to all targets), back to 0 at a reboot. A receiver can spot lost heartbeats from gaps. |
Engine ID |
RFC 3411 format: |
10. Web GUI and API
10.1. Pages
Send |
Quick buttons (Heartbeat, Reboot, Interface down, Interface up), a form for any event with its parameters and selected targets, scenarios, and running or recent scenarios with Cancel |
Schedules |
Table with an on/off switch per schedule; create, edit, delete |
Targets |
Table; create, edit, delete, Test (sends a test message to that target and shows the result) |
History |
The last 2000 notifications with time, notification, target, version, origin (manual, schedule, scenario, CLI) and result; filter; download the log |
Device |
Simulated device, uptime, sequence, reboots, engine ID, counters; download TRAPSIM-MIB |
Top bar |
Device up / Device rebooting (n s), device name and uptime, EN/NO, log out |
Footer |
Version, Licences, Licence report, Third-party notices |
10.2. Endpoints
| Path | Method | Purpose |
|---|---|---|
|
Session and language |
|
|
GET |
|
|
GET |
User manual in the selected language, with contents and search. The Manual button links to |
|
GET |
Event catalogue, enumerations, limits |
|
GET |
Device, uptime, down state, counters, scenarios |
|
POST |
|
|
POST |
|
|
POST |
Cancel |
|
GET/POST |
List (without secrets) / create or update |
|
POST |
Test / delete |
|
GET/POST |
Schedules |
|
POST |
On/off / delete |
|
GET |
Sent notifications with |
|
POST |
Device name and agent address / new engine ID |
|
GET |
TRAPSIM-MIB / |
|
GET |
Licence data |
10.3. Security
The same model as SNMP Trap Receiver: one password (scrypt hash), session
cookie HttpOnly + SameSite=Strict, back-off after 5 failed logins, CSRF
token on every POST, Content-Security-Policy: default-src 'self' without
inline script, X-Frame-Options: DENY, nosniff, and all values escaped
before they are shown. Request bodies are limited to 256 KB.
The sender can be used to flood a receiver (burst). Access to the GUI should therefore be limited to the people who run tests.
11. Configuration
/etc/snmp-trap-sender/config.ini (root:trapsender, 0640). Restart the
service after a change.
| Section | Key | Default | Meaning |
|---|---|---|---|
|
|
|
Web GUI address |
|
|
Login |
|
|
|
|
|
|
|
||
|
|
|
Upper limit for bursts, per second |
|
|
Largest burst |
|
|
|
Notifications kept for the History tab |
|
|
|
|
|
|
|
|
|
|
|
Log rotation |
Targets, schedules and the device are edited in the GUI and stored in
state.json.
12. Log format
Each line of sent_traps.jsonl is one sent notification:
{"id": 42, "time": "2026-10-02 12:20:53", "ts": 1790936453.2,
"event": "sim_if_down", "trap": "TRAPSIM-MIB::tsimInterfaceDown",
"origin": "manual", "target": "Receiver", "target_id": "1cce00181e",
"dest": "172.16.101.83:162", "version": "v2c", "notify": "trap",
"params": {"if_index": 1, "if_name": "GigabitEthernet0/1",
"if_alias": "Uplink", "severity": "major",
"message": "Fibre cut on uplink"},
"result": "sent", "error": "", "ms": 1.4}
result is sent, acknowledged (inform answered) or error.
13. Installation and operation
13.1. Files
Path |
Owner, mode |
Content |
|
root |
Program, Python environment, documentation; |
|
root:trapsender, 0640 |
Configuration |
|
trapsender, 0600 |
Device, targets (with secrets), schedules |
|
trapsender, 0750 |
|
|
root, 0755 |
Command line |
13.2. systemd and LXC
The service runs as the system user trapsender with no capabilities.
Sending to port 162 needs no privileges, because the source port is a
random high port. The unit itself only sets NoNewPrivileges, an empty
CapabilityBoundingSet and UMask=0027, which works in every container.
Further sandboxing is in a drop-in, snmp-trap-sender.service.d/hardening.conf
(ProtectSystem=strict, PrivateTmp, PrivateDevices,
ProtectKernel*, RestrictNamespaces, RestrictAddressFamilies, …). It
needs mount namespaces. They work in VMs and in Proxmox LXC containers with
nesting turned on, the default for new unprivileged containers. Without
nesting, systemd stops the service with status=226/NAMESPACE. The
installer notices this, removes the drop-in, starts again and says so.
--no-hardening skips the drop-in from the start.
The service does not listen on any SNMP port, so only the web port needs to be open.
13.3. Command line
|
Run (used by systemd) |
|
Web password (root) |
|
Add a target; restart the service afterwards |
|
Send one event now, e.g. |
|
End-to-end test (see Verification) |
|
13.4. Offline installer
The same design as SNMP Trap Receiver. A bash header checks the SHA-256 of
the appended archive with python3, unpacks it with the safe tarfile
data filter and starts install.sh. That script checks OS, Python 3.9,
architecture, glibc ≥ 2.34 and file checksums. It then builds a virtual
environment from the bundled wheels only (no network), installs program,
user, configuration and systemd unit, optionally adds a target and
heartbeat, starts the service, waits for /healthz and runs the self-test.
An upgrade keeps configuration, state.json and logs, and moves the
previous program to .previous/.
build-offline-installer.sh builds it on any machine with internet. It
downloads the wheels in Application/requirements.lock for CPython 3.9 on
x86_64 and aarch64, generates the licence files and the GPL scan, verifies
an offline install with Python 3.9 when the build machine has it, and runs
pip-audit when installed.
14. Verification
snmp-trap-sender selftest starts a pysnmp receiver on a free port on
127.0.0.1 (community selftest plus one SHA-256/AES-128 v3 user for the
sender’s engine ID) and uses temporary directories. It checks:
-
state.jsonhas mode 0600; four targets (v1, v2c trap, v2c inform, v3 authPriv) are saved; an invalid host is refused; -
every one of the 10 events is received through all four targets with the right
snmpTrapOID; the versions v1, v2c and v3 arrive; informs are acknowledged; the v1 agent address is the simulated one; the heartbeat carries device name and sequence 1;linkDowncarries ifIndex, ifAdminStatus = up and ifOperStatus = down; -
the reboot scenario produces
tsimReboot→coldStart→tsimDeviceUpand resetssysUpTime, sequence and reboot counter; a flap ×2 with both styles produces 8 notifications; a burst of 40 at 100/s takes between 0.3 and 3 s and delivers all 40; -
a 1 s heartbeat schedule produces increasing sequence numbers; history and log are written; an inform to a port without a receiver reports an error;
-
web: login, wrong password, English default, CSRF, sending through the API, refusal of invalid parameters, no secrets in the target list, editing a target keeps its keys, starting a scenario, MIB download, user manual in English and Norwegian, Norwegian page, security headers, licence inventory and documents in both languages.
The installer runs the self-test after every installation (46 checks).
15. Limits
-
HTTP only; put a TLS reverse proxy in front or use an SSH tunnel across untrusted networks.
-
One simulated device per installation. For several devices, run several containers.
-
The simulator does not answer SNMP GET, so a receiver that polls the device after a trap gets no answer.
-
Measured on one core: about 1000 v2c traps per second in a burst. The pysnmp engine is the limit.
16. Licences
All third-party components are under permissive licences. See
License-Report.md, THIRD_PARTY_NOTICES.txt and
third_party_inventory.json. TRAPSIM-MIB is part of this project and may
be used, copied and changed freely.
Appendix A: Ports
Port |
Protocol |
Direction |
Purpose |
8082 |
TCP |
in |
Web GUI (configurable) |
162 (configurable per target) |
UDP |
out |
Traps and informs to the receivers |