简体   繁体   English

排序列表…完成! 分段故障(核心已转储)

[英]SORTING LISTS …DONE! Segmentation fault (core dumped)

I'm using ns2 and I want to write a tcl code for implementing wireless sensor networks, I surfed the net and I found a non complete code, I made some modifications to it and run it, but the terminal gives this result: 我正在使用ns2,我想编写一个实现无线传感器网络的tcl代码,上网冲浪,发现一个不完整的代码,对其进行了一些修改并运行,但是终端给出了以下结果:

channel.cc:sendUp - Calc highestAntennaZ_ and distCST_ highestAntennaZ_ = 1.5, distCST_ = 550.0 SORTING LISTS ...DONE! Segmentation fault (core dumped)

Actually, this is a project, so its okay if anyone can tell me the error in the code or give me a link for source code of implementing wireless sensor networks. 实际上,这是一个项目,因此如果有人可以告诉我代码中的错误或为我提供实现无线传感器网络的源代码链接,也可以。 This is my code. 这是我的代码。 Thank you in advance. 先感谢您。

set val(chan)           Channel/WirelessChannel    ;# channel type 
set val(prop)           Propagation/TwoRayGround   ;# radio-propagation model 
set val(netif)          Phy/WirelessPhy            ;# network interface type 
set val(mac)            Mac/802_11                 ;# MAC type 
set val(ifq)            Queue/DropTail/PriQueue    ;# interface queue type 
set val(ll)             LL                         ;# link layer type 
set val(ant)            Antenna/OmniAntenna        ;# antenna model 
set val(ifqlen)         50                         ;# max packet in ifq 
set val(nn)             3                         ;# number of mobilenodes 
set val(rp)             DSR                       ;# routing protocol 
set val(x)              1200               ;# X dimension of topography 
set val(y)              1000               ;# Y dimension of topography   
set val(stop)       50             ;# time of simulation end 
set val(err)        UniformErrorProc
# Set up topography object 
#------------------------------------------- 
set ns        [new Simulator] 
set tracefd       [open simple.tr w] 
set windowVsTime2 [open win.tr w]  
set namtrace      [open simwrls.nam w]  
# $ns use-newtrace 
$ns trace-all $tracefd 
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

# set up topography object 
set topo [new Topography] 
$topo load_flatgrid $val(x) $val(y) 
create-god $val(nn) 

proc UniformErrorProc {} { 
    puts "dfdfad-----------------------------"
    set err [new ErrorModel] 
    $err unit pkt 

    $err set rate_ 0.1 

    return $err 
}      

$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) \
             -channel [new $val(chan)] \
             -topoInstance $topo \
             -agentTrace ON \
             -routerTrace OFF \
             -macTrace OFF \
             -movementTrace OFF \
             -IncomingErrProc $val(err)\
             -OutgoingErrProc $val(err)      

for {set i 0} {$i < $val(nn) } { incr i } { 
    set node_($i) [$ns node]     
} 

$node_(0) set X_ 600.0 
$node_(0) set Y_ 500.0 
$node_(0) set Z_ 0.0 

$node_(1) set X_ 800.0 
$node_(1) set Y_ 400.0 
$node_(1) set Z_ 0.0 

$node_(2) set X_ 1000.0 
$node_(2) set Y_ 400.0 
$node_(2) set Z_ 0.0 

set tcp [new Agent/TCP/Newreno] 
$tcp set class_ 2
set sink [new Agent/TCPSink] 
$ns attach-agent $node_(0) $tcp 
$ns attach-agent $node_(2) $sink 
$ns connect $tcp $sink 

set ftp [new Application/FTP] 
$ftp attach-agent $tcp 
$ns at 1.0 "$ftp start" 

set udp [new Agent/UDP] 
$udp set class_ 2
set null [new Agent/Null] 
$ns attach-agent $node_(1) $udp
$ns attach-agent $node_(2) $null 
$ns connect $udp $null

set cbr_(0) [new Application/Traffic/CBR] 
$cbr_(0) set packetSize_ 200 
$cbr_(0) set interval_ 0.01 
$cbr_(0) set random_ 1 
$cbr_(0) set maxpkts_ 10000 
$cbr_(0) attach-agent $udp 
$ns at 11.0 "$cbr_(0) start"

# Printing the window size 
proc plotWindow {tcpSource file} { 
    global ns 
    set time 5.00 
    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 } {
# 30 defines the node size for nam 
    $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"; 
} 
proc stop {} { 
    global ns tracefd namtrace 
    $ns flush-trace
    close $tracefd 
    close $namtrace 
    exec nam out.nam & 
} 

$ns run 

Segmentation fault (core dumped) 分段故障(核心已转储)

$err set rate_ must be >= 1.0 : $err set rate_必须> = 1.0:

30  proc UniformErrorProc {} { 
31      puts "dfdfad-----------------------------"
32      set err [new ErrorModel] 
33      $err unit pkt 
34  
35      $err set rate_ 1.0
36  
37      return $err

As is, the simulation will run for hours, and the three trace files can reach GB sizes. 照原样,模拟将运行几个小时,并且三个跟踪文件可以达到GB大小。 A "stop" can be added : 可以添加一个“停止”:

   13   set val(stop)       50000   ;# EDITED time of simulation end
   .
   .
   116  # Telling nodes when the simulation ends 
   117  for {set i 0} {$i < $val(nn) } { incr i } { 
   118      $ns at $val(stop) "$node_($i) reset"; 
   119  }
   120   $ns at $val(stop).0002 "puts \"NS EXITING...\" ; $ns halt" ;# added
   121   $ns at $val(stop).0001 "stop"                              ;# added
   122  proc stop {} { 
   123      global ns tracefd namtrace 
   124      $ns flush-trace
   125      close $tracefd 
   126      close $namtrace 
   127      exec nam simwrls &           ;# edited
   128  } 
   129  
   130  $ns run

Run the simulation ... 运行模拟...

$ ns235-64-orig s-WSN-Alibrahim.tcl
num_nodes is set 3
dfdfad-----------------------------
dfdfad-----------------------------
INITIALIZE THE LIST xListHead
dfdfad-----------------------------
dfdfad-----------------------------
dfdfad-----------------------------
dfdfad-----------------------------
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 550.0
SORTING LISTS ...DONE!
NS EXITING...

WSN examples, wsn-ex-11.17.tar.gz https://drive.google.com/file/d/1wd3r3QF3w2at44KsDxDDwQY-BxvfeqR0/view?usp=sharing ... All ~3000 simulations https://drive.google.com/drive/folders/0B7S255p3kFXNSmRYb2lGcDRUdWs?usp=sharing WSN示例,wsn-ex-11.17.tar.gz https://drive.google.com/file/d/1wd3r3QF3w2at44KsDxDDwQY-BxvfeqR0/view?usp=sharing ...全部〜3000个模拟https://drive.google。 com / drive / folders / 0B7S255p3kFXNSmRYb2lGcDRUdWs?usp = sharing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM