Giter VIP home page Giter VIP logo

snmpsim's Introduction

SNMP Simulator

PyPI Python Versions Build status GitHub license

This is a pure-Python, open source and free implementation of SNMP agents simulator distributed under 2-clause BSD license.

Features

  • SNMPv1/v2c/v3 support
  • SNMPv3 USM supports MD5/SHA/SHA224/SHA256/SHA384/SHA512 auth and DES/3DES/AES128/AES192/AES256 privacy crypto algorithms
  • Runs over IPv4 and/or IPv6 transports
  • Simulates many EngineID's, each with its own set of simulated objects
  • Varies response based on SNMP Community, Context, source/destination addresses and ports
  • Can gather and store snapshots of SNMP Agents for later simulation
  • Can run simulation based on MIB files, snmpwalk and sapwalk output
  • Can gather simulation data from network traffic or tcpdump snoops
  • Can gather simulation data from external program invocation or a SQL database
  • Can trigger SNMP TRAP/INFORMs on SET operations
  • Capable to simultaneously simulate tens of thousands of Agents
  • Offers REST API based control plane
  • Gathers and reports extensive activity metrics
  • Pure-Python, easy to deploy and highly portable
  • Can be extended by loadable Python snippets

Download

SNMP simulator software is freely available for download from PyPI and project site.

Installation

Just run:

$ pip install snmpsim

How to use SNMP simulator

Once installed, invoke snmpsim-command-responder and point it to a directory with simulation data:

$ snmpsim-command-responder --data-dir=./data --agent-udpv4-endpoint=127.0.0.1:1024

Simulation data is stored in simple plaint-text files having OID|TYPE|VALUE format:

$ cat ./data/public.snmprec
1.3.6.1.2.1.1.1.0|4|Linux 2.6.25.5-smp SMP Tue Jun 19 14:58:11 CDT 2007 i686
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.8072.3.2.10
1.3.6.1.2.1.1.3.0|67|233425120
1.3.6.1.2.1.2.2.1.6.2|4x|00127962f940
1.3.6.1.2.1.4.22.1.3.2.192.21.54.7|64x|c3dafe61
...

Simulator maps query parameters like SNMP community names, SNMPv3 contexts or IP addresses into data files.

You can immediately generate simulation data file by querying existing SNMP agent:

$ snmpsim-record-commands --agent-udpv4-endpoint=demo.snmplabs.com \
    --output-file=./data/public.snmprec
SNMP version 2c, Community name: public
Querying UDP/IPv4 agent at 195.218.195.228:161
Agent response timeout: 3.00 secs, retries: 3
Sending initial GETNEXT request for 1.3.6 (stop at <end-of-mib>)....
OIDs dumped: 182, elapsed: 11.97 sec, rate: 7.00 OIDs/sec, errors: 0

Alternatively, you could build simulation data from a MIB file:

$ snmpsim-record-mibs --output-file=./data/public.snmprec \
    --mib-module=IF-MIB
# MIB module: IF-MIB, from the beginning till the end
# Starting table IF-MIB::ifTable (1.3.6.1.2.1.2.2)
# Synthesizing row #1 of table 1.3.6.1.2.1.2.2.1
...
# Finished table 1.3.6.1.2.1.2.2.1 (10 rows)
# End of IF-MIB, 177 OID(s) dumped

Or even sniff on the wire, recover SNMP traffic there and build simulation data from it.

Besides static files, SNMP simulator can be configured to call its plugin modules for simulation data. We ship plugins to interface SQL and noSQL databases, file-based key-value stores and other sources of information.

We maintain publicly available SNMP simulator instance at demo.snmplabs.com. You are welcome to query it as much as you wish.

Besides stand-alone deployment described above, third-party SNMP Simulator control plane project offers REST API managed mass deployment of multiple snmpsim-command-responder instances.

Documentation

Detailed information on SNMP simulator usage could be found at snmpsim site.

Getting help

If something does not work as expected, open an issue at GitHub or post your question on Stack Overflow or try browsing snmpsim mailing list archives.

Feedback and collaboration

I'm interested in bug reports, fixes, suggestions and improvements. Your pull requests are very welcome!

Copyright (c) 2010-2019, Ilya Etingof. All rights reserved.

snmpsim's People

Contributors

aquette avatar derber avatar etingof avatar landy2005 avatar mlesyk avatar timlegge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snmpsim's Issues

couldn't create a lot for simulator.

hi.

i can created 1013 simulator.
but i will should create 2026 simulator.
And it was experiencing the following error.

[root@seob ~]# cat ips.txt | wc -l
2026

[root@seob ~]# snmpsimd.py --args-from-file=/root/ips.txt --data-dir=/usr/lib/python2.7/site-packages/snmpsim-0.3.0-py2.7.egg/snmpsim/data --v2c-arch --process-user=root --process-group=root --daemonize --pid-file=/root/snmpsimd.pid
ERROR: socket() failed: [Errno 24] Too many open files

can simulator create a lot ?

Abilty for record strings as Plain text.

I have old and new versions of snmprec:

Old version record string values as plain text.
snmprec --agent-udpv4-endpoint=x.x.x.x --start-oid=1.3.6.1.2.1 --stop-oid=1.3.6.1.2.1.1 --output-file=aix.snmprec

old (0.2.4):

1.3.6.1.2.1.1.1.0|4|AIX su0506 3 5 00C6E81B4C00
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.8072.3.2.15
1.3.6.1.2.1.1.3.0|67|1399875231
1.3.6.1.2.1.1.4.0|4|[email protected]
1.3.6.1.2.1.1.5.0|4|su0506
1.3.6.1.2.1.1.6.0|4|CDC Brno

new (0.3.1):

1.3.6.1.2.1.1.1.0|4x|414958207375303530362033203520303043364538314234433030
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.8072.3.2.15
1.3.6.1.2.1.1.3.0|67|1399644038
1.3.6.1.2.1.1.4.0|4x|706f73746d6173746572407277652d73657276696365732e637a
1.3.6.1.2.1.1.5.0|4|su0506
1.3.6.1.2.1.1.6.0|4x|4344432042726e6f

For devel purposes I prefer to use Plain strings (4) instead hex (4x).

Please add ability (command line argument) for force decode hex strings to plain in snmprec command.

AuthProtocol & PrivProtocol for incoming requests are overridden by Notification variation module

Summary
If authentication and/or privacy protocols differ between snmpsim and that configured in .snmprec for the Notification variation module, then second and subsequent SNMPv3 requests to snmpsim fail with usmStatsWrongDigests.

If for example snmpsim is configured with SHA and AES for authentication and privacy, but the Notification variation module is in use and the authentication and privacy protocols are not specified in the .snmprec file then the second and subsequent SNMPv3 requests incoming to snmpsim fail with usmStatsWrongDigests. This happens because the Notification module defaults to MD5 and DES, and these override the protocols configured in snmpsim.

Expected behaviour
The authentication and privacy protocols used by the notification module should be independent of those used for incoming SNMPv3 traffic to snmpsim.

model different devices

It would be great to host models devices. For example, I wrote a nagios check for dell openmanage devices. After changing companies, to one that did not use Dell, I was unable to continue development.

snmpsimd crashing after 10 min

Hi @etingof ,

I have been using snmpsim for simulating my hardware .On the setup I need to run multiple instances of snmp agent , and I am using the following command to run the agents:
/venv/bin/snmpsimd.py --v2c-arch --data-dir=/data --args-from-file=/data/public/ip_list.txt
--transport-id-offset=1 --process-user=root --process-group=root --daemonize --logging-method=file:/var/log/snmpsimd.log

The simulator is working fine with less nodes in the list(ip_list.txt ), but when the number of nodes is raised to 30 , the daemon is crashing with the following logs:

