Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am trying to write some code to emulate a number of agent devices on the network. These uses the SNMP protocol to communicate with a host computer. I have successfully used the SnmpListen function within winSNMP to read the requests sent by the host. My problems so far are:

1) When I send a response the SnmpSendMsg call succeeds but sometimes the port number instead of being 161 (as I set it) is some random number.

2) When I send messages I specify a source entity by using SnmpStrToEntity and specifying the IP address of the emulated device. My network setting have all the devices specified. However when I examine the packets with Wireshark they always have the same sourceIP address and not what I specified in the SnmpSendMsg call.

3) SnmpSendMsg is an asynchronous call. Can I reuse the PDU immediately or do I have to wait for the send to complete first. In other words, does the call make a copy of the PDU and entities, or does it use them directly. I suspect this is what is causing issue 1 above.

4) Is there an alternative SNMP library that I can use?

This is the environment that I am trying to use:

Language : C++ (unmanaged)
Operating system : Windows 7 and 10
SNMP version : v2c

What I have tried:

Tried declaring PDU as a member variable.
Tried explicitly specifying the source entity.
Tried creating a different session for the receiver and sender.
Posted
Comments
KarstenK 9-Mar-17 5:38am    
3. you shouldnt reuse a resource when it isnt done.
Anorexic Tribble 12-Mar-17 19:37pm    
But how do I know when it is done with the resource?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900