Simulation data

SNMP agent simulation revolves around the contents of .snmprec files.

File format

The .snmprec file format is optimised to be compact, human-readable and inexpensive to parse. It’s also important to store full and exact response information in a most intact form. Here’s an example data file content:|4|Linux SMP Tue Jun 19 14:58:11 CDT 2007 i686|6||67|233425120|4x|00127962f940|64x|c3dafe61

There is a pipe-separated triplet of OID|tag|value items where:

  • OID is a dot-separated set of numbers

  • Tag is a BER-encoded ASN.1 tag. A modifier can be appended to the tag number. The following modifiers are known:

    • x when the value is hexified (e.g. ‘0102’)
    • e when the value is a Python string literal (e.g. ‘x01x02hello’)
    • Colon-separated reference to a variation module
  • The value is either a printable string or a hexified string or a raw Python string. Unless it’s a number.

Valid tag values and their corresponding ASN.1/SNMP types are:

  • 2 - Integer32
  • 5 - NULL
  • 64 - IpAddress
  • 65 - Counter32
  • 66 - Gauge32
  • 67 - TimeTicks
  • 68 - Opaque
  • 70 - Counter64

Managing data files

The tool is designed to perform a few handy operations on the data files.

If you possess .snmpwalk or .sapwalk snapshots and wish to convert them into Simulator’s native .snmprec data file format (what can be required for using variation modules), run the tool like this:

$ --input-file=linux.snmpwalk --source-record-type=snmpwalk|4|Linux cray #2 SMP Sat Apr 9 23:39:07 CDT 2011 i686|6||67|121722922|4|Root <root@cray> (configure /etc/snmp/snmp.local.conf)|4|new system name|4|KK12 (edit /etc/snmp/snmpd.conf)|67|0|6||6||6|
# Records: written 3711, filtered out 0, deduplicated 0, broken 0, variated 0

SNMP Simulator requires data files to be sorted (by OID) and containing no duplicate OIDs. In case your data file does not comply with these requirements for some reason, you could pass it through the tool to fix data file:

$ --input-file=tcp-mib.snmprec --sort-records
  --ignore-broken-records --deduplicate-records|2|1|2|4|2|2|2|4
# Records: written 33, filtered out 0, deduplicated 0, broken 0, variated 0

If you have a huge data file and wish to use just a part of it for simulation purposes, tool could cut a slice form a data file and store records in a new one:

$ --input-file=tcp-mib.snmprec --start-oid=
# Records: written 5, filtered out 28, deduplicated 0, broken 0, variated 0

Merge of multiple data files into a single data file is also supported:

$ --input-file=tcp-mib.snmprec --input-file=udp-mib.snmprec
  --sort-records --deduplicate-records|2|1|2|4|2|2|2|4
# Records: written 49, filtered out 0, deduplicated 0, broken 0, variated 0

Having string values more human-readable may be more convenient in the course of adjusting simulation data, debugging etc. By default, strings in simulation data are hexified. By passing such .snmprec file through the –escaped-strings call, you can convert your .snmprec data into Python string literal representation:

$ head data/sample.snmprec|4x|00127962f940
$ --source-record-type=snmprec  --input-file=data/sample.snmprec
# Records: written 1, filtered out 0, deduplicated 0, broken 0, variated 0