2018-06-27 11:33:16,225 snmpsimd: Request var-binds: 1.3.6.1.4.1.5419.6.4.1.2.1.10.30=<>, flags: EXACT, GET
2018-06-27 11:33:16,226 snmpsimd: Response var-binds: 3.6.1.4.1.5419.6.4.1.2.1.10.30=<4127>
2018-06-27 11:33:16,231 snmpsimd: Shutting down variation modules:
2018-06-27 11:33:16,231 snmpsimd: Variation module "notification" shutdown OK
2018-06-27 11:33:16,232 snmpsimd: Variation module "sql" shutdown OK
2018-06-27 11:33:16,232 snmpsimd: Variation module "redis" shutdown OK
2018-06-27 11:33:16,232 snmpsimd: Variation module "numeric" shutdown OK
2018-06-27 11:33:16,232 snmpsimd: Variation module "subprocess" shutdown OK
2018-06-27 11:33:16,232 snmpsimd: Variation module "delay" shutdown OK
2018-06-27 11:33:16,232 snmpsimd: Variation module "multiplex" shutdown OK
2018-06-27 11:33:16,233 snmpsimd: Variation module "error" shutdown OK
2018-06-27 11:33:16,233 snmpsimd: Variation module "writecache" shutdown OK
2018-06-27 11:33:16,234 snmpsimd: Process terminated
2018-06-27 11:33:16,235 snmpsimd: Traceback (most recent call last):;
2018-06-27 11:33:16,235 snmpsimd: File "/venv/bin/snmpsimd.py", line 1436, in ; transportDispatcher.runDispatcher();
2018-06-27 11:33:16,235 snmpsimd: File "/venv/local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher; raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())));
2018-06-27 11:33:16,235 snmpsimd: PySnmpError: poll error: Traceback (most recent call last):;; File "/venv/local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher; use_poll=True, map=self.__sockMap, count=1);; File "/usr/lib/python2.7/asyncore.py", line 220, in loop; poll_fun(timeout, map);; File "/usr/lib/python2.7/asyncore.py", line 201, in poll2; readwrite(obj, flags);; File "/usr/lib/python2.7/asyncore.py", line 123, in readwrite; obj.handle_error();; File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite; obj.handle_read_event();; File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event; self.handle_read();; File "/venv/local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 163, in handle_read; self._cbFun(self, transportAddress, incomingMessage);; File "/venv/local/lib/python2.7/site-packages/pysnmp/carrier/base.py", line 70, in _cbFun; self, transportDomain, transportAddress, incomingMessage;; File "/venv/bin/snmpsimd.py", line 1010, in commandResponderCbFun; encoder.encode(rspMsg), transportDomain, transportAddress;; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 663, in call; substrate = concreteEncoder.encode(value, asn1Spec, self, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode; value, asn1Spec, encodeFun, **options;; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 450, in encodeValue; chunk = encodeFun(component, asn1Spec, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 663, in call; substrate = concreteEncoder.encode(value, asn1Spec, self, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 72, in encode; value, asn1Spec, encodeFun, **options;; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 522, in encodeValue; return encodeFun(component, asn1Spec, **options), True, True;; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 663, in call; substrate = concreteEncoder.encode(value, asn1Spec, self, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode; value, asn1Spec, encodeFun, **options;; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 450, in encodeValue; chunk = encodeFun(component, asn1Spec, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 663, in call; substrate = concreteEncoder.encode(value, asn1Spec, self, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode; value, asn1Spec, encodeFun, **options;; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 502, in encodeValue; substrate += encodeFun(value[idx], asn1Spec, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 663, in call; substrate = concreteEncoder.encode(value, asn1Spec, self, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode; value, asn1Spec, encodeFun, **options;; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 450, in encodeValue; chunk = encodeFun(component, asn1Spec, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 663, in call; substrate = concreteEncoder.encode(value, asn1Spec, self, **options);; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 85, in encode; value, asn1Spec, encodeFun, **options;; File "/venv/local/lib/python2.7/site-packages/pyasn1/codec/ber/encoder.py", line 270, in encodeValue; raise error.PyAsn1Error('Impossible first/second arcs at %s' % (value,));;PyAsn1Error: Impossible first/second arcs at **3.6.1.4.1.5419.6.4.1.2.1.10.30

**;;

The daemon is running fine for 5 -10 minutes , and we are getting proper response for the oid , but after some time . the "Request var-binds" response is not correct and the oid received has an omitted "1." , i.e, we are getting "3.6.1.4.1.5419.6.4.1.2.1.10.30" instead of "1.3.6.1.4.1.5419.6.4.1.2.1.10.30" .I have taken multiple runs and every time ,I am getting the same log , with different oid values , and "1." is missing from the reply .

Can you please help me out over here.

Thanks in Advance

,
Ashish

can't using my mib file

Hello everybody:
I'm trying to simulate snmp agent so I've used snmpsim but I can't use my own mib file
here is my mib file
could any one help me on that
thanks for supporting
my mib.txt

cache-dir created with wrong ownership when using process-user flag on 0.4.6

snmpsimd.py --process-user=nobody --process-group=nogroup --cache-dir=/tmp/snmp-cache

When running the above command with version 0.4.6, the newly created snmp-cache directory is owned by the user executing snmpsimd.py. On version 0.4.5 and below, the same command creates the cache directory with ownership assigned to the configurable process-user flag, ie. nobody.

This seems like a regression after the file permission changes in the new version.

snmpbulkget doesn't seem to be supported

$ snmpbulkget -v2c -c unit_tests 127.0.0.1:11161 sysDescr.0 sysName.0
Timeout: No Response from 127.0.0.1:11161
$ snmpget -v2c -c unit_tests 127.0.0.1:11161 sysDescr.0 sysName.0
SNMPv2-MIB::sysDescr.0 = STRING: Unit Tests sysDescr
SNMPv2-MIB::sysName.0 = STRING: Unit Tests sysName

Did I miss something?

Response without variable?

Hello.

Is possible to make respond without any value/OID? E.g. when error is used.
That's what happen to me on one device in real use and I would like to reproduce it.

Thank you

snmpsim 0.4.4 error variation module crashes sim UnboundLocalError local variable 'varBinds' referenced before assignment

I'm trying to use snmpsim version 0.4.4 to simulate SNMP Error Responses using the Error Variation Module. I'm developing an SNMP Manager and need to test "out of range" error handling for RFC1592 https://tools.ietf.org/html/rfc1592, Section 3.3.6, Table 18 " SNMP ERROR values for a RESPONSE error code". We're monitoring a SNMP agent device that sometimes returns an "out of range" value of 99 instead of 0 through 18.

I'm currently trying to use the error module but I'm encountering what looks like a defect in snmmpsim when using the error module. snmpsim is crashing with this error

File "C:\Python36-32\Scripts\snmpsimd.py", line 1007, in commandResponderCbFun;    pMod.apiPDU.setVarBinds(rspPDU, varBinds);
UnboundLocalError: local variable 'varBinds' referenced before assignment;

Here are the details of what is happening. My .snmprec file contains this single line

1.3.6.1.2.1.2.2.1.6.1|4:error|status=genError

I'm starting the simulator with a command-line like

snmpsimd.py --v2c-arch --data-dir=C:\dev\snmptest\data --agent-udpv4-endpoint=127.0.0.1:1024 --variation-modules-dir=c:\Python36-32\snmpsim\variation

I'm attempting a simple SNMP GET using SNMP Research's brassd utility getone version 18.1.0.20

getone -v2c -port 1024 127.0.0.1 error 1.3.6.1.2.1.2.2.1.6.1

This request crashes snmpsim with this traceback

Process terminated
Traceback (most recent call last):;
  File "c:\python36-32\lib\site-packages\pysnmp\carrier\asyncore\dispatch.py", line 46, in runDispatcher;    use_poll=True, map=self.__sockMap, count=1);
  File "c:\python36-32\lib\asyncore.py", line 207, in loop;    poll_fun(timeout, map);
  File "c:\python36-32\lib\asyncore.py", line 150, in poll;    read(obj);
  File "c:\python36-32\lib\asyncore.py", line 87, in read;    obj.handle_error();
  File "c:\python36-32\lib\asyncore.py", line 83, in read;    obj.handle_read_event();
  File "c:\python36-32\lib\asyncore.py", line 423, in handle_read_event;    self.handle_read();
  File "c:\python36-32\lib\site-packages\pysnmp\carrier\asyncore\dgram\base.py", line 163, in handle_read;    self._cbFun(self, transportAddress, incomingMessage);
  File "c:\python36-32\lib\site-packages\pysnmp\carrier\base.py", line 70, in _cbFun;    self, transportDomain, transportAddress, incomingMessage;
  File "C:\Python36-32\Scripts\snmpsimd.py", line 1007, in commandResponderCbFun;    pMod.apiPDU.setVarBinds(rspPDU, varBinds);
UnboundLocalError: local variable 'varBinds' referenced before assignment;
;During handling of the above exception, another exception occurred:;;
Traceback (most recent call last):;
  File "C:\Python36-32\Scripts\snmpsimd.py", line 1436, in <module>;    transportDispatcher.runDispatcher();
  File "c:\python36-32\lib\site-packages\pysnmp\carrier\asyncore\dispatch.py", line 50, in runDispatcher;    raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())));
pysnmp.error.PySnmpError: poll error: Traceback (most recent call last):;;  File "c:\python36-32\lib\site-packages\pysnmp\carrier\asyncore\dispatch.py", line 46, in runDispatcher;    use_poll=True, map=self.__sockMap, count=1);;  File "c:\python36-32\lib\asyncore.py", line 207, in loop;    poll_fun(timeout, map);;  File "c:\python36-32\lib\asyncore.py", line 150, in poll;    read(obj);;  File "c:\python36-32\lib\asyncore.py", line 87, in read;    obj.handle_error();;  File "c:\python36-32\lib\asyncore.py", line 83, in read;    obj.handle_read_event();;  File "c:\python36-32\lib\asyncore.py", line 423, in handle_read_event;    self.handle_read();;  File "c:\python36-32\lib\site-packages\pysnmp\carrier\asyncore\dgram\base.py", line 163, in handle_read;    self._cbFun(self, transportAddress, incomingMessage);;  File "c:\python36-32\lib\site-packages\pysnmp\carrier\base.py", line 70, in _cbFun;    self, transportDomain, transportAddress, incomingMessage;;  File "C:\Python36-32\Scripts\snmpsimd.py", line 1007, in commandResponderCbFun;    pMod.apiPDU.setVarBinds(rspPDU, varBinds);;UnboundLocalError: local variable 'varBinds' referenced before assignment;;

Exception with Walkling snmpAgent by snmprec.py

Exception Log:
2018-08-30 01:57:25,038 snmprec: OIDs dumped: 0/32800
2018-08-30 01:57:25,077 snmprec: OIDs dumped: 65650, elapsed: 180.19 sec, rate: 182.00 OIDs/sec, errors: 0
2018-08-30 01:57:25,077 snmprec: Traceback (most recent call last):;
2018-08-30 01:57:25,077 snmprec:   File "/usr/local/lib/python2.7/dist-packages/snmpsim-0.4.5-py2.7.egg/EGG-INFO/scripts/snmprec.py", line 745, in <module>;    snmpEngine.transportDispatcher.runDispatcher();
2018-08-30 01:57:25,077 snmprec:   File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher;    raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())));
2018-08-30 01:57:25,077 snmprec: PySnmpError: poll error: Traceback (most recent call last):;;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher;    use_poll=True, map=self.__sockMap, count=1);;  File "/usr/lib/python2.7/asyncore.py", line 220, in loop;    poll_fun(timeout, map);;  File "/usr/lib/python2.7/asyncore.py", line 201, in poll2;    readwrite(obj, flags);;  File "/usr/lib/python2.7/asyncore.py", line 123, in readwrite;    obj.handle_error();;  File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite;    obj.handle_read_event();;  File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event;    self.handle_read();;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dgram/base.py", line 163, in handle_read;    self._cbFun(self, transportAddress, incomingMessage);;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/base.py", line 70, in _cbFun;    self, transportDomain, transportAddress, incomingMessage;;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun;    self, transportDomain, transportAddress, wholeMsg;;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 328, in receiveMessage;    snmpEngine, transportDomain, transportAddress, wholeMsg;;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/mpmod/rfc2576.py", line 289, in prepareDataElements;    securityModel, securityLevel, wholeMsg, msg;;  File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/secmod/rfc2576.py", line 405, in processIncomingMsg;    maxSizeResponseScopedPDU = maxMessageSize - 128;;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/univ.py", line 136, in __sub__;    return self.clone(self._value - value);;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/base.py", line 349, in clone;    return self.__class__(value, **initilaizers);;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/univ.py", line 103, in __init__;    base.AbstractSimpleAsn1Item.__init__(self, value, **kwargs);;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/base.py", line 236, in __init__;    Asn1ItemBase.__init__(self, **kwargs);;  File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/base.py", line 46, in __init__;    readOnly.update(kwargs);;ValueError: dictionary update sequence element #0 has length 11; 2 is required;;
cliu@ubuntu:~$ pip list
adium-theme-ubuntu (0.3.4)
MySQL-python (1.2.4)
pip (8.1.1)
ply (3.11)
pyasn1 (0.4.4)
pycryptodomex (3.6.4)
pysmi (0.3.1)
pysnmp (4.4.4)
setuptools (20.7.0)
snmpsim (0.4.5)
unity-lens-photos (1.0)
wheel (0.29.0)
cliu@ubuntu:~$ 

