[ns] invalid command name "-adhocRouting"
=?gbk?B?wO7Wx8Hh?=
lizhiling126 at 126.com
Wed Apr 8 23:30:55 PDT 2009
Hello all£¬
It¡®s a problem of Mobile IP example .The code is in the end.
When I tried run the script-infra.tcl in NS2 ,I got errors look that
[root at RedHat9 examples]# ns script-infra.tcl
num_nodes is set 3
invalid command name "-adhocRouting"
while executing
"-adhocRouting DSDV \
"
(file "script-infra.tcl" line 191)
What should I do ? I running it both in ns.2.28 and ns.2.33 . Thanks for your help ¡..
code
[TCL script--infra.tcl]
# Copyright (c) 1997 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the Computer Systems
# Engineering Group at LawrenceBerkeley Laboratory.
# 4. Neither the name of the University nor of the Laboratory may be used
# to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# ======================================================================
# Options
# ======================================================================
set opt(nn) 1 ;# 1MH
set num_wired_nodes 2 ;# 2Óо¹üc
set opt(x) 670 ;# x coordinate of topology
set opt(y) 670 ;# y coordinate of topology
set opt(ftp1-start) 100.0 ;#é_ʼ÷ËÍftp
set opt(stop) 250 ;# Ä£M½YÊø
set opt(tr-ns) infra-out.tr ;#ÔO¶¨trace fileÃû·Q
set opt(tr-nam) infra-out.nam ;#ÔO¶¨namÃû·Q
# ======================================================================
# MAC
# ======================================================================
Mac/802_11 set dataRate_ 2.0e6 ;# ÷ËÍËÙ¶È2Mbps
Mac/802_11 set RTSThreshold_ 3000 ;# ²»Ê¹ÓÃRTS/CTS
# ======================================================================
# Nodes
# ======================================================================
set ns_ [new Simulator]
$ns_ node-config -addressType hierarchical ;# ʹÓÃëAÓʽµÄ¶¨Ö··½Ê½
AddrParams set domain_num_ 3 ;# ÔO¶¨3domain: wired, wireless, wireless
lappendcluster_num 2 1 1 ;# ÔO¶¨2clusters for wired domain,1½owireless 1, 1½owireless 2
AddrParams set cluster_num_ $cluster_num
lappendeilastlevel 1 1 2 1 ;# ÔO¶¨Ò»¹üc½owired domain, cluster 1, Ò»¹üc½o wired domain, cluster 2
;# ÔO¶¨É¹üc½owireless 1, cluster 1, Ò»¹üc½owireless 2, cluster 1
AddrParams set nodes_num_ $eilastlevel ; # of each domain
set tracefd [open $opt(tr-ns) w]
set namtrace [open $opt(tr-nam) w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
set topo [new Topography]
$topoload_flatgrid $opt(x) $opt(y)
create-god [expr $opt(nn) + 2]
# 2 for HA and FA
#-----------------------------------------------------------
# wired nodes
#-----------------------------------------------------------
#ÔO¶¨Óо¹üc
set temp {0.0.0 0.1.0} ;# hierarchical addresses
for {set i 0} {$i < $num_wired_nodes} {incri} {
set W($i) [$ns_ node [lindex $temp $i]]
}
#-----------------------------------------------------------
# hybrid and wireless nodes
#-----------------------------------------------------------
$ns_ node-config -mobileIP ON \
-adhocRouting DSDV \
-llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyTypePhy/WirelessPhy \
-channelType Channel/WirelessChannel \
-topoInstance $topo \
-wiredRouting ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF
# ÔO¶¨HAºÍFA
set HA [$ns_ node 1.0.0] ;#domain 2, cluster 1, node 1
set FA [$ns_ node 2.0.0] ;#domain 3, cluster 1, node 1
$HA set X_ 1.00
$HA set Y_ 2.00
$HA set Z_ 0.00
$FA set X_ 650.00
$FA set Y_ 600.00
$FA set Z_ 0.00
# create links between wired and BaseStation nodes
$ns_ duplex-link $W(0) $W(1) 5Mb 2ms DropTail
$ns_ duplex-link $W(1) $HA 5Mb 2ms DropTail
$ns_ duplex-link $W(1) $FA 5Mb 2ms DropTail
$ns_ duplex-link-op $W(0) $W(1) orient down
$ns_ duplex-link-op $W(1) $HA orient left-down
$ns_ duplex-link-op $W(1) $FA orient right-down
# create a mobilenode (in the domain of the HA)
# that is moving between HA and FA.
$ns_ node-config -wiredRouting OFF
#ÔO¶¨Mobile Host
set MH [$ns_ node 1.0.1]
#¸úHAÔ]Ô´ËMH
set HAaddress [AddrParams addr2id [$HA node-addr]]
[$MH set regagent_] set home_agent_ $HAaddress
$MH set Z_ 0.00
$MH set Y_ 2.00
$MH set X_ 2.00
# ÔÚµÚ100Ãë,MHé_ʼ³¯FAÒÆÓ
$ns_ at 100.00 "$MH setdest 640.00 610.00 20.00"
# ÔÚµÚ200Ãë,MHÓÖ³¯HAÒÆÓ
$ns_ at 200.00 "$MH setdest 2.00 2.00 20.00"
# Define initial node position in nam
$ns_ initial_node_pos $MH 20
#==================================================================
# Agents
#==================================================================
set tcp1 [new Agent/TCP]
$tcp1 set class_ 2
set sink1 [new Agent/TCPSink]
$ns_ attach-agent $W(0) $tcp1
$ns_ attach-agent $MH $sink1
$ns_ connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns_ at $opt(ftp1-start) "$ftp1 start"
#==================================================================
# End
#==================================================================
$ns_ at $opt(stop).0 "$MH reset";
$ns_ at $opt(stop).0 "$HA reset";
$ns_ at $opt(stop).0 "$FA reset";
$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop).0001 "finish"
proc finish {} {
global ns_ tracefdnamtrace
close $tracefd
close $namtrace
exec rm -f out-tcp.xgr
exec awk -f fil-tcp.awk infra-out.tr > out-tcp.xgr
exec xgraph out-tcp.xgr &
exec nam infra-out.nam &
}
puts "Starting Simulation..."
$ns_ run
--
lynn
More information about the Ns-users
mailing list