DSR协议的分段错误

时间:2016-05-09 09:36:40

标签: ns2

我一直试图找出分段错误发生的原因,但我无法通过以下代码来帮助

set val(chan)           Channel/WirelessChannel    ;
set val(prop)           Propagation/TwoRayGround   ;
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)         60                         ;
set val(nn)             20                         ;
set val(rp)             DSR                        ;
set val(x)              900                        ;
set val(y)              900                        ;  
set val(stop)           800                        ;

set ns            [new Simulator]
set tracefd       [open testDSR.tr w]
set namtrace      [open testDSR.nam w]
set windowVsTime2 [open win.tr w]

$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

set topo          [new Topography]

$topo load_flatgrid $val(x) $val(y)

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) \
                     -channelType $val(chan) \
                     -topoInstance $topo \
                     -agentTrace ON \
                     -routerTrace ON \
                     -macTrace OFF \
                     -movementTrace ON

    for {set i 0} {$i < $val(nn) } { incr i } {
            set node_($i) [$ns node]
    $node_($i) set X_ [ expr 10+round(rand()*480) ]
        $node_($i) set Y_ [ expr 10+round(rand()*380) ]
        $node_($i) set Z_ 0.0        
    }





 $ns at 10.0  "$node_(0) setdest 300.0 300.0 10.0"
 $ns at 15.0  "$node_(1) setdest 45.0 285.0 10.0"
 $ns at 110.0 "$node_(0) setdest 480.0 300.0 10.0"  
 $ns at 70.0  "$node_(3) setdest 180.0 30.0 10.0"
 $ns at 180.0 "$node_(8) setdest 410.0 770.0 15.0"
 $ns at 200.0 "$node_(10) setdest 363.0 335.0 15.0"
 $ns at 230.0 "$node_(7) setdest 304.0 720.0 10.0"
 $ns at 270.0 "$node_(0) setdest 580.0 790.0 25.0"
 $ns at 330.0 "$node_(0) setdest 810.0 790.0 20.0"
 $ns at 80.0 "$node_(4) setdest 480.0 790.0 25.0"
 $ns at 150.0 "$node_(7) setdest 610.0 790.0 10.0"


 $node_(4) color red
 $ns at 8.0 "$node_(4) color darkgreen"
 $ns at 8.0 "$node_(4) label Source"
 $node_(7) color red
 $ns at 8.0 "$node_(7) label Destination"
 $ns at 8.0 "$node_(7) color darkgreen"

 set tcp [new Agent/TCP/Newreno]
 $tcp set class_ 2
 $tcp set packetSize_ 1000
 set sink [new Agent/TCPSink]
 $ns attach-agent $node_(4) $tcp
 $ns attach-agent $node_(7) $sink
 $ns connect $tcp $sink
 set ftp [new Application/FTP]
 $ftp attach-agent $tcp
 $ftp set packetSize_ 1000
 $ns at 10.0 "$ftp start"  

 proc plotWindow {tcpSource file} {
 global ns
 set time 0.01
 set now [$ns now]
 set cwnd [$tcpSource set cwnd_]
 puts $file "$now $cwnd"
 $ns at [expr $now+$time] "plotWindow $tcpSource $file" }
 $ns at 10.1 "plotWindow $tcp $windowVsTime2"

 # Define node initial position in nam
 for {set i 0} {$i < $val(nn)} { incr i } {
     $ns initial_node_pos $node_($i) 30
 }


# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "$node_($i) reset";
}


$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 350.01 "puts \"end simulation\" ; $ns halt"
proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
    exit 0
}

$ns run 

我想知道需要哪些修改来避免分段错误错误。

感谢。

3 个答案:

答案 0 :(得分:1)

这里工作正常,模拟结束时出现“分段错误”。创建所有文件OK:testDSR.nam 4.1MB,testDSR.tr 4.4MB,win.tr 220kB。

并且:$ nam testDSR.nam→→一个OK NAM动画。

$ ns DSR_SUGMAR.tcl
num_nodes is set 20
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
INITIALIZE THE LIST xListHead
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 550.0
SORTING LISTS ...DONE!
Segmentation fault

答案 1 :(得分:1)

图:xgraph-12.x包含在ns-allinone-2.35中。也可以使用Debian,Mint,Ubuntu。

DSR:带延迟的示例图(2):Clustering-moc_v1.tcl(打开一个xgraph窗口。)

DSR:丢失图示例(3):DSR-project-code_input.tcl(六个xgraph窗口打开:移动顶部窗口观看&#34;丢失*,1 - 2 - 3&#34;。)

DSR:在wireless-udp-1.tcl中将协议更改为DSR(三个xgraph窗口打开,第二个有4次丢失图。四个延迟图是包含在顶部窗口中。)

所有xgraph_ns2-files-tcl_05.2016 https://drive.google.com/file/d/0B7S255p3kFXNajQ5S1NuOHNTcUE/view?usp=sharing

答案 2 :(得分:0)

DSR 适用于不同的队列类型。 尝试使用这个:

set val(ifq)            CMUPriQueue

希望,这应该可行。