짜증나는 세그먼트 에러 ns2

|

Re: segmentation fault (core dumped) using ZRP in ns-2.27

Click to flag this post

by Mubashir Rehmani Oct 04, 2008; 05:14pm :: Rate this Message: - Use ratings to moderate (?)

Reply | Reply | Reply to Author | Print | View Threaded | Show Only this Message


HI Batbold Toiruul,

here is no "the" solution to *segmentation* *fault*s. From what I've seen on
this list and
in practice, there can be several causes:
1. you deleted a resource from within TCL, causing pointers in C++ to point
to
    memory regions no longer in use. Fix: be careful what you delete in TCL.
2. you added or modified the ns2 source code:
    a. there is a dependency problem and parts of your source have not been
        recompiled. fix: type "make clean" and "make" to make ultimately
sure
        that all code is within sync with each other
    b. your additions are the cause of the memory violation. fix: fix!

how to find the location of your error?
a. first you have to convince your shell to produce a coredump when a
    *segmentation* *fault* occurs. Usually this is done with the command
    "ulimit -c 100000" which sets the limit of coredumps to really huge
    so that they are allways produced.
b. add "-g" to the CFLAGS in the Makefile (and Makefile.in to make sure
    your change is not removed when you ./configure ns2). This flag says
that
    debugging code is compiled into the executable.
c. make clean & make to have the debugging code properly compiled in.

When a *segmentation* *fault* occurs, type: "gdb -c core", then in gdb tell
it that you want to load symbols from the ns executable with "file ns",
and then you can inspect the stack ("bt"), select a stack frame ("select 0")
and inspect the values of variables in that stack frame. Use the online
help of gdb to get familiar with it.

This link may be useful to you.

http://article.gmane.org/gmane.network. ··· entation
+fault


Good luck debugging!

3. May be you are accessing the wrong memory location while declaring your
data structures like linked list, arrays etc

Regards

Mubashir Husain Rehmani

2008/10/4 Batbold Toiruul <tulaanaa1@...>

