Evalvid-RA floating point exception

Emily Weyulu <[email protected]> Sun, 10 Jan 2016 20:52:05 +0900
Newsgroups gmane.network.simulator.isi
Message-ID <CAA+LSPAwwf=LYhhvd1UwqdySLTDy5nmWbBS6mRLyz=zvZCTazg@mail.gmail.com>
Hello Everyone,

I am running a TCL file for video simulations using evalvid_ra in NS-2.28.
I am getting a floating point exception error but I don't see anywhere in
my implementation where I have division by 0.

*Below is the tcl file:*

proc getopt {argc argv} {
global opt
lappend optlist nn
for {set i 0} {$i < $argc} {incr i} {
set opt($i) [lindex $argv $i]
}
}

getopt $argc $argv

set ns [new Simulator]
set packetSize 1500
set num_wired_nodes 4
set num_mobile_nodes 1
set num_bs_nodes 1 ;# number of base stations
set num_nodes [expr $num_wired_nodes + $num_mobile_nodes + $num_bs_nodes]
set bs_id $num_wired_nodes

# Parameter for wireless nodes
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq)          Queue/DropTail/DropTail
set opt(ifq1)         Queue/DropTail/DropTail
#set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
#set opt(ifq1) Queue/DropTail/PriQueue
set opt(ifqlen) 50  ;# Max queue length
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(adhocRouting) DSDV; #NOAH ;# routing protocol
set opt(x) 500 ;# X dimension of the topography
set opt(y) 500 ;# Y dimension of the topography

Mac/802_11 set SlotTime_ 0.000020 ;# 20us
Mac/802_11 set SIFS_ 0.000010 ;# 10us
Mac/802_11 set PreambleLength_ 144 ;# 144 bit
Mac/802_11 set PLCPHeaderLength_ 48 ;# 48 bits
Mac/802_11 set PLCPDataRate_ 1.0e6 ;# 1Mbps
Mac/802_11 set dataRate_ 11.0e6 ;# 11Mbps
Mac/802_11 set basicRate_ 1.0e6 ;# 1Mbps
Mac/802_11 set ShortRetryLimit_ 7 ;# retransmittions (7, this value do not
effect FEC)
Mac/802_11 set LongRetryLimit_ 4 ;# retransmissions (4, effect the no. of
FEC packets)

#set up for hierarchical routing
#(needed for routing over a basestation)
$ns node-config -addressType hierarchical
AddrParams set domain_num_ 2 ;# domain number
lappend cluster_num 1 1 ;# cluster number for each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel $num_wired_nodes [expr $num_mobile_nodes +
$num_bs_nodes] ;# number of nodes for each cluster
AddrParams set nodes_num_ $eilastlevel

set ntr [open out.tr w]
$ns trace-all $ntr

set chan [new $opt(chan)]
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)

# Create God
create-god [expr $num_mobile_nodes + $num_bs_nodes]

# creating wired nodes
set s1 [$ns node 0.0.0]
set s2 [$ns node 0.0.1]
set s3 [$ns node 0.0.2]
set r1 [$ns node 0.0.3]

# creating base station
$ns node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channel $chan \
-topoInstance $topo \
-wiredRouting ON \
-agentTrace OFF \
-routerTrace OFF \
-macTrace OFF \
-movementTrace OFF

set BS(0) [$ns node 1.0.0]
$BS(0) random-motion 0
set bs_ifq [$BS(0) set ifq_(0)]
set bs_mac [$BS(0) set mac_(0)]
set bs_phy [$BS(0) set netif_(0)]
puts "Base-Station node $bs_id created"
#provide some co-ord (fixed) to base station node
$BS(0) set X_ 250.0
$BS(0) set Y_ 250.0
$BS(0) set Z_ 0.0

#$bs_ifq queuetype?
set queuechan [open qlen.tr w]
$bs_ifq trace curq_
$bs_ifq attach $queuechan

