在运行 ns2 .tcl 文件时遇到这个问题 Segmentation fault (core dumped)

问题描述 投票:0回答:1

在尝试运行 ns2 simulation.tcl 文件时遇到此错误“分段错误(核心已转储)”

`

`# define options 
 set val(chan) Channel/WirelessChannel                                      ;# channel type
 set val(prop) Propagation/TwoRayGround           ;# radio propagation             model 
 set val(netif) Phy/Wireless                                     ;# 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) 50                                              ;# number of mobile nodes 

set val(rp) MDAOMDV                                                        ;# Routing protocol 
set val(x) 800                                                    ;# X dimension of topography 
set val(y) 800                                                    ;# Y dimension of topography
set val(stop) 50                                                    ;# time of simulation end  
set val(energymodel) EnergyModel                                               ; 
set val(n_ch) chan_1 
#------------------------------------------------------------------------------ 
# ------------------------------------------------------------------------------ 
#remove-all-packet-headers 
#add- packet header IP LL Mac AODV AOMDV ATR DSDV DSR OLSR UDP TCP CBR FTP   ;# needed headers 
Mac /802_11 set CWMin_31 
Mac /802_11 set CWMax_1023 
Mac /802_set Slot Time _0.000020                                                  ;# 20us 
Mac /802_11 set SIFS_0.000010                                                        ;# 10us 
Mac /802_11 set preamble Length_144                                                 ;# 144 bit 
Mac /802_11 set short preamble Length _                                          ;# 72 bit 
Mac /802_ set preamble data rate_1.0e6                                              ;# 1Mbps
Mac /802_11 set PLCP  Header Length_ 48                                              ;# 48 bits 
Mac /802_11 set PLCP Data Rate_1.0e6                                               ;# 1Mbps 
Mac /802_11 set Short PLCP Data Rate_2.0e6                                             ;# 2Mbps 
Mac /802_11 set RTS Threshold_3000                                                 ;# bytes 
Mac /802_11 set Short Retry Limit_7                                          ;# retransmissions 
Mac /802_11 set Long Retry Limit _4                                      ;# retransmissions 
Mac /802_11 set new chipset_ false                  ;# use new chipset , allowing a more recent packet to be correctly received in place of the first sensed packet 
Mac /802_11 set Data Rate _2Mb                                ;# 802.11 data transmission rate 
Mac/802_11 set basic Rate_1Mb                                ;# 802.11 basic transmission 
Mac /802_11 set aarf_ false 
# creating simulation: 
set ns [new Simulator]
#use colors to differentiate the traffics 
$ns color 1 Green 
# creating nam and trace file: 
set trace fd[open mdaomdv.tr w] 
set namtrace [open mdaomdv.nam w] 
$ns trace _ all $ tracefd 
$ns nam trace-all-wireless $nam trace $val (x) $ val(y) 
#set up topography object 
Set topo[new Topography] 
$topo load_ flat grid $val(x) $val(y) 
Set god_[create-god val(nn)] 
#configure the nodes 
$ns node-config-ad hoc routing $val (rp) \ 
-ll Type $val(ll) \ 
-mac Type $val(mac) \ 
-ifq Type $ val (ifq)  \ 
-ifq Len $val (ifqlen) \ 
-ant Type $ val(ant) \ 
-prop Type $ (prop) \ 
-phy Type $val(net if) \ 
-channel Type $ val (chann) \ 
-topo Instance $topo \ 
-agent Trace ON \ 
-router Trace ON \ 
-mac Trace OFF \ 
-movement Trace ON 
-channel $chan_1 \ 
-energy Model $ val (energy model) \ 
#-rx power 0.3 \ 
#-tx power 0.6 \ 
#-initial Energy 90 
## creating node object  
For {set i 0} {$i < 20} { incr i } { 
Set node _ ($i) [$ns node] 
} for {set i 0} {$i < 20} {incr i } { 
$node _($i) color blue 
$ns at 0.0 "$node_($i) color blue"
} 
for {set i 20} {$i < 30 } { incr i } { 
set node _($) [$ns node] 
} 
for {set i 20} {$i < 30 } {incr i } { 
$node_($i) color cyan 
$ns at 1.0 "$node_($i) color cyan"
} 
for {set i 30} {$i < 50 } { incr i } { 
set node_($i) [$ns node] 
} 
for {set i 20} {$i < 50 } {incr i } { 
$node_($i) color red 
$ns at 2.0 "$node_($i) color red"
} 
##provide initial location of mobile nodes. 
for {set i 0} {$i < $val(nn) } { incr i } { 
set xx [expr rand()*800] 
set yy [expr rand()* 800] 
$node_($i) set X_ $xx 
$node_($i) set Y_ $yy 
} 
# Define node initial position in nam 
for {set i 0} {$i < $val(nn)} { incr i } { 
# defines the node size for nam  
$ns initial_ node_ pos $node_($i) 30  
}
Proc stop {} { 
Global ns tracefd nam trace 
$ns flush-trace 
Close $tracefd 
Close $nam trace 
Exec nam mdaomdv.nam &
} 
$ns run `

我试图找到损坏的包并使用此命令“sudo dpkg -l | grep ^..r | apt-get purge”强行删除它们并再次发生以下错误

[sudo] derara 的密码:E:无法打开锁定文件 /var/lib/dpkg/lock-frontend - 打开(13:权限被拒绝) E: 无法获取 dpkg 前端锁 (/var/lib/dpkg/lock-frontend),你是 root 吗?

ubuntu simulation ns2
1个回答
0
投票

没有损坏的“包”,但是“mdaomdv.tcl”文件中有很多拼写错误等错误。
“ns node-config”部分:Space

\
之后是禁止的。
tcl/otcl代码:for拼写为'for',Set拼写为'set',Proc拼写为'proc',Global拼写为'global',Close拼写为'close',Exec拼写为'exec'。
对于正确的拼写,请阅读例如
EnergyModel-examples-7.tar.gz
https://drive.google.com/file/d/1g8WnlHHHnNXBLc0rwJY4i1z9uieKtl9s/view?usp=sharing

参考。 https://drive.google.com/drive/folders/0B7S255p3kFXNSmRYb2lGcDRUdWs?resourcekey=0-vrEMHtGTFP3yLoTQz_UAwA&usp=share_link

除此之外,文件中缺少流量。我添加了一行

source cbr-50-20-4-512ns
以包含必要的交通/通信示例 → 您编辑的文件,示例“111_aomdv.tcl”+ 交通文件:使用 AOMDV 协议,而不是您未知的 MDAOMDV。两个文件上传到 → →
https://drive.google.com/drive/folders/14vdJfoIqqKj34clkdxuN0IclHc0o0Oml?usp=share_link


111_aomdv.tcl

 # define options 
 set val(chan) Channel/WirelessChannel                                      ;# channel type
 set val(prop) Propagation/TwoRayGround           ;# radio propagation             model 
 set val(netif) Phy/WirelessPhy          ;# !!!EDITED !!!  ;# 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)    50                                              ;# number of mobile nodes 

set val(rp)     AOMDV           ;# MDAOMDV   ;# Routing protocol 
set val(x) 800                                                    ;# X dimension of topography 
set val(y) 800                                                    ;# Y dimension of topography
set val(stop) 500                                                   ;# time of simulation end  
set val(energymodel) EnergyModel                                               ; 
set val(n_ch) chan_1
set val(initialenergy)  90   ;# edited/added ##########  ;# Initial energy in Joules
#----------------------------------------- 
# ---------------------------------------- 
#remove-all-packet-headers 
#add- packet header IP LL Mac AODV AOMDV ATR DSDV DSR OLSR UDP TCP CBR FTP   ;# needed headers 
Mac /802_11 set CWMin_31 
Mac /802_11 set CWMax_1023 
Mac /802_set Slot Time _0.000020                                                  ;# 20us 
Mac /802_11 set SIFS_0.000010                                                        ;# 10us 
Mac /802_11 set preamble Length_144                                                 ;# 144 bit 
Mac /802_11 set short preamble Length _                                          ;# 72 bit 
Mac /802_ set preamble data rate_1.0e6                                              ;# 1Mbps
Mac /802_11 set PLCP  Header Length_ 48                                              ;# 48 bits 
Mac /802_11 set PLCP Data Rate_1.0e6                                               ;# 1Mbps 
Mac /802_11 set Short PLCP Data Rate_2.0e6                                             ;# 2Mbps 
Mac /802_11 set RTS Threshold_3000                                                 ;# bytes 
Mac /802_11 set Short Retry Limit_7                                          ;# retransmissions 
Mac /802_11 set Long Retry Limit _4                                      ;# retransmissions 
Mac /802_11 set new chipset_ false                  ;# use new chipset , allowing a more recent packet to be correctly received in place of the first sensed packet

Mac /802_11 set Data Rate _2Mb                                ;# 802.11 data transmission rate 
Mac/802_11 set basic Rate_1Mb                                ;# 802.11 basic transmission 
Mac /802_11 set aarf_ false

 
# creating simulation: 
set ns [new Simulator]
# use colors to differentiate the traffics 
$ns color 1 green 
# creating nam and trace file: 
set tracefd [open mdaomdv.tr w]     ;# edited 
set namtrace [open mdaomdv.nam w] 
$ns trace-all $tracefd       ;# edited
$ns namtrace-all-wireless $namtrace $val(x) $val(y)     ;# edited

 
#set up topography object           
set topo    [new Topography]    ;# edited       
$topo load_flatgrid $val(x) $val(y) ;# edited

set god_    [create-god val(nn)]
 
#configure the nodes        #### section is edited #################
## all lines in this section are edited, +added: -initialEnergy $val(initialenergy) #####
$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 \
-n_chType  $val(n_ch) \
-energyModel $val(energymodel) \
#-rx power 0.3 \
#-tx power 0.6 \
-initialEnergy $val(initialenergy)


## creating node object  ### edited section ################
for {set i 0} {$i < $val(nn) } {incr i} {
        set node_($i) [$ns node]    
#       $node_($i) random-motion 0
        }

for {set i 0} {$i < 20} {incr i} {      ;# edited
$node_($i) color blue
$ns at 0.0 "$node_($i) color blue"
} 
for {set i 20} {$i < 30} {incr i} { 
set node_($) [$ns node]             
} 
for {set i 20} {$i < 30} {incr i} { 
$node_($i) color cyan
$ns at 1.0 "$node_($i) color cyan"
} 
for {set i 30} {$i < 50} {incr i} { 
set node_($i) [$ns node] 
}
for {set i 20} {$i < 50} {incr i} {
$node_($i) color red
$ns at 2.0 "$node_($i) color red"
}

source cbr-50-20-4-512ns
 
# provide initial location of mobile nodes 
for {set i 0} {$i < $val(nn) } { incr i } { 
set xx [expr rand()*800] 
set yy [expr rand()* 800] 
$node_($i) set X_ $xx 
$node_($i) set Y_ $yy 
}
 
# Define node initial position in nam    ;# this section is edited #####
for {set i 0} {$i < $val(nn)} {incr i} { 
# defines the node size for nam  
$ns initial_node_pos $node_($i) 30  
}

proc stop {} { 
global ns tracefd nam trace 
$ns flush-trace 
close $tracefd 
close $nam trace 
}

# Tell all the nodes when the simulation ends ###############
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns at $val(stop).000000001 "$node_($i) reset";
}
$ns at $val(stop).00000001 "puts \"NS EXITING...\" ; $ns halt"

$ns run

exec nam mdaomdv.nam &
© www.soinside.com 2019 - 2024. All rights reserved.