Wireless Simulation Scenarios in ns-2

[ mobility | traffic pattern | Back to Network Simulator 2 for Wireless ]


1.Node Movement and Topology Generation

Instead of specifying and control each nodes' position and movement pattern, we use a CMU tool "setdest" to generate large number of nodes and there movements. The tool use a random waypoint model.

Setdest

Setdest tool is used to generate the positions of nodes and their moving speed and moving directions.
The syntax is:
 setdest -v 1 -n $numnodes -p $pt -M $maxspeed -t $simtime -x $maxx -y $maxy
for example: setdest -v 1 -n 50 -p 0 -M 20 -t 900 -x 1500 -y 300
will generate a 1500*300 topology with 50 nodes random distributed labeled by a XY(Z) coordinates.  ( Note that, there is a bug in the README file, which gives a wrong option for specifying the speed, we should use "-M" instead of "-s" ).

After the initial position information, the nodes are specified with their movement destination and speed.

After that, the initial distance (hop counts) information are counted by a GOD. Currently, the god object is used only to store an array of the shortest number of hops required to reach from one node to an other. The god object does not calculate this on the fly during simulation runs, since it can be quite time consuming. The information is loaded into the god object from the movement pattern file (this file)..

Then, the nodes are going to move during this 900-second simulation scenario. During this, the distance (hop-counts) information is going to change, thus, the following lines are going to show this recent change. Note that the distance is calculated based on a nominal radio change as "250" meters. The god information should not be available to any of the node. Thus, for a routing protocol, it has to discover the distance by itself with some mechanism.

It's possible that a node reaches its destination before the simulation timer ends. Thus, it needs to re-specify a new direction and speed for it. Also, the average pause time is a parameter to allow a node stop to move in a destination before moving again.

Finally, there are some statistics about this movement file? During the simulation, some nodes get isolated from all other nodes which results one count of "destination unreachable". Also, all route changes and link changes are calculated.

            
# nodes: 50, pause: 0.00, max speed: 20.00, max x: 1500.00, max y: 300.00
#
$node_(0) set X_ 1472.239335818631
$node_(0) set Y_ 218.102475038104
$node_(0) set Z_ 0.000000000000
$node_(1) set X_ 266.329091949493
$node_(1) set Y_ 188.988756134562
$node_(1) set Z_ 0.000000000000
.....
$ns_ at 0.000000000000 "$node_(0) setdest 298.258250355189 34.553480936942 5.763540789209"
$ns_ at 0.000000000000 "$node_(1) setdest 783.793876303622 280.181784294036 16.832727003192"
$ns_ at 0.000000000000 "$node_(2) setdest 978.836090908830 151.467060345492 19.354908025316"
$ns_ at 0.000000000000 "$node_(3) setdest 376.126888262665 139.747808400435 11.497476206039"
$ns_ at 0.000000000000 "$node_(4) setdest 370.541780738321 185.032792269909 8.002013555825"
$ns_ at 0.000000000000 "$node_(5) setdest 1463.652810766312 132.618506062927 17.607998988233"
$ns_ at 0.000000000000 "$node_(6) setdest 1020.046295404814 40.982731716802 15.434148765705"
......
$god_ set-dist 0 1 6
$god_ set-dist 0 2 1
$god_ set-dist 0 3 4
$god_ set-dist 0 4 2
$god_ set-dist 0 5 4
$god_ set-dist 0 6 8
$god_ set-dist 0 7 6
......
$ns_ at 0.141920608238 "$god_ set-dist 17 24 2"
$ns_ at 0.165720133690 "$god_ set-dist 3 15 1"
$ns_ at 0.263269271549 "$god_ set-dist 1 46 2"
$ns_ at 0.263269271549 "$god_ set-dist 7 46 2"
$ns_ at 0.263269271549 "$god_ set-dist 12 46 1"
$ns_ at 0.263269271549 "$god_ set-dist 25 46 3"
$ns_ at 0.263269271549 "$god_ set-dist 46 47 3"
$ns_ at 0.314230786054 "$god_ set-dist 5 42 5"
......
$ns_ at 12.602131706040 "$god_ set-dist 16 36 2"
$ns_ at 12.623221733243 "$node_(12) setdest 424.679916546080 186.581540202946 5.803287072825"
$ns_ at 12.682532746855 "$god_ set-dist 18 40 3"
.....
$ns_ at 899.907548331028 "$god_ set-dist 32 40 1"
$ns_ at 899.932142983319 "$god_ set-dist 22 40 1"
$ns_ at 899.991403308054 "$god_ set-dist 3 29 1"
#
# Destination Unreachables: 429
#
# Route Changes: 72037
#
# Link Changes: 11892
#
# Node | Route Changes | Link Changes
# 0 | 2709 | 433
# 1 | 3098 | 467
# 2 | 2651 | 496
# 3 | 3398 | 642Setdest
# 4 | 3036 | 548
# 5 | 2755 | 252
# 6 | 3471 | 601

