parse_op.pl
上传用户:wzkunzhan
上传日期:2022-04-23
资源大小:2618k
文件大小:3k
- #!/usr/bin/perl
- #use strict;
- #use Socket 'inet_ntoa';
- #use Sys::Hostname 'hostname';
- my $remote_ip=$ARGV[0];
- #my $local_ip= inet_ntoa(scalar gethostbyname(hostname() || 'localhost'));
- my $local_ip="local_host";
- for $side (sideA, sideB){
- open( LOGPPL, "<$side.ppl");
- $i=-1;
- foreach $line (<LOGPPL>){
- $i++;
- (@time[$i], @rtt[$i], @psent[$i], @plost[$i], @ptoo_late[$i], @djitter[$i]) = split(" ",$line);
- #print "$ime n";
- #print @time[$i], "t", @rtt[$i], "t", @psent[$i], "t", @plost[$i], "t", @ptoo_late[$i], "t",@djitter[$i], "n";
- @de[$i] = $rtt[$i]/2; #plota somente atraso na rede.
-
- }
- close (LOGPPL);
- $min_de = $ave_de =$max_de =@de[0];
- $min_loss = $ave_loss =$max_loss =@plost[0];
- $min_too = $ave_too =$max_too =@ptoo_late[0];
- $min_jitt = $ave_jitt =$max_jitt =@djitter[0];
- $total_de =$total_loss = $total_too = $total_jitt = 0;
- foreach $j (0..$i) {
- $total_de = $total_de + @de[$i];
- if ($max_de lt @de[$i]) {$max_de = @de[$i];}
- if ($min_de gt @de[$i]) {$min_de = @de[$i];}
-
- $total_loss = $total_loss + @plost[$i];
- if ($max_loss lt @plost[$i]) { $max_loss = @plost[$i];}
- if ($min_loss gt @plost[$i]) {$min_loss = @plost[$i];}
- $total_too = $total_too + @ptoo_late[$i];
- if ($max_too lt @ptoo_late[$i]) {$max_too = @ptoo_late[$i];}
- if ($min_too gt @ptoo_late[$i]) {$min_too = @ptoo_late[$i];}
- $total_jitt = $total_jitt + @djitter[$i];
- if ($max_jitt lt @djitter[$i]) {$max_jitt = @djitter[$i];}
- if ($min_jitt gt @djitter[$i]) {$min_jitt = @djitter[$i];}
- }
- if($total_de !=0) {$ave_de = $total_de/($i+1);} else {$ave_de=0;}
- if($total_loss !=0) {$ave_loss = $total_loss/($i+1);} else {$ave_loss = 0;}
- if($total_too !=0) {$ave_too = $total_too/($i+1);} else {$ave_too =0;}
- if($total_jitt !=0) {$ave_jitt = $total_jitt/($i+1);} else {$ave_jitt = 0;}
- open (MOS,"<sideA.mos");
- @MS =<MOS>;
- $mos = @MS[0];
- print "nTest Summary from $local_ip to $remote_ipn";
- print "=============================================nn";
- printf ("Delay(ms) - Min: %2.6ft",$min_de);
- printf ("Avg: %2.6ft",$ave_de);
- printf ("Max: %2.6fn",$max_de);
- printf ("Loss(pkts) - Min: %2.6ft",$min_loss);
- printf ("Avg: %2.6ft",$ave_loss);
- printf ("Max: %2.6fn",$max_loss);
- printf ("Jitter Buffer Discard(pkts) - Min: %2.6ft",$min_too);
- printf ("Avg: %2.6ft",$ave_too);
- printf ("Max: %2.6fn",$max_too);
- printf ("Jitter(ms) - Min: %2.6ft",$min_jitt);
- printf ("Avg: %2.6ft",$ave_jitt);
- printf ("Max: %2.6fn",$max_jitt);
- printf ("MOS(1-5) - Avg: %2.6fn",$mos);
- #change and remote ips
- $temp = $local_ip;
- $local_ip= $remote_ip;
- $remote_ip= $temp;
- }