- Home Page of ProjectGuideline.com ›
- Forums ›
- Get Help to do your B.E., and M.E., M.Tech., & M.S., Project in Ns2 ›
- Simulation times and traffic stream label
The version of ns2 I am using in ns-2.30.Now I can view node in the
nam, the node can move,but I can not see label that node sends ftp stream.
aother question is that nam can only run 30s, simulation time in Tclscript
is 50s, why? how to solve ?
Thank you !
tcl script as follows!
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(ni) 2
set ns_ [new Simulator]
$ns_ use-newtrace
set tracefd [open simple.tr w]
$ns_ trace-all $tracefd
set namtracefd [open lys.nam w]
$ns_ namtrace-all-wireless $namtracefd 500 500
# set up topography object
set topo [new Topography]
$topo load_flatgrid 500 500
set chan_(0) [new $val(chan)]
set chan_(1) [new $val(chan)]
set chan_(2) [new $val(chan)]
set god_ [create-god $val(nn)]
$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)
-channel $chan_(0)
-topoInstance $topo
-agentTrace ON
-routerTrace ON
-macTrace OFF
-movementTrace OFF
-ifNum $val(ni)
$ns_ change-numifs $val(ni)
$ns_ add-channel 0 $chan_(0)
$ns_ add-channel 1 $chan_(1)
set node(0) [$ns_ node]
# set node0 [$ns_ node]
$node(0) random-motion 0
$ns_ change-numifs 1
$ns_ add-channel 1 $chan_(1)
# -ifNum 1
set node(1) [$ns_ node]
$node(1) random-motion 0
$node(0) set X_ 50
$node(0) set Y_ 50
$node(0) set Z_ 0.0
$node(1) set X_ 100
$node(1) set Y_ 100
$node(1) set Z_ 0.0
set tcp [new Agent/TCP]
set sink [new Agent/TCPSink]
$ns_ attach-agent $node(0) $tcp
$ns_ attach-agent $node(1) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ initial_node_pos $node(0) 30
$ns_ initial_node_pos $node(1) 30
$ns_ at 10.0 “$ftp start”
$ns_ at 50.0 “stop”
$ns_ at 50.1 “puts “NS EXITING…” ; $ns_ halt”
proc stop {} {
global ns_ tracefd namtracefd
$ns_ flush-trace
close $tracefd
close $namtracefd
exec nam lys.nam &
exit 0
}
puts “Starting Simulation…”
$ns_ run
While runing your script on ns2.28, 2.29 and 2.31, it is showing following error. ( I will try it on ns2.30 latter).
num_nodes is set 2
(_o3 cmd line 1)
invoked from within
“_o3 cmd change-numifs 2”
invoked from within
“catch “$self cmd $args” ret”
invoked from within
“if [catch “$self cmd $args” ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error “error when calling class $cls: $args” $…”
(procedure “_o3” line 2)
(SplitObject unknown line 2)
invoked from within
“$ns_ change-numifs $val(ni)”
(file “test2.tcl” line 41)
You can set the label of a node as we set the color previously.
while running a simulation, if there is nothing for recording (ie, no traffic due to some reason), then the simulation will not show anything beyond that even if you are running it for some more time.
I added multi-channel support in ns-2.30, IF you do not implement multi-channel in ns2 , It will create error.