0% found this document useful (0 votes)
79 views31 pages

Toaz - Info Network Management System 40nms41 PR

The document discusses the Simple Network Management Protocol (SNMP) and how it facilitates network management. It describes SNMP versions 1 and 2, the basic components of an SNMP network including managed devices, agents, and network management systems. It also outlines management information bases, SNMP commands, and the structure of management information as defined in SNMPv1.

Uploaded by

Shahzeb Sha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views31 pages

Toaz - Info Network Management System 40nms41 PR

The document discusses the Simple Network Management Protocol (SNMP) and how it facilitates network management. It describes SNMP versions 1 and 2, the basic components of an SNMP network including managed devices, agents, and network management systems. It also outlines management information bases, SNMP commands, and the structure of management information as defined in SNMPv1.

Uploaded by

Shahzeb Sha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

‫بسم الله الرحمن الرحيم‬

An Najah National University


Faculty Of Engineering
Computer Engineering Department

Software Graduation Project


Documentation

1st semester
2006-12-21

Network Management System


(NMS)

Contents:
 SNMP overview.
 The project implementation.
 Project's user manual.

Instructor:
 Dr.: Laui Malhees.

Prepared by:
 Fuad Nassar
 Ali Hussien.
Overview:
What is SNMP:
The Simple Network Management Protocol (SNMP) is an application layer protocol
that facilitates the exchange of management information between network devices. It is
part of the Transmission Control Protocol/Internet Protocol (TCP/IP) protocol suite.
SNMP enables network administrators to manage network performance, find and solve
network problems, and plan for network growth.

Two versions of SNMP exist: SNMP version 1 (SNMPv1) and SNMP version2
(SNMPv2). Both versions have a number of features in common, but SNMPv2 offers
enhancements, such as additional protocol operations.

Basic Components:
An SNMP-managed network consists of three key components: managed devices,
agents, and network-management systems (NMSs).

A managed device is a network node that contains an SNMP agent and that resides
on a managed network. Managed devices collect and store management information and
make this information available to NMSs using SNMP. Managed devices, sometimes
called network elements, can be routers
and access servers, switches and bridges, hubs, computer hosts, or printers.
An agent is a network-management software module that resides in a managed device.
An agent has local knowledge of management information and translates that information
into a form compatible with SNMP.

An NMS executes applications that monitor and control managed devices. NMSs
provide the bulk of the processing and memory resources required for network
management. One or more NMSs must exist on any managed network.

The following figure will make the image clear about the network management job ,
and how the administrator can managed and monitoring the network devices , and show
the place of the databases and agents.
FIG 1: Network Management System.

Basic Commands:
Managed devices are monitored and controlled using four basic SNMP commands:
read, write, trap , and traversal operations.
The read command is used by an NMS to monitor managed devices. The NMS
examines different variables that are maintained by managed devices.
The write command is used by an NMS to control managed devices. The NMS
changes the values of variables stored within managed devices.
The trap command is used by managed devices to asynchronously report events to
the NMS. When certain types of events occur, a managed device sends a trap to the NMS.
Traversal operations are used by the NMS to determine which variables a managed
device supports and to sequentially gather information in variable tables, such as a
routing table.

Management Information Base:

A Management Information Base (MIB) is a collection of information that is


organized hierarchically.
MIBs are accessed using a network-management protocol such as SNMP. They are
comprised of managed objects and are identified by object identifiers.

A managed object (sometimes called a MIB object, an object, or a MIB) is one of


any number of specific characteristics of a managed device.
Managed objects are comprised of one or more object instances ,which are
essentially variables.

Two types of managed objects exist: scalar and tabular. Scalar objects define a
single object instance.
Tabular objects define multiple related object instances that are grouped in MIB
tables.

An example of a managed object is at input , which is a scalar object that contains a


single object instance, the integer value that indicates the total number of input AppleTalk
packets on a router interface.

An object identifier (or object ID) uniquely identifies a managed object in the MIB
hierarchy. The MIB hierarchy can be depicted as a tree with a nameless root, the levels of
which are assigned by different organizations.
The top-level MIB object IDs belong to different standards organizations, while lower-
level object IDs are allocated by associated organizations.
Vendors can define private branches that include managed objects for their own products.
MIBs that have not been standardized typically are positioned in the experimental branch.

The managed object at input can be uniquely identified either by the object
name—iso.identified organization.dod.internet.private.enterprise.cisco.temporary
variables.AppleTalk.at input—or by the equivalent object descriptor, 1.3.6.1.4.1.9.3.3.1.

