BabyPinky8888
Programmer
I have a function called record which records the number of packets at the sink for computing the throughput.. I am doing this for more than 1 flow and I need the average for which I am using the record function.. the function is as follows.. and i get the o/p as below. I dont know where the 0 at the very first line is coming from.. I know the last line in o/p as 0 because I am printing now.. I also understand that one of the reasons why segmentation fault occurs is due to overflow of stack.. If you have any suggestions please let me know thanks!
0
bytes 0
bytes1 0
bytes2 0
bytes3 0
0
Segmentation fault ..
Function:
proc record {} {
global ns tcpflow tcpSrc sink cwn tput tcpsink tcp
set time 1.0
set now [$ns now]
$ns at [expr $now + $time] "record"
set bytes [$sink(0) set bytes_]
set tbytes(0) [expr $bytes/1]
set bytes1 [$sink(1) set bytes_]
set t1bytes(1) [expr $bytes1/1]
set bytes2 [$sink(2) set bytes_]
set t2bytes(2) [expr $bytes2/1]
set bytes3 [$sink(3) set bytes_]
set t3bytes(3) [expr $bytes3/1]
set totalbytes [expr $tbytes(0) + $t1bytes(1) + $t2bytes(2) + $t3bytes(3) ]
set finalaverage [expr $totalbytes/$tcpflow]
puts "$finalaverage"
puts "bytes $tbytes(0)"
puts "bytes1 $t1bytes(1)"
puts "bytes2 $t2bytes(2)"
puts "bytes3 $t3bytes(3)"
#set total [expr $bytes1 + $bytes]
set cwnd(0) [$tcp(0) set cwnd_]
set cwnd(1) [$tcp(1) set cwnd_]
set cwnd(2) [$tcp(2) set cwnd_]
set cwnd(3) [$tcp(3) set cwnd_]
puts $tput(0) "$now $tbytes(0)"
puts $tput(1) "$now $t1bytes(1)"
puts $tput(2) "$now $t2bytes(2)"
puts $tput(3) "$now $t3bytes(3)"
puts $cwn(0) "$now $cwnd(0)"
puts $cwn(1) "$now $cwnd(1)"
puts $cwn(2) "$now $cwnd(2)"
puts $cwn(3) "$now $cwnd(3)"
$sink(0) set bytes_ 0
$sink(1) set bytes_ 0
$sink(2) set bytes_ 0
$sink(3) set bytes_ 0
puts "$now"
}
0
bytes 0
bytes1 0
bytes2 0
bytes3 0
0
Segmentation fault ..
Function:
proc record {} {
global ns tcpflow tcpSrc sink cwn tput tcpsink tcp
set time 1.0
set now [$ns now]
$ns at [expr $now + $time] "record"
set bytes [$sink(0) set bytes_]
set tbytes(0) [expr $bytes/1]
set bytes1 [$sink(1) set bytes_]
set t1bytes(1) [expr $bytes1/1]
set bytes2 [$sink(2) set bytes_]
set t2bytes(2) [expr $bytes2/1]
set bytes3 [$sink(3) set bytes_]
set t3bytes(3) [expr $bytes3/1]
set totalbytes [expr $tbytes(0) + $t1bytes(1) + $t2bytes(2) + $t3bytes(3) ]
set finalaverage [expr $totalbytes/$tcpflow]
puts "$finalaverage"
puts "bytes $tbytes(0)"
puts "bytes1 $t1bytes(1)"
puts "bytes2 $t2bytes(2)"
puts "bytes3 $t3bytes(3)"
#set total [expr $bytes1 + $bytes]
set cwnd(0) [$tcp(0) set cwnd_]
set cwnd(1) [$tcp(1) set cwnd_]
set cwnd(2) [$tcp(2) set cwnd_]
set cwnd(3) [$tcp(3) set cwnd_]
puts $tput(0) "$now $tbytes(0)"
puts $tput(1) "$now $t1bytes(1)"
puts $tput(2) "$now $t2bytes(2)"
puts $tput(3) "$now $t3bytes(3)"
puts $cwn(0) "$now $cwnd(0)"
puts $cwn(1) "$now $cwnd(1)"
puts $cwn(2) "$now $cwnd(2)"
puts $cwn(3) "$now $cwnd(3)"
$sink(0) set bytes_ 0
$sink(1) set bytes_ 0
$sink(2) set bytes_ 0
$sink(3) set bytes_ 0
puts "$now"
}