#$bs_ifq set threshold1 10
#$bs_ifq set threshold2 40
#$bs_ifq set maxfecpkts 4
#$bs_ifq set staticfecpkts 0
#$bs_ifq set qweight 0.1
#$bs_ifq set fecpktsize 500
#$bs_ifq set from_mac 1
#$bs_ifq set threshold3 5
#$bs_ifq set threshold4 15
#$bs_ifq set sweight 0.1

#proc qlength {} {
# global ns bs_ifq
# set qlen [$bs_ifq qlen?]
# puts "qlen:$qlen"
#}

#$ns at 10.0 "qlength"

#$bs_mac set_filename bs_mac
#$ns at 105.0 "$bs_mac closefile"

set rng [new RNG]
$rng seed $opt(0)
set rand1 [new RandomVariable/Uniform]
$rand1 use-rng $rng
$rand1 set min_ -50.0
$rand1 set max_ 50.0

# creating mobile nodes
$ns node-config -wiredRouting OFF
$ns node-config -ifqType $opt(ifq1)
#$ns node-config -IncomingErrProc $opt(err1)
#$ns node-config -OutgoingErrProc $opt(err1)
for {set i 0} {$i < $num_mobile_nodes} {incr i} {
set wl_node_($i) [$ns node 1.0.[expr $i + 1]]
$wl_node_($i) random-motion 0 ;# disable random motion
puts "wireless node $i created ..."
$wl_node_($i) base-station [AddrParams addr2id [$BS(0) node-addr]]
set x [expr 250+[$rand1 value]]
set y [expr 250+[$rand1 value]]
$wl_node_($i) set X_ $x
$wl_node_($i) set Y_ $y
$wl_node_($i) set Z_ 0.0
puts "X_:$x Y_:$y"
}

#$wl_phy set-error-level $pGG $pBB $pG $pB $loss_model
#loss model->(0:random uniform; 1:GE)
set wl_phy [$wl_node_(0) set netif_(0)]
$wl_phy set-error-level $opt(1) $opt(2) $opt(3) $opt(4) $opt(5)

$ns duplex-link $s1 $r1 10Mb 1ms DropTail
$ns duplex-link $s2 $r1 10Mb 1ms DropTail
$ns duplex-link $s3 $r1 10Mb 1ms DropTail

# linking of root to base-station node
$ns duplex-link $r1 $BS(0) 100Mb 1ms DropTail
set q1 [[$ns link $r1 $BS(0)] queue]

#------------------------------------------------------------------------------
set  rng  [new RNG]
$rng  seed 1

set  rand2  [new RandomVariable/Uniform]

$rand2  use-rng $rng
$rand2  set  min_ 0.0
$rand2  set  max_ 3.0

# The followong file is used as ns-2 adapted (by Chih-Heng, Ke from Taiwan)
version of
# the Evalvid (J. Klaue) generated file above
# Sender trace file from mp4.exe containing frame type and size
puts "Start making GOP and Frame trace files for 30 Rate variants"
for {set i 1} {$i <= 30} {incr i} {
    set original_file_name($i) st_bridge-close_cif.yuv_Q[expr $i + 1].txt
    set original_file_id($i) [open $original_file_name($i) r]
}
set trace_file_name video_audio.dat
set trace_file_id [open $trace_file_name w]
set trace_file [new vbrTracefile2]
$trace_file filename $trace_file_name

set frame_count 0
set last_time 0

# AL: toggle between multiple input files!
#set original_file_id $original_file_id(1)
set source_select 1


