Regardz
Muhammad Musaddiq
+92-332-4197661

----- Forwarded Message -----
From: Muhammad Musaddiq <hi_02...@yahoo.com>
To: "ns-users@isi.edu" <ns-users@isi.edu> 
Sent: Monday, May 7, 2012 11:16 AM
Subject: how to handle floating point exception error


 Respected guyz !
 i am getting floating point exception error in the given below code,kindly do 
reply that how can i remove this error. thannnxxx alot -plz reply me early.

 
# -*- Mode:tcl; tcl-indent-level:8; tab-width:8; indent-tabs-mode:t -*-
Agent/TCP set tcpTick_ 0.1
# The default for tcpTick_ is being changed to reflect a changing reality.
Agent/TCP set rfc2988_ false
# The default for rfc2988_ is being changed to true.
# This test suite is for validating the snoop protocol
remove-all-packet-headers ; # removes all except common
add-packet-header Flags IP TCP Snoop Arp LL Mac ; # hdrs reqd for validation
# FOR UPDATING GLOBAL DEFAULTS:
Agent/TCP set precisionReduce_ false ; # default changed on 2006/1/24.
Agent/TCP set rtxcur_init_ 6.0 ; # Default changed on 2006/01/21
Agent/TCP set updated_rttvar_ false ; # Variable added on 2006/1/21
Agent/TCP set minrto_ 1
# default changed on 10/14/2004.
Agent/TCP set singledup_ 0
# The default is being changed to 1
Agent/TCP set useHeaders_ false
# The default is being changed to useHeaders_ true.
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_3
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(seed) 0
set val(ifqlen) 100 ;# max packet in ifq
set val(nn) 2 ;# how many nodes are simulated
set val(rp) AODV 
set val(x) 800 ;# X dimension of the topography
set val(y) 800 ;# Y dimension of the topography
set val(stop) 50 ;# simulation time
 
 
 
set basenode(bs) 2
set ns_ [new Simulator]
set tracefd [open snoop.tr w]
set namtrace [open snoop.nam w]
set cwnd [open tcpcwnd.tr w]
set file1 [open throughput1.tr w]
set f1 [open goodput1.tr w]
$ns_ trace-all $tracefd
$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 [expr $val(nn)+$basenode(bs)]
 
$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 \
-wiredRouting ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF 
for {set i 0} {$i < $basenode(bs) } { incr i } {
set base($i) [$ns_ node] 
$base($i) random-motion 0 
}
$base(0) set X_ 200.0
$base(0) set Y_ 550.0
$base(0) set Z_ 0.0
 
$base(1) set X_ 450.0
$base(1) set Y_ 550.0
$base(1) set Z_ 0.0
set lan [$ns_ make-lan [list $base(1)] 11Mb 2ms LL $val(ifq) $val(mac)]
$lan addNode [list $base(0)] 11Mb 2ms LL/LLSnoop $val(ifq) $val(mac)
 
for {set j 0} {$j < $val(nn) } { incr j } {
set wireless($j) [$ns_ node] 
}
 
$ns_ node-config -macType Mac/802_11 
$ns_ node-config -wiredRouting OFF
$ns_ node-config -agentTrace ON 
$ns_ node-config -routerTrace ON
$ns_ node-config -movementTrace ON
$wireless(0) set X_ 150.0
$wireless(0) set Y_ 525.0
$wireless(0) set Z_ 0.0
 
$wireless(1) set X_ 550.0
$wireless(1) set Y_ 525.0
$wireless(1) set Z_ 0.0
 
 
 
 
$wireless(0) base-station [AddrParams addr2id [$base(0) node-addr]]
$wireless(1) base-station [AddrParams addr2id [$base(1) node-addr]]
 
 
 