for generate scenarios in a patch, we could use following shell scripts.

#!/bin/csh
unset noclobber
set outdir = wzb-scen

set maxspeed = 1
set numnodes = 50
set maxx = 1500
set maxy = 300
set simtime = 900

foreach pt (5 10 15 20 25 30 40 50)
foreach scen ( 1 2 3 4 5)
echo scen $scen : setdest -n $numnodes -p $pt -M $maxspeed -t $simtime \
-x $maxx -y $maxy
time ./setdest -n $numnodes -p $pt -M $maxspeed -t $simtime \
-x $maxx -y $maxy \
>$outdir/scen-${maxx}x${maxy}-${numnodes}-${pt}-${maxspeed}-${scen}
echo
end
end

กก

2. Traffic Pattern Generation

cbrgen

Random traffic connections of TCP and CBR can be setup between mobilenodes using a traffic-scenario generator script. This traffic generator script is available under ~ns/indep-utils/cmu-scen-gen and is called cbrgen.tcl. It can be used to create CBR and TCP traffics connections between wireless mobilenodes. In order to create a traffic-connection file, we need to define the type of traffic connection (CBR or TCP), the number of nodes and maximum number of connections to be setup between them, a random seed and incase of CBR connections, a rate whose inverse value is used to compute the interval time between the CBR pkts. So the command line looks like the following:

ns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed seed] [-mc connections][-rate rate] >output.tcl
The start times for the TCP/CBR connections are randomly generated with a maximum value set at 180.0s, thus the simulation time is at least 180 seconds. And the number of nodes has no relationship to the maximum number of connections (mc), we can have 10 nodes, also 10 connections as one node could have multiple simultaneous connections to other nodes. The parameter "rate" means how many packets per second, thus, for CBR traffic, the packet intervel is the reversal of this parameter. And for TCP traffic, we don't have to specify rate, ftp connections are going to be used. the default packet size is 512B. Actully, we can change all this in the "output.tcl" file.

Note that there is no guarantee that the number of connections are created and the actual nodes involved as source and sink. A typical generated CBR traffic file looks like:

#
# 2 connecting to 3 at time 82.557023746220864
#
set udp_(0) [new Agent/UDP]
$ns_ attach-agent $node_(2) $udp_(0)
set null_(0) [new Agent/Null]
$ns_ attach-agent $node_(3) $null_(0)
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 512
$cbr_(0) set interval_ 0.25
$cbr_(0) set random_ 1
$cbr_(0) set maxpkts_ 10000
$cbr_(0) attach-agent $udp_(0)
$ns_ connect $udp_(0) $null_(0)
$ns_ at 82.557023746220864 "$cbr_(0) start"
......
#
#Total sources/connections: 4/6
#

The last lines shows how many actual connections are created and how many nodes are used for the source.

กก

กก

กก