Unable to request the UDP Port

My first time with Python - I installed the 64 bit python and pip and also the snmpsim.
With help of this command "snmpsimd.py --data-dir=./data --agent-udpv4-endpoint=10.60.120.121:1025"
I was able to get the below message
"Listening at UDP/IPv4 endpoint 10.60.120.121:1025, transport ID 1.3.6.1.6.1.1.0"
Means I am able to start a UDP port on my local ip.

However when I try to execute the below command
"snmprec.py --agent-udpv4-endpoint=10.60.120.121:1025 --output-file=C:/Users/Santhoshkumar.Sekar/AppData/Local/Programs/Python/Python36/snmpsim/data/public.snmprec"
I get this error,
"SNMP Engine error: No SNMP response received before timeout"

Also attached the full logs. Please check and let me know.

Regards,
Santhosh
snmpsim.txt
snmprec.txt

Bulkget on non-existent oid table causes snmpsim to go into infinite loop

Hi,

All released versions on github have the same issue except version 0.3.0-2 which can be installed on Ubuntu via sudo apt-get install snmpsim.

snmpbulkget -v2c -c iloop ip:port 1.3.6.1.2.1.2.2.1.2 1.3.6.1.2.1.2.2.1.3 1.3.6.1.2.1.2.2.1.4 1.3.6.1.2.1.2.2.1.5 1.3.6.1.2.1.2.2.1.6 1.3.6.1.2.1.2.2.1.7 1.3.6.1.2.1.2.2.1.8 1.3.6.1.2.1.2.2.1.8 1.3.6.1.2.1.2.2.1.9

snmpsimd.py --v2c-arch --process-user=root --process-group=root --data-dir=datadir --agent-udpv4-endpoint=ip:port

iloop.snmprec.txt

Any chance of running `snmpsim` under `pypy`?

Hi,

We're trying to squeeze more performance out of snmpsim, and are attempting to get it to run in a pypy virtual environment.

However, pypy doesn't support the (deprecated) bsddb library upon which snmpsim depends. Is there a workaround or solution that you're aware of that can help us?

Cheers,
Simon.

snmpwalk terminates snmpsimd process while Simulating SNMP Agents

I have recorded oids from a device, placed the rec file in one of the folders and set up the snmpsimd as
snmpsimd --agent-udpv4-endpoint=127.0.0.1:1161
and I get:

...
Listening at UDP/IPv4 endpoint 127.0.0.1:1161, transport ID 1.3.6.1.6.1.1.0

when I do an snmpwalk (also tried snmpget with same results), like:
snmpwalk -On -v1 -c recorded/ubnt-system localhost:1161
snmpsimd process is terminated with Traceback list of calls like:

Process terminated
Traceback (most recent call last):;
File "/usr/bin/snmpsimd", line 1281, in <module>;
transportDispatcher.runDispatcher();
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher; raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())));
PySnmpError: poll error: Traceback (most recent call last):;;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher; use_poll=True, map=self.__sockMap, count=1);;  
File "/usr/lib/python2.7/asyncore.py", line 220, in loop;    
poll_fun(timeout, map);;  
File "/usr/lib/python2.7/asyncore.py", line 201, in poll2;    readwrite(obj, flags);;  
File "/usr/lib/python2.7/asyncore.py", line 123, in readwrite;    obj.handle_error();;  
File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite;    obj.handle_read_event();;  
File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event;    self.handle_read();;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 163, in handle_read;    self._cbFun(self, transportAddress, incomingMessage);; 
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/carrier/base.py", line 70, in _cbFun;    self, transportDomain, transportAddress, incomingMessage;;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun;    self, transportDomain, transportAddress, wholeMsg;;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/proto/rfc3412.py", line 433, in receiveMessage;    PDU, maxSizeResponseScopedPDU, stateReference);;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 140, in processPdu;    (self.__verifyAccess, snmpEngine));;  
File "/usr/bin/snmpsimd", line 991, in handleMgmtOperation;    PDU, acInfo;;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 262, in handleMgmtOperation;    rspVarBinds = mgmtFun(varBinds, (acFun, acCtx));;  
File "/usr/bin/snmpsimd", line 429, in readNextVars;    varBinds, **self.__getCallContext(acInfo, True);;  
File "/usr/bin/snmpsimd", line 410, in __getCallContext;    pduType ) = acCtx  # this is not [yet] documented;;TypeError: 'SnmpEngine' object is not iterable;;
...

Is there something going on with my python modules or with the simulator?

All agents at `demo.snmplabs.com` appear to be down

No socket is listening on any of the documented ports:

[09:34:48] jstorm[0]@alarbus:~$ sudo nmap -oG - -n -Pn -p 161,1161,2161,3161 -sU demo.snmplabs.com
# Nmap 7.70 scan initiated Sat Aug  4 09:34:53 2018 as: nmap -oG - -n -Pn -p 161,1161,2161,3161 -sU demo.snmplabs.com
Host: 104.236.166.95 () Status: Up
Host: 104.236.166.95 () Ports: 161/closed/udp//snmp///, 1161/closed/udp//health-polling///, 2161/closed/udp//apc-2161///, 3161/closed/udp//doc1lm///
# Nmap done at Sat Aug  4 09:34:53 2018 -- 1 IP address (1 host up) scanned in 0.50 seconds

Results are the same from multiple networks.

use Simulator on a Windows machine

from document "To use Simulator on a Windows machine, simply download and run supplied executable to install pre-compiled binaries and demo data files. "
I didn't find this executable file.

snmpsim import error while running with root

Hi

I'm trying to use snmpsim to simulate response from a switch. I need to open 161 port to get the management end fooled by snmpsim. I ran it as normal user without problems but when I ran it as root it gives-me an error.

