[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] trace per flow queue length.



Hi All.

I want to get per flow queue lenght vs time. using xgraph.

In my simulation, 20 sender have it's own tcp connection. so total flow = 20

To do so, I use

$ns trace-queue $g0 $r0 $f

and get out.tr and make simple perl script to produce 20 qlength.vs.time
file. I test it and it seems works for me. But not sure :<

Of course, If I use RED or RIO (FIFO) I easily get q length. I already
search mailing list, grep ~ns/tcl but I can't find any helpful tcl script or
example...

Could anybody give information or advice for me?

Any information helpful and appreciated.

________________________________

ChoiYoungSoo
[email protected]

________________________________


Here are my perl script. Any advice about my code, mail me plz :)

#!/usr/local/bin/perl
#20 flows
$flownum = 20;
$flowname = "flow";

open( FH, "out.tr" ) || die "Failed opening out.tr\n";

#to make 20 file handle
for ( $i = 1; $i <= $flownum; $i++ ) {
        open( "HQ_$i", ">$flowname.$i" ) || die "Failed opening\n";
}

#q length
for ( $i = 1; $i <= $flownum; $i++ ) {
        $QL[$i]=0.0;
}

#to record q length per about 1 sec.
$tick_time = 1.0;
while (<FH>)
{
        ($Fld1,$Fld2,$Fld3,$Fld4,$Fld5,$Fld6,$Fld7,$Fld8,$Fld9) = split(' ',
$_, 9999);
        select STDOUT;
        $current_time = $Fld2;
        if ( $current_time < $tick_time ) {
                #enque add
                if ($Fld1 eq '+') {
                        $QL[$Fld9]++;
                        $QL_TOT++;
                }
                if ($Fld1 eq '-') {
                        $QL[$Fld9]--;
                        $QL_TOT--;
                }
                if ($Fld1 eq 'd') {
                        $QL[$Fld9]--;
                        $QL_TOT--;
                }
        }
        else {
                select STDOUT;
                #get file handle and write time and q length
                for ( $i = 1; $i <= $flownum; $i++ ) {
                        select "HQ_$i";
                        print "$tick_time \t $QL[$i] \n";
                }
                $tick_time = $tick_time + 1.0;
        }
}
close  (FH);
close  (TOT);
for ( $i = 0; $i < $flownum; $i++ ) {
        close( "HQ_$i" )
}