An example script for the ping application is under tcl/ex/diffusion3/simple-diffusion.tcl. The example scenario consists of 3 nodes of which one is a ping-sender and another is a ping-receiver. The source and sink nodes are far away from one another and communicate only through a third node. The option adhocRouting is defined as Directed_Diffusion. This enables a core-diffusion agent to be created during the time of node creation. Also it creates a diffusionApplication agent if one is not present already. And a gradient filter is attached by default to each diffusion-enabled node.
The ping sender application is created in the following way:
set src_(0) [new Application/DiffApp/PingSender] $ns_ attach-diffapp $node_(0) $src_(0) $ns_ at 0.123 "$src_(0) publish"
The first line creates a ping-sender object. Simulator class method attach-diffapp basically attaches the application to the underlying diffusionApplication agent for that given node. The command publish essentially ``starts'' the sender application.
Similarly the ping sink is created as follows:
#Diffusion sink application set snk_(0) [new Application/DiffApp/PingReceiver] $ns_ attach-diffapp $node_(2) $snk_(0) $ns_ at 1.456 "$snk_(0) subscribe"
The command subscribe once again starts the ping-receiver application.
Thus in order to create your own application, you need to :
See tcl/lib/ns-lib.tcl, ns-diffusion.tcl for implementations of OTcl hooks for directed diffusion. Alo see chapter on Mobility in this manual for details on mobility model and wireless simulations in .
Paul Kroon 2008-03-16