LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-13-2018, 05:27 AM   #1
ariefhi
LQ Newbie
 
Registered: Aug 2018
Posts: 9

Rep: Reputation: Disabled
Question [Segmentation fault (core dumped)]running tcl


hi everyone
i got the problem when i run tcl as Segmentation fault (core dumped), if i add energy, it working
anyone can help me?
Quote:
#
# Define options
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) 25 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 500 ;# Y dimension of topography
set val(stop) 100 ;# time of simulation end
;

set ns [new Simulator]
set tracefd [open ex-1_without-energy.tr w]
set windowVsTime2 [open win.tr w]
set namtrace [open ex-1_without-energy.nam w]

$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)

#
# Create nn mobilenodes [$val(nn)] and attach them to the channel.
#

# configure the nodes
$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

# Menginisialisasi node
set node_(0) [$ns node]
set node_(1) [$ns node]
set node_(2) [$ns node]
set node_(3) [$ns node]
set node_(4) [$ns node]
set node_(5) [$ns node]
set node_(6) [$ns node]
set node_(7) [$ns node]
set node_(8) [$ns node]
set node_(9) [$ns node]
set node_(10) [$ns node]
set node_(11) [$ns node]
set node_(12) [$ns node]
set node_(13) [$ns node]
set node_(14) [$ns node]
set node_(15) [$ns node]
set node_(16) [$ns node]
set node_(17) [$ns node]
set node_(18) [$ns node]
set node_(19) [$ns node]
set node_(20) [$ns node]
set node_(21) [$ns node]
set node_(22) [$ns node]
set node_(23) [$ns node]
set node_(24) [$ns node]

# provide inisialisasi koordinat node
# node 0
$node_(0) set X_ 0.0
$node_(0) set Y_ 0.0
$node_(0) set Z_ 0.0

#node 1
$node_(1) set X_ 100.0
$node_(1) set Y_ 0.0
$node_(1) set Z_ 0.0

#node 2
$node_(2) set X_ 200.0
$node_(2) set Y_ 0.0
$node_(2) set Z_ 0.0

#node 3
$node_(3) set X_ 300.0
$node_(3) set Y_ 0.0
$node_(3) set Z_ 0.0

#node 4
$node_(4) set X_ 400.0
$node_(4) set Y_ 0.0
$node_(4) set Z_ 0.0

#node 5
$node_(5) set X_ 0.0
$node_(5) set Y_ 100.0
$node_(5) set Z_ 0.0

# node 6
$node_(6) set X_ 100.0
$node_(6) set Y_ 100.0
$node_(6) set Z_ 0.0

#node 7
$node_(7) set X_ 200.0
$node_(7) set Y_ 100.0
$node_(7) set Z_ 0.0

#node 8
$node_(8) set X_ 300.0
$node_(8) set Y_ 100.0
$node_(8) set Z_ 0.0

#node 9
$node_(9) set X_ 400.0
$node_(9) set Y_ 100.0
$node_(9) set Z_ 0.0

#node 10
$node_(10) set X_ 0.0
$node_(10) set Y_ 200.0
$node_(10) set Z_ 0.0

#node 11
$node_(11) set X_ 100.0
$node_(11) set Y_ 200.0
$node_(11) set Z_ 0.0

# node 12
$node_(12) set X_ 200.0
$node_(12) set Y_ 200.0
$node_(12) set Z_ 0.0

#node 13
$node_(13) set X_ 300.0
$node_(13) set Y_ 200.0
$node_(13) set Z_ 0.0

#node 14
$node_(14) set X_ 400.0
$node_(14) set Y_ 200.0
$node_(14) set Z_ 0.0

#node 15
$node_(15) set X_ 0.0
$node_(15) set Y_ 300.0
$node_(15) set Z_ 0.0

#node 16
$node_(16) set X_ 100.0
$node_(16) set Y_ 300.0
$node_(16) set Z_ 0.0

#node 17
$node_(17) set X_ 200.0
$node_(17) set Y_ 300.0
$node_(17) set Z_ 0.0

# node 18
$node_(18) set X_ 300.0
$node_(18) set Y_ 300.0
$node_(18) set Z_ 0.0

#node 19
$node_(19) set X_ 400.0
$node_(19) set Y_ 300.0
$node_(19) set Z_ 0.0

