SNMP Trap is a message initiated by a Network Element to notify the Management Station of a significant event. Trap Receiver play a very crucial role in Fault Management Applications, by receiving and parsing the bytes into meaningful messages. In this article we shall discuss the implementation of a SNMP Trap receiver using Apache MINA (Multipurpose Infrastructure for Network Applications). Apache MINA is network application frameworks which help the users develop high performance and highly scalable network applications easily. It provides an abstract - event-driven - asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO.
The article focuses on developing a Trap Receiver using Apache MINA and available SNMP stacks like SNMP4J, joesnmp etc.
Figure 1: Apache MINA Architecture
Apache MINA is a simple, yet, full-featured network application framework which provides:
A “good” Trap Receiver should be able to handle sustained high Trap rate and have virtually no dependencies towards the SNMP stack used for decoding. Such a Trap Receiver should have:
The figure below describes a high level Functional View of a Trap Receiver Processing Layer
Figure 2: Functional View of Trap Receiver
The conventional Trap Receiver implementation comprises of three layers with distinct functional role at each level:
In the conventional architecture, these three layers functions are performed using a single thread and many a times, a thread pool is used for higher performance.
This section describes the Architecture of HSC Trap Receiver. The architecture has been redefined to achieve high processing rate, along with minimum dependencies on any SNMP stacks. The steps briefly describe what all shall be needed:
Figure 3: Architecture of HSC Trap Receiver
Apache MINA framework takes care of all IO related and housekeeping functions like creating input Queue and passing the message through the processing chain.
With the IO infrastructure in place, we can concentrate on our prime Business Logic, of decoding the byte array into an SNMP messages. An implementation of MINA’s protocol Decoder shall convert bytes into SNMP object representation using SNMP4J. MINA ProtocolDecoder’s being the added into the protocol chain can easily be replaced with other implementation, without changing the remaining code.
Sample SNMP4J based MINA codec is listed below
With Protocol codec in place, its time to put the glue code in place
SNMP Codec factory return a new instance of SNMP4JCodec. With SNMP4J codec added into Filter chain MINA uses the codec to decode the byte array into SNMP object of SNMP4J and pass onto next filter, and subsequently to IOHandler.
The SNMP4J codec can be easily replaced with joesnmp codec or Adventnet codec, by implementing a Protocol decoder using the library and returning the instance from ProtocolCodec factory class.
To use SEDA, Executors can be added in between filter’s to achieve threadpool based processing, within each filter/
Apache MINA eases creation of high performance Network applications. The Design of HSC Trap Receiver, based on Apache MINA, makes it easy to use any SNMP stack in the Fault Management application. Additionally, the design based on IOFilter chain, gives flexibility in adding additional functionality like blacklisting IP, managing throughput without modifying the Decoding logic or Trap processing. Under the Test environment (Intel Core2 Duo 2.2 GHz, Windows XP, 1 GB RAM), the implementation achieved a sustained rate of 3000 Traps/sec without dropping any packets.
Do you have an upcoming project and wantus
to help speed up your time to market?