set frame_size_file frame_size.dat
set frame_size_file_id [open $frame_size_file w]
for {set i 1} {$i <= 30} {incr i} {
    set frame_size($i) 0
}
set gop_size_file gop_size.dat
set gop_size_file_id [open $gop_size_file w]
for {set i 1} {$i <= 30} {incr i} {
    set gop_size($i) 0
}
set old_no -1
set gop_numb 0
# Convert ASCII sender file on frame size granularity to ns-2 adapted
internal format
while {[eof $original_file_id(1)] == 0} {
    for {set i 1} {$i <= 30} {incr i} {
gets $original_file_id($i) current_line($i)
    }

    scan $current_line(1) "%d%s%d%s%s%s%d%s" no_ frametype_ length_ tmp1_
tmp2_ tmp3_ tmp4_ tmp5_
    if {$no_ == $old_no} {
# prevent the last line to be read twice! (bug found 20.05.07)
break
    }
    set old_no $no_
    #puts "$no_ $frametype_ $length_ $tmp1_ $tmp2_ $tmp3_ $tmp4_ $tmp5_"

    # 30 frames/sec. if one want to generate 25 frames/sec, one can use set
time [expr 1000*1000/25]
    set tempStr "%.0f"
    set time [expr 1000 * 1000/30]

    set time [format $tempStr $time]


    if { $frametype_ == "I" } {
   set type_v 1
set time 0
    }

    if { $frametype_ == "P" } {
   set type_v 2
    }

    if { $frametype_ == "B" } {
   set type_v 3
    }

    # Write to GOP size file after each H-frame found:
    if { $frametype_ == "H" } {
set puts_string "$gop_numb"
for {set i 1} {$i <= 30} {incr i} {
    set puts_string "$puts_string $gop_size($i)"
}
puts $gop_size_file_id $puts_string
set gop_numb [expr $gop_numb + 1]
   set type_v 0 ;# Must have different type than I-frame so that the
LB(r,b) algorithm finds it!
    }
# Write to frame_size.dat:
    set puts_string "$no_"
    for {set i 1} {$i <= 30} {incr i} {
set puts_string "$puts_string $gop_size($i)"
    }
    puts $frame_size_file_id $puts_string

    for {set i 1} {$i <= 30} {incr i} {
scan $current_line($i) "%d%s%d%s%s%s%d%s" no_ frametype_ length($i) tmp1_
tmp2_ tmp3_ tmp4_ tmp5_
set gop_size($i) [expr $gop_size($i) + $length($i) ]
    }

# Write to video2.dat:
    set puts_string "$time $length_ $type_v 1000"
    for {set i 2} {$i <= 30} {incr i} {
set puts_string "$puts_string $length($i)"
    }
    puts  $trace_file_id $puts_string
    incr frame_count

}
puts "#of frames written to GOP and Frame trace files: $frame_count"
#close $original_file_id
close $trace_file_id  ;# Note that this new trace file is closed for
writing and
# opened below for reading through being a new Tracefile in
eraTraceFile2::setup()
#set end_sim_time [expr 1.0 * 1000/30 * ($frame_count + 1)  / 1000]
set end_sim_time 450

puts "end_sim_time is $end_sim_time"

$ns color 1 RED
set numb_vbr 1
set SD_TRACE_NUM 1
set cbr_true     0


set rng2 [new RNG]
$rng2 seed 20
set xRate [new RandomVariable/Uniform]
$xRate use-rng $rng2
$xRate set min_ 0
$xRate set max_ 2.5e3

set vbr_rate 1.0e6  ;# Evalvid-RA video: select base rate on VBR sources
(includes IP overhead)
set cbr_rate 2.5e6  ;# Rate adaptiv CBR sources max r