#node 20
$node_(20) set X_ 0.0
$node_(20) set Y_ 400.0
$node_(20) set Z_ 0.0

#node 21
$node_(21) set X_ 100.0
$node_(21) set Y_ 400.0
$node_(21) set Z_ 0.0

#node 22
$node_(22) set X_ 200.0
$node_(22) set Y_ 400.0
$node_(22) set Z_ 0.0

#node 23
$node_(23) set X_ 300.0
$node_(23) set Y_ 400.0
$node_(23) set Z_ 0.0

#node 24
$node_(24) set X_ 400.0
$node_(24) set Y_ 400.0
$node_(24) set Z_ 0.0

# Set a TCP connection between node_(2) and node_(8)
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(4) $tcp
$ns attach-agent $node_(20) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"



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_(24) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"

# Printing the window size
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 } {
# 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";
}

# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 150 "puts "end simulation" ; $ns halt"
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
exec nam ex-1_without-energy.nam &
}

$ns run
 
Old 09-14-2018, 01:10 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,366

Rep: Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335Reputation: 2335
Your English is unclear, but let me try.
You are getting a segmentation fault and a dumped core when you run that tcl code - is that correct?
You also write:"if i add energy, it working."
Is this a laptop? Do you get a segmentation fault on battery, but it works with a power supply? Replace the battery.

Otherwise, a segmentation fault is a memory error, and tcl is established a long time. Tcl or your code are hardly the problem. I would reinstall tcl, check the disks, and run memtest86 on the memory.
 
Old 09-14-2018, 01:39 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Segmentation fault is a memory error, and it is typically a fault in your program.

Since the system says a core file was output, one can analyze that core file using debug utilities.

I'm familiar with how to do this using GDB and for a C or C++ program, but not for tcl. However for these NS2 simulations, I understand that there are C++ utilities which are used as part of the simulation. In order to debug this the way I know how, you'd need the source code and to compile it using the -ggdb flag.

Another way to debug this is similar to what you are doing, varying the content or input files you are using.

Perhaps as opposed to showing the whole script and summarizing what you've tried, you can indicate the exact position in the script where you modify it to use energy versus not, and show the syntax which works and which doesn't. That may give some people a clue as to how to better advise you.
 
Old 09-15-2018, 01:56 AM   #4
ariefhi
LQ Newbie
 
Registered: Aug 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
Question

What c ++ compiler is suitable for supporting NS2
Quote:
Originally Posted by rtmistler View Post
Segmentation fault is a memory error, and it is typically a fault in your program.

Since the system says a core file was output, one can analyze that core file using debug utilities.

I'm familiar with how to do this using GDB and for a C or C++ program, but not for tcl. However for these NS2 simulations, I understand that there are C++ utilities which are used as part of the simulation. In order to debug this the way I know how, you'd need the source code and to compile it using the -ggdb flag.

Another way to debug this is similar to what you are doing, varying the content or input files you are using.

Perhaps as opposed to showing the whole script and summarizing what you've tried, you can indicate the exact position in the script where you modify it to use energy versus not, and show the syntax which works and which doesn't. That may give some people a clue as to how to better advise you.
 
Old 09-17-2018, 09:13 PM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,513

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #1.

Same answer as the one you got ``Sept 13´´ https://groups.google.com/forum/?fro...w/KLgHvWw_CAAJ

About 'Segmentation fault' : ns2 can do Segmentation fault for no obvious reason:
. https://www.linuxquestions.org/quest...20fault%20ns2/
. https://www.linuxquestions.org/quest...-4175499342/#2


Re #4.

Ubuntu 16.04 : The default g++-5.4 is OK.
Ubuntu 18.04 : Use g++-4.8 . I.e. no later than -5.4 can compile ns2.

-
 
  


Reply

Tags
ns2



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
[SOLVED] segmentation fault(core dumped) while running wireless simulation rc49 Linux - Newbie 3 08-13-2015 09:15 AM
[SOLVED] Segmentation fault (core dumped) message when running nam command in ubuntu 14 Rita Ahmad Ubuntu 4 03-21-2015 03:39 AM
Segmentation fault (core dumped) sirjase Programming 8 12-18-2013 03:40 AM
segmentation fault (core dumped) - what??? Micro420 Programming 6 12-07-2006 01:03 AM
Segmentation fault (core dumped) plisken Linux - General 8 09-17-2003 03:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:56 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