Creating SNMP Agent (Server) in JAVA using SNMP4j

In Previous article, we have seen that how to create SNMP client in JAVA using SNMP4j.

To create the Agent for SNMP which listens for the request should extend the abstract class BaseAgent.
The BaseAgent abstract class defines a framework for writing SNMP agents using the SNMP4J-Agent API. To implement your own SNMP agent, extend this class and implement the abstract methods defined by BaseAgent. The hook methods do not need any specific implementation. They only provide a defined mechanism to customize your agent.

Create SNMP Client in JAVA Using SNMP4j

There are lots of open source library for SNMP is available, even java have library for the same,  But in this article I will explain a simple example of using SNMP4j in JAVA to create a simple client which will display the hardware information.

Note : To run this program, SNMP service must be installed. Check this article to know that how to install SNMP in Windows XP.

Download libraries from

Create Simple NMS (Network management station / Client) in JAVA using SNMP4j:

Install SNMP Service in Windows XP and Overview of MIB Explorer

Enable SNMP services in Windows Xp:

  1. To open the Windows Components Wizard, click Start, click Control Panel, double-click Add or Remove Programs, and then click Add/Remove Windows Components.
  2. In Components, click Management and Monitoring Tools (but do not select or clear its check box), and then click Details.
  3. Select the Simple Network Management Protocol check box, and click OK.
  4. Click Next.
Install SNMP Service in Windows XP
Install SNMP Service in Windows XP

Terminologies used in SNMP

In Previous article, we have seen that what actually is SNMP.  In this article we will discuss on different terminologies used in SNMP.

(1) SNMP

  • Application-layer protocol for managing TCP/IP based networks.
  • Runs over UDP, which runs over IP

(2) NMS (Network Management Station)

  • Device that pools SNMP agent for info (Client)

(3) SNMP Agent

  • Device (e.g. Router) running software that understands SNMP language. You can imagine like a Server.

(4) MIB

  • Database of info conforming to SMI.

(5) SMI (Structure of Management Information)

  • Standard that defines how to create a MIB.

(6) Trap:

  • Traps are like events. This is a way the SNMP agent pushes the information to client. Asynchronously, events can be fired to client from server (agent).

(7) Ports:

  • The SNMP agent receives requests on UDP port 161. The manager may send requests from any available source port to port 161 in the agent. The agent response will be sent back to the source port on the manager. The manager receives notifications (Traps and InformRequests) on port 162. The agent may generate notifications from any available port.
Categorized as SNMP Tagged

Introduction to SNMP

SNMP stands for Simple Network Management Protocol – and is one of the most widely spread internet management protocols. It is based on UDP and uses BER (Basic Encoding Rules) for encoding.

SNMP is an internet technology – specified by means of RFCs (Requests For Comments), which are issued through the Internet Engineering Task Force (IETF).

SNMP defines both how to structure management information (data model exposed for management), and how to access it (protocol). According to SNMP, the management information is structured into MIBs (Management Information Bases). A MIB is defined using a formal language called Structure of Management Information (SMI) – whose syntax uses a subset of ASN.1 (Abstract Syntax Notation 1).

Categorized as SNMP Tagged