proc finish {} {
global ns_ tracefd namtrace cwnd file1 f1
$ns_ flush-trace
close $tracefd
close $namtrace
close $cwnd
close $file1
close $f1
exec xgraph tcpcwnd.tr -x "Time (RTT)" -y "Window" -t "CWND0" -geometry 800*400 
&
exec xgraph throughput1.tr -t "throughput1" -geometry 800*400 &
exec xgraph goodput1.tr -t "goodput1" -geometry 800*400 &
exec nam snoop.nam &
puts "finishing.."
exit 0
}
 
# simple test
#
# Network topology:
#
# A----B
# _|_(lan) 
# |
# C----D
#
# A sends data to destination D
#
# B is snoop agent. 
# set up TCP flow from A to D
set tcp [new Agent/TCP]
#$tcp set windowInit_ 1
#max congestion window size
#$tcp set maxcwnd_ 32
set sink [new Agent/TCPSink]
$ns_ attach-agent $wireless(0) $tcp
$ns_ attach-agent $wireless(1) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
#$ftp set packetSize_ 1024
#$ftp set interval_ 0.001
#$ftp set rate_ 8Mb
#$ftp set window_ 40
$ftp attach-agent $tcp
 
 
 
set rtt1 3
set rto1 64 
proc congestionwindow {} {
global ns_ cwnd tcp current_cwnd current_wndw roundtriptime retimeout ssthresh 
rtt1 rto1
# set the time after which the procedure should be called again
set time 0.1
# get the current time
set now [$ns_ now]
set current_cwnd [$tcp set cwnd_]
set current_wndw [$tcp set window_]
set roundtriptime [$tcp set rtt_]
set retimeout [$tcp set maxrto_]
set ssthresh [expr $current_cwnd/2]
if {$current_cwnd < $ssthresh} {
if {$roundtriptime < $rtt1} {
set current_cwnd [expr $current_cwnd +1]
} else {
set rtt1 $roundtriptime
} 
} else {
set current_cwnd [expr $current_cwnd +(1 /$current_cwnd)]
}
if {$retimeout > $rto1} {
set ssthresh [expr $current_wndw/2]
set current_cwnd 1.0
$ns_ at [expr $now + $time] "congestionwindow"
} else {
set rto1 $retimeout
}
puts $cwnd "$now $current_cwnd"
$ns_ at [expr $now + $time] "congestionwindow"
} 
proc throughput1 {} {
global ns_ roundtriptime tcp file1 result
set time 1
set now [$ns_ now]
set totalval 0.0
set datasent [$tcp set ndatabytes_]
set throughput [expr $datasent*8/[$ns_ now]]
puts $file1 "$now $throughput"
$ns_ at [expr $now + $time] "throughput1"
}
set last_sentbytes 0.0
set last_tcp2 0.0
proc goodput1 {} {
global ns_ f1 last_tcp2 last_sentbytes tcp 
set time 0.5
set now [$ns_ now]
set totalval 0.0
puts "[$tcp set ndatabytes_] [$tcp set ndatapack_] [$tcp set nackpack_] [$tcp 
set nrexmitpack_]"
set abc_tcp0 [$tcp set ndatabytes_]
set abc_tcp1 [$tcp set ndatapack_]
set abc_tcp2 [$tcp set nackpack_]
set abc_tcp3 [$tcp set nrexmitpack_]
set temp [expr $abc_tcp0-$last_tcp2]
puts $f1 "$now [expr $temp*8/$time]"
set totalval [expr $totalval+$temp]
set last_sentbytes $abc_tcp0
set last_tcp2 $abc_tcp3
set nextTime1 [expr $now+$time]
$ns_ at $nextTime1 "goodput1"
}
 
 
for {set j 0} {$j < $val(nn)} { incr j } {
# 30 defines the node size for nam
$ns_ initial_node_pos $wireless($j) 40
}
 
# set times to start/stop actions
$ns_ at 5.0 "$ftp start"
$ns_ at 50 "$ftp stop"
$ns_ at 5.0 "congestionwindow"
$ns_ at 5.0 "throughput1"
$ns_ at 5.0 "goodput1"
$ns_ at 50 "finish"
$ns_ run
 

Regardz
Muhammad Musaddiq
+92-332-4197661

Reply via email to