MIBs’ groups:
 MIB-II system group (1.3.6.1.2.1.1)
 Interfaces group (1.3.6.1.2.1.2)
 Address Translation group (1.3.6.1.2.1.3)
 Internet Protocol group (1.3.6.1.2.1.4)
 Internet Control Message Protocol group (1.3.6.1.2.1.5)
 Transmission Control Protocol group (1.3.6.1.2.1.6)
 User Datagram Protocol group (1.3.6.1.2.1.7)
 Exterior Gateway Protocol group (1.3.6.1.2.1.8)
 SNMP group (1.3.6.1.2.1.11)
 Transmission group (1.3.6.1.2.1.10)

SNMP Version 1:
SNMP version 1 (SNMPv1) is the initial implementation of the SNMP protocol. It
is described in Request For Comments (RFC) 1157 and functions within the
specifications of the Structure of Management Information (SMI). SNMPv1 operates
over protocols such as User Datagram Protocol (UDP), Internet Protocol (IP), OSI
Connectionless Network Service (CLNS), AppleTalk Datagram-Delivery Protocol
(DDP), and Novell Internet Packet Exchange (IPX). SNMPv1 is widely used and is the
de facto network-management protocol in the Internet community.

SNMPv1 and Structure of Management Information:


The Structure of Management Information (SMI) defines the rules for describing
management information, using Abstract Syntax Notation One (ASN.1). The SNMPv1
SMI is defined in RFC 1155.
The SMI makes three key specifications: ASN.1 data types, SMI-specific data types,
and SNMP MIB tables.

SNMPv1 and ASN.1 Data Types:


The SNMPv1 SMI specifies that all managed objects have a certain subset of
Abstract Syntax Notation One (ASN.1) data types associated with them. Three ASN.1
data types are required: name, syntax, and encoding. The name serves as the object
identifier (object ID). The syntax defines the data type of the object (for example, integer
or string). The SMI uses a subset of the ASN.1 syntax definitions. The encoding data
describes how information associated with a managed object is formatted as a series of
data items for transmission over the network.

SNMPv1 and SMI-Specific Data Types:


The SNMPv1 SMI specifies the use of a number of SMI-specific data types, which
are divided into two categories: simple data types and application-wide data types.

Three simple data types are defined in the SNMPv1 SMI, all of which are unique
values: integers, octet strings, and object IDs. The integer data type is a signed integer in
the range of –2,147,483,648 to 2,147,483,647. Octet strings are ordered sequences of 0 to
65,535 octets. Object IDs come from the set
of all object identifiers allocated according to the rules specified in ASN.1.
Seven application-wide data types exist in the SNMPv1 SMI: network addresses,
counters, gauges, time ticks, opaque, integers, and unsigned integers. Network addresses
represent an address from a particular
protocol family. SNMPv1 supports only 32-bit IP addresses. Counters are non-negative
integers that increase until they reach a maximum value and then return to zero. In
SNMPv1, a 32-bit counter size is specified. Gauges are non-negative integers that can
increase or decrease but that retain the maximum
value reached. A time tick represents a hundredth of a second since some event. An
opaque represents an arbitrary encoding that is used to pass arbitrary information strings
that do not conform to the strict
data typing used by the SMI. An integer represents signed integer-valued information.
This data type redefines the integer data type, which has arbitrary precision in ASN.1 but
bounded precision in the SMI.
An unsigned integer represents unsigned integer-valued information and is useful when
values are always non-negative. This data type redefines the integer data type, which has
arbitrary precision in ASN.1 but bounded precision in the SMI.

SNMP MIB Tables:


The SNMPv1 SMI defines highly structured tables that are used to group the
instances of a tabular object (that is, an object that contains multiple variables). Tables are
composed of zero or more rows, which are indexed in a way that allows SNMP to
retrieve or alter an entire row with a single Get, Get Next, or Set command.

SNMPv1 Protocol Operations:


SNMP is a simple request/response protocol. The network-management system
issues a request, and managed devices return responses. This behavior is implemented by
using one of four protocol operations: Get, Get Next , Set, and Trap. The Get operation is
used by the NMS to retrieve the value of
one or more object instances from an agent. If the agent responding to the Get operation
cannot provide values for all the object instances in a list, it does not provide any values.
The Get Next operation is used by the NMS to retrieve the value of the next object
instance in a table or a list within an agent. The Set
operation is used by the NMS to set the values of object instances within an agent. The
Trap operation is used by agents to asynchronously inform the NMS of a significant
event.

