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 

 

[r...@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           ;# 1個MH

set num_wired_nodes      2           ;# 2個有線節點

 

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          ;# 模擬結束

 

set opt(tr-ns)    infra-out.tr             ;#設定trace file名稱

set opt(tr-nam)  infra-out.nam         ;#設定nam名稱

 

# ======================================================================

#                               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          ;# 使用階層式的定址方式

 

AddrParams set domain_num_ 3           ;# 設定3個domain: wired, wireless, wireless

lappendcluster_num 2 1 1              ;# 設定2個clusters for wired 
domain,1個給wireless 1, 1個給wireless 2

AddrParams set cluster_num_ $cluster_num

lappendeilastlevel 1 1 2 1            ;# 設定一個節點給wired domain, cluster 1, 一個節點給 
wired domain, cluster 2

                                ;# 設定兩個節點給wireless 1, cluster 1, 一個節點給wireless 
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

#-----------------------------------------------------------

 

#設定有線節點

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 

 

# 設定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

 

#設定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

Reply via email to