Introduction to Mibble

Mibble is an open-source SNMP (Simple Network Managment Protocol) MIB (Manageable Information Base) parser library for Java. It reads MIB files (in ASN.1 syntax) and provides an API to access all the information, including OIDs, types, descriptions, comments and the original MIB source text.

Example MIB source text from TCP-MIB (RFC 4022):

-- the TCP base variables group

tcp      OBJECT IDENTIFIER ::= { mib-2 6 }

-- Scalars

tcpRtoAlgorithm OBJECT-TYPE
                    other(1),    -- none of the following
                    constant(2), -- a constant rto
                    rsre(3),     -- MIL-STD-1778, Appendix B
                    vanj(4),     -- Van Jacobson's algorithm
                    rfc2988(5)   -- RFC 2988
    MAX-ACCESS read-only
    STATUS     current
           "The algorithm used to determine the timeout value used for
            retransmitting unacknowledged octets."
    ::= { tcp 1 }

This document assumes that you are familiar with some common concepts in SNMP. If you are not, you can find more information about SNMP in RFC 3411 - An Architecture for Describing SNMP Management Frameworks or elsewhere on the web.

Running Utilities

Mibble is primarily a library, but also comes bundled with a few small utilities — a pretty-printer, a validator and a MIB browser. Information about how to run these programs can be found in the installation instructions in the release documentation.

The output from the pretty-printer may not be very pretty, but it allows simple extraction of some MIB fields (for scripting). It also supports a number of output modes. Below is the --mibtree output for TCP-MIB for example:

[email protected]:~/mibble$ bin/ --mibtree TCP-MIB
 ┣━ SNMPv2-SMI
 ┃   ┗━ SNMPv2-SMI
     ┣━ SNMPv2-SMI
     ┗━ SNMPv2-TC
         ┗━ SNMPv2-SMI

Alternatively, the pretty-printer can output the full OID tree for the MIB:

[email protected]:~/mibble$ bin/ --oid TCP-MIB

Parsing a MIB File

The amount of processing that can be easily done on the output from the pretty-printer is clearly limited. Advanced filtering or extraction of certain features of the information requires the writing of a specialized application using the Mibble parsing library.

In order to parse a MIB file, a MIB loader must first be created. The MIB loader handles the loading session, managing all imports, and making sure that no file is loaded more than once. The MIB loader also contains an import path, which can be modified to add directories with referenced MIB files.

Below is The Java source code for a simple method for loading a MIB. Note that the directory containing the MIB file is added to the import path in this example.

import net.percederberg.mibble.*;

public Mib loadMib(File file)
    throws FileNotFoundException, MibLoaderException {

    // In real code, a single MibLoader instance should be reused
    MibLoader loader = new MibLoader();

    // The MIB file may import other MIBs (often in same dir)

    // Once initialized, MIB loading is straight-forward
    return loader.load(file);

Processing a MIB file

Once the MIB file has been loaded, the contents can be accessed and processed. The sample code below demonstrates some simple methods for extracting all the names of value symbols with an object identifier value. The list of methods and accessors available can be found in the Mibble Java API.

import net.percederberg.mibble.*;
import net.percederberg.mibble.value.*;

public HashMap<String,ObjectIdentifierValue> extractOids(Mib mib) {
    HashMap<String,ObjectIdentifierValue> map = new HashMap<>();
    for (MibSymbol symbol : mib.getAllSymbols()) {
        ObjectIdentifierValue oid = extractOid(symbol);
        if (oid != null) {
            map.put(symbol.getName(), oid);
    return map;

public ObjectIdentifierValue extractOid(MibSymbol symbol) {
    if (symbol instanceof MibValueSymbol) {
        MibValue value = ((MibValueSymbol) symbol).getValue();
        if (value instanceof ObjectIdentifierValue) {
            return (ObjectIdentifierValue) value;
    return null;