API Reference snmpkit v#2.0.1

Modules

Unified API for SnmpKit - A comprehensive SNMP toolkit for Elixir.

An SNMP agent: exposes your application's own data to managers over SNMPv1, v2c and v3.

Behaviour for a module that serves one subtree of an agent's MIB.

Answers one request PDU against an agent's registered subtrees: GET, GETNEXT, GETBULK and SET with SNMPv1 and SNMPv2c/v3 semantics (RFC 1157, RFC 3416, and the v1/v2 error mapping of RFC 3584). Used by SnmpKit.Agent; it has no state of its own.

Scalars kept in an ETS table: the handler behind SnmpKit.Agent.put/4.

Serves a conceptual table from rows produced by a function.

MIB (Management Information Base) operations.

Abstract Syntax Tree definitions for MIB compilation.

Name/OID table and curated syntax metadata for the standard objects SnmpKit knows without loading any MIB file (SNMPv2-MIB, IF-MIB, IP-MIB, TCP-MIB, UDP-MIB, HOST-RESOURCES-MIB, BRIDGE-MIB, Q-BRIDGE-MIB, DOCS-IF-MIB and friends).

Main MIB compiler that orchestrates the entire compilation process.

Interprets SMIv2 DISPLAY-HINT strings (RFC 2579 section 3.1) for OCTET STRING and INTEGER values.

Enhanced error handling with recovery and detailed diagnostics.

Turns parsed or compiled MIB data into the name_to_oid / name_to_meta maps the registry merges: object OIDs, base syntax, textual conventions, display hints, access, status and description.

Semantic checks for a parsed or compiled MIB, in the spirit of libsmi's smilint levels 1 and 2. The parser only decides whether a file is syntactically a MIB; this module checks whether it makes sense: do all OIDs resolve, are the referenced types and objects defined or imported, do table rows have indexes, do SEQUENCE fields match their columns, and is the module consistent with the SMI version it claims.

Structured logging for MIB compilation with proper log levels.

Pure native SNMP MIB parser using custom Elixir grammar.

Preprocessor for MIB files to handle problematic constructs before parsing.

Static name/OID resolution over the built-in MIB table.

Pure functions over name->OID and OID->name maps: forward and reverse lookups (with instance suffixes), children, subtree walks and normalisation of parsed OID representations. SnmpKit.SnmpMgr.MIB holds the maps; this module never touches process state, so it is safe to call from anywhere.

True 1:1 Elixir port of Erlang SNMP tokenizer (snmpc_tok.erl).

Turns the syntax terms produced by the MIB grammar into a small description: base type, textual convention, DISPLAY-HINT and enumeration labels.

Decodes the instance sub-identifiers of a conceptual row into the values of the table's INDEX objects (RFC 2578 section 7.7).

Direct port of Erlang snmpc_lib.erl utility functions to Elixir.

SNMP client operations for querying and managing SNMP devices.

Deltas and per-second rates from successive SNMP samples, with Counter32 and Counter64 wraparound handled.

Guarded file access for user-supplied inputs: walk files, JSON/YAML profiles, MIB sources and compiled MIBs, whether they reach the simulator, the MIB compiler, the linter or the manager's MIB registry.

SNMP device simulation for testing and development.

Protocol layer of SnmpKit: RFC-compliant PDU encoding and decoding, ASN.1 BER, OID utilities, SNMP data types, UDP transport, a low-level manager and the SNMPv3 User-based Security Model.

Comprehensive ASN.1 BER (Basic Encoding Rules) encoding and decoding utilities.

Standard SNMP error handling and error code utilities.

Error handling for SNMP operations: retry with exponential backoff, error classification, adaptive timeouts and device quarantine.

Comprehensive host and port parsing for all possible input formats.

High-level SNMP management operations providing a simplified interface for common SNMP tasks.

Socket handling and the request/response cycle for SnmpKit.SnmpLib.Manager: encoding the PDU into a message, sending with retries, and waiting for the response whose request id matches while ignoring stray datagrams.

Turns decoded SNMP response messages into the manager's result tuples: GET / GETNEXT / GETBULK / SET result extraction and error-status decoding (RFC 1157 and RFC 3416 error codes).

SNMPv3 (USM) request path for the manager: engine discovery, key localization, time synchronisation, and the report-driven retries RFC 3414 requires.

Comprehensive OID (Object Identifier) manipulation utilities for SNMP operations.

SNMP PDU (Protocol Data Unit) encoding and decoding with RFC compliance.

High-level PDU and message building functions for SNMP operations.

Constants and type definitions for SNMP PDU operations.

ASN.1 BER decoding functions for SNMP PDUs and messages.

ASN.1 BER encoding functions for SNMP PDUs and messages.

SNMPv3 message encoding and decoding with User Security Model (USM) support.

SNMPv3 security framework.

Authentication protocols for SNMPv3 User Security Model.

Remembers what the manager has learned about remote SNMPv3 engines: the authoritative engine id of each {host, port} and its boots/time, so a request does not need a discovery round trip and a time synchronisation every time.

Key derivation and management for SNMPv3 User Security Model.

Implements SNMPv3 privacy protocols for message encryption and decryption.

User Security Model (USM) implementation for SNMPv3 - RFC 3414 compliant.

UDP transport layer for SNMP communications.

SNMP data type validation, formatting, and coercion utilities.

Human-readable formatting and parsing helpers for SNMP values: uptime from TimeTicks, IP addresses, byte counts, rates, hex strings. SnmpKit.SnmpLib.Types delegates here.