SNMP Version 2:

SNMP version 2 (SNMPv2) is an evolution of the initial version, SNMPv1.


Originally, SNMPv2 was published as a set of proposed Internet standards in 1993;
currently, it is a draft standard. As with SNMPv1, SNMPv2 functions within the
specifications of the Structure of Management Information (SMI). In theory, SNMPv2
offers a number of improvements to SNMPv1, including additional protocol operations.

SNMP Management:
SNMP is a distributed-management protocol. A system can operate exclusively as
either an NMS or an agent, or it can perform the functions of both. When a system
operates as both an NMS and an agent, another NMS might require that the system query
manage devices and provide a summary of the information learned, or that it report
locally stored management information.

This is a fast overview about SNMP and the related topics that may help the reader
to know the main feature of the SNMP, what we do in our project is an interface that take
benefit of these SNMP feature and make it more user friendly to link the network's
administrator with the NMS that use SNMP, and enable him to easily apply the SNMP
commands on any network component.

Implementation:
As I said this project is just an interface help the administrator to apply the SNMP
command using graphical user interface components to make this operations easy and
fast.

We implement this interface using visual .NET 2005 framework environment using
C# language as a simple strong and comprehensive object oriented language , in visual
.NET 2005 all graphical user interface components that the software developer may need
such as buttons , textboxes , popup menu , drag and drop controls , list view , tree
view , picture boxes , and all well known components.

The fact that the C# is object orient language make it easy to benefit from the
different classes that it contain , also this simplify the process of define objects and use
the methods of that object in a simple way.

The most part in this language help us is the ability to define property especial in
this kind of project that deal with GET and SET operations and the property definition
must use those methods on C# make it easier and flexible to access (read or write) the
property.

Ex:

public String Oid


{
get { return oid; }
set { oid = value; }
}

In this project we use a very useful and easy and comprehensive package that been
built for .NET environment , the implementation of this project classes and objects is
depend on this package and also on the visual .NET C# basics parts such that Property
and interfaces that C# included, as we said this project is just an interface between the
user and the NMS so the use for a ready interface package will make the developing of
the project easy and fast and more reliable and easy to repair, this part of the document
will include this package main features that been used in this project this package named
as:
Advent Net SNMP API .NET:
A comprehensive toolkit for rapid development of SNMP-based management
applications that are reliable and scalable. With well-proven APIs enriched with customer
experience and an integrated set of easy-to-use tools and features, AdventNet SNMP API
caters to the complete development life cycle of network element management.

Network management developers can leverage AdventNet SNMP library to build


standalone and Web-based applications. The library provides many of the commonly used
functions and components out-of-the-box to make the development simpler.

The core of AdventNet SNMP API .NET Edition is a set of APIs that can be
integrated in any application. Built using the best software design patterns and optimized
performance, it is a powerful suite to secure APIs to build cross-platform, real-time
application for monitoring and tracking the performance of network elements.

Developing Management Applications:


 Using MIBs in Applications.
 Configuring SNMP Agent Parameters.

 Data Retrieval Operations.

 Data Altering Operations.

 Traps and Notifications.

 Deployment Instructions.

Using MIBs in Applications:


Loading MIBs
Applications can load the MIB modules directly from a file. The MibOperations class in
the MIB support API provides the methods necessary to load and unload MIB modules in
the management applications.
The method loadMibModules(String) of the MibOperations class can be used to load
the MIBs. The loadMibModules method loads a set of MIB modules specified by file
names separated by space.

The following piece of code illustrates how applications use MibOperations to load MIB
files.

MibOperations mibops = new MibOperations();

