ns2

Segmentation fault for the DSR protocol


I have been trying to find out why the segmentation fault occurs but i couldn't with following code can somebody help

set val(chan)           Channel/WirelessChannel    ;
set val(prop)           Propagation/TwoRayGround   ;
set val(netif)          Phy/WirelessPhy            ;
set val(mac)            Mac/802_11                 ;
set val(ifq)            Queue/DropTail/PriQueue    ;
set val(ll)             LL                         ;
set val(ant)            Antenna/OmniAntenna        ;
set val(ifqlen)         60                         ;
set val(nn)             20                         ;
set val(rp)             DSR                        ;
set val(x)              900                        ;
set val(y)              900                        ;  
set val(stop)           800                        ;

set ns            [new Simulator]
set tracefd       [open testDSR.tr w]
set namtrace      [open testDSR.nam w]
set windowVsTime2 [open win.tr w]

$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

set topo          [new Topography]

$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

       $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

    for {set i 0} {$i < $val(nn) } { incr i } {
            set node_($i) [$ns node]
    $node_($i) set X_ [ expr 10+round(rand()*480) ]
        $node_($i) set Y_ [ expr 10+round(rand()*380) ]
        $node_($i) set Z_ 0.0        
    }





 $ns at 10.0  "$node_(0) setdest 300.0 300.0 10.0"
 $ns at 15.0  "$node_(1) setdest 45.0 285.0 10.0"
 $ns at 110.0 "$node_(0) setdest 480.0 300.0 10.0"  
 $ns at 70.0  "$node_(3) setdest 180.0 30.0 10.0"
 $ns at 180.0 "$node_(8) setdest 410.0 770.0 15.0"
 $ns at 200.0 "$node_(10) setdest 363.0 335.0 15.0"
 $ns at 230.0 "$node_(7) setdest 304.0 720.0 10.0"
 $ns at 270.0 "$node_(0) setdest 580.0 790.0 25.0"
 $ns at 330.0 "$node_(0) setdest 810.0 790.0 20.0"
 $ns at 80.0 "$node_(4) setdest 480.0 790.0 25.0"
 $ns at 150.0 "$node_(7) setdest 610.0 790.0 10.0"


 $node_(4) color red
 $ns at 8.0 "$node_(4) color darkgreen"
 $ns at 8.0 "$node_(4) label Source"
 $node_(7) color red
 $ns at 8.0 "$node_(7) label Destination"
 $ns at 8.0 "$node_(7) color darkgreen"

 set tcp [new Agent/TCP/Newreno]
 $tcp set class_ 2
 $tcp set packetSize_ 1000
 set sink [new Agent/TCPSink]
 $ns attach-agent $node_(4) $tcp
 $ns attach-agent $node_(7) $sink
 $ns connect $tcp $sink
 set ftp [new Application/FTP]
 $ftp attach-agent $tcp
 $ftp set packetSize_ 1000
 $ns at 10.0 "$ftp start"  

 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 } {
     $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";
}


$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 350.01 "puts \"end simulation\" ; $ns halt"
proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
    exit 0
}

$ns run 

I would like to know what modifications are needed to avoid segmentation fault error.

Thanks.


Solution


  • Plots : xgraph-12.x is included in ns-allinone-2.35. Also available with Debian, Mint, Ubuntu.

    DSR : Example with delay plots (2) : Clustering-moc_v1.tcl (One xgraph window opens.)

    DSR : Example with loss plots (3) : DSR-project-code_input.tcl (Six xgraph windows opens : Move the top windows to watch "lost*, 1 - 2 - 3".)

    DSR : Change the protocol to DSR in wireless-udp-1.tcl (Three xgraph windows opens, the second with 4 times loss plots. Four delay plots are included in the top window.)

    All xgraph_ns2-files-tcl_05.2016 https://drive.google.com/file/d/0B7S255p3kFXNajQ5S1NuOHNTcUE/view?usp=sharing