hi dear
go to this location

ns-allinone/ns-2.31/indep-util/cmu
then write the scenerio file there
by writing these commands u can create scenerio

ns cbrgen.tcl -type cbr -nn 60 -seed 0.1 -mc 10 -rate 0.000125 >cp1
ns cbrgen.tcl -type cbr -nn 60 -seed 0.1 -mc 20 -rate 0.000125 >cp2
ns cbrgen.tcl -type cbr -nn 60 -seed 0.1 -mc 30 -rate 0.000125 >cp3
ns cbrgen.tcl -type cbr -nn 60 -seed 0.1 -mc 40 -rate 0.000125 >cp4




where
ns cbrgen.tcl [-type cbr] [-nn nodes] [-seed seed] [-mc connections] [-rate
rate]


then go to setdest folder
then write these command
./setdest -n 60 -p 0   -M 10 -t 100 -x 500 -y 500 > sc1
./setdest -n 60 -p 10  -M 10 -t 100 -x 500 -y 500 > sc2
./setdest -n 60 -p 20  -M 10 -t 100 -x 500 -y 500 > sc3
./setdest -n 60 -p 40  -M 10 -t 100 -x 500 -y 500 > sc4
./setdest -n 60 -p 100 -M 10 -t 100 -x 500 -y 500 > sc5

where
./setdest -n <num_of_nodes> -p <pausetime> -s <maxspeed> -t <simtime> -x
<maxx> -y <maxy> > filename

after that
write this code in a file and save it as .tcl file

 #################################################################


set val(chan)       Channel/WirelessChannel  ;# Type of Channel to be used
set val(prop)       Propagation/TwoRayGround ;# Propagation Model
set val(netif)      Phy/WirelessPhy   ;# Network Interface Type
set val(mac)        Mac/802_11    ;# MAC layer Standard

set val(ll)         LL
set val(ant)        Antenna/OmniAntenna  ;# Type of Antenna

set val(ifq)        Queue/DropTail/PriQueue  ;# Type of Queue
set val(ifqlen)         50                ;# Maximum Packets in IFQ Queue
set val(seed)           0.1

set val(x)              500       ;# X dimension of the topography
set val(y)              500       ;# Y dimension of the topography
set val(nn)             60                 ;# Total number of nodes
simulated

set val(adhocRouting)    AODV   ;# Protocol for Simulation
set val(cp)
"/ns-allinone-2.28/ns-2.28/indep-utils/cmu-scen-gen/cp1"
;# Connection Pattern File Path
set val(sc)
"/ns-allinone-2.28/ns-2.28/indep-utils/cmu-scen-gen/setdest/sc1"
;#  Mobility Model File Path
set val(stop)             100.0     ;# Simulation time


# Where to Store Output

set val(tr)  "/cp1sc1.tr"
set val(na)  "/cp1sc1.nam"


# ===============================================================
# Main Program
# ===============================================================
# Initialize Global Variables

set ns_  [new Simulator]   ;# create simulator instance
set topo [new Topography]   ;# setup topography object
set tracefd [open $val(tr) w]   ;# create trace object for ns and nam
set namtrace    [open $val(na) w]

$ns_ trace-all $tracefd
$ns_ use-newtrace
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)

# define topology
$topo load_flatgrid $val(x) $val(y)

set god_ [create-god $val(nn)]   ; # Create God

#global node setting
$ns_ node-config  -adhocRouting $val(adhocRouting) \
                   -llType $val(ll) \
                   -macType $val(mac) \
            -ifqType $val(ifq) \
                   -ifqLen $val(ifqlen) \
                   -antType $val(ant) \
                   -propType $val(prop) \
-phyType $val(netif) \
                   -channelType $val(chan) \
    -topoInstance $topo \
    -agentTrace ON \
                   -routerTrace OFF \
                   -macTrace OFF

for {set i 0} {$i < $val(nn) } {incr i} {

 set node_($i) [$ns_ node]  ;#  Create the specified number of nodes
 $node_($i) random-motion 0  ;# disable random motion

}

 # Define node movement model

puts "Loading connection pattern..."
source $val(cp)    ;# Loading Connection pattern File defined


# Define traffic model

puts "Loading scenario file..."
source $val(sc)    ;# Loading Movement model file


# Define node initial position in nam

for {set i 0} {$i < $val(nn)} {incr i} {

    $ns_ initial_node_pos $node_($i) 20

}

# Tell nodes when the simulation ends

for {set i 0} {$i < $val(nn) } {incr i} {

    $ns_ at $val(stop).0 "$node_($i) reset";

}

$ns_ at  $val(stop).0002 "puts \"NS EXITING...\"
$ns_ halt"

# Run Simulation

puts "Starting Simulation..."
$ns_ run



###################################################################


now compile it and u will find the .tr & .name files at the roots folder

Reply via email to