LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-20-2016, 06:43 AM   #1
derekman
LQ Newbie
 
Registered: Apr 2016
Posts: 10

Rep: Reputation: Disabled
segmentation fault in ns2


hello, I have problem,when I add more than 2 nodes as a source, I got segmentation fault, please help, I don't know why I got the problem, is it the routing protocol / queue / or anything?

Code:
#===================================
#     Simulation parameters setup
#===================================
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/RED							;# interface queue type
set val(ll)     LL									;# link layer type
set val(ant)    Antenna/OmniAntenna					;# antenna model
set val(ifqlen) 20									;# max packet in ifq
set val(nn)     40									;# number of mobilenodes
set val(rp)     AODV								;# routing protocol
set val(x)      1000								;# X dimension of topography
set val(y)      1000								;# Y dimension of topography
set val(stop)   20									;# time of simulation end
set val(energymodel)	EnergyModel					;# type of energy
set val(initialenergy)  100							;# Initial energy in Joules
set val(rxPower)        0.00175						;# reception power in Joules
set val(txPower)		0.00175						;# transmition power in Joules
#Phy/WirelessPhy set CSThresh_ 1.20174e-13		;# 100m sensing range
#Phy/WirelessPhy set RXThresh_ 4.4613e-10 			;# 250m transmition range

#===================================
#        Initialization        
#===================================
#Create a ns simulator
set ns [new Simulator]

#Define color in NAM
#$ns color 1 Blue
#$ns color 2 Red
#$ns color 3 Black
#$ns color 4 Blue
#$ns color 5 Red
#$ns color 6 Black
#$ns color 7 Blue
#$ns color 8 Red
#$ns color 9 Black
#$ns color 10 Blue
#$ns color 11 Red
#$ns color 12 Black
#$ns color 13 Blue
#$ns color 14 Red
#$ns color 15 Black

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

#Open the NS trace file
set tracefile [open Scenario-1-RED-20.tr w]
$ns trace-all $tracefile