(snmpsim-env) [root@management ~]# snmpsimd.py --data-dir ./data --agent-udpv4-endpoint=192.168.123.2:1611 --process-user=nobody --process-group=nobody
Scanning "/root/.snmpsim/variation" directory for variation modules...
Directory "/root/.snmpsim/variation" does not exist
Scanning "/root/snmpsim-env/snmpsim/variation" directory for variation modules...
Directory "/root/snmpsim-env/snmpsim/variation" does not exist
Scanning "/root/snmpsim-env/share/snmpsim/variation" directory for variation modules...
Directory "/root/snmpsim-env/share/snmpsim/variation" does not exist
Scanning "/root/snmpsim-env/lib/python2.7/site-packages/snmpsim/variation" directory for variation modules...
Directory "/root/snmpsim-env/lib/python2.7/site-packages/snmpsim/variation" does not exist
ERROR: SNMPv3 Engine initialization failed, EngineID "auto": local variable 'p' referenced before assignment
(snmpsim-env) [root@management ~]#

Regards

Exception when invoking as root using udp port 161

snmpsim loads but then fails when queried. This only happens when invoking as root on port 161. When running on a non privileged port as a user it works great.

(py36-venv) [root@vSNMP pydev]# snmpsimd.py --agent-udpv4-endpoint=192.0.0.5:161 --process-user=user1 --process-group=group1
Scanning "/root/.snmpsim/variation" directory for variation modules...
Directory "/root/.snmpsim/variation" does not exist
Scanning "/root/pydev/py36-venv/snmpsim/variation" directory for variation modules...
A total of 9 modules found in /root/pydev/py36-venv/snmpsim/variation
Scanning "/root/pydev/py36-venv/share/snmpsim/variation" directory for variation modules...
Directory "/root/pydev/py36-venv/share/snmpsim/variation" does not exist
Scanning "/root/pydev/py36-venv/lib64/python3.6/site-packages/snmpsim/variation" directory for variation modules...
Directory "/root/pydev/py36-venv/lib64/python3.6/site-packages/snmpsim/variation" does not exist
Initializing variation modules...
Variation module "delay" from "/root/pydev/py36-venv/snmpsim/variation/delay.py" loaded OK
Variation module "error" from "/root/pydev/py36-venv/snmpsim/variation/error.py" loaded OK
Variation module "multiplex" from "/root/pydev/py36-venv/snmpsim/variation/multiplex.py" loaded OK
Variation module "notification" from "/root/pydev/py36-venv/snmpsim/variation/notification.py" loaded OK
Variation module "numeric" from "/root/pydev/py36-venv/snmpsim/variation/numeric.py" loaded OK
ERROR Variation module "redis" from "/root/pydev/py36-venv/snmpsim/variation/redis.py" load FAILED: Redis connect parameters not specified
ERROR Variation module "sql" from "/root/pydev/py36-venv/snmpsim/variation/sql.py" load FAILED: database type not specified
Variation module "subprocess" from "/root/pydev/py36-venv/snmpsim/variation/subprocess.py" loaded OK
Variation module "writecache" from "/root/pydev/py36-venv/snmpsim/variation/writecache.py" loaded OK
--- SNMP Engine configuration
SNMPv3 EngineID: 0x80004fb80576534e4d502bb0ba48
  --- Data directories configuration
  SNMPv3 Context Engine ID: 0x80004fb80576534e4d502bb0ba48
  Scanning "/root/.snmpsim/data" directory for  *.dump, *.MVC, *.sapwalk, *.snmpwalk, *.snmprec data files...
  Directory "/root/.snmpsim/data" does not exist
  Scanning "/root/pydev/py36-venv/snmpsim/data" directory for  *.dump, *.MVC, *.sapwalk, *.snmpwalk, *.snmprec data files...
    Configuring /root/pydev/py36-venv/snmpsim/data/bgp.snmprec controller
    SNMPv1/2c community name: bgp
    SNMPv3 Context Name: ec50a8f4d28bcb39103379379ddc5185 or bgp
    Configuring /root/pydev/py36-venv/snmpsim/data/cisco_16_switch.snmprec controller
    SNMPv1/2c community name: cisco_16_switch
    SNMPv3 Context Name: 906aed851a6090332cfcf762181810af or cisco_16_switch
    Configuring /root/pydev/py36-venv/snmpsim/data/hp_perf.snmprec controller
    SNMPv1/2c community name: hp_perf
    SNMPv3 Context Name: 2711b75cd6dea2b25c6d9db79dff3abd or hp_perf
    Configuring /root/pydev/py36-venv/snmpsim/data/hp_perf2.snmprec controller
    SNMPv1/2c community name: hp_perf2
    SNMPv3 Context Name: c030cd1687fce01f8b29682f28f91d6d or hp_perf2
    Configuring /root/pydev/py36-venv/snmpsim/data/public.snmprec controller
    SNMPv1/2c community name: public
    SNMPv3 Context Name: 4c9184f37cff01bcdc32dc486ec36961 or public
    Configuring /root/pydev/py36-venv/snmpsim/data/1.3.6.1.6.1.1.0/127.0.0.1.snmprec controller
    SNMPv1/2c community name: 1.3.6.1.6.1.1.0/127.0.0.1
    SNMPv3 Context Name: b00e7c4780fffc4ca0a74e262dd116bc or 1.3.6.1.6.1.1.0/127.0.0.1
    Configuring /root/pydev/py36-venv/snmpsim/data/foreignformats/linux.snmpwalk controller
    SNMPv1/2c community name: foreignformats/linux
    SNMPv3 Context Name: bd63505107ebbd71e0046f4f30ce9c74 or foreignformats/linux
    Configuring /root/pydev/py36-venv/snmpsim/data/foreignformats/winxp1.snmpwalk controller
    SNMPv1/2c community name: foreignformats/winxp1
    SNMPv3 Context Name: 80212f5c9cbc92e175293565ef100834 or foreignformats/winxp1
    Configuring /root/pydev/py36-venv/snmpsim/data/foreignformats/winxp2.sapwalk controller
    SNMPv1/2c community name: foreignformats/winxp2
    SNMPv3 Context Name: da761cfc8c94d3aceef4f60f049105ba or foreignformats/winxp2
    Configuring /root/pydev/py36-venv/snmpsim/data/mib2dev/host-resources-mib.snmprec controller
    SNMPv1/2c community name: mib2dev/host-resources-mib
    SNMPv3 Context Name: e15efa7fd2910fcd23721edfe04d6f12 or mib2dev/host-resources-mib
    Configuring /root/pydev/py36-venv/snmpsim/data/mib2dev/ip-mib.snmprec controller
    SNMPv1/2c community name: mib2dev/ip-mib
    SNMPv3 Context Name: b545e61d091faca8a69f426b2bc5285d or mib2dev/ip-mib
    Configuring /root/pydev/py36-venv/snmpsim/data/mib2dev/tcp-mib.snmprec controller
    SNMPv1/2c community name: mib2dev/tcp-mib
    SNMPv3 Context Name: ce7ca72c4091055613e6f9a22279bbcc or mib2dev/tcp-mib
    Configuring /root/pydev/py36-venv/snmpsim/data/mib2dev/udp-mib.snmprec controller
    SNMPv1/2c community name: mib2dev/udp-mib
    SNMPv3 Context Name: 2193fe4afb8daee928db9dcbf9ace768 or mib2dev/udp-mib
    Configuring /root/pydev/py36-venv/snmpsim/data/public/1.3.6.1.2.1.100.1.13.0.snmprec controller
    SNMPv1/2c community name: public/1.3.6.1.2.1.100.1.13.0
    SNMPv3 Context Name: 1099b06180350d8b30b977aef5a79faa or public/1.3.6.1.2.1.100.1.13.0
    Configuring /root/pydev/py36-venv/snmpsim/data/public/1.3.6.1.2.1.100.1.2.0/__1.snmprec controller
    SNMPv1/2c community name: public/1.3.6.1.2.1.100.1.2.0/__1
    SNMPv3 Context Name: 99d7c3808c1c0725693315846b8d42ae or public/1.3.6.1.2.1.100.1.2.0/__1
    Configuring /root/pydev/py36-venv/snmpsim/data/public/1.3.6.1.6.1.1.0/127.0.0.1.snmprec controller
    SNMPv1/2c community name: public/1.3.6.1.6.1.1.0/127.0.0.1
    SNMPv3 Context Name: d4c09769d12b4ec404a0a31386bd42f6 or public/1.3.6.1.6.1.1.0/127.0.0.1
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/linksys-system.snmprec controller
    SNMPv1/2c community name: recorded/linksys-system
    SNMPv3 Context Name: 1a764f7fd0e7b0bf98bada8fe723e488 or recorded/linksys-system
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/linux-full-walk.snmprec controller
    SNMPv1/2c community name: recorded/linux-full-walk
    SNMPv3 Context Name: a172334d7d97871b72241397f713fa12 or recorded/linux-full-walk
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/solaris-system.snmprec controller
    SNMPv1/2c community name: recorded/solaris-system
    SNMPv3 Context Name: 21dd004374d17d03e3dfa074cf39d03c or recorded/solaris-system
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/udp-endpoint-table-walk.snmprec controller
    SNMPv1/2c community name: recorded/udp-endpoint-table-walk
    SNMPv3 Context Name: 441ae36bd8c97e17421768a049541373 or recorded/udp-endpoint-table-walk
    Configuring /root/pydev/py36-venv/snmpsim/data/recorded/winxp-full-walk.snmprec controller
    SNMPv1/2c community name: recorded/winxp-full-walk
    SNMPv3 Context Name: d55520dd841a3fcd0a7618889301f4ad or recorded/winxp-full-walk
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/delay.snmprec controller
    SNMPv1/2c community name: variation/delay
    SNMPv3 Context Name: 6334719eb92fc00f20e7df14ffc8f6d2 or variation/delay
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/error.snmprec controller
    SNMPv1/2c community name: variation/error
    SNMPv3 Context Name: 83e5bd723f8095e1a27fb2b404e50404 or variation/error
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex.snmprec controller
    SNMPv1/2c community name: variation/multiplex
    SNMPv3 Context Name: 1016117d6836664ee15b9b2af5642c3c or variation/multiplex
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/notification.snmprec controller
    SNMPv1/2c community name: variation/notification
    SNMPv3 Context Name: fb800ce0bec7d161fcbf0249793a2b69 or variation/notification
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/sql.snmprec controller
    SNMPv1/2c community name: variation/sql
    SNMPv3 Context Name: 3fe8eeff6b172158b39f89ca150c8b0a or variation/sql
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/subprocess.snmprec controller
    SNMPv1/2c community name: variation/subprocess
    SNMPv3 Context Name: b399244b6b33799beedc357f453a0119 or variation/subprocess
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/virtualtable.snmprec controller
    SNMPv1/2c community name: variation/virtualtable
    SNMPv3 Context Name: 329a935947144eb87ad0cdc5e08927b1 or variation/virtualtable
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/writecache.snmprec controller
    SNMPv1/2c community name: variation/writecache
    SNMPv3 Context Name: 0886e1397d572377c17c15036a1e6c66 or variation/writecache
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00000.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00000
    SNMPv3 Context Name: 14de4d7a19be68c2a09429578218d80a or variation/multiplex/00000
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00001.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00001
    SNMPv3 Context Name: 78ed3493c53f1b7769901ad4eba77a6f or variation/multiplex/00001
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00002.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00002
    SNMPv3 Context Name: a98f363190bae0bb6eb215069e4e0694 or variation/multiplex/00002
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00003.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00003
    SNMPv3 Context Name: e2846ec4e4e23399ae1bea52c3cc3f25 or variation/multiplex/00003
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00004.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00004
    SNMPv3 Context Name: f816184db84e89f16bf1a3f0f798ce6e or variation/multiplex/00004
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00005.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00005
    SNMPv3 Context Name: 3b19457c6530b5c4d41a04107aed2cdc or variation/multiplex/00005
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00006.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00006
    SNMPv3 Context Name: 4d5ef03b64553186ccb161418552d1df or variation/multiplex/00006
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00007.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00007
    SNMPv3 Context Name: db2a4a17f7826b121cd6baaf830ad714 or variation/multiplex/00007
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00008.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00008
    SNMPv3 Context Name: 2fe88e4455aa806f0e05cf234df01c89 or variation/multiplex/00008
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00009.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00009
    SNMPv3 Context Name: 6e0f5ddb1317240d8451de240210a611 or variation/multiplex/00009
    Configuring /root/pydev/py36-venv/snmpsim/data/variation/multiplex/00010.snmprec controller
    SNMPv1/2c community name: variation/multiplex/00010
    SNMPv3 Context Name: d9439360a67b45f63b56ef60b6245f54 or variation/multiplex/00010
  Scanning "/root/pydev/py36-venv/share/snmpsim/data" directory for  *.dump, *.MVC, *.sapwalk, *.snmpwalk, *.snmprec data files...
  Directory "/root/pydev/py36-venv/share/snmpsim/data" does not exist
  Scanning "/root/pydev/py36-venv/lib64/python3.6/site-packages/snmpsim/data" directory for  *.dump, *.MVC, *.sapwalk, *.snmpwalk, *.snmprec data files...
  Directory "/root/pydev/py36-venv/lib64/python3.6/site-packages/snmpsim/data" does not exist
  --- SNMPv3 USM configuration
  SNMPv3 USM SecurityName: simulator
  SNMPv3 USM authentication key: auctoritas, authentication protocol: MD5
  SNMPv3 USM encryption (privacy) key: privatus, encryption protocol: DES
  Maximum number of variable bindings in SNMP response: 64
  --- Transport configuration
  Listening at UDP/IPv4 endpoint 192.0.0.5:161, transport ID 1.3.6.1.6.1.1.0
