The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ... The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

nmlab.korea.ac.kr
from nmlab.korea.ac.kr More from this publisher
12.07.2015 Views

Next you need to add the c++ function command(..) that allows execution of tcl commands through the compiled shadowobject. For example the otcl command start is used to start a filter application as follows $app start. While commandspublish and subscribe are used to start sender and receiver applications respectively. The command function is added,again with the NS_DIFFUSION scope using ifdef statements, as follows:#ifdef NS_DIFFUSIONint LogFilter::command(int argc, const char*const* argv)if (argc == 2)if (strcmp(argv[1], "start") == 0)run();return TCL_OK;return DiffApp::command(argc, argv);#endif // NS_DIFFUSIONNote how the parent class command function is invoked incase the command string is not found. Look into lib/diffapp.* tosee all otcl commands supported for the DiffApp class.Once these changes made to your c++ code, you would also need to write a tcl script (see the section on test-suite for exampletcl scripts) that uses your diffusion application using the right tcl APIs.20.7 Test-suites for diffusionwe start with a simple testcase of 3 nodes with 1 ping source and 1 ping sender. There are other tests for 2 phase-pull(2pp), 1phase-pull(1pp), push and gear (with 2pp and push) scenarios. In future we plan to extend the test-suite for testing differentcomponents/functionalities of directed diffusion. All diffusion3 related test cases can be found under ~ns/tcl/test/test-suitediffusion3.tcl.20.8 Commands at a glanceFollowing is a list of commands used for diffusion related simulation in ns.$ns_ node-config -adhocRouting $opt(adhocRouting)-llType $opt(ll)...-diffusionFilter $opt(filters)-stopTime $(pre-stop)...where,value of opt(adhocRouting) is set to Directed_DiffusionThis command is used to enable directed diffusion in wireless nodes.value of opt(filters) can be a list of filters that is required to be attached to diffusion nThis command allows adding filter objects to diffusion-enabled nodes.199

value of opt(pre-stop) is usually the time simulation stops when all statistical data is dumpThis command allows dumping of statistical data into an output file after running a diffusionset src [new Application/DiffApp/PingSender]This command is used to create ping-sender application.set snk [new Application/DiffApp/PingReceiver]This command is used to create ping-receiver application.set src [new Application/DiffApp/PushSender]This command is used to create push-sender application.set snk [new Application/DiffApp/PushReceiver]This command is used to create push-receiver application.set src [new Application/DiffApp/GearSenderApp]This command is used to create gear-sender application.set snk [new Application/DiffApp/GearReceiverApp]This command is used to create gear-receiver application.$gearApp push-pull-options This command defines the type of routing algorithm gear is using. Incase the second option is defined as region, allfour co-ordinates should be defined. While if point is chosen, only X1 and Y1 maybe defined.$ns_ attach-diffapp $node_ $src_where the diffusion application $src_ gets attached to the given $node_.$src_(0) publishCommand to start a ping source (sender).$snk_(0) subscribeCommand to start a ping sink (receiver).200

Next you need to add the c++ function comm<strong>and</strong>(..) th<strong>at</strong> allows execution of tcl comm<strong>and</strong>s through the compiled shadowobject. For example the otcl comm<strong>and</strong> start is used to start a filter applic<strong>at</strong>ion as follows $app start. While comm<strong>and</strong>spublish <strong>and</strong> subscribe are used to start sender <strong>and</strong> receiver applic<strong>at</strong>io<strong>ns</strong> respectively. <strong>The</strong> comm<strong>and</strong> function is added,again with the NS_DIFFUSION scope using ifdef st<strong>at</strong>ements, as follows:#ifdef NS_DIFFUSIONint LogFilter::comm<strong>and</strong>(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv)if (argc == 2)if (strcmp(argv[1], "start") == 0)run();return TCL_OK;return DiffApp::comm<strong>and</strong>(argc, argv);#endif // NS_DIFFUSIONNote how the parent class comm<strong>and</strong> function is invoked incase the comm<strong>and</strong> string is not found. Look into lib/diffapp.* tosee all otcl comm<strong>and</strong>s supported for the DiffApp class.Once these changes made to your c++ code, you would also need to write a tcl script (see the section on test-suite for exampletcl scripts) th<strong>at</strong> uses your diffusion applic<strong>at</strong>ion using the right tcl APIs.20.7 Test-suites for diffusionwe start with a simple testcase of 3 nodes with 1 ping source <strong>and</strong> 1 ping sender. <strong>The</strong>re are other tests for 2 phase-pull(2pp), 1phase-pull(1pp), push <strong>and</strong> gear (with 2pp <strong>and</strong> push) scenarios. In future we plan to extend the test-suite for testing differentcomponents/functionalities of directed diffusion. All diffusion3 rel<strong>at</strong>ed test cases can be found under ~<strong>ns</strong>/tcl/test/test-suitediffusion3.tcl.20.8 Comm<strong>and</strong>s <strong>at</strong> a glanceFollowing is a list of comm<strong>and</strong>s used for diffusion rel<strong>at</strong>ed simul<strong>at</strong>ion in <strong>ns</strong>.$<strong>ns</strong>_ node-config -adhocRouting $opt(adhocRouting)-llType $opt(ll)...-diffusionFilter $opt(filters)-stopTime $(pre-stop)...where,value of opt(adhocRouting) is set to Directed_DiffusionThis comm<strong>and</strong> is used to enable directed diffusion in wireless nodes.value of opt(filters) can be a list of filters th<strong>at</strong> is required to be <strong>at</strong>tached to diffusion nThis comm<strong>and</strong> allows adding filter objects to diffusion-enabled nodes.199

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!