Hello, > > I am a beginner in ns2 and doing some implementation in ns2 but its giving > "segmentation fault". Please help me out of this. > Topology i used is 5 nodes of which 1st one is still and other 4 moving > towards it with some speed. All the nodes are arranged in a line. And 1st > node send a communication signal to all the other nodes using multihop. > > I am pasting and also attaching the tcl file i used. > Kindly help. > > Regards, > Vishal > > ##code > # ====================================================================== > # Define options > # ====================================================================== > set val(chan) Channel/WirelessChannel ;# channel type > set val(prop) Propagation/TwoRayGround ;# radio-propagation model > set val(ant) Antenna/OmniAntenna ;# Antenna type > set val(ll) LL ;# Link layer type > set val(x) 1000 ;# X dimension of the > topography > set val(y) 1000 ;# Y dimension of the > topography > set val(ifq) CMUPriQueue ;# Interface queue type > set val(ifqlen) 50 ;# max packet in ifq > set val(netif) Phy/WirelessPhy ;# network interface type > set val(mac) Mac/802_11 ;# MAC type > set val(adhocRouting) DSR ;# ad-hoc routing protocol > > set val(nn) 5 ;# number of mobilenodes > > > # ===================================================================== > # Main Program > # ====================================================================== > > # > # Initialize Global Variables > # > > # create simulator instance > > set ns_ [new Simulator] > > # setup topography object > > set topo [new Topography] > > # create trace object for ns and nam > > set tracefd [open try1-out.tr w] > set namtrace [open try1-out.nam w] > > $ns_ trace-all $tracefd > $ns_ namtrace-all-wireless $namtrace $val(x) $val(y) > > # define topology > $topo load_flatgrid $val(x) $val(y) > > # > # Create God > # > set god_ [create-god $val(nn)] > > # > # define how node should be created > # > > #global node setting > > $ns_ node-config -adhocRouting $val(adhocRouting) \ > -llType $val(ll) \ > -macType $val(mac) \ > -ifqType $val(ifq) \ > -ifqLen $val(ifqlen) \ > -antType $val(ant) \ > -propType $val(prop) \ > -phyType $val(netif) \ > -channel [new $val(chan)] \ > -topoInstance $topo \ > -agentTrace ON \ > -routerTrace ON \ > -macTrace OFF \ > -movementTrace ON > > # > # Create the specified number of nodes [$val(nn)] and "attach" them > # to the channel. > > #Next we create the 5 mobilenodes as follows: > for {set i 0} {$i < $val(nn) } {incr i} { > set node_($i) [$ns_ node] > $node_($i) random-motion 0 ;# disable random motion > # $node_($i) set Y_ 0.0 > # $node_($i) set Z_ 0.0 > } > > #have created mobilenodes, need to give them a position to start with > $node_(0) set X_ 0.0 > $node_(0) set Y_ 0.0 > $node_(0) set Z_ 0.0 > $node_(1) set X_ 200.0 > $node_(1) set Y_ 0.0 > $node_(1) set Z_ 0.0 > $node_(2) set X_ 400.0 > $node_(2) set Y_ 0.0 > $node_(2) set Z_ 0.0 > $node_(3) set X_ 600.0 > $node_(3) set Y_ 0.0 > $node_(3) set Z_ 0.0 > $node_(4) set X_ 800.0 > $node_(4) set Y_ 0.0 > $node_(4) set Z_ 0.0 > > #Next producing node movements > # > # Node_(1,2,3,4) starts to move towards node_(0) > # > $ns_ at 10.0 "$node_(1) setdest 100.0 0.0 1.0" > $ns_ at 15.0 "$node_(2) setdest 300.0 0.0 1.0" > $ns_ at 20.0 "$node_(3) setdest 500.0 0.0 1.0" > $ns_ at 25.0 "$node_(4) setdest 700.0 0.0 1.0" > #Nodes Movement defined > > > # 1500 - 20 byte IP header - 40 byte TCP header = 1440 bytes > #Agent/TCP set packetSize_ 1440 ;# This size EXCLUDES the TCP header > set tcp [new Agent/TCP] > $tcp set class_ 2 > set sink [new Agent/TCPSink] > $ns_ attach-agent $node_(0) $tcp > $ns_ attach-agent $node_(4) $sink > $ns_ connect $tcp $sink > set ftp [new Application/FTP] > $ftp attach-agent $tcp > $ns_ at 10.0 "$ftp start" > set agent [new Agent/TCP] > set app [new Application/FTP] > > > > # 120 seconds of running the simulation time > $ns_ at 0.0 "$app start" > > # > # Tell nodes when the simulation ends > # > for {set i 0} {$i < $val(nn) } {incr i} { > $ns_ at 120.0 "$node_($i) reset"; > } > $ns_ at 120.0001 "stop" > $ns_ at 120.0002 "puts \"NS EXITING...\" ; $ns_ halt" > proc stop {} { > global ns_ tracefd > $ns_ flush-trace > close $tracefd > } > > puts "Starting Simulation..." > $ns_ run > >