faced this problem when try to run ns2 simulation.tcl file below this error "Segmentation fault (core dumped)"
`
`# 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 `
I tried to find the broken packages and delete them forcefully using this command "sudo dpkg -l | grep ^..r | apt-get purge" and again the following error happened
[sudo] password for derara: E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?