try {

mibops.loadMibModule("RFC1213-MIB");

catch (Exception ex){

System.err.println("Error loading MIBs: " +ex);

Factors to Consider While Loading MIB Files:


The imported modules should be present in the current directory or the directory in which
the MIB file is present. For example, the dependency file for the IF-MIB should be
present in the same directory or in the current directory.

If the imported module is in a different directory, we can set the search path before
loading the MIB. The search path can be set by using the method setMibPath(String) .
The API searches for the module in the path specified. Multiple paths can be given
separated by a pipe(|) symbol.

The following code snippet shows how to load a MIB file which has its dependency file
in another directory. For example, if the IF-MIB is in mibs directory and if SNMPv2-
MIB (dependency file for IF-MIB) is in the patchmibs directory, the following code
shows how to load IF-MIB.

MibOperations mibops = new MibOperations();

try {

mibops.setMibPath("C:\AdventNet\SNMPAPI\mibs\ | C:\test\patchmibs\ ");

mibops.loadMibModule("IF-MIB");
}

catch (Exception ex)

System.err.println("Error loading MIBs: " +ex);}

The API can load MIB files with the extensions mib, txt, and my. The method
setMibFileExtension(String) can be used to set the MIB file extension for the file to be
loaded.

Retrieving MIB Information:


Manipulating OIDs:
The MibModule class enables operations on the loaded MIB modules. This class
instance for a MIB module is obtained by loading the MIB through the MibOperations
object.

The translateToNames(String) method of the MibModule is used for translating


numbered OID String to named OID String. The translateToNumbers(String) method is
used for translating named OID String to numbered OID String. If the OID does not start
with a dot, the standard prefix .1.3.6.1.2.1 is automatically appended and the OID String
is returned.

The getInstanceString(SnmpOID) method of MibOperations class gets the instance


component of the OID as a String. Instances of scalar objects are identified by the OID
value of the object suffixed with ".0". Instances of columnar objects are identified by
their OID values suffixed by their index components. The getInstanceString(SnmpOID,
MibNode) method of MibOperations class avoids having to search for node if already
available. However, it is not ensured that a null is returned for a mismatched node. This
returns the sub-string corresponding to the instance. For example, if the MibNode is
system and the OID as sysDescr, the return value starts with the sub-id of mib-2. The
intersection of the node OID and the given OID are eliminated from the returned OID
string.

The getNearestNode() method of MibModule class gets the nearest MIB node
corresponding to the int array of the OID. The getNearestNode(SnmpOID) method of
MibOperations class searches all MIB modules loaded in this MibOperations instance
and returns the OID if found.

The getSubID() of the MibNode class gives the sub identifier of this node's object-
identifier. The ObjectIdentifier have the 128 sub-identifiers, each sub-identifier can have
the value ranges from 0 to 4294967295. The getNumberedOIDString() method of the
MibNode class gives the numbered OID string of the node. The getOID() method of the
MibNode class gives the numbered OID of the node as an int array. The getOIDString()
method of the MibNode class gives the named OID of the node. The getOIDVector()
method of the MibNode class gets the named OID of the node as a vector.

Processing MIB Information:


The createVariableBinding(String varName, String[] indexes, String value) method of
the MibOperations class creates an SnmpVarBind instance with the supplied parameters.

The method decodeInstanceString(String, Vector) of the LeafSyntax class decodes an


instance string based on the instance and index nodes. The encodeInstanceString()
method of the MibOperations class encodes an instance string based on the SNMP type
of the index node. This encoded instance string should be concatenated to the node OID
to get the complete OID. The encodeInstanceString() method of the LeafSyntax class
encodes an instance string based on the index vector and index nodes.

The createSnmpVarBind(Vector, SnmpVar, Vector) method of the MibNode class creates


an SnmpVarBind instance with the supplied parameters.

The method decodeDefval() of the MibNode class decodes the DEFVAL value that is
defined for this node and returns the corresponding SnmpVar object.

Displaying MIB Information:


To print the value in hex string format, you can use the toByteString() method. To print
the values in the NVT ASCII format, the setIgnoreSpecificControlCodes(boolean)
method of the MibOperations class can be to set true. If the value is between 32 and 127,
the ASCII value is printed.

Configuring SNMP Agent Parameters:


AdventNet SNMP API provides methods to configure the common agent parameters.
The following table describes the API methods used for configuring the agent parameters:

Agent Class/Component
Description API Methods
Parameter Name
SnmpSession
SNMP Refers to the SNMP version Version = int value
Version of the agent. If the SNMP SnmpPDU
version is not explicitly set,
the default version is taken
as SNMPv1. To set the
specific SNMP version, we
need to use the following
methods. The value 1 is for
SNMPv2c.

This refers to the network


address or the host name of RemoteAddress =
the node in which the agent InetAddress
is installed. Applications use
Host Name UDPProtocolOptions
the host name or the IP RemoteHost = String
address of the device to value
communicate with the agent
of the device.

The management
applications communicate
with the SNMP agents in the
managed node in a
particular port number. This
remote port number is the
UDP port 161. By default,
all the SNMP request
messages are received in
RemotePort = int
Port Number this port. Sometimes, the UDPProtocolOptions
value
agent may also be
configured to receive
messages in ports other than
161. The management
applications normally have
the provision to send request
to the default port and also
the option to set different
port numbers.
SnmpSession Community = String
Community Community strings are used value
Name to authenticate SNMP SnmpPDU
PDUs. Since SNMP packets WriteCommunity =
are usually sent using UDP String value
packets, there is no
connection established as in
the case of TCP/IP packets.
Therefore, when a UDP
packet arrives at the agent,
the agent validates the
packet. It accepts and sends
a response if the community
string of the PDU is equal to
that set on the agent, else
drops the packet. The agent
does not change the
community name after
communicating.
Applications typically
communicate with the
SNMP agents by specifying
the community name of the
agent.

The timeout is the time


interval that an application
waits for a response
message from an agent.
Typically these values are
given in milliseconds or in
seconds. If the value is 5 SnmpSession Timeout = int value
Timeout and seconds, the application
Retries waits for 5 seconds for the SnmpPDU Retries = int value
response before timing out.
Retries are the number of
times a request is sent when
a timeout occurs. If the retry
value is 0, the request is not
re-transmitted during
timeout.

The Max Repetitions value


specifies the number of
lexicographic successors to SnmpSession
Max MaxRepetitions = int
be returned for the
Repetitions SnmpPDU value
remaining variables in the
variable-bindings list. The
default value is 50.
SnmpSession
Non Repeaters The Non Repeaters value NonRepeaters = int)-
specifies the number of SnmpPDU value
variables in the variable
bindings list for which a
single lexicographic
successor is to be returned.
The default value is 0.

