Network Management Assignment 2: SNMP Table Parsing
Due: March 20^H^H27 (though the basic ideas may appear on our exam March 13) -- Peter Dordal
The abstract OID for ifTable is mib2.2.2; the OID for ifEntry
is mib2.2.2.1. I'll refer to this latter value as tableRoot. All
entries in the table, or any SNMP table, have OIDs of the form
tableRoot.colNum.index, where colNum is almost always a single integer
value and index can be an OID string of any length.
In this assignment you will use the Drexel SNMP library to write some
methods to process a table downloaded as the result of
retrieveMIBTable(String baseID); the table will be an
SNMPVarBindList, which is like an ArrayList of
<OID,value> SNMPVariablePair pairs. The table will be
referred to as tableList. Note
that the baseID to retrieve ifTable could have been either ifTable or
ifEntry or ifEntry.1. For some of the methods you will need to have
tableRoot available; for others that is not necessary. The OID of each
entry is, of course, the first element of the <OID,value> pair.
Here are the methods you are to implement, now in ArrayList<SNMPSequence> format
Note that the component type here, SNMPSequence, is probably the
simplest choice. SNMPObject is too general, and using SNMPVariablePair
as the component type does not bring any practical benefit.
ArrayList<SNMPSequence> getRow(String index, ArrayList<SNMPSequence> tableList)
This takes an OID string representing the index and returns the list of
all <OID,value> pairs from tableList representing the row
specified by the given value of index. They should be returned in the
same order in which they appeared within tableList. You're looking for
the OIDs which have index as a terminal subsequence; you shouldn't need
tableRoot.
Here's a snippet of possible code from getRow(), illustrating string-based matching; index has been replaced by "." + index:
for (int i=0; i<tableList.size(); i++) {
SNMPSequence pair = tableList.get(i);
// extract the
object identifier from the pair; it's the first element in the sequence
SNMPObjectIdentifier snmpOID =
(SNMPObjectIdentifier)pair.getSNMPObjectAt(0);
String snmpOIDstr = snmpOID.toString();
// now see if index is a terminal substring of this: (
// Can you find a better terminal-substring test?
if (
snmpOIDstr.lastIndexOf(index) == snmpOIDstr.length() - index.length() )
{
result.add(pair);
}
}
SNMPVariablePair getValue(String index, int column, ArrayList<SNMPSequence> tableList)
This returns the value of the pair at position tableRoot.column.index.
Try to do this one without using tableRoot as a parameter, but you may
add it if you need to.
ArrayList<SNMPSequence> getColumn(int column, SNMPObjectIdentifier tableRoot, ArrayList<SNMPSequence> tableList)
This returns the list of <OID,value> pairs that represent the
given column. Bonus points if you can do this without using tableRoot;
see commonRoot() below.
ArrayList<String> getIndex(SNMPObjectIdentifier tableRoot, ArrayList<SNMPSequence> tableList)
This returns an ordinary ArrayList of the index values; note that
entries should consist of just the index portion and not the entire
OID. Each index value should appear only once; the values should be in
the order in which they first
appeared in tableList. Assume the column is specified by a single
integer. For the ulam2 ifTable, this should return the list ["1", "2"]
(there are two interfaces).
SNMPObjectIdentifier commonRoot(ArrayList<SNMPSequence> tableList)
This returns the longest common OID prefix of all the OIDs from the
list of <OID,value> pairs. Except in degenerate cases, this is
just tableRoot.
ArrayList<SNMPObjectIdentifier> getIndex(ArrayList<SNMPSequence> tableList)
Same as getIndex() above, but without having access to tableRoot. This is harder; consider using commonRoot(). May also return ArrayList<String>.
Here are the methods in the original format
SNMPVarBindList getRow(String index, SNMPVarBindList tableList)
This takes an OID string representing the index and returns the list of
all <OID,value> pairs from tableList representing the row
specified by the given value of index. They should be returned in the
same order in which they appeared within tableList. You're looking for
the OIDs which have index as a terminal subsequence; you shouldn't need
tableRoot.
SNMPVariablePair getValue(String index, int column, SNMPVarBindList tableList)
This returns the value of the pair at position tableRoot.column.index.
Try to do this one without using tableRoot as a parameter, but you may
add it if you need to.
SNMPVarBindList getColumn(int column, SNMPObjectIdentifier tableRoot, SNMPVarBindList tableList)
This returns the list of <OID,value> pairs that represent the
given column. Bonus points if you can do this without using tableRoot;
see commonRoot() below.
ArrayList<String> getIndex(SNMPObjectIdentifier tableRoot, SNMPVarBindList tableList)
This returns an ordinary ArrayList of the index values; note that
entries should consist of just the index portion and not the entire
OID. Each index value should appear only once; the values should be in
the order in which they first
appeared in tableList. Assume the column is specified by a single
integer. For the ulam2 ifTable, this should return the list ["1", "2"]
(there are two interfaces).
SNMPObjectIdentifier commonRoot(SNMPVarBindList tableList)
This returns the longest common OID prefix of all the OIDs from the
list of <OID,value> pairs. Except in degenerate cases, this is
just tableRoot.
ArrayList<SNMPObjectIdentifier> getIndex(SNMPVarBindList tableList)
Same as above, but without having access to tableRoot. This is harder; consider using commonRoot().
ArrayList<SNMPSequence > makeArrayList(SNMPVarBindList list)
General-purpose converter from an SNMPVarBindList to an ArrayList of SNMPVariablePair pairs.
Test your methods with the result of
SNMPv1CommunicationInterface.getTable(ifTable), and also ipAddrTable
and ipRouteTable. You can enable SNMP on your home computer (linux or
windows) and use data from there, at least for preliminary testing.