Tuesday, December 13, 2011

[ns] Floating Point exception

Hi All,

When i am trying to run below code, i am getting floating point exception,
Can someone please let me know the reason

# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation
model
set val(netif) Phy/WirelessPhy/802_15_4 ;# network interface type
set val(mac) Mac/802_15_4 ;# 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) 4 ;# 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(finish) 500 ;# time of simulation end
set val(energymodel) EnergyModel ;# Energy Model
set val(initialenergy) 100 ;# value
# ======================================================================

# Main Program
# ======================================================================

# Initialize Global Variables

set ns [new Simulator]
set tracefd [open tracefile.tr w]
#set log [open output.tr w]
set namtrace [open out.nam w]

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

set dist(5m) 7.69113e-06
set dist(9m) 2.37381e-06
set dist(10m) 1.92278e-06
set dist(11m) 1.58908e-06
set dist(12m) 1.33527e-06
set dist(13m) 1.13774e-06
set dist(14m) 9.81011e-07
set dist(15m) 8.54570e-07
set dist(16m) 7.51087e-07
set dist(20m) 4.80696e-07
set dist(25m) 3.07645e-07
set dist(30m) 2.13643e-07
set dist(35m) 1.56962e-07
set dist(40m) 1.20174e-07
Phy/WirelessPhy set CSThresh_ $dist(20m)
Phy/WirelessPhy set RXThresh_ $dist(20m)


# Set up topography object

set topo [new Topography]

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

# Create God

create-god $val(nn)

#Create channel
set channel1_ [new $val(chan)]

# Configure 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) \
-channel $channel1_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace OFF \
-energyModel $val(energymodel) \
-initialEnergy $val(initialenergy) \
-rxPower 35.28e-3 \
-txPower 31.32e-3 \
-idlePower 712e-6 \
-sleepPower 144e-9

for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns node]
}

# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes

$node_(0) set X_ 250.0
$node_(0) set Y_ 250.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 260.0
$node_(1) set Y_ 250.0
$node_(1) set Z_ 0.0

$node_(2) set X_ 270.0
$node_(2) set Y_ 250.0
$node_(2) set Z_ 0.0

$node_(3) set X_ 280.0
$node_(3) set Y_ 250.0
$node_(3) set Z_ 0.0


$ns at 5.0 "$node_(1) setdest 270.0 250.0 0.83"
$ns at 19.0 "$node_(1) setdest 280.0 250.0 0.83"

# Setup traffic flow between nodes
# UDP connections from node_(1) and node_(0)

set udp_(0) [new Agent/UDP]
$ns attach-agent $node_(1) $udp_(0)
set null_(0) [new Agent/Null]
$ns attach-agent $node_(0) $null_(0)
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set type_ CBR
$cbr_(0) set packetSize_ 32
$cbr_(0) set interval_ 0.2
$cbr_(0) attach-agent $udp_(0)
$ns connect $udp_(0) $null_(0)
$ns at 0.2 "$cbr_(0) start"
$ns at 487 "$cbr_(0) stop"

# Setup traffic flow between nodes
# UDP connections from node_(2) and node_(1)

set udp_(1) [new Agent/UDP]
$ns attach-agent $node_(2) $udp_(1)
set null_(1) [new Agent/Null]
$ns attach-agent $node_(1) $null_(1)
set cbr_(1) [new Application/Traffic/CBR]
$cbr_(1) set type_ CBR
$cbr_(1) set packetSize_ 32
$cbr_(1) set interval_ 0.2
$cbr_(1) attach-agent $udp_(1)
$ns connect $udp_(1) $null_(1)
$ns at 18 "$cbr_(1) start"
#$ns at 487 "$cbr_(1) stop"

# Define node initial position in nam

for { set i 0 } { $i < $val(nn) } { incr i } {
$ns initial_node_pos $node_($i) 5
}

# Telling nodes when the simulation ends
for {set i 0 } {$i < $val(nn) } {incr i} {
$ns at $val(finish) "$node_($i) reset";
}

# Ending nam and the simulation

$ns at $val(finish) "$ns nam-end-wireless $val(finish)"
$ns at $val(finish) "finish"
$ns at 490 "puts \"ns EXITING...\" ; $ns halt"

puts "Starting Simulation..."

# Define a 'finish' procedure

proc finish {} {
global ns tracefd log namtrace
$ns flush-trace
close $tracefd
close $namtrace
}

$ns run

2 comments:

  1. I also face the same problem. what is the solution? have you find the solution?

    If yes, plz share

    ReplyDelete
    Replies
    1. please someone hae found the solution about this problem i have the same error

      Delete

Counter

blogger analytics