如何在AquaSim(ns2)中创建简单的水下传感器网络时解决错误?

时间:2016-02-17 07:16:07

标签: ns2

我是ns2的新手,正在使用基于ns2的模拟器AquaSim。我正在尝试制作一个简单的水下无线网络。 "传播"以下代码可以正常工作和" Phy"被设置为" TwoRayGround"和" WirelessPhy"分别但当我把它们改为" UnderwaterPropagation"和#34; UnderwaterPhy",它给出错误(在代码后附上)。请建议如何处理这个问题。最诚挚的问候

set val(chan)           Channel/UnderwaterChannel;
set val(prop)           Propagation/UnderwaterPropagation;
set val(netif)          Phy/WirelessPhy;
set val(mac)            Mac/802_11;
set val(ifq)            Queue/DropTail/PriQueue;
set val(ll)             LL;
set val(ant)            Antenna/OmniAntenna;
set val(ifqlen)         50;
set val(nn)             2;
set val(rp)             DSDV;

set ns_     [new Simulator]

set tracefd     [open simple.tr w]
$ns_ trace-all $tracefd

# set up topography object
set topo       [new Topography]
$topo load_flatgrid 500 500

create-god $val(nn)

# ===============================================
# Create channel #1
# ===============================================
set chan_1_ [new $val(chan)]

# configure node
        $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) \
             -topoInstance $topo \
             -agentTrace ON \
             -routerTrace ON \
             -macTrace ON \
             -channel $chan_1_\
             -movementTrace OFF         


    for {set i 0} {$i < $val(nn) } {incr i} {
        set node_($i) [$ns_ node]   
        $node_($i) random-motion 0      ;
    }


$node_(0) set X_ 5.0
$node_(0) set Y_ 2.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 390.0
$node_(1) set Y_ 385.0
$node_(1) set Z_ 0.0

$ns_ at 50.0 "$node_(1) setdest 25.0 20.0 15.0"
$ns_ at 10.0 "$node_(0) setdest 20.0 18.0 1.0"

$ns_ at 100.0 "$node_(1) setdest 490.0 480.0 15.0" 

set tcp [new Agent/TCP]
$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 ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 10.0 "$ftp start" 

for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at 150.0 "$node_($i) reset";
}
$ns_ at 150.0 "stop"
$ns_ at 150.01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
    global ns_ tracefd
    $ns_ flush-trace
    close $tracefd
}

puts "Starting Simulation..."
$ns_ run

错误消息:

num_nodes is set 2

    (_o20 cmd line 1)
    invoked from within
"_o20 cmd node_on _o15"
    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 "_o20" line 2)
    (SplitObject unknown line 2)
    invoked from within
"$mac node_on $self"
    (procedure "_o15" line 95)
    (Node/MobileNode/UnderwaterSensorNode add-interface line 95)
    invoked from within
"$node add-interface $chan $propInstance_ $llType_ $macType_  $ifqType_ $ifqlen_ $phyType_ $antType_ $topoInstance_  $inerrProc_ $outerrProc_ $FECProc_"
    (procedure "_o3" line 96)
    (Simulator create-wireless-node line 96)
    invoked from within
"_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
"eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
"$ns_ node"
    ("for" body line 2)
    invoked from within
"for {set i 0} {$i < $val(nn) } {incr i} {
                set node_($i) [$ns_ node]
                $node_($i) random-motion 0              ;# disable random motion
        }"
    (file "simw.tcl" line 107)

2 个答案:

答案 0 :(得分:0)

您似乎还没有在ns2中配置AquaSim包。以下链接可能对您有所帮助。

http://naveenshanmugam.blogspot.in/2015/03/aqusim-under-water-sensor-network-in-ns2.html

答案 1 :(得分:0)

您没有配置ns和aquasim。试图在ns2中配置AquaSim,非常适合您。