12.07.2015 Views

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 ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

file="test-suite-$f.tcl" # <strong>The</strong> name of the <strong>ns</strong> script.directory="test-output-$f" # Subdirectory to hold the test resultsversion="v2" # Speficy the <strong>ns</strong> version.# Pass the arguments to test-all-templ<strong>at</strong>e1, which will run through# all the test cases defined in test-suite-wireless-lan.tcl../test-all-templ<strong>at</strong>e1 $file $directory $version $@You also need to cre<strong>at</strong>e several test cases in the <strong>ns</strong> script (test-suite-xxx.tcl) by defining a subclass of TestSuite for eachdifferent test. For example, in test-suite-wireless-lan.tcl, each test case uses a different Ad Hoc routing protocol. <strong>The</strong>y aredefined as:Class TestSuite# wireless model using destin<strong>at</strong>ion sequence distance vectorClass Test/dsdv -superclass TestSuite# wireless model using dynamic source routingClass Test/dsr -superclass TestSuite... ...Each test case is basically a simul<strong>at</strong>ion scenario. In the super class TestSuite, you can define some functio<strong>ns</strong>, like init <strong>and</strong>finish to do the work required by each test case, for example setting up the network topology <strong>and</strong> <strong>ns</strong> trace. <strong>The</strong> test specificconfigur<strong>at</strong>io<strong>ns</strong> are defined within the corresponding sub-class. Each sub-class also has a run function to start the simul<strong>at</strong>ion.TestSuite i<strong>ns</strong>tproc init {} {global opt tracefd topo chan propglobal node_ god_$self i<strong>ns</strong>tvar <strong>ns</strong>_ testName_set <strong>ns</strong>_[new Simul<strong>at</strong>or]... ...}TestSuite i<strong>ns</strong>tproc finish {} {$self i<strong>ns</strong>tvar <strong>ns</strong>_global quiet$<strong>ns</strong>_ flush-trace}puts "finishing.."exit 0Test/dsdv i<strong>ns</strong>tproc init {} {global opt node_ god_$self i<strong>ns</strong>tvar <strong>ns</strong>_ testName_set testName_ dsdv... ...$self next245

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

Saved successfully!

Ooh no, something went wrong!