Shutting down variation modules:
Variation module "delay" shutdown OK
Variation module "error" shutdown OK
Variation module "multiplex" shutdown OK
Variation module "notification" shutdown OK
Variation module "numeric" shutdown OK
Variation module "redis" shutdown OK
Variation module "sql" shutdown OK
Variation module "subprocess" shutdown OK
Variation module "writecache" shutdown OK
Process terminated
ERROR Traceback (most recent call last):;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher;
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 207, in loop;    poll_fun(timeout, map);
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 188, in poll2;    readwrite(obj, flags);
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 123, in readwrite;    obj.handle_error();
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 108, in readwrite;    obj.handle_read_event();
ERROR   File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 423, in handle_read_event;    self.handle_read();
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 170, in handle_read;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/base.py", line 70, in _cbFun;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/proto/rfc3412.py", line 284, in receiveMessage;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/smi/builder.py", line 426, in importSymbols;
ERROR pysnmp.smi.error.MibNotFoundError: No module __SNMPv2-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7fea663117f0>;
ERROR ;During handling of the above exception, another exception occurred:;;
ERROR Traceback (most recent call last):;
ERROR   File "/root/pydev/py36-venv/bin/snmpsimd.py", line 1466, in <module>;
ERROR   File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher;
ERROR pysnmp.error.PySnmpError: poll error: Traceback (most recent call last):;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher;;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 207, in loop;    poll_fun(timeout, map);;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 188, in poll2;    readwrite(obj, flags);;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 123, in readwrite;    obj.handle_error();;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 108, in readwrite;    obj.handle_read_event();;  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncore.py", line 423, in handle_read_event;    self.handle_read();;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 170, in handle_read;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/carrier/base.py", line 70, in _cbFun;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/proto/rfc3412.py", line 284, in receiveMessage;;  File "/root/pydev/py36-venv/lib64/python3.6/site-packages/pysnmp/smi/builder.py", line 426, in importSymbols;;pysnmp.smi.error.MibNotFoundError: No module __SNMPv2-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7fea663117f0>;caused by <class 'pysnmp.smi.error.MibNotFoundError'>: No module __SNMPv2-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7fea663117f0>;

Malformed Object ID when try to convert snmpwalk in datafile.py

I try converting snmpwalk to snmprec format:

$ datafile.py --source-record-type=snmpwalk --input-file=walk.txt
# Input file #0, processing records from the beginning till the end
Traceback (most recent call last):
  File "/usr/local/bin/datafile.py", line 202, in <module>
    oid, value = recordsSet[srcRecordType].evaluate(line, backdoor=backdoor)
  File "/usr/local/lib/python3.5/dist-packages/snmpsim/record/dump.py", line 42, in evaluate
    oid = self.evaluateOid(oid)
  File "/usr/local/lib/python3.5/dist-packages/snmpsim/record/dump.py", line 20, in evaluateOid
    return univ.ObjectIdentifier(oid)
  File "/usr/local/lib/python3.5/dist-packages/pyasn1/type/base.py", line 240, in __init__
    value = self.prettyIn(value)
  File "/usr/local/lib/python3.5/dist-packages/pyasn1/type/univ.py", line 1191, in prettyIn
    'Malformed Object ID %s at %s: %s' % (value, self.__class__.__name__, sys.exc_info()[1])
pyasn1.error.PyAsn1Error: Malformed Object ID SNMPv2-MIB::sysDescr.0 at ObjectIdentifier: None

File walk.txt attached

# pip list
Package               Version
--------------------- ----------------------
chardet               3.0.4
command-not-found     0.3
devscripts            2.16.2ubuntu3
language-selector     0.1
Magic-file-extensions 0.2
pip                   10.0.1
ply                   3.10
pyasn1                0.4.2
pycryptodome          3.4.5
pycryptodomex         3.4.7
pycurl                7.43.0
pygobject             3.20.0
PyMySQL               0.7.9
pysmi                 0.3.0
pysnmp                4.4.4
python-apt            1.1.0b1+ubuntu0.16.4.1
python-debian         0.1.27
python-systemd        231
requests              2.9.1
setuptools            20.7.0
six                   1.10.0
snmpsim               0.4.4
ssh-import-id         5.5
ufw                   0.35
unattended-upgrades   0.1
urllib3               1.22
virtualenv            15.0.1