>
> Dear ns-users,
> I installed Zone Routing Protocol (ZRP) on ns-2.27. However, when i use ZRP
> to run below example, I got the segmentation fault (Core Dumped).
> I don't know why this kind of error is occured. if anyone knows, please
> help
> me.
>
> thank you very much in advance
> sincerely,
>   Batbold
>
>
> set val(chan)           Ch.annel/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)         500                         ;# max packet in ifq
> set val(nn)             22                         ;# number of mobilenodes
> set val(rp)             ZRP                        ;# routing protocol
> set val(x)        1000
> set val(y)        [expr ($val(nn)+1)*250]
>
> # Initialize Global Variables
> set ns_        [new Simulator]
> set tracefd     [open mo4.tr w]
> $ns_ trace-all $tracefd
>
> set namtrace [open mo4.nam w]
> $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
> create-god $val(nn)
>
> # New API to config node:
> # 1. Create channel (or multiple-channels);
> # 2. Specify channel in node-config (instead of channelType);
> # 3. Create nodes for simulations.
>
> # Create channel #1 and #2
> set chan_1_ [new $val(chan)]
> set chan_2_ [new $val(chan)]
>
> # Create node(0) "attached" to channel #1
>
> # configure node, please note the change below.
> $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) \
>       -topoInstance $topo \
>        -agentTrace ON \
>        -routerTrace ON \
>       -macTrace ON \
>        -movementTrace ON \
>        -channel $chan_1_
>
>
> # node_(1) can also be created with the same configuration, or with a
> different
> # channel specified.
> # Uncomment below two lines will create node_(1) with a different channel.
> #  $ns_ node-config \
> #         -channel $chan_2_
> #set node_(0) [$ns_ node]
> #set node_(8) [$ns_ node]
>
> #$node_(0) random-motion 0
> #$node_(8) random-motion 0
>
> for {set i 0} {$i < $val(nn)} {incr i} {
>    set node_($i) [$ns_ node]
>    $node_($i) random-motion 0
>    $ns_ initial_node_pos $node_($i) 20
> }
>
> #
> # Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
> #
> #$node_(0) set X_  500.0
> #$node_(0) set Y_  250.0
> #$node_(0) set Z_ 0.0
> #...
> #$node_(8) set X_  500.0
> #$node_(8) set Y_ 2250.0
> #$node_(8) set Z_ 0.0
>
> for {set i 0} {$i < 10 } {incr i} {
>   $node_($i) set X_  750.0
>   $node_($i) set Y_ [expr $i*250+5]
>   $node_($i) set Z_ 0.0
> }
> for {set i 10} {$i < 20 } {incr i} {
>   $node_($i) set X_ 250.0
>   $node_($i) set Y_ [expr ($i-10)*250+5]
>   $node_($i) set Z_ 0.0
> }
>
> $node_(20) set X_ 500.0
> $node_(20) set Y_ 5.0
> $node_(20) set Z_ 0.0
>
> $node_(21) set X_ 500.0
> $node_(21) set Y_ 505.0
> $node_(21) set Z_ 0.0
>
> #for {set i 0} {$i < 3} {incr i} {
>  #for {set j 0} {$j < 3} {incr j} {
>    #$node_([expr $i+$j*3]) set X_ [expr $i*250]
>    #$node_([expr $i+$j*3]) set Y_ [expr $j*250]
>    #$node_([expr $i+$j*3]) set Z_ 0.0
>  #}
> #}
>
>
> # Now produce some simple node movements
> # Node_(1) starts to move towards node_(0)
> #
> #$ns_ at 3.0 "$node_(5) setdest 100.0 500.0 05.0"
> #$ns_ at 100.0 "$node_(5) setdest 100.0 500.0 00.0"
> #$ns_ at 200.0 "$node_(5) setdest 005.0 700.0 05.0"
> #$ns_ at 3.0 "$node_(0) setdest 48.0 38.0 5.0"
>
> # Node_(1) then starts to move away from node_(0)
> #$ns_ at 20.0 "$node_(1) setdest 490.0 480.0 30.0"
>
> # Setup traffic flow between nodes
> #TCP connections between node_(0) and node_(1)
>
> set udp [new Agent/UDP]
> $udp set fid_ 2
> set sink [new Agent/Null]
> $ns_ attach-agent $node_(10) $udp
> $ns_ attach-agent $node_(9) $sink
> $ns_ connect $udp $sink
>
> set cbr [new Application/Traffic/CBR]
> $cbr attach-agent $udp
> $cbr set type_ CBR
> $cbr set packet_size_ 100
> $cbr set rate_ 10kb
> $cbr set random_ false
> $ns_ at 10.0 "$cbr start"
> $ns_ at 100.0 "$cbr stop"
>
> #set tcp [new Agent/TCP]
> #$tcp set class_ 1
> #$tcp set fid_ 2
> #set sink [new Agent/TCPSink]
> #$ns_ attach-agent $node_(2) $tcp
> #$ns_ attach-agent $node_(5) $sink
> #$ns_ connect $tcp $sink
>
> #set ftp [new Application/FTP]
> #$ftp attach-agent $tcp
> #$ftp set type_ FTP
> #$ns_ at 23.0 "$ftp start"
> #$ns_ at 173.0 "$ftp stop"
>
> Mac/802_11 set dataRate_ 1Mb
>
> for {set i 0} {$i < $val(nn) } {incr i} {
>     set r_($i) [$node_($i) set ragent_]
>      $ns_ at 0.0 "$r_($i) radius 2.0"
>     # @@@ $ns_ at 0.4 "$r_($i) beacon_period 12.0"
>     # @@@ $ns_ at 0.0 "$r_($i) radius 1.0"
>  }
>
> #
> # Tell nodes when the simulation ends
> #
> for {set i 0} {$i < $val(nn) } {incr i} {
>    $ns_ at 100.0 "$node_($i) reset";
> }
> $ns_ at 100.0 "stop"
> $ns_ at 100.01 "puts \"NS EXITING...\" ; $ns_ halt"
> proc stop {} {
>    global ns_ tracefd
>    $ns_ flush-trace
>    close $tracefd
> }
>
> puts "Starting Simulation..."
> $ns_ run
>



--
Mubashir Husain Rehmani

And