SNMP on Zephyr: zephyr-snmp works on a Teensy 4.1
Zephyr has no SNMP agent of its own. The external module simpleiot/zephyr-snmp fills that gap. It is a port of the lwIP SNMP agent to the native Zephyr network stack, and it supports SNMP v1 and v2c over IPv4. We tested release v0.1.0 (commit 1c52aa6) on real hardware. It works.
Test setup
- Board: PJRC Teensy 4.1 (NXP i.MX RT1062, Cortex-M7 at 600 MHz).
- Zephyr v4.4.2, Zephyr SDK 1.0.1 (GCC 14.3).
- Network: Ethernet over the USB cable (USB CDC-NCM), so the board needs no Ethernet connector. The PC uses the Linux
cdc_ncmdriver and bridges the USB link to its wired LAN, so the board is reachable from the lab network. - The agent runs on the shared Zephyr socket-service thread, next to a telnet shell. It has no thread of its own.
- A private MIB under the documentation enterprise number 32473 (RFC 5612) exposes six byte-sized boot counters, one of them writable, and a control object for an LED blink thread.
- Clients: Net-SNMP (
snmpwalk,snmpget,snmpset,snmptrapd) and a graphical MIB browser.
What we verified on the board
- WALK of the boot-counter subtree returns all six counters. The standard MIB-2 system group is also available.
- GET and SET work. A value written over SNMP is the same value that the serial shell shows, and the reverse.
- The agent rejects bad writes with the correct error: out-of-range integers give
wrongValue, a string giveswrongType, and a write to a read-only object givesnotWritable. - The agent stops and starts again at run time. While it is stopped, requests time out; after the restart, they get replies.
- A SET can start and stop the LED blink thread, and each LED-on event sends an SNMPv2c trap that
snmptrapdreceives. - Net-SNMP and the MIB browser both load our MIB file, and a symbolic GET returns the expected value from the board.
What it costs
From our size study of Zephyr services: the agent adds 17 KB of flash and 3.4 KB of static RAM on top of a UDP socket stack. Trap support adds 0.7 KB and a small private MIB 0.3 KB. The complete USB setup (CDC-NCM, IPv4, UDP, TCP, sockets, the SNMP agent with traps and a private MIB) is 168 KB of flash and 64 KB of static RAM, including the console, shell and logging of the reference app.
Limits to know
- No SNMPv3. With v1 and v2c, the community string travels in clear text. Use them only on a trusted management network.
- We checked the MIB file with Net-SNMP and the browser only, not with a full SMI checker such as
smilint.
Two issues filed
We found two small defects in v0.1.0 and reported them upstream, each with a workaround:
- #15: the public MIB macros use
LWIP_ARRAYSIZE, which is defined only in a private header, so the README's private-MIB example does not compile. Workaround: defineLWIP_ARRAYSIZE(x)asARRAY_SIZE(x)before includingsnmp/snmp_core.h. - #16:
snmp_init()is declared but not defined. Workaround: start the agent withnet_snmp_agent_start().
Next
We will decide later whether to contribute fixes to the project. At the moment, our work goes into something much larger. Thanks to the zephyr-snmp maintainers for a clean, Zephyr-native agent.