#Open the NAM trace file
set namfile [open Scenario-1-RED-20.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel

#===================================
#     Mobile node parameter setup
#===================================
$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       $chan \
                -topoInstance  $topo \
                -agentTrace    ON \
                -routerTrace   ON \
                -macTrace      ON \
                -movementTrace ON

#===================================
#        Nodes Definition        
#===================================
#Create 40 nodes
set n0 [$ns node]
$n0 set X_ 37
$n0 set Y_ 36
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20

set n1 [$ns node]
$n1 set X_ 30
$n1 set Y_ 263
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20

set n2 [$ns node]
$n2 set X_ 103
$n2 set Y_ 161
$n2 set Z_ 0.0
$ns initial_node_pos $n2 20

set n3 [$ns node]
$n3 set X_ 177
$n3 set Y_ 196
$n3 set Z_ 0.0
$ns initial_node_pos $n3 20

set n4 [$ns node]
$n4 set X_ 248
$n4 set Y_ 241
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20

set n5 [$ns node]
$n5 set X_ 240
$n5 set Y_ 30
$n5 set Z_ 0.0
$ns initial_node_pos $n5 20

set n6 [$ns node]
$n6 set X_ 146
$n6 set Y_ 355
$n6 set Z_ 0.0
$ns initial_node_pos $n6 20

set n7 [$ns node]
$n7 set X_ 295
$n7 set Y_ 449
$n7 set Z_ 0.0
$ns initial_node_pos $n7 20

set n8 [$ns node]
$n8 set X_ 116
$n8 set Y_ 503
$n8 set Z_ 0.0
$ns initial_node_pos $n8 20

set n9 [$ns node]
$n9 set X_ 80
$n9 set Y_ 922
$n9 set Z_ 0.0
$ns initial_node_pos $n9 20

set n10 [$ns node]
$n10 set X_ 260
$n10 set Y_ 970
$n10 set Z_ 0.0
$ns initial_node_pos $n10 20

set n11 [$ns node]
$n11 set X_ 206
$n11 set Y_ 853
$n11 set Z_ 0.0
$ns initial_node_pos $n11 20

set n12 [$ns node]
$n12 set X_ 61
$n12 set Y_ 837
$n12 set Z_ 0.0
$ns initial_node_pos $n12 20

set n13 [$ns node]
$n13 set X_ 172
$n13 set Y_ 798
$n13 set Z_ 0.0
$ns initial_node_pos $n13 20

set n14 [$ns node]
$n14 set X_ 850
$n14 set Y_ 41
$n14 set Z_ 0.0
$ns initial_node_pos $n14 20

set n15 [$ns node]
$n15 set X_ 956
$n15 set Y_ 128
$n15 set Z_ 0.0
$ns initial_node_pos $n15 20

set n16 [$ns node]
$n16 set X_ 767
$n16 set Y_ 78
$n16 set Z_ 0.0
$ns initial_node_pos $n16 20

set n17 [$ns node]
$n17 set X_ 914
$n17 set Y_ 187
$n17 set Z_ 0.0
$ns initial_node_pos $n17 20

set n18 [$ns node]
$n18 set X_ 800
$n18 set Y_ 259
$n18 set Z_ 0.0
$ns initial_node_pos $n18 20

set n19 [$ns node]
$n19 set X_ 943
$n19 set Y_ 936
$n19 set Z_ 0.0
$ns initial_node_pos $n19 20

set n20 [$ns node]
$n20 set X_ 785
$n20 set Y_ 983
$n20 set Z_ 0.0
$ns initial_node_pos $n20 20

set n21 [$ns node]
$n21 set X_ 882
$n21 set Y_ 880
$n21 set Z_ 0.0
$ns initial_node_pos $n21 20

set n22 [$ns node]
$n22 set X_ 967
$n22 set Y_ 805
$n22 set Z_ 0.0
$ns initial_node_pos $n22 20

set n23 [$ns node]
$n23 set X_ 810
$n23 set Y_ 804
$n23 set Z_ 0.0
$ns initial_node_pos $n23 20

set n24 [$ns node]
$n24 set X_ 523
$n24 set Y_ 503
$n24 set Z_ 0.0
$ns initial_node_pos $n24 20

set n25 [$ns node]
$n25 set X_ 850
$n25 set Y_ 420
$n25 set Z_ 0.0
$ns initial_node_pos $n25 20

set n26 [$ns node]
$n26 set X_ 748
$n26 set Y_ 506
$n26 set Z_ 0.0
$ns initial_node_pos $n26 20

set n27 [$ns node]
$n27 set X_ 836
$n27 set Y_ 588
$n27 set Z_ 0.0
$ns initial_node_pos $n27 20

set n28 [$ns node]
$n28 set X_ 703
$n28 set Y_ 665
$n28 set Z_ 0.0
$ns initial_node_pos $n28 20

set n29 [$ns node]
$n29 set X_ 642
$n29 set Y_ 807
$n29 set Z_ 0.0
$ns initial_node_pos $n29 20

set n30 [$ns node]
$n30 set X_ 536
$n30 set Y_ 906
$n30 set Z_ 0.0
$ns initial_node_pos $n30 20

set n31 [$ns node]
$n31 set X_ 415
$n31 set Y_ 912
$n31 set Z_ 0.0
$ns initial_node_pos $n31 20

set n32 [$ns node]
$n32 set X_ 398
$n32 set Y_ 760
$n32 set Z_ 0.0
$ns initial_node_pos $n32 20

set n33 [$ns node]
$n33 set X_ 315
$n33 set Y_ 594
$n33 set Z_ 0.0
$ns initial_node_pos $n33 20

set n34 [$ns node]
$n34 set X_ 113
$n34 set Y_ 632
$n34 set Z_ 0.0
$ns initial_node_pos $n34 20

set n35 [$ns node]
$n35 set X_ 367
$n35 set Y_ 188
$n35 set Z_ 0.0
$ns initial_node_pos $n35 20

set n36 [$ns node]
$n36 set X_ 505
$n36 set Y_ 58
$n36 set Z_ 0.0
$ns initial_node_pos $n36 20

set n37 [$ns node]
$n37 set X_ 674
$n37 set Y_ 184
$n37 set Z_ 0.0
$ns initial_node_pos $n37 20

set n38 [$ns node]
$n38 set X_ 670
$n38 set Y_ 335
$n38 set Z_ 0.0
$ns initial_node_pos $n38 20

set n39 [$ns node]
$n39 set X_ 496
$n39 set Y_ 302
$n39 set Z_ 0.0
$ns initial_node_pos $n39 20

#===================================
#        Agents Definition        
#===================================

set udp0 [new Agent/UDP]
$udp0 set fid_ 2
$ns attach-agent $n9 $udp0

set udp1 [new Agent/UDP]
$udp1 set fid_ 2
$ns attach-agent $n12 $udp1


#set udp12 [new Agent/UDP]
#$udp12 set fid_ 12
#$ns attach-agent $n16 $udp11

set null0 [new Agent/Null]
$ns attach-agent $n24 $null0

$ns connect $udp0 $null0
$ns connect $udp1 $null0
$ns connect $udp12 $null0

#===================================
#        Applications Definition        
#===================================
#Setup a cbr Application over udp connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 set interval_ 0.05 
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 128 
$ns at 1.0 "$cbr0 start"
$ns at 20.0 "$cbr0 stop"

#Setup a cbr Application over udp connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set interval_ 0.05 
$cbr1 set packetSize_ 128 
$ns at 1.0 "$cbr1 start"
$ns at 20.0 "$cbr1 stop"

#Setup a cbr Application over udp connection
set cbr12 [new Application/Traffic/CBR]
$cbr12 attach-agent $udp12
$cbr12 set interval_ 0.05
$cbr12 set packetSize_ 128 
$ns at 10.0 "$cbr12 start"
$ns at 20.0 "$cbr12 stop"

#===================================
#        Termination        
#===================================
#Define a 'finish' procedure
proc finish {} {
    global ns tracefile namfile
    $ns flush-trace
    close $tracefile
    close $namfile
    exec nam Scenario-1-RED-20.nam &
    exit 0
}

#for {set i 0} {$i < $val(nn) } { incr i } {
   #$ns at $val(stop) "\$n$i reset"
#}



$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
Code:
root$door:~$ ns235-mannasim Network-Topology-Test.tcl 
num_nodes is set 40
INITIALIZE THE LIST xListHead
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 550.0
SORTING LISTS ...DONE!
Segmentation fault (core dumped)

Last edited by derekman; 05-20-2016 at 07:17 AM.
 
Old 05-20-2016, 07:24 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2021 CentOS7.9 + 50+ other Linux OS, for test only.
Posts: 17,435

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Please read http://www.linuxquestions.org/questi...-4175530493/#2
and http://www.linuxquestions.org/questi...-4175507630/#3
Ref. http://www.linuxquestions.org/questi...20fault%20ns2/

About your file Network-Topology-Test.tcl :
$ ns235-mannasim Network-Topology-Test-1.tcl
... is creating Scenario-1-RED-20.nam 2.3MB, Scenario-1-RED-20.tr 1.3MB .
$ nam Scenario-1-RED-20.nam & : Seems to be an OK animation.

Conclusion : The 'Segmentation fault' happens at the simulation end? and can be ignored.
-
Attached Files
File Type: txt Network-Topology-Test-1.tcl.txt (8.3 KB, 109 views)

Last edited by knudfl; 05-20-2016 at 07:28 AM.
 
Old 05-20-2016, 09:42 AM   #3
derekman
LQ Newbie
 
Registered: Apr 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
Please read http://www.linuxquestions.org/questi...-4175530493/#2
and http://www.linuxquestions.org/questi...-4175507630/#3
Ref. http://www.linuxquestions.org/questi...20fault%20ns2/

About your file Network-Topology-Test.tcl :
$ ns235-mannasim Network-Topology-Test-1.tcl
... is creating Scenario-1-RED-20.nam 2.3MB, Scenario-1-RED-20.tr 1.3MB .
$ nam Scenario-1-RED-20.nam & : Seems to be an OK animation.

Conclusion : The 'Segmentation fault' happens at the simulation end? and can be ignored.
-
so does it mean the results from the tcl are not broken because of segmentation fault?
 
Old 05-20-2016, 01:43 PM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2021 CentOS7.9 + 50+ other Linux OS, for test only.
Posts: 17,435

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Re #3.
Quote:
does it mean the results from the tcl are not broken because of segmentation fault ?
Please run $ nam Scenario-1-RED-20.nam &
... and see for yourself.
And please read the trace file, Scenario-1-RED-20.tr .
 
Old 05-21-2016, 12:49 AM   #5
derekman
LQ Newbie
 
Registered: Apr 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
Re #3.

Please run $ nam Scenario-1-RED-20.nam &
... and see for yourself.
And please read the trace file, Scenario-1-RED-20.tr .
i found from the tr that the simulation stopped at 10

it should be finished at 20s
 
Old 05-21-2016, 03:55 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2021 CentOS7.9 + 50+ other Linux OS, for test only.
Posts: 17,435

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Re #5.

Please read the links in post #3 : ns2 has some limitations.
When things get too complicated, you will get 'Segmentation fault'.

Setting the "set val(stop)" to 9 : No 'Segmentation fault'.

Complex simulations : Use e.g. OPNET.


-
 
Old 05-21-2016, 04:22 AM   #7
derekman
LQ Newbie
 
Registered: Apr 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
Re #5.

Please read the links in post #3 : ns2 has some limitations.
When things get too complicated, you will get 'Segmentation fault'.

Setting the "set val(stop)" to 9 : No 'Segmentation fault'.

Complex simulations : Use e.g. OPNET.


-
so ns can't handle complex simulation, am I right?

I tried to use this more-simple scenario below

Code:
# This script is created by NSG2 beta1
# <http://wushoupong.googlepages.com/nsg>

#===================================
#     Simulation parameters setup
#===================================
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) 20                         ;# max packet in ifq
set val(nn)     21                         ;# number of mobilenodes
set val(rp)     AODV                       ;# routing protocol
set val(x)      1836                      ;# X dimension of topography
set val(y)      100                      ;# Y dimension of topography
set val(stop)   10.0                         ;# time of simulation end

