This chapter assumes that the previous chapter covering
the basic components of building an active network application in Magician
has been read and understood. In this chapter, and throughout the rest of
this tutorial, we add incremental features to our sample application known
as LoadGen.
Remember from Chapter 1 that the SNMP MIB serves as the
connection between the active application to be enhanced with Atropos prediction
and the Atropos physical process model as shown in right side of the following
figure.
Key Concept
- Simple Network Management Protocol (SNMP) Objects are used by
the Atropos System in order to work with an application. In this chapter
we focus solely on adding an active network implementation of SNMP using
the Magician execution environment.
- The first step is to decide what information is required to
manage this toy application. We have decided that two elements are critical
to management:
- The length of time the application has been running
- The number of packet transmission rate
- The first piece of information tells us how long the application
has been running and provides a first level view of availability. The second
piece of information is critical for determining the performance of the application.
One could probably list many other pieces of information that would be relevant
for this relatively simple application, but we will focus on the two above
in order to keep things simple. The class that implements the active SNMP
is called AppCommunicator and is shown in the code segment below:
transient
private AppCommunicator context;
context.addSubAgent(oid, value);
context.updateSubAgent(oid, value,
index);
|
The SubAgent methods will update the SNMP Object Identifier
(oid) with (value). Index (index) is the index into the table of SNMP Object
Identifiers if oid is a table. addSubAgent
will throw DuplicateEntryException if the entry has already been added.
updateSubAgent will throw an InvalidIdException
if the oid has not been added yet.
The remainder of this chapter provides details on the changes
to the program classes from Chapter 3.
LoadGenAppSnmp
- imports
- New classes and packages need to be imported in order to instrument
the application with SNMP.
- LoadGenAppSnmp
- The constructor should create the SNMP agent connection.
- addObject
- This series of overloaded methods allows various types of values
of SNMP Object Identifiers to be created.
- context
- This is an instance of the connection to the active SNMP Agent.
- ObjectIds
- These object identifiers form a tree with two nodes: one for
the application uptime and one for the total number of active packets transmitted.
- updateObject
- This series of overloaded methods allows various types of SNMP
Object Identifier values to be updated reflecting changes in the application
state.
- exec
- This is where the application keeps the SNMP agent updated with
recent changes to managed objects.
LoadPacketAppSnmp
- import
- The active packet needs access to the SNMP and SNMP Agent packages.
- uptime
- The total application uptime is maintained in this member variable.
- ObjectId
- These object identifiers form a tree with two nodes: one for
the application uptime and one for the total number of active packets transmitted.
- context
- This is an instance of the connection to the active SNMP Agent.
- incrObject
- Increment an existing SNMP Object Identifiers value, or create
a new one with a value of zero. This method is kept in a critical area so
that multiple instances of this call will not interfere with one another.
- setObject
- Set an object identifier's value; create it if it does not already
exist. This method is kept in a critical area so that multiple instances
of this call will not interfere with one another.
- updateObject
- This series of overloaded methods allows various types of SNMP
Object Identifier values to be updated reflecting changes in the application
state.
- addObject
- This series of overloaded methods allows various types of values
of SNMP Object Identifiers to be created.
- LoadPacketAppSnmp
- This is the constructor for the active packets that are created
by LoadGenAppSnmp. The total time that LoadGenAppSnmp has been executing
is passed into this constructor.
- exec
- This method overrides the Magician method within a Magician
packet. This is where the action occurs; in this case we can check whether
our packet is currently on the source or on the destination.
LoadAppSnmpBase
- imports
- Include access to the active SNMP and active SNMP Agent packages.
- transient classes
- Include the active SNMP and SNMP Agent classes.
Running the Active Application
After reading through this code and understanding what it does, you can compile
the code "as-is" using the included Makefile. Run in the Magician execution
environment by entering:
- send InjectSnmp AH-1
- send LoadGenAppBasic AH-1
The object identifiers created within the application should now be queriable
via an SNMP client.
|