Skip to content

SNMP_Embedded v3.4.4 — Zero-Heap Packet Path · Hardened Parser · Bounded-Memory Proof

Latest

Choose a tag to compare

@syntax1269 syntax1269 released this 08 Sep 19:18
· 1 commit to main since this release

SNMP_Embedded v3.4.4 brings deterministic memory behavior, hardened packet
validation, and visible runtime resource statistics together in one release.
It is designed for embedded devices that must answer SNMP requests reliably for
long periods without progressive heap fragmentation caused by packet traffic.

1. True zero-heap packet path

The v3.4.0 zero-copy baseline removed packet copies but still constructed
values through std::shared_ptr, which could allocate a heap control block for
each value. v3.4.4 replaces the built-in packet-path ownership with the
move-only, pool-owning AsnPtr<T>. The pool itself carries the ownership state.

The corrected comparison is against the v3.4.0 baseline, not v3.4.1:

Packet path GET SET GETNEXT GETBULK
zero-copy, v3.4.0 baseline 11 9 9 2
classic compatibility path, v3.4.0 baseline 94 87 94 42
v3.4.4 current, both paths 0 0 0 0

The built-in callback classes use the optimized pool-owning path. The
deprecated callback bridge remains available for source compatibility with
external subclasses; new callback implementations should use the optimized
raw-value factory.

2. Hardened parser

Network data is treated as untrusted input. The decoder now rejects malformed
BER length fields that extend beyond the supplied buffer, use unsupported
forms, or exceed the supported length width. Hostile SNMP version integers are
validated as raw values before conversion to the protocol enum.

The fixes cover both the owning compatibility path and the in-place packet
path, with permanent regression coverage for truncated packets, invalid BER
lengths, deep nesting, malformed OIDs, oversized integers, malformed SET and
GETBULK requests, hostile version fields, and random packet contents.

3. Runtime statistics and bounded memory

A sketch can inspect the agent without allocating a reporting object:

SNMP_RuntimeStats stats;
snmp.getRuntimeStats(&stats);

Serial.printf("rx=%u malformed=%u rejected=%u tooBig=%u pool=%u/%u peak=%u\n",
    (unsigned)stats.packets_received,
    (unsigned)stats.malformed_packets,
    (unsigned)stats.packets_rejected,
    (unsigned)stats.too_big_responses,
    (unsigned)stats.pool_used,
    (unsigned)stats.pool_cap,
    (unsigned)stats.pool_high_water);

The snapshot provides current pool use, pool high-water, pool capacity, packet
receipts, malformed packets, community rejections, tooBig responses, pool
allocation failures, and double-release alarms.

SNMP_ENGINE_MAX_RAM_BYTES is a compile-time constant for the configured
engine footprint. It accounts for the ASN pool arena, packet buffer, and
worst-case VarBind array.

Hardware verification

Reference platform: ESP8266 ESP-01, 80 MHz, 768-byte packet profile.

  • One-minute flood soak: 181 operations, 0 failures.
  • Five-minute flood soak: 928 operations, 0 failures on the clean run.
  • Pool high-water: 27 of 33 slots.
  • Heap diagnostic drift: zero net drift in the clean soak measurements.
  • Alarms, crashes, and reboots: 0, 0, and 0.

Network-hardness verification

Malformed and hostile packet shapes were replayed against the live agent,
including truncated and overrun lengths, indefinite forms, deep nesting,
malformed OIDs, oversized integers, malformed SET and GETBULK requests,
hostile version fields, all-zero and all-0xff data, random garbage, and
prefix truncations.

Across three campaigns:

  • 16,387 hostile datagrams were transmitted.
  • 615 of 615 liveness probes were answered.
  • The pool remained at 27/33 high-water occupancy.
  • There were 0 alarms, 0 crashes, and 0 reboots.
  • Malformed packets were rejected without destabilizing the agent.

Compatibility

The normal agent lifecycle and sketch-facing handler API remain compatible.
The default in-place packet path is selected by SNMP_ZERO_COPY=1; the owning
compatibility path remains available with SNMP_ZERO_COPY=0. The SNMP_NO_TRAPS
and SNMP_NO_BUILTIN_SYSUPTIME footprint flags remain available for builds
that do not need those features.

Validation summary

  • Built-in packet paths: zero heap allocations per GET, SET, GETNEXT, and
    GETBULK in the v3.4.4 allocation census.
  • Malformed BER and hostile-version regression cases: passing.
  • ESP8266 flood soaks: passing with stable pool occupancy and no alarms.
  • ESP8266 hostile network campaigns: passing with full liveness recovery.

See README.md for the progressive overview and
SNMP_Embedded_Technical_Manual.md for
complete API and configuration details.