No mib2dev from Free SNMP simulator in ubuntu 16.4

I have installed free SNMP simulator and I followed the installation instructions: https://github.com/etingof/snmpsim and everything seemed to be ok.

However, when I tried to mib2dev tool I get command not found.
When I tried to find if it exists i get:

    ~$ sudo find -name "mib2dev"
    ./.local/snmpsim/data/mib2dev

but still no mib2dev.py anywhere.

    ~/.local/snmpsim/data/mib2dev$ ls -a
    host-resources-mib.snmprec  ip-mib.snmprec  tcp-mib.snmprec  udp-mib.snmprec

I even tried reinstalling but nothing changed.
Any help would be appreciated.

variation-module-options not picking up custom notifications

I'm setting up my own notifications.snmprec locally, and want to start the simulator with it. For that I use the --variation-module-options cli option:

> snmpsimd.py ... --variation-module-options=file:./test/custom/notifications.snmprec

For testing purposes, I'm only using v1, which notifies on sysDescr.0 get request. I've replaced all instances of localhost ip address to all:

# in the original, 0.0.0.0 is 127.0.0.1

1.3.6.1.2.1.1.1.0|4:notification|op=get,version=1,community=public,proto=udp,host=0.0.0.0,port=162,ntftype=trap,trapoid=1.3.6.1.4.1.20408.4.1.1.2.0.432,uptime=12345,agentaddress=0.0.0.0,enterprise=1.3.6.1.4.1.20408.4.1.1.2,varbinds=1.3.6.1.2.1.1.1.0:s:snmpsim agent:1.3.6.1.2.1.1.3.0:i:42,value=SNMPv1 trap sender

However, I'm not seeing the simulator picking up the variation module. Nothing in the boot log shows me that. Neither does the notification log, when I send the aforementioned get request:

generateRequestMsg: Message:
 version=0
 community=public
 data=PDUs:
  trap=TrapPDU:
   enterprise=1.3.6.1.4.1.20408.4.1.1.2
   agent-addr=NetworkAddress:
    internet=127.0.0.1

   generic-trap='enterpriseSpecific'
   specific-trap=432
   time-stamp=12345
   variable-bindings=VarBindList:
    VarBind:
     name=1.3.6.1.2.1.1.1.0
     value=ObjectSyntax:
      simple=SimpleSyntax:
       string=snmpsim agent


sendPdu: MP succeeded
sendMessage: outgoingMessage queued (75 octets) 
00000: 30 49 02 01 00 04 06 70 75 62 6C 69 63 A4 3C 06 
00016: 0C 2B 06 01 04 01 81 9F 38 04 01 01 02 40 04 7F 
00032: 00 00 01 02 01 06 02 02 01 B0 43 02 30 39 30 1B 
00048: 30 19 06 08 2B 06 01 02 01 01 01 00 04 0D 73 6E 
00064: 6D 70 73 69 6D 20 61 67 65 6E 74
sendPdu: message sent
sendVarBinds: notificationHandle 1248347119, sendRequestHandle None, timeout 100
sendVarBinds: notificationHandle 1248347119, sendRequestHandle None, notification(s) sent
notification: sending Notification to CommunityData(communityIndex='s-89801506981894444', communityName=<COMMUNITY>, mpModel=0, contextEngineId=None, contextName='', tag='7195984095063770675', s
'7195984095063770675')
Response var-binds: 1.3.6.1.2.1.1.1.0=<SNMPv1 trap sender>
sendVarBinds: stateReference 1246831, errorStatus 0, errorIndex 0, varBinds [(ObjectIdentifier('1.3.6.1.2.1.1.1.0'), OctetString('SNMPv1 trap sender'))]
v2ToV1: v2Pdu ResponsePDU:
 request-id=15477247
 error-status='noError'
 error-index=0
 variable-bindings=VarBindList:
  VarBind:
   name=1.3.6.1.2.1.1.1.0
   =_BindValue:
    value=ObjectSyntax:
     simple=SimpleSyntax:
      string-value=SNMPv1 trap sender

I still see 127.0.0.1, so I conclude that the option was ignored.

Is this a bug or a wrong usage of the platform?

Just as a note on why this is important for me: I'm running the simulator in a docker container for isolation. I want to expose port 162 of the container and listen there for the notifications, so the snmpsim has to be sending the notifications to 0.0.0.0 interface.

Retransmit(doublicate) SNMP packet

hi guys
i have a question about retransmit SNMP message

I want realize next scheme
SNMP-client send SNMP packet to one SNMP-server that's will listening one port (for example 172.16.77.10:161)
On that port listening software that retransmit(doublicate) SNMP packet to two different host (for example 172.16.77.20:161 and 172.16.77.30:161 )

Can i embody this cheme?

Unable to create simulation data for IF-MIB

Hi!

I'm trying to simulate a snmp capable switch so I want to create IF-MIB data for achieving that. But when I try to create the simulation data I got a weird ValueError. I can't figure out what is happening.

Here is the output:

➜  qemu-vms git:(master) ✗ mib2dev.py --mib-module=IF-MIB 
# MIB module: IF-MIB, from the beginning till the end
# Starting table IF-MIB::ifTable (1.3.6.1.2.1.2.2)
*** Inconsistent value: Display format eval failure: b'kept acted forward but oxen': invalid literal for int() with base 16: 'kept acted forward but oxen'caused by <class 'ValueError'>: invalid literal for int() with base 16: 'kept acted forward but oxen'
*** See constraints and suggest a better one for:
# Table IF-MIB::ifTable
# Row IF-MIB::ifEntry
# Index IF-MIB::ifIndex (type InterfaceIndex)
# Column IF-MIB::ifPhysAddress (type PhysAddress)
# Value ['kept acted forward but oxen'] ? 

The snipped kept acted forward but oxen change every time I ran, as was something random to fill gaps. I can't understand from where it is coming from :-/. How can I further debug this?

I installed snmpsim from pip for python3, the version is:

➜  qemu-vms git:(master) ✗ pip3 show snmpsim        
Name: snmpsim
Version: 0.4.5
Summary: SNMP Agents simulator
Home-page: https://github.com/etingof/snmpsim
Author: Ilya Etingof <[email protected]>
Author-email: [email protected]
License: BSD
Location: /home/geckos/.local/lib/python3.6/site-packages
Requires: pysnmp
You are using pip version 9.0.3, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
➜  qemu-vms git:(master) ✗ 

I'm on Fedora 27, python 3.6.5

pcap2dev.py does not support encrypted .pcap traffic

In order to simulate a large switch, we have captured a pcap file of an snmpbulkwalk of (almost) an entire switch. However, this was done using SNMPv3 with -l authPriv, so the resulting pcap file contains encrypted SNMP traffic.

It appears that pcap2dev.py has no means to decrypt such a pcap file. Is this possible?

(and no, it was not possible to use snmprec.py to bulk-walk the switch; the host from which we walked the switch does not have snmpsim installed, and we cannot install it there for reasons).

Tag above 9 is not accepted

data error at ./data2\192.168.0.68.snmprec controller for 1.3.6.1.2.1.1.2.0: value evaluation error for tag '67', value '4 days, 15:06:46.85'

Cannot contact SNMP agent

Hi,

I am trying to simulate a Brother printer.
I use SNMP Agent Simulator on a ubuntu computer.

I recorded the data with snmprec:
snmprec --protocol-version=1 --agent-udpv4-endpoint=192.168.1.100 --start-oid=1.3.6.1.2.1.1.1.0 --stop-oid=1.3.6.1.4.1.2435.2.4.3.1240.1.3.0 --output-file=/usr/share/doc/snmpsim/examples/data/recorded/Brother.snmprec

