Stephen F. Bush and Amit Kulkarni
(bushsf@crd.ge.com,
kulkarni@crd.ge.com)
|
|
|
This chapter begins the explanation of how to develop application SmartPackets in Magician. The application we will try to develop performs the very simple task of generating SmartPackets at some given rate. This application is called LoadGenAppBasic. This application consists of three user-developed Java classes: LoadGenAppBasic: This
class forms the active packet that generates active packets and
contains the loop shown above. In Magician, every application that uses more than one SmartPacket must define a base packet class that contains definitions of the application's constituent packets. In our example, this base class is defined in LoadGenAppBasicBase. The next section shows how to create a base class for an application. What is Magician?Magician is a toolkit for creating a new prototype network called an active network. Active networks are a new class of networks that enable the programming of intermediate nodes in the network. A network is defined to be active if it allows applications to inject customized programs into the network to modify the behavior of the network nodes. This allows applications to customize the network processing and adapt it to the application's immediate requirements. This enables new protocols and new services to be introduced into the network without the need for network-wide standardization. In an active network, program code and data is placed inside
specialized packets called SmartPackets. The nodes of an active
network are called active nodes and they are programmable in
the sense that when a SmartPacket reaches an active node, the
code inside the SmartPacket is extracted and executed. Depending
on the nature of the code inside the SmartPacket, the SmartPacket
either modifies the behavior of the active node or transforms
the data it is carrying. Magician provides the tools for creating
a prototype active network using general-purpose computing environments,
deploying active nodes in the network, and the tools and interfaces
for creating SmartPackets that can install new services and protocols
in the active network. Magician is implemented in JavaTM and
provides a Java-like API for developers to create their applications.
This reduces the learning curve for application development and
also leverages the benefits of the Java programming language
and the virtual machine environment. Creating a Base Application ClassMagician provides two basic pre-defined frameworks to users: (1) a framework providing unreliable delivery service; and (2) a framework providing reliable delivery service. The functionality of these frameworks is similar to the UDP datagram/TCP socket abstractions in traditional networks. The difference is that in Magician, users can replace, extend, or customize functionality of the frameworks to achieve application-specific service.
In Magician, a user-defined SmartPacket utilizing the default unreliable delivery service is created by extending the magician.Node.KU_SmartPacket_V2 class as shown below.
The package magician.Node is imported because it contains classes that provide the API for creating and executing SmartPackets. The API for accessing node resources (e.g., getting node name, finding out the next hop etc.) is provided by the magician.Node.KU_SmartPacket_V2 interface. The basic unreliable service provides forwarding and routing functions. The RIP routing protocol is the default routing protocol that is implemented by all active nodes running Magician. On the other hand, SmartPackets that require assured delivery service are created by extending the properties of the magician.Node.ReliableCommFW class as shown below:
The basic reliable service framework adds a sequencing module, a hop-by-hop stop-and-wait-acknowledgment protocol module, and a retransmission module to provide assured delivery. A hop-by-hop protocol is chosen because, in an active networking environment, the destination of a SmartPacket can possibly change during its execution at an active node. This is the simplest reliable delivery mechanism that can handle dynamic destination changes. For example, if a client request packet traversing the network towards a server node encounters information about the location of a proxy that merges duplicate requests to the server, then the request packet resets its destination to the location of the proxy. If an end-to-end acknowledgment/retransmission protocol is used in this case, it will fail because the server node is expecting the packet to be received but the packet never gets there. Getting back to the LoadGenAppBasicBase class, one can see that it has a constructor and only one access method:
This method is required to be defined for the base class. The only change that an application developer needs to make in the method body is to insert the fully qualified name of the base class in the Class.forName(...) method. Additionally, the developer must add dummy definitions of all the other non-Magician classes that the application uses. In our example, the application uses only one other class -- LoadGenAppBasic. Therefore, it is defined as a transient private variable.
This is required so that Magician is able to package all application classes and inject them into the network nodes. Otherwise, the application will exit with a ClassNotFoundException. The developer may add additional methods or variables in this class that are application-specific. Once the base application class is defined, the other application classes can be developed. Writing Application ClassesThis example has two application classes: LoadGenAppBasic and LoadPacketAppBasic. This section shows the manner in which the LoadGenAppBasic class is created. All application classes are created in the same way.
As mentioned earlier, LoadGenAppBasicBase is the base packet class for all packets in this application. Therefore, all application classes must extend the base class. Each application class must override the exec() method of the magician.Node.KU_SmartPacket_V2. The exec() method is the entry point for the user code.
The user can define other custom methods for the application
class, but Magician will not call those methods directly. It
is up to the code in the exec() method to invoke the user's custom
method. Invoking Magician PrimitivesThe application class accesses active networking features embedded in Magician by directly invoking methods from the magician.Node.KU_SmartPacket_V2 class. For example, a packet puts itself to sleep by invoking the sleep() method with an interval after which the packet is to be woken up.
In the above statement, the packet relinquishes the CPU and is put to sleep for 250 microseconds. In Magician, a packet is generally injected into the network from a host node using the Magician command line interface. However, a SmartPacket can create another packet belonging to the same application as the parent SmartPacket and inject it into the network at run-time. The commands
create a new SmartPacket of type LoadPacket (which extends the LoadGenAppBasicBase class and hence belongs to the same application as LoadGenAppBasic), and send the packet to the destination active node named AN-5. The packet will execute on every node along the way including the source and destination nodes. Now that we know how to build applications in Magician, let us try to develop a simple AVNMP application.
|