Hi Ns users,

can anyone tell is this the correct way to define the scenario file in the
tcl script can anyboby tell me how to achieve node movement for this tcl
script by giving a suitable example as how to generate node movement and i
am also confused whether the set dest syntax command and traffic generation
command for CBR traffic should be given in command prompt should we also
give file name such as output.tcl for traffic generation.

Kindly help me,

Reg:
Vijay


# wrls1.tcl

# A 10-node example for ad-hoc simulation withAODV

# Define options

set val(chan) Channel/WirelessChannel ;# channel type

set val(prop) Propagation/TwoRayGround ;# radio-propagation model

set val(netif) Phy/WirelessPhy ;# network interface type

set val(mac) Mac/802_11 ;# MAC type

set val(ifq) Queue/DropTail/PriQueue ;# interface queue type

set val(ll) LL ;# link layer type

set val(ant) Antenna/OmniAntenna ;# antenna model

set val(ifqlen) 50 ;# max packet in ifq

set val(nn) 10 ;# number of mobilenodes

set val(rp) AODV ;# routing protocol

set val(x) 1000 ;# X dimension of topography

set val(y) 1000 ;# Y dimension of topography

set opt(cp) "../mobility/scene/cbr-10-1-10-20"

#set opt(sc) "../mobility/scene/scen-670x670-50-600-20-0"

set val(stop) 500 ;# time of simulation end

set ns [new Simulator]

set tracefd [open simple126.tr w]

set windowVsTime2 [open win.tr w]

set namtrace [open simwrls126.nam w]

$ns trace-all $tracefd

$ns namtrace-all-wireless $namtrace $val(x) $val(y)

# set up topography object

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

#

# Create nn mobilenodes [$val(nn)] and attach them to the channel.

#

# configure the nodes

$ns node-config -adhocRouting $val(rp) \

-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 ON \

-macTrace OFF \

-movementTrace ON

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

set node_($i) [$ns node]

$node_($i) random-motion 1

}

#

# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes

#

$node_(0) set X_ 5.0

$node_(0) set Y_ 2.0

$node_(0) set Z_ 0.0

$node_(1) set X_ 120.0

$node_(1) set Y_ 55.0

$node_(1) set Z_ 0.0

$node_(2) set X_ 145.0

$node_(2) set Y_ 25.0

$node_(2) set Z_ 0.0

$node_(3) set X_ 290.0

$node_(3) set Y_ 185.0

$node_(3) set Z_ 0.0

$node_(4) set X_ 350.0

$node_(4) set Y_ 220.0

$node_(4) set Z_ 0.0

$node_(5) set X_ 139.0

$node_(5) set Y_ 285.0

$node_(5) set Z_ 0.0

$node_(6) set X_ 450.0

$node_(6) set Y_ 220.0

$node_(6) set Z_ 0.0

$node_(7) set X_ 390.0

$node_(7) set Y_ 385.0

$node_(7) set Z_ 0.0

$node_(8) set X_ 250.0

$node_(8) set Y_ 200.0

$node_(8) set Z_ 0.0

$node_(9) set X_ 100.0

$node_(9) set Y_ 105.0

$node_(9) set Z_ 0.0





# Set a TCP connection between node_(0) and node_(1)

set tcp [new Agent/TCP/Newreno]

$tcp set class_ 2

set sink [new Agent/TCPSink]

$ns attach-agent $node_(0) $tcp

$ns attach-agent $node_(1) $sink

$ns connect $tcp $sink

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $tcp

$ns at 10.0 "$cbr start"

set tcp [new Agent/TCP/Newreno]

$tcp set class_ 2

set sink [new Agent/TCPSink]

$ns attach-agent $node_(0) $tcp

$ns attach-agent $node_(2) $sink

$ns connect $tcp $sink

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $tcp

$ns at 20.0 "$cbr start"

set tcp [new Agent/TCP/Newreno]

$tcp set class_ 2

set sink [new Agent/TCPSink]

$ns attach-agent $node_(0) $tcp

$ns attach-agent $node_(3) $sink

$ns connect $tcp $sink

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $tcp

$ns at 30.0 "$cbr start"

set tcp [new Agent/TCP/Newreno]

$tcp set class_ 2

set sink [new Agent/TCPSink]

$ns attach-agent $node_(0) $tcp

$ns attach-agent $node_(4) $sink

$ns connect $tcp $sink

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $tcp

$ns at 40.0 "$cbr start"

set tcp [new Agent/TCP/Newreno]

$tcp set class_ 2

set sink [new Agent/TCPSink]

$ns attach-agent $node_(0) $tcp

$ns attach-agent $node_(5) $sink

$ns connect $tcp $sink

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $tcp

$ns at 50.0 "$cbr start"

set tcp [new Agent/TCP/Newreno]

$tcp set class_ 2

set sink [new Agent/TCPSink]

$ns attach-agent $node_(0) $tcp

$ns attach-agent $node_(6) $sink

$ns connect $tcp $sink

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $tcp

$ns at 60.0 "$cbr start"

set tcp [new Agent/TCP/Newreno]

$tcp set class_ 2

set sink [new Agent/TCPSink]

$ns attach-agent $node_(0) $tcp

$ns attach-agent $node_(7) $sink

$ns connect $tcp $sink

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $tcp

$ns at 70.0 "$cbr start"

set tcp [new Agent/TCP/Newreno]

$tcp set class_ 2

set sink [new Agent/TCPSink]

$ns attach-agent $node_(0) $tcp

$ns attach-agent $node_(8) $sink

$ns connect $tcp $sink

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $tcp

$ns at 80.0 "$cbr start"

# Printing the window size

proc plotWindow {tcpSource file} {

global ns

set time 0.01

set now [$ns now]

set cwnd [$tcpSource set cwnd_]

puts $file "$now $cwnd"

$ns at [expr $now+$time] "plotWindow $tcpSource $file" }

$ns at 10.1 "plotWindow $tcp $windowVsTime2"

# Define node initial position in nam

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

# 30 defines the node size for nam

$ns initial_node_pos $node_($i) 30

}

# Telling nodes when the simulation ends

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

$ns at $val(stop) "$node_($i) reset";

}

# ending nam and the simulation

$ns at $val(stop) "$ns nam-end-wireless $val(stop)"

$ns at $val(stop) "stop"

$ns at 150.01 "puts \"end simulation\" ; $ns halt"

proc stop {} {

global ns tracefd namtrace

$ns flush-trace

close $tracefd

close $namtrace

}

$ns run

Reply via email to