Data Retrieval Operations :


SNMPGet:
Following are the steps involved in performing a simple SNMP GET operation using
the API.

1. Instantiate the SnmpAPI class.

SnmpAPI api = new SnmpAPI();


2. Instantiate and open the SnmpSession class.

SnmpSession session = new SnmpSession(api);

session.Open();

3. The default protocol used for SNMP communications is UDP. Every


packet that is sent through SnmpSession goes through the UDP implementation of
SnmpTransportProvider. Parameters that are required for such operations are given
through the UDPProtocolOptions class. After SnmpSession is opened for SNMP
communication, the default values such as remoteHost and remotePort can be set
using the UDPProtocolOptions object. If the remoteHost and remotePort is not
specified in the SnmpPDU object, the API takes it from SnmpSession.

An SnmpPDU instance needs to be created to send any request to an SNMP peer.


The SnmpPDU provides most of the communication parameters related methods that are
available with SnmpSession and it overrides the value in the session.

Set the SNMP version using the Version() method and use the Command() method to
send an SNMP request. The command constants are defined in the SnmpAPI class. The
following command sets the constant to GET_REQ_MSG to perform an SNMP GET
operation.

//Build GET Request PDU

SnmpPDU pdu = new SnmpPDU();


//get the value from the command line

UDPProtocolOptions option = new UDPProtocolOptions(remoteHost);

pdu.ProtocolOptions=option;

pdu.Command=SnmpAPI.GET_REQ_MSG;

4. To make a query for an OID or a list of OIDs, the SnmpOID class is


to be instantiated. SnmpOID is the sub class of the SnmpVar class that provides
abstract methods to present a uniform interface for applications working with the
SNMP variables.

The OID can be given in the form x.x.x... or .x.x.x.... The OID given in the form
.x.x.x.x is assumed to be fully qualified, and the OID in the form x.x.x is not fully
qualified in which case the value of the SnmpAPI.getOIDPrefix() method is added to the
OID as a prefix.

This prefix can be changed by the user but it should be to applied across the entire
application. The AddNull method in the SnmpPDU class adds a variable binding with the
OID specified and a null variable value. Multiple OIDs can also be given as input.

SnmpOID oid = new SnmpOID("1.1.0"); //Here the OID is .1.3.6.1.2.1.1.0

pdu.AddNull(oid);

5. After the SnmpPDU and the OID is setup using the above methods, it
should be sent over a session to the peer SNMP entity. The method SyncSend(pdu)
is used to send synchronous requests. The PrintVarBinds() methods is used to print
the descriptive value of the OID and the variables. An error message is displayed if
the request fails.

SnmpPDU result = session.SyncSend(pdu);

System.Console.Out.WriteLine(result.PrintVarBinds());

6. Close the session and the API thread.

session.Close();

api.Close();
SNMP GETNEXT:
The SNMP GETNEXT operation is similar to the SNMP GET operation. The
GETNEXT operation retrieves the value of the next OID in the tree. The GETNEXT
operation is particularly useful for retrieving the table data and also for variables that
cannot be specifically named. It is used for traversing the MIB tree.

