kitsonrp has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know how to change the transport from UDP to TCP when using the Net::SNMP module as I need to guarantee delivery of a snmp trap Thanks
  • Comment on SNMP how to change transport from UDP to TCP ?

Replies are listed 'Best First'.
Re: SNMP how to change transport from UDP to TCP ?
by Ninthwave (Chaplain) on Nov 13, 2003 at 10:58 UTC

    Net::SNMP Documentation

    Transport Layer Arguments

    The Net::SNMP module uses UDP/IP as the Transport Layer to pass SNMP messages between the local and remote devices. The destination device can be specified using the -hostname argument. The -hostname argument accepts either an IP network hostname or an IP address in dotted notation. This argument is optional and defaults to "localhost". The destination UPD port number can be specified using the -port argument. This argument is also optional and defaults to 161, which is the port number on which devices using default values expect to receive SNMP request messages. The -port argument will need to be specified for remote devices expecting to receive SNMP notifications since these device typically default to port 162.

    By default, the source IP address and port number are assigned dynamically by the local device on which the Net::SNMP module is being used. This dynamic assignment can be overridden by using the -localaddr and -localport arguments. These values default to INADDR_ANY (typically 0.0.0.0) and 0 respectively. The -localaddr argument will accept either an IP network hostname or an IP address in dotted notation. If a hostname is specified, the resolved IP address must be a valid address on the local device.

    From the above quote the answer is there is no way to do it with that module out of the box.

    "No matter where you go, there you are." BB
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: SNMP how to change transport from UDP to TCP ?
by ptkdb (Monk) on Nov 13, 2003 at 12:35 UTC
    Traps by default are via TCP. However, if you're looking to change the transport for other SNMP operations, if Net::SNMP operates the same way that the C and java APIs work, you can specify the transport in the 'hostspec'.

    hostname = "tcp:host:port" ;
    I have not tried this in the perl implementation myself however.

      SNMP only uses udp, according to Managing Internetworks with SNMP, pgs 24, 154-155, 157, 166, and so on. I don't think it can be changed to tcp.
      Thanks for the info . I was unaware trap are sent via TCP, problem solved
Re: SNMP how to change transport from UDP to TCP ?
by sauoq (Abbot) on Nov 13, 2003 at 10:56 UTC

    Short of modifying Net::SNMP, you're out of luck, I believe.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: SNMP how to change transport from UDP to TCP ?
by zengargoyle (Deacon) on Nov 13, 2003 at 19:45 UTC

    there is no such thing as guaranteed delivery of SNMP anything.

    although net-snmp tools have an option to change the transport...

    General communication options -p <P> use port P instead of the default port. -T <LAYER> use LAYER for the network layer. (UDP or TCP).

    i've never seen a device that can use anything other than UDP

    even encrypted SNMPv3 is still UDP...

Re: SNMP how to change transport from UDP to TCP ?
by Anonymous Monk on Nov 14, 2003 at 04:03 UTC
    The net-snmp package provides a "SNMP" perl module that supports TCP, but very few other packages do support it. If you use the net-snmp package, configure it using

    --with-perl-modules

    And then make, make install and then the SNMP perl module will work just fine with a hostname of "tcp:localhost:161" for example. (net-snmp supports many transports, including IPv6, IPX, ...) HOWEVER!!! Just because a packet arrives via TCP doesn't mean that the *application* received it. It just means the stack received it. Thus, SNMP has its *own* confirmed method of a trap that is called an "INFORM" and is simply an acknowleged trap. But, you must use SNMPv2c or higher (preferrably v3 with security turned on). So, if you use the inform() method of the SNMP module, it will send an inform that will be acknowledged even over UDP.