++ed by:

3 PAUSE users
1 non-PAUSE user.

Author image Max Baker


SNMP::Info::Bridge - Perl5 Interface to SNMP data available through the BRIDGE-MIB (RFC1493)


Max Baker (max@warped.org)


 my $bridge = new SNMP::Info ( 
                             AutoSpecify => 1,
                             Debug       => 1,
                             DestHost    => 'switch', 
                             Community   => 'public',
                             Version     => 2

 my $class = $cdp->class();
 print " Using device sub class : $class\n";

 # Grab Forwarding Tables
 my $interfaces = $bridge->interfaces();
 my $fw_mac     = $bridge->fw_mac();
 my $fw_port    = $bridge->fw_port();
 my $bp_index   = $bridge->bp_index();

 foreach my $fw_index (keys %$fw_mac){
    my $mac   = $fw_mac->{$fw_index};
    my $bp_id = $fw_port->{$fw_index};
    my $iid   = $bp_index->{$bp_id};
    my $port  = $interfaces->{$iid};

    print "Port:$port forwarding to $mac\n";


BRIDGE-MIB is used by most Layer 2 devices, and holds information like the MAC Forwarding Table and Spanning Tree Protocol info.

Q-BRIDGE-MIB holds 802.11q information -- VLANs and Trunking. Cisco tends not to use this MIB, but some proprietary ones. HP and some nicer vendors use this. This is from RFC2674_q.

Create or use a subclass of SNMP::Info that inherits this class. Do not use directly.

For debugging you can call new() directly as you would in SNMP::Info

 my $bridge = new SNMP::Info::Bridge(...);

Inherited Classes


Required MIBs



BRIDGE-MIB needs to be extracted from ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz


These are methods that return scalar values from SNMP


Returns the MAC Address of the root bridge port



Returns the number of ports in device



Returns the type? of the device



Returns what version of STP the device is running. Either decLb100 or ieee8021d.



Returns time since last topology change detected. (100ths/second)



Returns root of STP.





Number of VLANS on this device.



These are methods that return tables of information in the form of a reference to a hash.

Forwarding Table (dot1dTpFdbEntry)


Returns reference to hash of forwarding table MAC Addresses



Returns reference to hash of forwarding table entries port interface identifier (iid)



Returns reference to hash of forwading table entries status


Bridge Port Table (dot1dBasePortEntry)


Returns reference to hash of bridge port table entries map back to interface identifier (iid)



Returns reference to hash of bridge port table entries physical port name.


Spanning Tree Protocol Table (dot1dStpPortTable)

Descriptions are lifted straight from BRIDGE-MIB.my


"The port number of the port for which this entry contains Spanning Tree Protocol management information."



"The value of the priority field which is contained in the first (in network byte order) octet of the (2 octet long) Port ID. The other octet of the Port ID is given by the value of dot1dStpPort."



"The port's current state as defined by application of the Spanning Tree Protocol. This state controls what action a port takes on reception of a frame. If the bridge has detected a port that is malfunctioning it will place that port into the broken(6) state. For ports which are disabled (see dot1dStpPortEnable), this object will have a value of disabled(1)."




"The contribution of this port to the path cost of paths towards the spanning tree root which include this port. 802.1D-1990 recommends that the default value of this parameter be in inverse proportion to the speed of the attached LAN."



"The unique Bridge Identifier of the Bridge recorded as the Root in the Configuration BPDUs transmitted by the Designated Bridge for the segment to which the port is attached."



"The Bridge Identifier of the bridge which this port considers to be the Designated Bridge for this port's segment."




"The Port Identifier of the port on the Designated Bridge for this port's segment."



Gives the vlan used by interfaces



Either admitAll or admitOnlyVlanTagged. This is a good spot to find trunk ports.



Human-entered name for vlans.



uhh. active !