Unlike SNMP GET, providing the instance value as part of the OID is not
mandatory. The SNMP GETNEXT operation always returns the next OID in the MIB tree
regardless of whether we specify the particular instance of OID.

This is similar to performing a SNMP GET operation as discussed in SNMP GET


topic.

To perform the SNMP GETNEXT operation, we need to use the


GETNEXT_REQ_MSG command constant instead of GET_REQ_MSG.

//Build GETNEXT Request PDU

SnmpPDU pdu = new SnmpPDU();

//get the value from the command line

UDPProtocolOptions option = new UDPProtocolOptions(remoteHost);

pdu.ProtocolOptions=option;

pdu.Command=SnmpAPI.GETNEXT_REQ_MSG;

The rest of the steps remain the same as SNMP GET.

SNMP GETBULK:
The GETBULK operation is normally used for retrieving large amount of data,
particularly from large tables. A GETBULK request is made by giving an OID list along
with a Max-Repetitions value and a Nonrepeaters value.

The GETBULK operation performs a continuous GETNEXT operation based on the


Max-Repetitions value. The Nonrepeaters value determines the number of variables in
the variable list for which a simple GETNEXT operation has to be done. For the
remaining variables, the continuous GETNEXT operation is done based on the Max-
Repetitions value.

In other words, the SNMP GETBULK operation does a simple GETNEXT


operation for the first N variable bindings in the request and does M GETNEXT
operation (continuous) for each of the remaining R variable bindings in the request list
where

N is the minimum of

 the value of the Non-Repeaters field in the request


 the number of variable bindings in the request

M is the Max-Repetitions field of the request

R is the maximum of

 the number of variable bindings in the request


 zero

Thus the total number of varbinds in the response message is (N + M x R).

This is similar to performing a SNMP GET operation as discussed in SNMP GET


topic. The additional parameters for the SNMP GETBULK operations can be set using
the following methods.

 MaxRepetitions()
 NonRepeaters()

To perform an SNMP GETBULK operation, the command constant


GETBULK_REQ_MSG defined in the SnmpAPI class is used.

//Build GETNEXT Request PDU

SnmpPDU pdu = new SnmpPDU();

//get the value from the command line

UDPProtocolOptions option = new UDPProtocolOptions(remoteHost);

pdu.ProtocolOptions=option;

pdu.Command=SnmpAPI.GETBULK_REQ_MSG;

pdu.MaxRepetitions=10;

pdu.NonRepeaters=0;

The rest of the steps will remain the same as the SNMP GET operation.
Data Altering Operations:
SNMP SET:
The SNMP SET operation is used by the management applications to modify the
value of the managed object. Most of the managed objects have a default value
maintained by the agent. Sometimes the applications might want to modify one or more
MIB variables by using the SNMP SET operation.

The applications typically perform an SNMP SET operation by providing the host
name of the agent, one or more OIDs along with its instance, and the new value. The
agent processes the request and assigns the new value to the MIB variable. If an error
occurs, the new value is not assigned.

The SnmpAPI, SnmpSession, and SnmpPDU classes are used for most of the
management operations.

To use the communication services available with the API, we must instantiate
SnmpAPI. The SnmpAPI class is a thread which monitors SNMP sessions and it contains
various SNMP parameters.

To communicate with SNMP entities, we need to instantiate the SnmpSession class.


The Open() method is to be invoked to get the socket, SnmpTransportProvider,
(DatagramSocket in case of UDP) for SNMP communication. Various parameters, such
as remote host, remote port, version, community, retries, and timeouts can be set using
this class.

Following are the steps involved in performing a simple SNMP SET operation using
the API.

Instantiate the SnmpAPI class.

SnmpAPI api = new SnmpAPI();

Instantiate and open the SnmpSession class.

SnmpSession session = new SnmpSession(api);

session.Open();

To perform SNMP SET operations, the command constant SET_REQ_MSG defined in


the SnmpAPI class should be used.

// Build set request PDU


SnmpPDU pdu = new SnmpPDU();

pdu.Command=SnmpAPI.SET_REQ_MSG;

To perform SET operations we need to know the OID, its type, and its value. These
values are needed to build the varbind and can be received as user input. The variable
binding or the varbind is the pairing of the OID and its corresponding value. This varbind
should be added to the PDU for performing SET operations.

The type of the variable can be INTEGER, STRING, COUNTER, etc. The
SnmpAPI class provides constants for all the SNMP data types. Using this type, the value
an instance of SnmpVar is created.

