DSR 协议的分段错误

Segmentation fault for the DSR protocol

我一直在尝试找出出现分段错误的原因,但我无法使用以下代码有人可以提供帮助

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 

我想知道需要进行哪些修改才能避免分段错误。

谢谢。


这里工作正常,在模拟结束时 "segmentation fault"。所有文件都创建好了: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


绘图:xgraph-12.x 包含在 ns-allinone-2.35 中。也适用于 Debian、Mint、Ubuntu.

DSR:带有 delay 图的示例 (2):聚类-moc_v1.tcl(打开一个 xgraph window。)

DSR:带有 loss 图的示例 (3):DSR-project-code_input.tcl(六个 xgraph windows 打开:移动顶部 windows 观看 "lost*, 1 - 2 - 3".)

DSR:在 wireless-udp-1.tcl 中将协议更改为 DSR(三个 xgraph windows 打开,第二个有 4 次 loss 图。顶部 window 中包含四个 delay 图。)

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


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

set val(ifq)            CMUPriQueue

希望,这应该有用。