tags:

views:

29

answers:

2

Hi, Iam using snmp to access the remote system data.But according to the requirement iam encoding the snmp request data to OAMPDU packet format and sending to remote system.the remote system receives the OAMPDU packet,decodes it and is sending the snmp request to snmp agent through UDP socket which is bind to port 161.but iam unable to receive the response from snmp agent.i have created a udp socket which is bind to 161 port to receive the response.

if i use any other free port number other than 161 for receiving snmp agent is not sending the response to that port.

can any one please suggest me how to overcome this problem.

Can we configure the different ports for tx,rx ???

How do we know on which port does snmp sends the response ???

+1  A: 

Each UDP packet has a source port and a destination port. An SNMP manager sends out an SNMP request using any source port, and destination port 161. The agent will reply to the source port on the manager. For example:

Manager                                    Agent

source port: <random number>
dest port: 161
content: what is your sysUpTime 
                                           source port: 161
                                           destination port: <same random number>
                                           content: sysUpTime is 42 seconds

Replies arrive on random number port, not port 161. So a manager listening on port 161 is unlikely to receive many replies. Instead of listening on port 161, listen on the same socket you used to send out the request. That socket will remember the source port it chose for sending.

P.S. When you use SNMP to query, SNMP's manager is UDP's client, and SNMP's agent is UDP's server.

Andomar
actually my application is neither snmp manager or snmp agent.my application interacts only with snmp agent.if my application send request through udp socket,port 161 then how can i get the response from snmp agent.i mean through which port i can receive the response because it is choosing a random port number.
@user381956: You should listen for replies using the same socket you use to send the request. Search for examples on Google, there are plenty.
Andomar
A: 

By Default the SNMP port uses is Port 161 and 162. Now for some purpose I need to use other port say 8162 which is unreserved and can be used. I did some reading on netsnmp manuals and stuff but could not find any fixed steps to do, most are like trial and error methods. Can some one throw some light on this. To add more to the pain, it is in OS running Solaris.

  1. How do I configure the SNMP agent so that it route/send the message via port 8162 rather than 161/162 port

  2. How do I verify that the message which it received is SNMP and not UDP message.

  3. When I use wireshark to capture packet it is shown as UDP tag and not SNMP.

george keishing