String value = "localhost";

sbyte dataType = SnmpAPI.STRING;

SnmpOID oid = new SnmpOID("1.5.0"); // sysName

SnmpVar var = null;

// create SnmpVar instance for the value and the type

var = SnmpVar.CreateVariable(value_Renamed, dataType);

This SnmpVar object is used to create the varbind.

//create varbind

SnmpVarBind varbind = new SnmpVarBind(oid, var);

The variable binding is then added to the PDU.

//add variable binding

pdu.AddVariableBinding(varbind);

Now the request should be sent over a session to the peer SNMP entity. The method
SyncSend(pdu) is used to send synchronous requests. The PrintVarBinds() methods is
used to print the descriptive value of the OID and the variables. An error message is
displayed if the request fails.

result = session.SyncSend(pdu);
System.Console.Out.WriteLine("Response PDU received from " + result.Address+ ",
community: " + result.Community);

System.Console.Out.WriteLine(result.PrintVarBinds());

Close the session and the API thread.

session.Close();

api.Close();

Traps and Notifications:


Trap Parameters:

Management applications can receive trap messages sent by the agent. Following are
the trap parameters that are to be set while developing applications

Enterprise OID:

This is the OID of the management enterprise that defines the trap message.

The value is represented as an OBJECT IDENTIFIER and has a variable length. The
following table displays the method that can be used for setting the enterprise OID.

Class/Component Name API Methods

SNMP PDU EnterpriseOID = SnmpOID

Agent Address

This specifies the source IP address from which the trap was sent. The following
table displays the method that can be used for setting the agent address.

Class/Component Name API Methods

SNMP PDU AgentAddr=String value

Generic and Specific Type


The SNMP standard defines seven traps that can be generated by SNMPv1 agents.
Six of these traps are "generic" traps and the seventh trap is enterprise specific. The
enterprise-specific trap is used by the private organizations to define their device-specific
traps. The six generic trap types defined for SNMPv1 agents are as follows.

 coldStart trap (0)


 warmStart trap (1)

 linkDown trap(2)

 linkUp trap(3)

 authenticationFailure trap(4)

 egpNeighborLoss trap(5)

The generic traps are fixed and cannot be defined. On the other hand, it is possible to
define multiple enterprise-specific traps.

The trap message identity is determined based on the values contained in the
Enterprises, Standard Trap Type, and Specific Trap Type fields of the Trap PDU. If the
Trap Type value is zero through five, the trap is one of the generic traps and the value of
the Specific Trap Type field will be zero. If the Trap type value is six, the trap is
enterprise specific and is defined in a private MIB. It can take any integer value between
0 and 2147483647.

The following table lists the methods that can be used for setting the trap type. The
following table lists the methods that can be used for setting the generic and specific
traps.

Class/Component Name API Methods Remarks

TrapType = int value The TrapType method


sets the generic type of the
SnmpPDU SpecificType = String trap and the SpecificType
value sets the specific type of the
trap.

Time Stamp

This is the value stored in the MIB-II sysUpTime variable converted into hours,
minutes, and seconds. It is a 32-bit unsigned value indicating the number of centiseconds
that have elapsed since the start of the SNMP agent and the sending of the trap. The
following table displays the method that can be used for setting the time stamp.

Class/Component Name API Methods

SNMP PDU UpTime= longvalue

Trap Port

The traps are normally received in the UDP port no 162. However, this port number
can be different and the applications should be able to handle this.

The following table lists the methods that can be used for setting the trap port.

Class/Component Name API Methods

UDPProtocolOptions LocalPort =int value

An SNMPv2 trap may need to be translated to an SNMPv1 trap. The following table
shows the notification parameters that make up an SNMPv1 trap and SNMPv2 traps.

SNMPv2 Trap
SNMPv1 Trap

enterprise value sysUpTime (first variable -binding)

agent address snmpTrapOIDvalue(nextvariable bindings)

generic-trap value snmpTrapEnterprise value (optional)

specific-trap value additional variable bindings

timestamp

variable-bindings

Deployment Instructions:
The deployed environment should have the following installed:
1. The .NET Framework version 1.1 redistributable package to run applications
developed using the .NET Framework.

2. The Microsoft Visual J# .NET version 1.1 Redistributable Package to run


your Visual J# .NET applications on a computer that already has the Microsoft .NET
Framework version 1.1 installed.

The application meant for deployment should have the following in the PATH

 mscorlib (part of the .NET Framework version 1.1 redistributable)


 AdventNetSnmp.dll

 <your application libraries>

In addition to the above, if the application has some reference to the MIB, the
following needs to be in the PATH

 vjslib (part of the Microsoft® Visual J#™ .NET version 1.1 redistributable)
 AdventNetMibsAPI.dll.

This is the main parts on AdventNet package features that the project has deal with
and so the implementation part of the project is complete, this package give the project
the following benefits keys:

Flexibility - provides a hierarchy of .net library packages, which allow flexible


selection of the level of library support desired. Therefore, you can access the detailed
SNMP.

 Multi-lingual support: Complete support for SNMPv1 and SNMPv2c


 Robust SMIv1 and SMIv2 MIB Parser: Seamlessly parses the MIB definitions
from any OEM vendor. Offers various flavors of parsing based on the MIB
definitions.

 Command line utilities: Perform SNMP operations such as, SNMP GET, SNMP
GETNEXT, SNMP SET, SNMP BULK, SNMP WALK, etc. on remote agents.
USER MANUAL:

HOW TO USE THE SOFTWARE:

this part contain the correct way to use this software using figures to each state in the
application:

SNMP Main Form:

the following picture show the main form for this SNMP interface , and below it the
function of each button in that form:

FIG 1: Application main form

the main form contain four button and three menu items each one has a function to open
another forms , each button do the following:
 Configuration: open the following configuration form :

FIG 2 :Configuration Form

the component of this form do the following :

 Brows: enable the user to load the MIB file from any location , this MIB file will
contain the standard MIB variables according to the SNMP version this
Application can deal with the two version SNMPV1 and SNMPV2 , those
variables must be arranged as a MIB tree on the list area under the browse textbox ,
this will help the user not to memorize all the MIB variables (surely he can't) , so
he can take any MIB variable ID from this part.
 Get NMS Values: by it name it will open a form that enable the user to get the
wanted variable parameters , the following figure show the opened form :
FIG 3: Get NMS Values form

the component of this form do the following :

 Get NMS values: will return the values of this variable in a sorted form using
browser list that arrange the values in beautiful way , this need the ID for that
variable which can be taken from the configuration form if not been memorized by
the user , the other part needed to achieve the GET command is the IP address for
the remote managed device , after apply the a correct GET command the following
figure appear containing the wanted values:
FIG 4 : Correct Get Command

the File menu on each form contain Exit submenu that will close the corresponding form ,
and the help menu will activate this CHM file help , on this way the GET operation is
completed.

 Get Next NMS: represent an event that can retrieve the next variable parameters to
that OID on the text box, and update the text box with the new retrieved OID, this
enable the user to walk over the MIB and also get the variables parameters also.
 Get Bulk NMS Values: represent an event that can retrieve a set of variables from
the given kind of MIB node ID, and arrange them on the list box at the same row.
 Set NMS value: from the configuration form this button from it name used to
enable user to open the form that enable him to set the value for a given variable ,
this button will activate the following form:
FIG 5: Set NMS Values Form

the only event in this form is:

 Set NMS New Values : button that will set the value of the wanted MIB variables
by the inserted value , the event need to choose the type of the remote variable
from the combo box that contain all type of the MIB variables , the event also
need the IP address for the remote device , and the ID of the MIB variable wanted
to reset , after the correct set command apply a list is appear with the new value to
be sure that the value is reset as the following :
FIG 6: Correct Set Command.

 NW FM : this button from the configuration form is related with the network trap
messages that come from the different network devices , the mentioned SNMP trap
services on the system is the median between the network nodes and this
application you must configure that services to be able to catch the trap messages,
this button will open a form that act as a server that listen to any coming trap
message and put it format on the form body to enable the administrator to read it
and to take a good decision according to that message , the following figure show
the NW FM form catching a trap message.
FIG 7: NW FM catching message.

 Statistics: is a button that open the following form that can apply walk command
on the MIB or on the Agent, this will return all variable (statistics) on the MIB or
on the agent, the MIB group that the user select from the combo box will help in
getting the leaves of the same MIB group node forming the mib tree.
 help: button used to activate this help file.
 the option menu contain three submenus this menu option is can be used to do all
the operations mentioned , the submenu are:

1. configuration : which contain submenu named (load mib file) work as the
configuration button..
2. NW FM : work as the NW FM button.
3. statistics : Forming the MIB tree from MIB file or Agent.

FIG 8: Application Menus

******END******

You might also like