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) 2 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(stop) 100 ;# time of simulation end
set val(x) 500 ;# X dimension of topography
set val(y) 400 ;# Y dimension of topography
set ns_ [new Simulator]
set tracefd [open wireless2node1.tr w]
$ns_ trace-all $tracefd
set namtrace [open wireless2node1.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
#create-god $val(nn)
set god_ [create-god $val(nn)]
# 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 [new $val(chan)] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF
#############################
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$ns_ initial_node_pos $node_($i) 20.0
$node_($i) random-motion 0
}
#########################
$node_(0) set X_ 5.0
$node_(0) set Y_ 10.0
$node_(0) set Z_ 0.0
$ns_ at 0.0 "$node_(0) setdest 5.0 10.0 0.0"
$node_(1) set X_ 400.0
$node_(1) set y_ 300.0
$node_(1) set Z_ 0.0
$ns_ at 1.0 "$node_(1) setdest 24.01 20.01 15.1"
$ns_ at 0.0 "$node_(1) setdest 400.0 300.0 0.0"
$ns_ at 2.0 "$node_(0) setdest 155.0 110.0 55.0"
$ns_ at 5.0 "$node_(1) setdest 105.0 110.0 21.0"
$ns_ at 10.0 "$node_(0) setdest 185.0 260.0 45.0"
$ns_ at 40.0 "$node_(0) setdest 105.0 140.0 33.0"
$ns_ at 45.0 "$node_(1) setdest 125.0 210.0 33.0"
$ns_ at 50.0 "$node_(0) setdest 115.0 230.0 60.0"
$ns_ at 100.0 "$node_(1) setdest 200.0 280.0 10.0"
$ns_ at 130.0 "$node_(0) setdest 250.0 380.0 22.0"
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
exit 0
}
set tcp [new Agent/TCP]
$ns_ attach-agent $node_(0) $tcp
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(1) $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ connect $tcp $sink
$ns_ at 0.0.050000 "$ftp start"
$ns_ at 150.0.050000 "stop"
puts "Starting Simulation for you.."
$ns_ run