2016-05-09 40 views
0

我一直在试图找出为什么分割故障发生,但我不能与下面的代码可以有人帮助分段故障的DSR协议

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 

我想知道需要什么样的修改,以避免分段错误错误。

感谢。

回答

1

图:xgraph-12.x的被包括在NS-ALLINONE-2.35。也可用于Debian,Mint,Ubuntu。

DSR:实施例与延迟图(2):聚类-moc_v1.tcl(一张xgraph窗口打开。)

DSR:实施例与损失图(3):DSR-项目code_input。 tcl(六个xgraph窗口打开:移动顶部窗口观看“lost *,1 - 2 - 3”。)

DSR:将协议更改为DSR无线udp-1.tcl(三个xgraph窗口打开,用4倍损失曲线的第二个。四个延迟地块包括在顶部WINDO W的)

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


+0

谢谢你的建议:) – Karthi13

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 

+0

ü可以建议我一些图形技术和如何绘制此路由协议的时延和丢包。 – Karthi13