Range and shape validation for SNMP values (Counter32/64, Gauge32, TimeTicks, Unsigned32, INTEGER, OCTET STRING, OID, IpAddress, Opaque). SnmpKit.SnmpLib.Types delegates here.

Common utilities for SNMP operations including pretty printing, data formatting, timing utilities, and validation functions.

Efficient SNMP table walking with bulk operations and streaming support.

Lightweight SNMP client library for Elixir.

Intelligent SNMP walk operations with adaptive parameter tuning.

Advanced SNMP bulk operations using GETBULK (SNMPv2c or SNMPv3).

Configuration management for SnmpKit.SnmpMgr.

Core SNMP operations using Erlang's SNMP PDU functions directly.

The manager's shared UDP socket and response correlator.

SNMP error handling and error code translation.

SNMP data formatting and presentation utilities.

MIB compilation and symbolic name resolution.

High-performance concurrent multi-target SNMP operations.

Sends SNMP notifications: v2c/v1 traps (fire and forget) and v2c informs (acknowledged by the receiver).

Performance benchmarking and profiling tools for SNMP operations.

Atomic request ID generator using ETS for thread-safe counter operations.

High-performance streaming SNMP operations for memory-efficient processing.

Table processing utilities for SNMP table data.

Target parsing and validation for SNMP requests.

SNMP data type handling and conversion.

Handles iterative SNMP walks for one or many targets.

SNMP walk operations using iterative GETNEXT requests.

Top-level API for the SNMP device simulator.

Configuration system for enhancing walk files with realistic behaviors. Provides easy-to-use behavior presets and customization options.

Efficient GETBULK implementation for SNMPv2c. Handles non-repeaters, max-repetitions, and response size management.

Configuration management for SnmpSim with support for JSON and YAML files.

High-performance UDP server for SNMP request handling. Supports concurrent packet processing with minimal latency.

Agent-side SNMPv3 User-based Security Model for simulated devices (RFC 3414): engine identity, boots and time, per-user localized keys, authentication and privacy on both directions, and the usmStats reports that drive a manager's discovery and time synchronisation.

Implement realistic correlations between different metrics.

Lightweight Device GenServer for handling SNMP requests. Uses shared profiles and minimal device-specific state for scalability.

Error injection functionality for SNMP device simulation. Handles various error conditions like timeouts, packet loss, SNMP errors, and malformed responses.

Uptime of a simulated device, derived from the monotonic clock at which the device started. Used for sysUpTime.0, ifLastChange and the sysUpTime carried by notifications the device sends.

State machine and helpers for DOCSIS modem firmware upgrade simulation.

OID handling and value generation for SNMP device simulation. Handles dynamic OID value generation, interface statistics, and MIB walking.

Handles SNMP PDU processing for devices.

Simplified PDU processor for devices with walk data. Handles GET, GETNEXT, and GETBULK requests using walk file data with support for dynamic counters and gauges.

Device Type Distribution for realistic device type assignment across port ranges. Supports mixed device populations for authentic testing environments.

Inject realistic error conditions for comprehensive testing.

Lazy Device Pool Manager for on-demand device creation and lifecycle management. Supports 10K+ devices with minimal memory footprint through lazy instantiation.

Automatically determine realistic behaviors from MIB object definitions. Analyze object names, descriptions, and types to infer simulation patterns.

MIB Compiler for SNMP Simulator (Elixir)

Memory-efficient shared OID profiles using ETS tables. Reduces memory from 1GB to ~10MB for 10K devices by sharing profile data.

Optimized OID tree for fast lookups and lexicographic traversal. Supports GETNEXT operations and GETBULK bulk retrieval.

Provides utility functions for PDU manipulation.

Flexible profile loading supporting multiple sources and progressive enhancement. Start with simple walk files, upgrade to MIB-based simulation when ready.

Records a real device into the walk-file format the simulator loads, so a device can be captured once and replayed with SnmpKit.SnmpSim.ProfileLoader.load_profile(type, {:walk_file, path}).

Former name of SnmpKit.SafeFile (1.4.0); every function delegates to it.

Realistic time-based variations for network metrics. Implements daily, weekly, and seasonal patterns for authentic simulation.

Generate realistic values based on MIB-derived behavior patterns. Supports counters, gauges, enums, and correlated metrics with time-based variations.

Counter32/Counter64 wrap arithmetic (exact modulo 2^32 / 2^64), wrap prediction, device-specific wrap behaviour and discontinuity handling.

Device-type traffic configuration and time-of-day usage patterns (residential, business, voice, backbone, CMTS, server) used to shape simulated counter rates.

Variance, burst, smoothing and jitter functions applied to simulated rates and gauges. Randomness comes from the process RNG, which SnmpKit.SnmpSim.ValueSimulator.simulate_value/3 seeds deterministically per device/object.

Parse both named MIB and numeric OID walk file formats. Handle different snmpwalk output variations automatically.

:telemetry events emitted by SnmpKit.

Receives SNMP notifications (SNMPv1 traps, SNMPv2c traps and informs) and hands each one to a handler.

Mix Tasks

Retrieves objects from a device and prints them one per line.

Compiles MIB files or directories with the native compiler and prints the warnings the parser recorded (vendor constructs, bad literals, encoding).

Runs SnmpKit.MIB.Lint over MIB files or directories and prints the findings, one per line, followed by a summary.

Starts simulated devices and keeps them running until interrupted.

Walks a subtree and prints every object, like snmpwalk.