AVNMP

Active Virtual Network Management Prediction
Chapter 4: Building Applications

Stephen F. Bush and Amit Kulkarni
(bushsf@crd.ge.com, kulkarni@crd.ge.com)
Previous Chapter
Beginning of Tutorial
Next Chapter
 
This chapter begins the explanation of how to use Atropos code by first developing a simple Magician application. This application performs the simple task of generating active packets at a given rate. This application is called LoadGenAppBasic and it will be kept as simple as possible. Atropos will not be used until we build up to it a few chapters from now. The links below point to specific sections of the LoadGenAppBasic code. 

Key Concept

Our first task is to create an active packet that generates active packets. We will first focus on building how our active application will behave. The code segment that generates and transmits an active packet (which is found in LoadGenAppBasic) is shown here: 
 
LoadPacket lp = new LoadPacket();

lp.SendForProcessing("AN-5");
 
These two lines of code create an instance of an active packet of class 'LoadPacket' and send it to active node 'AN-5'. We will want these active packets to be created and transmitted at a given rate. Therefore, we loop through the above code segment, generating and transmitting packets until we reach the requested packets per second as shown in the code segment below: 
 
 while(Rate() < PacketsPerSecond)
{
    System.out.println("Packets/Second: "+ Rate());

    LoadPacket lp = new LoadPacket();

    lp.SendForProcessing("AN-5");

    numPkts++;

}
 
The remaining code and class definitions are required to interface with the Magician execution environment and to create the utility methods needed to support the code in the loop above. There are three classes required to implement the above code:

 
  1. LoadGenAppBasic: This class forms the active packet that generates active packets and contains the loop shown above. 
  2. LoadPacketAppBasic: This class implements the active packets that are generated by LoadGenAppBasic. 
  3. LoadAppBasicBase: This is a class derived from the Magician active packet class and from which the above two class are derived. This class handles the interface between this application and Magician. 

  4.  
The explanation below provides detail on each section of the three classes. 

LoadGenAppBasic

package 
This is the usual Java package command. This AVNMP sample application will be implemented within the specified package. 
imports 
The only required package that needs to be imported for this example is the util package because the Date class is used to get the current time. 
class 
The class for LoadGenAppBasic is defined here. Note that LoadGenAppBasic is derived from LoadGenAppBasicBase . The LoadBase class is a requirement of the Magician execution environment. 
numPkts  
This is the total number of packets transmitted. It is used to determine the current number of packets that have been transmitted during the last second. 
PacketsPerSecond  
This PacketsPerSecond method is used to determine the current number of packets that have been transmitted during the last second. 
Date 
The Date class is required in order to get millisecond accuracy in timing. 
LoadGenAppBasic  
Magician requires that a constructor exist. Here we have written an empty constructor. However, in later chapters we will need to place code within the constructor. 
milliSeconds  
This method returns the number of milliseconds since LoadGenAppBasic began running. 
Seconds 
This method returns the number of seconds since LoadGenAppBasic began running. 
Rate 
This method computes the rate of packet transmission LoadGenAppBasic began running.
exec 
This method overrides the Magician method within a Magician packet. This is where the action occurs; the application, which is itself an active packet, begins generating new packets -- LoadPacketAppBasic. Note that the active LoadPacketAppBasic packet is sent to node AN-5. Any node name can be used here as long as it is in the Magician configuration. 
sleep 
Sleep for a quarter of a second, allowing the active node to process other packets. 

LoadPacketAppBasic

package  
This is the usual Java package command. This AVNMP sample application will be implemented within the specified package. 
class 
The class for LoadGenAppBasic is defined here. Note that LoadGenAppBasic is derived from LoadPacketAppBasic . The LoadBase class is a requirement of the Magician execution environment. 
LoadPacketAppBasic  
Magician requires that a constructor exist. Here we use the uptime of the LoadGenAppBasic application. 
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. 
Destination check 
If we're on the destination node, then halt execution of the packet. 

LoadAppBasicBase

package 
This is the usual Java package command. This AVNMP sample application will be implemented within the specified package. 
imports 
The only required package that needs to be imported for this example is the util package because the Date class is used to get the current time. 
class 
The class for LoadAppBasicBase is defined here. The LoadBase class is a requirement of the Magician execution environment. 
LoadGenAppBasicBase  
Magician requires that a constructor exist. Here we use the uptime of the LoadGenAppBasic application. 
writeObject  
Serialize any external classes to be used within active packets. 

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 LoadGenAppBasic AH-1. 
Previous Chapter
Beginning of Tutorial
Next Chapter

The complete AVNMP documentation is found in the AVNMP API
This research is funded by DARPA/ITO Contract Number: F30602-98-C-0230 supported by the Air Force Research Laboratory/IF.
The project web site is http://www.crd.ge.com/~bushsf/an

SourceForge
Logo