throughput.pl

来自「介绍相关NS2的资料对于NS2的一些介绍」· PL 代码 · 共 50 行

PL
50
字号
# type: perl throughput.pl <trace file> <required node> <granlarity>   >    output file$infile=$ARGV[0];$tonode=$ARGV[1];$granularity=$ARGV[2];#we compute how many bytes were transmitted during time interval specified#by granularity parameter in seconds$sum=0;$clock=0;      open (DATA,"<$infile")        || die "Can't open $infile $!";      while (<DATA>) {             @x = split(' ');#column 1 is time if ($x[1]-$clock <= $granularity){#checking if the event corresponds to a reception if ($x[0] eq 'r') { #checking if the destination corresponds to arg 1if ($x[3] eq $tonode) { #checking if the packet type is TCPif ($x[4] eq 'tcp') {    $sum=$sum+$x[5];}}}}else{   $throughput=$sum/$granularity;    print STDOUT "$x[1] $throughput\n";    $clock=$clock+$granularity;    $sum=0;}   }   $throughput=$sum/$granularity;    print STDOUT "$x[1] $throughput\n";    $clock=$clock+$granularity;    $sum=0;    close DATA;exit(0); 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?