When I run the agent with the following command:
snmpsimd --agent-udpv4-endpoint=localhost:161 --agent-udpv6-endpoint='[::1]:161' --process-user=simulator --process-group=simulator`

the installation wizard of the printer does not find the agent on the network.
I noticed that, when running the agent, I get:
Listening at UDP/IPv4 endpoint localhost:161, transport ID 1.3.6.1.6.1.1.0 Listening at UDP/IPv6 endpoint [::1]:161, transport ID 1.3.6.1.2.1.100.1.2.0

but the SNMP requests from the installation wizard are:
1.3.6.1.2.1.1.1.0
1.3.6.1.2.1.1.5.0
1.3.6.1.2.1.1.6.0
1.3.6.1.2.1.2.2.1.6.1
1.3.6.1.4.1.1240.2.3.4.5.2.6.0
1.3.6.1.4.1.2435.2.3.9.1.1.7.0
1.3.6.1.4.1.2435.2.4.3.1240.1.3.0

Maybe there is another issue, but it looks like the agent is not listening on the correct transport ID.
How can I change that? I do not find any option for that.

Thank you for your help.

variation module not given snmpEngine

Thanks for writing this Simulator; it is a great software.

Variation module notification.py reports this error when attempting to snmpget the "trigger OID":

2018-03-16 16:14:41,810 snmpsimd: data error at /home/qrobinson/.snmpsim/data/notify.snmprec controller for 1.3.6.1.4.1.5591.1.3.1.1.0: variation module not given snmpEngine

I found a thread dated from Thu, Nov 7 2013 addressing this issue here.
The error persists since updating snmpsim to the latest release (0.4.4) with pip; please advise.

Regards

There is no CPU data?

I can't find the CPU info in the public community

$ snmpwalk -v 2c -c public 127.0.0.1| grep -i cpu
$

Improve performance

Hi @etingof

Thanks for snmpsim, we are using it at https://github.com/librenms/librenms to test our software.

I was wondering if you had any tips or perhaps code improvements to speed up our tests run time. We've only just started adding data to automated tests and the time is starting to add up. Our unit tests are up to almost 9 minutes.

Unable to understand tutorial

Hi, i am new to ubantu os, But in tutorial they explained everything with the combination of ubantu only.
Can i find any youtube videos on this tutorial.please provide link

GetRequest

GetRequest command to non existing OID in capture return next data instead of noSuchIstance. GetRequest works like GetNextRequest.

snmpsimd crashing with core dump

We use snmpsim to simulate our devices, The simulator is working fine with single node, when I run more than one simulator, Simulator quit by core Dump.

I run simulator like the follow cmd on ubuntu 16.0.4:

cliu      14057  0.0  0.4 139784 33080 ?        S    Aug23  12:29 /usr/bin/python /usr/local/bin/snmpsimd.py --agent-udpv4-endpoint=10.10.10.10:161 --data-dir=./10.10.10.10 --process-user=cliu --process-group=cliu --variation-module-options=sql:dbtype:MySQLdb,host:10.10.10.2,port:3306,user:mpup,passwd:mpup,db:snmpsim_wlan --logging-method=null
root      97587  0.5  0.3 140920 31656 ?        S    20:00   0:52 /usr/bin/python /usr/local/bin/snmpsimd.py --agent-udpv4-endpoint=10.10.10.101:161 --data-dir=/home/cliu/devices/10.10.10.101/ --process-user=root --process-group=root --variation-module-options=sql:dbtype:MySQLdb,host:10.10.10.2,port:3306,user:mpup,passwd:mpup,db:snmpsim_basenm --daemonize --logging-method=file:10.10.10.101.log
root      98246  0.0  0.0  61972  3964 pts/1    S+   20:27   0:00 sudo snmpsimd.py --agent-udpv4-endpoint=10.10.10.104:161 --data-dir=/home/cliu/devices/10.10.10.104/ --process-user=root --process-group=root --variation-module-options=sql:dbtype:MySQLdb,host:10.10.10.2,port:3306,user:mpup,passwd:mpup,db:snmpsim_basenm --logging-method=file:10.10.10.104.log
root      98247  0.1  0.4 140416 33716 pts/1    S+   20:27   0:16 /usr/bin/python /usr/local/bin/snmpsimd.py --agent-udpv4-endpoint=10.10.10.104:161 --data-dir=/home/cliu/devices/10.10.10.104/ --process-user=root --process-group=root --variation-module-options=sql:dbtype:MySQLdb,host:10.10.10.2,port:3306,user:mpup,passwd:mpup,db:snmpsim_basenm --logging-method=file:10.10.10.104.log
root      98309  0.0  0.0  61972  4080 pts/24   S+   20:28   0:00 sudo snmpsimd.py --agent-udpv4-endpoint=10.10.10.103:161 --data-dir=/home/cliu/devices/10.10.10.103/ --process-user=root --process-group=root --variation-module-options=sql:dbtype:MySQLdb,host:10.10.10.2,port:3306,user:mpup,passwd:mpup,db:snmpsim_basenm --logging-method=file:10.10.10.104.log
root      98310  0.2  0.4 145700 39116 pts/24   S+   20:28   0:19 /usr/bin/python /usr/local/bin/snmpsimd.py --agent-udpv4-endpoint=10.10.10.103:161 --data-dir=/home/cliu/devices/10.10.10.103/ --process-user=root --process-group=root --variation-module-options=sql:dbtype:MySQLdb,host:10.10.10.2,port:3306,user:mpup,passwd:mpup,db:snmpsim_basenm --logging-method=file:10.10.10.104.log

And I Tried to debug the core file,But it's difficult to me to understand the debug message:

cliu@ubuntu:~/devices$ gdb python core
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...Reading symbols from /usr/lib/debug/.build-id/66/b65551cc62504bf758e2f57514d33cf3017b8f.debug...done.
done.
/home/cliu/devices/core: Permission denied.
(gdb) quit
cliu@ubuntu:~/devices$ sudo gdb python core
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...Reading symbols from /usr/lib/debug/.build-id/66/b65551cc62504bf758e2f57514d33cf3017b8f.debug...done.
done.

warning: core file may not match specified executable file.
[New LWP 98179]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/bin/python /usr/local/bin/snmpsimd.py --agent-udpv4-endpoint=10.10.10.100:'.
Program terminated with signal SIGBUS, Bus error.
#0  PyDict_GetItem (key=<optimized out>, op=<optimized out>) at ../Objects/dictobject.c:714
714	../Objects/dictobject.c: No such file or directory.
(gdb) py-bt
Traceback (most recent call first):
  File "/usr/local/lib/python2.7/dist-packages/pyasn1/type/univ.py", line 817, in __init__
    kwargs['encoding'] = self.encoding
  File "/usr/local/lib/python2.7/dist-packages/snmpsim-0.4.5-py2.7.egg/EGG-INFO/scripts/snmpsimd.py", line 290, in processVarBinds
    line = self.__recordIndex.lookup(str(univ.OctetString('.'.join(['%s' % x for x in oid]))))
  File "/usr/local/lib/python2.7/dist-packages/snmpsim-0.4.5-py2.7.egg/EGG-INFO/scripts/snmpsimd.py", line 481, in readNextVars
    varBinds, **self.__getCallContext(acInfo, True)
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 262, in handleMgmtOperation
    rspVarBinds = mgmtFun(varBinds, (acFun, acCtx))
  File "/usr/local/lib/python2.7/dist-packages/snmpsim-0.4.5-py2.7.egg/EGG-INFO/scripts/snmpsimd.py", line 1094, in handleMgmtOperation
    PDU, (None, snmpEngine)  # custom acInfo
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 140, in processPdu
    (self.__verifyAccess, snmpEngine))
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 433, in receiveMessage
    PDU, maxSizeResponseScopedPDU, stateReference)
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun
    self, transportDomain, transportAddress, wholeMsg
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/base.py", line 70, in _cbFun
    self, transportDomain, transportAddress, incomingMessage
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dgram/base.py", line 163, in handle_read
    self._cbFun(self, transportAddress, incomingMessage)
  File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event
    self.handle_read()
  File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite
    obj.handle_read_event()
  File "/usr/lib/python2.7/asyncore.py", line 201, in poll2
    readwrite(obj, flags)
  File "/usr/lib/python2.7/asyncore.py", line 220, in loop
    poll_fun(timeout, map)
  File "/usr/local/lib/python2.7/dist-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher
    use_poll=True, map=self.__sockMap, count=1)
  File "/usr/local/lib/python2.7/dist-packages/snmpsim-0.4.5-py2.7.egg/EGG-INFO/scripts/snmpsimd.py", line 1386, in <module>
    v3ContextEngineIds[-1][1].append(opt[1])
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1504, in run_script
    exec(code, namespace, namespace)
---Type <return> to continue, or q <return> to quit--- 
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 719, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/bin/snmpsimd.py", line 4, in <module>
    __import__('pkg_resources').run_script('snmpsim==0.4.5', 'snmpsimd.py')
(gdb) 

The core file is attached.
core.zip

The python pip list as follows:

cliu@ubuntu:~$ pip list
adium-theme-ubuntu (0.3.4)
MySQL-python (1.2.4)
pip (8.1.1)
ply (3.11)
pyasn1 (0.4.4)
pycryptodomex (3.6.4)
pysmi (0.3.1)
pysnmp (4.4.4)
setuptools (20.7.0)
snmpsim (0.4.5)
unity-lens-photos (1.0)
wheel (0.29.0)

Could you please help me.
Thank you very mach!

ERROR: pylibpcap package is missing!

I tried to use pcap2dev.py tool against an tcpdump file and got the issue:

[root@mimicsnmp ~]# pcap2dev.py --output-dir=/opt/SNMP_repo/tcpdumps --capture-file=net_trace_63.218.170.5.tc pdump
ERROR: pylibpcap package is missing!
Get it from http://sourceforge.net/projects/pylibpcap/
Usage: /usr/bin/pcap2dev.py [--help]
[--version]
....

I'm running a python version 2.7 and understood that I need to install the pylibpcap package but got the following issue when I tried to install that package:

[root@mimicsnmp ~]# pip install pylibpcap -vvv
Collecting pylibpcap
1 location(s) to search for versions of pylibpcap:

  • https://pypi.python.org/simple/pylibpcap/
    Getting page https://pypi.python.org/simple/pylibpcap/
    Looking up "https://pypi.python.org/simple/pylibpcap/" in the cache
    No cache entry available
    Starting new HTTPS connection (1): pypi.python.org
    "GET /simple/pylibpcap/ HTTP/1.1" 200 93
    Updating cache with response from "https://pypi.python.org/simple/pylibpcap/"
    Caching b/c date exists and max-age > 0
    Analyzing links from page https://pypi.python.org/simple/pylibpcap/
    Could not find a version that satisfies the requirement pylibpcap (from versions: )
    Cleaning up...
    No matching distribution found for pylibpcap
    Exception information:
    Traceback (most recent call last):
    File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
    File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
    wb.build(autobuilding=True)
    File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
    File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
    File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
    File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
    File "/usr/lib/python2.7/site-packages/pip/index.py", line 514, in find_requirement
    'No matching distribution found for %s' % req
    DistributionNotFound: No matching distribution found for pylibpcap
    Looking up "https://pypi.python.org/pypi/pip/json" in the cache
    Current age based on date: 5465272
    Freshness lifetime from max-age: 600
    The cached response is "stale" with no etag, purging
    Starting new HTTPS connection (1): pypi.python.org
    "GET /pypi/pip/json HTTP/1.1" 200 72983
    Updating cache with response from "https://pypi.python.org/pypi/pip/json"
    Caching b/c date exists and max-age > 0

Any idea to help me to make it running this great tool on my Redhat :-) ?

Thanks for your help

Christophe

unable to snmpwalk demo.snmplabs.com?

Looks like udp/161 is up but I'm unable to snmpwalk demo.snmplabs.com.

$ nc -v -w 10 -u demo.snmplabs.com 161
found 0 associations
found 1 connections:
     1:	flags=82<CONNECTED,PREFERRED>
	outif (null)
	src 10.0.0.85 port 53885
	dst 104.236.166.95 port 161
	rank info not available

Connection to demo.snmplabs.com port 161 [udp/snmp] succeeded!

However,

(venv) keshav@atac-vm-t3-115-ubuntu16:~$ snmprec.py --agent-udpv4-endpoint=demo.snmplabs.com --output-file=./snmp_data/public.snmprec --timeout=60 --retries=1
SNMP version 2c, Community name: public
Querying UDP/IPv4 agent at 104.236.166.95:161
Agent response timeout: 60.00 secs, retries: 1
Sending initial GETNEXT request for 1.3.6 (stop at <end-of-mib>)....

SNMP Engine error: No SNMP response received before timeout
OIDs dumped: 0, elapsed: 120.18 sec, rate: 0.00 OIDs/sec, errors: 1
(venv) keshav@atac-vm-t3-115-ubuntu16:~$

So as snmpwalk.

$ snmpwalk -v2c -c public demo.snmplabs.com system
Timeout: No Response from demo.snmplabs.com
$

Can not find Notification Module

$ ./scripts/snmpsimd.py --agent-udpv4-endpoint=10.10.10.11:1062 --data-dir=./data

Scanning "/home/vagrant/.snmpsim/variation" directory for variation modules...
Directory "/home/vagrant/.snmpsim/variation" does not exist
Scanning "/usr/snmpsim/variation" directory for variation modules...
Directory "/usr/snmpsim/variation" does not exist
Scanning "/usr/share/snmpsim/variation" directory for variation modules...
Directory "/usr/share/snmpsim/variation" does not exist
Scanning "/usr/local/lib/python2.7/dist-packages/snmpsim/variation" directory for variation modules...
Directory "/usr/local/lib/python2.7/dist-packages/snmpsim/variation" does not exist

Migrate from pylibpcap

The pcap2dev.py tool relies upon pylibpcap for traffic dissection.

It seems that pylibpcap project is dead. It is probably time to migrate to a more lively Python wrapper around pcap. May be pcapy or something else.

Variation module 'writecache' referenced but not loaded

I install the SNMPsim on my site. And I convert the file to the format of .snmprec. When I start the sim, I found an error "Variation module 'writecache' referenced but not loaded" when I get a request from the "iftable".
1.3.6.1.2.1.2.2.1.7.1|2:writecache|value=1
This is my command for start SNMPsim.
C:\Python27\scripts\snmpsimd.py --data-dir=C:/Workspace/walkfile --agent-udpv4-endpoint=192.168..

Variation Modules limitations

Hello @etingof,

First of all, thank you for creating SNMPSim and supporting it. We are currently using your tool to simulate Cisco and Xirrus Access Points. We used the snmprec functionality to create .snmprec files based on real Cisco and Xirrus devices and it worked perfectly.

Since we needed to simulate SNMPSet behaviour, I read SNMPSim's documentation regarding varation modules and since I picked the writecache module. Editing the snmprecs generated from the Access Points, I changed all OIDs I was interested to edit according to the tutorial to be like this:

1.3.2.4.23.3|2:writecache|value=27 for example.

However, I noticed that the writecache flag seems to be incompatible with encoded datatypes. For example, some Xirrus OIDs contain encoded strings and have the '4x' datatype instead of simply '4.
When SNMPSim tries to parse '4x:writecache' it throws an error about invalid type. Consequently, I added 'writecache' only to non-encoded OIDs.

Is there any way to use the writecache for encoded OIDs or should I resort to other solutions such as MySQL backed storage.

Finally, I attempted to create a new Tunnel on my simulated Xirrus device. To do this, I have to add new OIDs while the simulation is running that reflect the tunnel creation on the device. I can easily do this by editing the .snmprec file and SNMPSim will detect it. However, this is not a desirable solution in our case and I would like to know if there are other ways in which I can instruct SNMPSim to create new OIDs and then fetch them via SNMPGet. Will a MySQL backend once again help here?

Your help would be much appreciated, thanks in advance!

mib2dev prints enum text instead of numerical values

Hi,

I'm trying to use mib2dev to generate some simulation data, however when I run it is printing the enum text values instead of the numerical ones.
The problem with this is that when I try to use this file on the simulator it complains because the data doesn't match the type (is expecting numbers and not text I presume).

There is any way to tell the script to print the integer values instead of the text?

Thanks.

1.3.6.1.4.1.13712.791.21.1.1.1.1.1.0|66|23522
1.3.6.1.4.1.13712.791.21.1.1.1.2.1.1.0|2|waitingForAcquisition
1.3.6.1.4.1.13712.791.21.1.1.1.2.1.2.0|2|txInhibited
1.3.6.1.4.1.13712.791.21.1.1.1.2.2.1.0|4|quaintly
1.3.6.1.4.1.13712.791.21.1.1.1.2.2.2.0|2|geographicRestrictions
1.3.6.1.4.1.13712.791.21.1.1.1.2.3.1.0|64x|3cb42955
1.3.6.1.4.1.13712.791.21.1.1.1.2.3.2.0|66|27459
1.3.6.1.4.1.13712.791.21.1.1.1.3.1.1.0|2|true
1.3.6.1.4.1.13712.791.21.1.1.1.3.2.1.0|2|warning

Running 'pip install snmpsim' with python2.6 installs snmpsim for python3.5

Hi!

I'm having problems installing snmpsim with python2.6.6, when I was using pip 1.3 is worked perfectly since it fetched the egg files but now when I'm using a newer version of pip it tries to use the wheel file. I had a look at pypi https://pypi.python.org/pypi/snmpsim/0.3.0 and found that the Py Version states 3.5 when I think it should be py2.py3.

I think this is the same problem described here: http://stackoverflow.com/questions/30438216/how-do-i-upload-a-universal-python-wheel-for-python-2-and-3

Have a nice day!

mib2dev start new row

hi, i am using the mib2dev.py for generate values base on a MIB file.

i am a little confused about this line:

line 315:

    if rowOID and not rowOID.isPrefixOf(oid):

should it be ?

    if rowOID and rowOID.isPrefixOf(oid):

Pip install on windows is not enough

Hello.

On windows the simulator can't be simply installed with pip install snmpsim.
I had to download the repository and run python setup.py install from the folder to get the simulator to work, which I found accidentally in issue #14 . This setup file is not included in the pip installation. The download version must be same (last release is now 0.4.6, on pip is 0.4.5)

It took me a while to figure it out. Would be nice to have it in wiki or working pip installation.

After successful install I found, that SNMP-error 1 (TooBig) is not possible to simulate, but never mind :D

Installation problem in windows7

Iam using latest version of vxsnmpsimulator-2.0.1 . I am following steps that you mentioned in readme file.
But it is throwing me error like as follows
Error: Could not find or load main class Files\Java\jdk1.8.0_60\bin\JAVA -jar j
ar\SnmpAgentSimulator-jetty-console.war --headless --contextPath .SnmpAgentSimul
ator --port 8080
I checked java path also(i reinstalled also).
Iam thinking that is due to any port issues. please help me in this.
Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.