#######################################################################
# Add Evalvid-RA RA-SVBR sources                                      #
#######################################################################
for {set i 0} {$i < $numb_vbr} {incr i} {
    #puts "In SVBR TFRC loop, i=$i"
    set tfrc($i) [new Agent/TFRC]
    $ns attach-agent $s1  $tfrc($i)
    if {$cbr_true == 0} {
set vbr($i) [new Application/Traffic/eraVbrTrace]
    } else {
set vbr($i) [new Application/Traffic/CBR_RA]
$vbr($i) set size 1500
    }
    $vbr($i) attach-agent $tfrc($i)

    $tfrc($i) set packetSize_ 1028;# this is the MSS for the TFRC
    $tfrc($i) set TOS_field_ 1     ;# New 120905: tag ECF enabled sources!
0 is default.
    $tfrc($i) set fid_ 1
#    if {$i == 0 || $i == 1}
    if {$i < $SD_TRACE_NUM} {
$tfrc($i) set_filename sd_be_$i ;# Connect a file name to TFRC source to
write transmit trace data
    }

    $vbr($i) set running_ 0
    set offRate [$xRate value]
    if {$cbr_true == 0} {
$vbr($i) set r_ [expr $vbr_rate + $offRate]   ;# Set the rate instead of
packet interval,
#$vbr($i) set r_ [expr $vbr_rate + 0.0]   ;# Set the rate instead of packet
interval,
#$vbr($i) set r_ [expr $vbr_rate + $i*0.5e3]   ;# Set the rate instead of
packet interval,
;# eraVbrTrace will calculate the interval.
$vbr($i) attach-tracefile $trace_file
#    $vbr($i) set b_ [expr $vbr_rate * 1.5]
$vbr($i) set b_ 1.5
$vbr($i) set q_ 8
$vbr($i) set GoP_ 12
$vbr($i) set fps_ 30
    } else {
$vbr($i) set rate_ [expr $cbr_rate + 0]   ;# Set the max rate instead of
    }

    if {($i >= ($numb_vbr))} {
$tfrc($i) set class_ 4
    }

    set sink [new Agent/TFRCSink]

    $ns attach-agent $wl_node_(0)  $sink
    $ns connect $tfrc($i) $sink
    if {$i == 0} {
$sink set_trace_filename rd_be_$i ;# Connect a file name to TFRC sink to
# write receivce trace data
    }
}
#-------------------------------------------------------------------------------------
set udp2 [new Agent/UDP]
$ns attach-agent $s2 $udp2
set null2 [new Agent/Null]
$ns attach-agent $wl_node_(0) $null2
$ns connect $udp2 $null2
set traffic [new Application/Traffic/Exponential]
$traffic set packetSize_ $packetSize
$traffic set burst_time_ 0.5
$traffic set idle_time_ 0.5
$traffic set  rate_ 256kb #original is 256kb
$traffic attach-agent $udp2

set tcp1 [new Agent/TCP/Reno]
$ns attach-agent $s3 $tcp1
set tcpsink1 [new Agent/TCPSink]
$ns attach-agent $wl_node_(0) $tcpsink1
$ns connect $tcp1 $tcpsink1
set ftp1 [$tcp1 attach-source FTP]

set rng [new RNG]
$rng seed $opt(0)
set RVstart [new RandomVariable/Uniform]
$RVstart set min_ 1
$RVstart set max_ 2
$RVstart use-rng $rng
set startT_video [expr [$RVstart value]]
puts "startT_video: $startT_video sec"

set RVstart2 [new RandomVariable/Uniform]
$RVstart2 set min_ 0
$RVstart2 set max_ 1
$RVstart2 use-rng $rng
set startT_ftp [expr [$RVstart2 value]]
set startT_traffic [expr [$RVstart2 value]]
puts "startT_ftp: $startT_ftp sec"
puts "startT_traffic: $startT_traffic sec"

# Tell nodes when the simulation ends
for {set i 0} {$i < $num_mobile_nodes } {incr i} {
$ns at [expr $end_sim_time + 5.0] "$wl_node_($i) reset";
}

proc stop {} {
global ns ntr
$ns flush-trace
close $ntr
#set fecno [$bs_ifq fecno?]
#puts "total fec no:$fecno"
}

$ns at $startT_ftp "$ftp1 start"
$ns at $startT_traffic "$traffic start"
$ns at $startT_video "$vbr(0) start"
$ns at 450 "$vbr(0) stop"
$ns at 450 "$ftp1 stop"
$ns at 450 "$traffic stop"

$ns run