LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Floating point exception (core dumped) getting this error while running zishan.tcl (https://www.linuxquestions.org/questions/linux-networking-3/floating-point-exception-core-dumped-getting-this-error-while-running-zishan-tcl-4175542301/)

Md Zishan Khan 05-11-2015 03:33 PM

Floating point exception (core dumped) getting this error while running zishan.tcl
 
#trying to calculate LET(link expiration time for particular link in the simulation )
#zishan.tcl
# wrls1.tcl
# A 3-node example for ad-hoc simulation with DSDV

# 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) 4 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 400 ;# Y dimension of topography
set val(stop) 80 ;# time of simulation end

set ns [new Simulator]
set tracefd [open dsdvzis.tr w]

set namtrace [open dsdvzis.nam w]
set D_los 250.0
$ns trace-all $tracefd
$ns use-newtrace
$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

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

# Provide initial location of mobilenodes
set xi(0) 5.0
set yi(0) 5.0
set zi(0) 0.0
$node_(0) set X_ $xi(0)
$node_(0) set Y_ $yi(0)
$node_(0) set Z_ $zi(0)

set xi(1) 490.0
set yi(1) 285.0
set zi(1) 0.0
$node_(1) set X_ $xi(1)
$node_(1) set Y_ $yi(1)
$node_(1) set Z_ $zi(1)

set xi(2) 150.0
set yi(2) 240.0
set zi(2) 0.0
$node_(2) set X_ $xi(2)
$node_(2) set Y_ $yi(2)
$node_(2) set Z_ $zi(2)

set xi(3) 190.0
set yi(3) 50.0
set zi(3) 0.0
$node_(3) set X_ $xi(3)
$node_(3) set Y_ $yi(3)
$node_(3) set Z_ $zi(3)
# Generation of movements
set t(0) 2.0
set t(1) 8.0
set t(2) 8.0
set t(3) 8.0

set xf(0) 76.0
set yf(0) 76.0

set xf(1) 330.0
set yf(1) 285.0

set xf(2) 180.0
set yf(2) 210.0

set xf(3) 260.0
set yf(3) 10.0

$ns at $t(0) "$node_(0) setdest $xf(0) $yf(0) 5.0"
$ns at $t(1) "$node_(1) setdest $xf(1) $yf(1) 5.0"
$ns at $t(2) "$node_(2) setdest $xf(2) $yf(2) 5.0"
$ns at $t(3) "$node_(3) setdest $xf(3) $yf(3) 5.0"

# Calculating LET (wrt 250) for each node in the simulation
for {set i 0} {$i < $val(nn) } { incr i } {

puts "\n"

for {set j 0} {$j < $val(nn) } { incr j } {

set dxi [expr $xi($i) - $xi($j)]
set dyi [expr $yi($i) - $yi($j)]

set dxf [expr $xf($i) - $xf($j)]
set dyf [expr $yf($i) - $yf($j)]

set dx1 [expr $dxi * $dxi]
set dy1 [expr $dyi * $dyi]

set dx2 [expr $dxf * $dxf]
set dy2 [expr $dyf * $dyf]

set h1 [expr $dx1 + $dy1]
set h2 [expr $dx2 + $dy2]

set hi($i-$j) [expr pow($h1, 0.5)]
set hf($i-$j) [expr pow($h2, 0.5)]
puts "initial distance of node($i) from node($j) = $hi($i-$j)"
puts "final distance of node($i) from node($j) = $hf($i-$j)"
}
}
# For calculating LET initial and final for a node wrt every node

for {set i 0} {$i < $val(nn) } { incr i } {

puts "\n"

for {set j 0} {$j < $val(nn) } { incr j } {

set t1i_($i$j) [expr $D_los - $hi($i-$j)]
puts "$t1i_($i$j)"



set sl1i_($i$j) [expr {$xi($i)-$xi($j)}]
set sl2i_($i$j) [expr {$yi($i)-$yi($j)}]
set sfi_($i$j) [expr { $sl2i_($i$j)/$sl1i_($i$j)} ]
set t2i_($i$j) [expr {2*5*sin($sfi_($i$J)2)* 57.32}]

set t1f_($i$j) [expr $D_los - $hf($i-$j)]
puts "$t1f_($i$j)"

set sl1f_($i$j) [expr {$xf($i)-$xf($j)}]
set sl2f_($i$j) [expr {$yf($i)-$yf($j)}]
set sff_($i$j) [expr { $sl2f_($i$j)/$sl1f_($i$j)} ]
set t2f_($i$j) [expr {2*5*sin($sff_($i$j)/2)* 57.32}]

set leti_($i$j) [expr { $t1i_($i$j)/$t2i_($i$j)}]
set letf_($i$j) [expr { $t1f_($i$j)/$t2f_($i$j)}]

puts "The LET Initial of node no $i with link $j is : $leti_($i$j)"
puts "The LET Final of node no $i with link $j is : $letf_($i$j)"

}
}
# for calculating angle
for {set i 0} {$i < $val(stop)} {incr i} { # for time from 0

for {set j 0} {$j < $val(nn)} {incr j} { # for every node/time

#puts "xi($j)= $xi($j)"
#puts "xf($j)= $xf($j)"
#puts "t($j)= $t($j)"

if { $i <= $t($j) && ($i+1) > $t($j) } {
puts "OK $j $t($j) $xi($j) $yi($j) $xf($j) $yf($j) "

# Calculation of angle between node from initial to final position

set sl1 [expr {$xf($j)-$xi($j)}]
set sl2 [expr {$yf($j)-$yi($j)}]
set sf [expr { $sl2/$sl1} ]
puts "The tan of Slope $j: [expr {atan($sf)*57.32}]"

}

}
}




# Set a TCP connection between node_(0) and node_(1)
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_(1) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 8.0 "$ftp start"



# 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 80.01 "puts "end simulation" ; $ns halt"
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
}

$ns run

John VV 05-11-2015 04:20 PM

am i correct is GUESSING
that this is one of ???? many different versions of ns2 .?????

if so
please STATE THAT !
and it's version?
How it was installed ?
and on what Operating system ?

also VERY VERY IMPORTANT!!!!!!!!
please USE THE CODE TAGS!!!!!!! around your code

with 16 posts you should already know to do that .
PHP Code:

 [codethe code goes here  [/code



All times are GMT -5. The time now is 02:46 PM.