#===================================
#        Initialization        
#===================================
#Create a ns simulator
set ns [new Simulator]

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

#Open the NS trace file
set tracefile [open dont_know.tr w]
$ns trace-all $tracefile

#Open the NAM trace file
set namfile [open dont_know.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel

#===================================
#     Mobile node parameter setup
#===================================
$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       $chan \
                -topoInstance  $topo \
                -agentTrace    ON \
                -routerTrace   ON \
                -macTrace      ON \
                -movementTrace ON

#===================================
#        Nodes Definition        
#===================================
#Create 21 nodes
set n0 [$ns node]
$n0 set X_ 1100
$n0 set Y_ 1200
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 998
$n1 set Y_ 1300
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 1200
$n2 set Y_ 1300
$n2 set Z_ 0.0
$ns initial_node_pos $n2 20
set n3 [$ns node]
$n3 set X_ 1201
$n3 set Y_ 1097
$n3 set Z_ 0.0
$ns initial_node_pos $n3 20
set n4 [$ns node]
$n4 set X_ 1001
$n4 set Y_ 1098
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20
set n5 [$ns node]
$n5 set X_ 894
$n5 set Y_ 1481
$n5 set Z_ 0.0
$ns initial_node_pos $n5 20
set n6 [$ns node]
$n6 set X_ 829
$n6 set Y_ 1445
$n6 set Z_ 0.0
$ns initial_node_pos $n6 20
set n7 [$ns node]
$n7 set X_ 808
$n7 set Y_ 1378
$n7 set Z_ 0.0
$ns initial_node_pos $n7 20
set n8 [$ns node]
$n8 set X_ 782
$n8 set Y_ 1326
$n8 set Z_ 0.0
$ns initial_node_pos $n8 20
set n9 [$ns node]
$n9 set X_ 801
$n9 set Y_ 1043
$n9 set Z_ 0.0
$ns initial_node_pos $n9 20
set n10 [$ns node]
$n10 set X_ 827
$n10 set Y_ 989
$n10 set Z_ 0.0
$ns initial_node_pos $n10 20
set n11 [$ns node]
$n11 set X_ 864
$n11 set Y_ 933
$n11 set Z_ 0.0
$ns initial_node_pos $n11 20
set n12 [$ns node]
$n12 set X_ 942
$n12 set Y_ 898
$n12 set Z_ 0.0
$ns initial_node_pos $n12 20
set n13 [$ns node]
$n13 set X_ 1261
$n13 set Y_ 1421
$n13 set Z_ 0.0
$ns initial_node_pos $n13 20
set n14 [$ns node]
$n14 set X_ 1327
$n14 set Y_ 1429
$n14 set Z_ 0.0
$ns initial_node_pos $n14 20
set n15 [$ns node]
$n15 set X_ 1389
$n15 set Y_ 1413
$n15 set Z_ 0.0
$ns initial_node_pos $n15 20
set n16 [$ns node]
$n16 set X_ 1388
$n16 set Y_ 1332
$n16 set Z_ 0.0
$ns initial_node_pos $n16 20
set n17 [$ns node]
$n17 set X_ 1347
$n17 set Y_ 1082
$n17 set Z_ 0.0
$ns initial_node_pos $n17 20
set n18 [$ns node]
$n18 set X_ 1368
$n18 set Y_ 1009
$n18 set Z_ 0.0
$ns initial_node_pos $n18 20
set n19 [$ns node]
$n19 set X_ 1322
$n19 set Y_ 986
$n19 set Z_ 0.0
$ns initial_node_pos $n19 20
set n20 [$ns node]
$n20 set X_ 1254
$n20 set Y_ 925
$n20 set Z_ 0.0
$ns initial_node_pos $n20 20

#===================================
#        Agents Definition        
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns attach-agent $n5 $udp0

set udp1 [new Agent/UDP]
$ns attach-agent $n6 $udp1

set udp2 [new Agent/UDP]
$ns attach-agent $n7 $udp2

set udp3 [new Agent/UDP]
$ns attach-agent $n8 $udp3

set udp4 [new Agent/UDP]
$ns attach-agent $n9 $udp4

set udp5 [new Agent/UDP]
$ns attach-agent $n10 $udp5

set udp6 [new Agent/UDP]
$ns attach-agent $n11 $udp6

set udp7 [new Agent/UDP]
$ns attach-agent $n12 $udp7

set udp8 [new Agent/UDP]
$ns attach-agent $n13 $udp8

set udp9 [new Agent/UDP]
$ns attach-agent $n14 $udp9

set udp10 [new Agent/UDP]
$ns attach-agent $n15 $udp10

set udp11 [new Agent/UDP]
$ns attach-agent $n16 $udp11

set udp12 [new Agent/UDP]
$ns attach-agent $n17 $udp12

set udp13 [new Agent/UDP]
$ns attach-agent $n18 $udp13

set udp14 [new Agent/UDP]
$ns attach-agent $n19 $udp14

set udp15 [new Agent/UDP]
$ns attach-agent $n20 $udp15

set null16 [new Agent/Null]
$ns attach-agent $n0 $null16

$ns connect $udp0 $null16
$udp0 set packetSize_ 512
$ns connect $udp1 $null16
$udp0 set packetSize_ 512
$ns connect $udp2 $null16
$udp0 set packetSize_ 512
$ns connect $udp3 $null16
$udp0 set packetSize_ 512
$ns connect $udp4 $null16
$udp0 set packetSize_ 512
$ns connect $udp5 $null16
$udp0 set packetSize_ 512
$ns connect $udp6 $null16
$udp0 set packetSize_ 512
$ns connect $udp7 $null16
$udp0 set packetSize_ 512
$ns connect $udp8 $null16
$udp0 set packetSize_ 512
$ns connect $udp9 $null16
$udp0 set packetSize_ 512
$ns connect $udp10 $null16
$udp0 set packetSize_ 512
$ns connect $udp11 $null16
$udp0 set packetSize_ 512
$ns connect $udp12 $null16
$udp0 set packetSize_ 512
$ns connect $udp13 $null16
$udp0 set packetSize_ 512
$ns connect $udp14 $null16
$udp0 set packetSize_ 512
$ns connect $udp15 $null16
$udp0 set packetSize_ 512

#===================================
#        Applications Definition        
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 128
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns at 1.0 "$cbr0 start"
$ns at 8.0 "$cbr0 stop"

#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 128
$cbr1 set rate_ 1.0Mb
$cbr1 set random_ null
$ns at 1.0 "$cbr1 start"
$ns at 8.0 "$cbr1 stop"

#Setup a CBR Application over UDP connection
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
$cbr2 set packetSize_ 128
$cbr2 set rate_ 1.0Mb
$cbr2 set random_ null
$ns at 1.0 "$cbr2 start"
$ns at 8.0 "$cbr2 stop"

#Setup a CBR Application over UDP connection
set cbr3 [new Application/Traffic/CBR]
$cbr3 attach-agent $udp3
$cbr3 set packetSize_ 128
$cbr3 set rate_ 1.0Mb
$cbr3 set random_ null
$ns at 1.0 "$cbr3 start"
$ns at 8.0 "$cbr3 stop"

#Setup a CBR Application over UDP connection
set cbr4 [new Application/Traffic/CBR]
$cbr4 attach-agent $udp4
$cbr4 set packetSize_ 128
$cbr4 set rate_ 1.0Mb
$cbr4 set random_ null
$ns at 1.0 "$cbr4 start"
$ns at 8.0 "$cbr4 stop"

#Setup a CBR Application over UDP connection
#set cbr5 [new Application/Traffic/CBR]
$cbr5 attach-agent $udp5
$cbr5 set packetSize_ 128
$cbr5 set rate_ 1.0Mb
$cbr5 set random_ null
$ns at 1.0 "$cbr5 start"
$ns at 8.0 "$cbr5 stop"

#Setup a CBR Application over UDP connection
#set cbr6 [new Application/Traffic/CBR]
$cbr6 attach-agent $udp6
$cbr6 set packetSize_ 128
$cbr6 set rate_ 1.0Mb
$cbr6 set random_ null
$ns at 1.0 "$cbr6 start"
$ns at 8.0 "$cbr6 stop"

#Setup a CBR Application over UDP connection
#set cbr7 [new Application/Traffic/CBR]
$cbr7 attach-agent $udp7
$cbr7 set packetSize_ 128
$cbr7 set rate_ 1.0Mb
$cbr7 set random_ null
$ns at 1.0 "$cbr7 start"
$ns at 8.0 "$cbr7 stop"

#Setup a CBR Application over UDP connection
#set cbr8 [new Application/Traffic/CBR]
$cbr8 attach-agent $udp8
$cbr8 set packetSize_ 128
$cbr8 set rate_ 1.0Mb
$cbr8 set random_ null
$ns at 1.0 "$cbr8 start"
$ns at 8.0 "$cbr8 stop"

#Setup a CBR Application over UDP connection
#set cbr9 [new Application/Traffic/CBR]
$cbr9 attach-agent $udp9
$cbr9 set packetSize_ 128
$cbr9 set rate_ 1.0Mb
$cbr9 set random_ null
$ns at 1.0 "$cbr9 start"
$ns at 8.0 "$cbr9 stop"

#Setup a CBR Application over UDP connection
#set cbr10 [new Application/Traffic/CBR]
$cbr10 attach-agent $udp10
$cbr10 set packetSize_ 128
$cbr10 set rate_ 1.0Mb
$cbr10 set random_ null
$ns at 1.0 "$cbr10 start"
$ns at 8.0 "$cbr10 stop"

#Setup a CBR Application over UDP connection
#set cbr11 [new Application/Traffic/CBR]
$cbr11 attach-agent $udp11
$cbr11 set packetSize_ 128
$cbr11 set rate_ 1.0Mb
$cbr11 set random_ null
$ns at 1.0 "$cbr11 start"
$ns at 8.0 "$cbr11 stop"

#Setup a CBR Application over UDP connection
#set cbr12 [new Application/Traffic/CBR]
$cbr12 attach-agent $udp12
$cbr12 set packetSize_ 128
$cbr12 set rate_ 1.0Mb
$cbr12 set random_ null
$ns at 1.0 "$cbr12 start"
$ns at 8.0 "$cbr12 stop"

#Setup a CBR Application over UDP connection
#set cbr13 [new Application/Traffic/CBR]
$cbr13 attach-agent $udp13
$cbr13 set packetSize_ 128
$cbr13 set rate_ 1.0Mb
$cbr13 set random_ null
$ns at 1.0 "$cbr13 start"
$ns at 8.0 "$cbr13 stop"

#Setup a CBR Application over UDP connection
#set cbr14 [new Application/Traffic/CBR]
$cbr14 attach-agent $udp14
$cbr14 set packetSize_ 128
$cbr14 set rate_ 1.0Mb
$cbr14 set random_ null
$ns at 1.0 "$cbr14 start"
$ns at 8.0 "$cbr14 stop"

#Setup a CBR Application over UDP connection
#set cbr15 [new Application/Traffic/CBR]
$cbr15 attach-agent $udp15
$cbr15 set packetSize_ 128
$cbr15 set rate_ 1.0Mb
$cbr15 set random_ null
$ns at 1.0 "$cbr15 start"
$ns at 8.0 "$cbr15 stop"


#===================================
#        Termination        
#===================================
#Define a 'finish' procedure
proc finish {} {
    global ns tracefile namfile
    $ns flush-trace
    close $tracefile
    close $namfile
    exec nam dont_know.nam &
    exit 0
}
#for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "\$n$i reset"
#}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
it does run without any problem, but when I changed the val(ifq) from DropTail/PriQueue to RED or CoDel, the "segmentation fault" occured, strange....

sadly, I don't have the license of opnet

Last edited by derekman; 05-21-2016 at 04:46 AM.
 
Old 05-21-2016, 05:14 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2021 CentOS7.9 + 50+ other Linux OS, for test only.
Posts: 17,435

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Re #7. Please do not quote entire posts. A "one word reference" will do.

In post #1 you show code.tcl, which isn't working unless edited.
The same for post #7 :
cbr5 ....... cbr15 are not set : #set cbr15 [new Application/Traffic/CBR]
.. etc. etc. error.


-
 
Old 05-21-2016, 05:22 AM   #9
derekman
LQ Newbie
 
Registered: Apr 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Re #8

sorry about that, I copied the wrong one and yes I did remove the #, and it does run without any problem, but when I changed the val(ifq) from DropTail/PriQueue to RED or CoDel, the "segmentation fault" occured

could it be happen because failed patch?
 
Old 05-21-2016, 05:33 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2021 CentOS7.9 + 50+ other Linux OS, for test only.
Posts: 17,435

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Re #9 : RED and CoDel are well tested, but may not work at all with a mannasim simulation.

Other simulators for WSN .... ns3 etc.
. https://sourceforge.net/directory/os...networks%20ns3
. https://www.google.com/webhp?hl=all&...l=en&q=ns3+wsn
. https://www.google.com/webhp?hl=all&...ork+simulators

OMNeT++, Castalia, ns3 are free ...
. https://groups.google.com/forum/?fro...!forum/omnetpp
. https://groups.google.com/forum/#!fo...alia-simulator
. https://groups.google.com/forum/?fro...rum/ns-3-users


-
 
Old 05-21-2016, 05:42 AM   #11
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2021 CentOS7.9 + 50+ other Linux OS, for test only.
Posts: 17,435

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Re #9.

Did you read the CodelDT examples ?

Queue/CoDelDt set target_ [delay_parse 5ms]
Queue/CoDelDt set interval_ [delay_parse 100ms]

tcl/ex/ : codel-test.tcl, sfqcodel-test.tcl, simple-codeldt.tcl, tcpDrop.tcl


-
 
Old 05-21-2016, 06:12 AM   #12
derekman
LQ Newbie
 
Registered: Apr 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Re #10,

I still don't understand, I red several papers, they could even run more complex simulation than mine using ns2 without having any problem, strange I ran on 64 bit 14.04 ubuntu, could the environment is the problem?

Re #11
my main focuses are CoDel and RED, so no, I didn't read CoDelDT examples

==================================

I did several changes with more simple, it seems CoDel works okay, but I still got segmentation fault when I changed the queue variable to RED

Code:
# This script is created by NSG2 beta1
# <http://wushoupong.googlepages.com/nsg>

#===================================
#     Simulation parameters setup
#===================================
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/CoDel    ;# interface queue type
set val(ll)     LL                         ;# link layer type
set val(ant)    Antenna/OmniAntenna        ;# antenna model
set val(ifqlen) 30                         ;# max packet in ifq
set val(nn)     9                          ;# number of mobilenodes
set val(rp)     AODV                       ;# routing protocol
set val(x)      2710                      ;# X dimension of topography
set val(y)      100                      ;# Y dimension of topography
set val(stop)   20.0                         ;# time of simulation end

#===================================
#        Initialization        
#===================================
#Create a ns simulator
set ns [new Simulator]

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

#Open the NS trace file
set tracefile [open Final.tr w]
$ns trace-all $tracefile

#Open the NAM trace file
set namfile [open Final.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel

#===================================
#     Mobile node parameter setup
#===================================
$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       $chan \
                -topoInstance  $topo \
                -agentTrace    ON \
                -routerTrace   ON \
                -macTrace      ON \
                -movementTrace ON

#===================================
#        Nodes Definition        
#===================================
#Create 9 nodes
set n0 [$ns node]
$n0 set X_ 1598
$n0 set Y_ 1093
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 1350
$n1 set Y_ 1097
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 1845
$n2 set Y_ 1095
$n2 set Z_ 0.0
$ns initial_node_pos $n2 20
set n3 [$ns node]
$n3 set X_ 1241
$n3 set Y_ 1320
$n3 set Z_ 0.0
$ns initial_node_pos $n3 20
set n4 [$ns node]
$n4 set X_ 1110
$n4 set Y_ 1088
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20
set n5 [$ns node]
$n5 set X_ 1272
$n5 set Y_ 861
$n5 set Z_ 0.0
$ns initial_node_pos $n5 20
set n6 [$ns node]
$n6 set X_ 1930
$n6 set Y_ 1322
$n6 set Z_ 0.0
$ns initial_node_pos $n6 20
set n7 [$ns node]
$n7 set X_ 2088
$n7 set Y_ 1077
$n7 set Z_ 0.0
$ns initial_node_pos $n7 20
set n8 [$ns node]
$n8 set X_ 1927
$n8 set Y_ 862
$n8 set Z_ 0.0
$ns initial_node_pos $n8 20

#===================================
#        Agents Definition        
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns attach-agent $n3 $udp0
$udp0 set packetSize_ 512
set udp1 [new Agent/UDP]
$ns attach-agent $n4 $udp1
$udp1 set packetSize_ 512

set udp2 [new Agent/UDP]
$ns attach-agent $n5 $udp2
$udp2 set packetSize_ 512

set udp3 [new Agent/UDP]
$ns attach-agent $n6 $udp3
$udp3 set packetSize_ 512

set udp4 [new Agent/UDP]
$ns attach-agent $n7 $udp4
$udp4 set packetSize_ 512

set udp5 [new Agent/UDP]
$ns attach-agent $n8 $udp5
$udp5 set packetSize_ 512

set null6 [new Agent/Null]
$ns attach-agent $n0 $null6

$ns connect $udp0 $null6
$ns connect $udp1 $null6
$ns connect $udp2 $null6
$ns connect $udp3 $null6
$ns connect $udp4 $null6
$ns connect $udp5 $null6



#===================================
#        Applications Definition        
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 128
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns at 1.0 "$cbr0 start"
$ns at 8.0 "$cbr0 stop"

#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 128
$cbr1 set rate_ 1.0Mb
$cbr1 set random_ null
$ns at 1.0 "$cbr1 start"
$ns at 8.0 "$cbr1 stop"

#Setup a CBR Application over UDP connection
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
$cbr2 set packetSize_ 128
$cbr2 set rate_ 1.0Mb
$cbr2 set random_ null
$ns at 1.0 "$cbr2 start"
$ns at 8.0 "$cbr2 stop"

#Setup a CBR Application over UDP connection
set cbr3 [new Application/Traffic/CBR]
$cbr3 attach-agent $udp3
$cbr3 set packetSize_ 128
$cbr3 set rate_ 1.0Mb
$cbr3 set random_ null
$ns at 1.0 "$cbr3 start"
$ns at 8.0 "$cbr3 stop"

#Setup a CBR Application over UDP connection
set cbr4 [new Application/Traffic/CBR]
$cbr4 attach-agent $udp4
$cbr4 set packetSize_ 128
$cbr4 set rate_ 1.0Mb
$cbr4 set random_ null
$ns at 1.0 "$cbr4 start"
$ns at 8.0 "$cbr4 stop"

#Setup a CBR Application over UDP connection
set cbr5 [new Application/Traffic/CBR]
$cbr5 attach-agent $udp5
$cbr5 set packetSize_ 128
$cbr5 set rate_ 1.0Mb
$cbr5 set random_ null
$ns at 1.0 "$cbr5 start"
$ns at 8.0 "$cbr5 stop"


#===================================
#        Termination        
#===================================
#Define a 'finish' procedure
proc finish {} {
    global ns tracefile namfile
    $ns flush-trace
    close $tracefile
    close $namfile
    exec nam Final.nam &
    exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run

Last edited by derekman; 05-21-2016 at 06:45 AM.
 
Old 05-21-2016, 07:41 AM   #13
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2021 CentOS7.9 + 50+ other Linux OS, for test only.
Posts: 17,435

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Re #12.
Quote:
I red several papers
Well, then follow the links in post #3.
 
1 members found this post helpful.
Old 05-21-2016, 09:01 AM   #14
derekman
LQ Newbie
 
Registered: Apr 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Re #13.

thank you, I found the solution now, I should put the parameter more spesific for both queue....

thank you knudfl!
 
Old 05-21-2016, 09:53 AM   #15
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2021 CentOS7.9 + 50+ other Linux OS, for test only.
Posts: 17,435

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Re #14.

Please share the solution ... for the benefit of all mannasim users.
 
  


Reply

Tags
ns2, segmentation fault, segmentation fault ns2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
aodv-uu segmentation fault on ns2.34 sarf2k4 Linux - Newbie 7 04-01-2014 02:01 AM
ns2 segmentation fault when using energy model edsionwang Programming 0 04-27-2013 05:45 PM
A segmentation fault in NS2 kadij Linux - Newbie 0 06-14-2012 08:56 AM
Agentj and Ns2 Question Segmentation fault krabieh Linux - Newbie 0 10-11-2011 06:41 PM
ns2.34 Segmentation fault over Ubuntu 11.04 Amro1 Ubuntu 7 09-28-2011 08:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration