[AGENT++] Can we specify the TRAP source port ?

Jochen Katz katz at agentpp.com
Wed Apr 4 22:49:04 CEST 2007


Hi,

>     NotificationOriginator notifier;
>     UdpAddress dest("192.168.0.100");
>     dest.set_port(4701);
>     notifier.add_v1_trap_destination(dest);
> 
> Unless I'm mistaken, the above should cause TRAPs to be sent to
> 192.168.0.100:4701. So anything listening on port 4701 at 192.168.0.100
> should (hopefully) receive the TRAP.

yes.

> QUESTION : does anyone know if it is also possible to select the
> **SOURCE** port of the TRAP. In other words, the port from which the
> TRAP is sent.

This is not possible without patching snmp_request.cpp.

> I have been observing the SNMP traffic using Ethereal and I see that my
> TRAPs are sent from a seemingly random high numbered port. For example,
> when sending a TRAP from one machine (192.168.0.99) to another
> (192.168.0.100), I get the following :
> 
> 192.168.0.99 : 32826  -------- [TRAP] ------>  192.168.0.100 : 4701
>    [TRAP SENDER]                                  [TRAP RECEIVER]

Yes, this is caused by the SnmpRequest class that creates a new Snmpx
object for each trap. The source port is not specified, as this would
lead to problems of two threads want to send traps at the same time.

> Interestingly for ordinary GET and SET traffic, the source port for the
> GET-RESPONSE messages seem to be sent from the same port on which the
> GET-REQUEST and SET is received. And the AGENT++ snmpGet, snmpWalk, et
> al.  Programs all seem to send their GETs, SETs, etc from a seemingly
> random high numbered port. For example :
> 
> 
> 192.168.0.99 : 4700   <------- [GET] ---------  192.168.0.100 : 32826
> 192.168.0.99 : 4700   ---- [GET-RESPONSE] --->  192.168.0.100 : 32826
>    [SNMP AGENT]                                    [SNMP MANAGER]

For answers, the agent uses the Snmpx object, that was used to receive
the request, so the same port is used. The consoleExamples don't need a
special port, so they let the operating system assign a free one.

Regards,
  Jochen



More information about the AGENTPP mailing list