Commit 74182d47 authored by Olav Kvittem's avatar Olav Kvittem

Bugs in field names and values for flows.

parent 05a946c8
......@@ -18,7 +18,7 @@ use NetPacket::IP qw(:strip :protos);;
use NetPacket::UDP;
use NetPacket::TCP;
use Net::IPv6Addr;
use NetPacket::IPv6 qw(ipv6_strip);
#use NetPacket::IPv6 qw(ipv6_strip);
#use Net::RTP;
use Net::RTP::Packet;
use Time::HiRes qw/ sleep time tv_interval gettimeofday/;
......@@ -175,14 +175,14 @@ if ($opt_dump){
open DUMP, ">$opt_dump";
}
if ($opt_test){
if ($opt_test){
if($opt_mpeg || $opt_rtp || $opt_tcp_t){
&unit_test;
}
else {
print "You need to choose a test. (mpeg, tcp or rtp) \n";
}
}
}
if ($opt_pcap || ($opt_tcp && !$opt_rtmp)){ # listen in parallell
alarm($opt_last) if $opt_last;
......@@ -265,17 +265,17 @@ sub unit_test_2{
}
sub xml_parser {
my $file = shift;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ($file);
my $root = $doc->getFirstChild();
my $nodelist = $root->getChildNodes();
my $node = $nodelist->item(1);
my $dup;
my $flow_childs = $node->getChildNodes();
my @test_array = ();
my %test_hash = ();
foreach my $child ($node->getChildNodes()) {
my $file = shift;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ($file);
my $root = $doc->getFirstChild();
my $nodelist = $root->getChildNodes();
my $node = $nodelist->item(1);
my $dup;
my $flow_childs = $node->getChildNodes();
my @test_array = ();
my %test_hash = ();
foreach my $child ($node->getChildNodes()) {
if ($child->getNodeType == ELEMENT_NODE) {
if ($child->getChildNodes()){
my @children = $child->getChildNodes();
......@@ -838,7 +838,7 @@ sub eat_pcap_streams{ # open groups and listen on pcap
}
sub set_network_info{
my ($f,$src_ip,$dst_ip,$src_port,$dst_port) = @_;
my ($f,$src_ip,$src_port,$dst_ip,$dst_port) = @_;
$network_info{$f}{'src_ip'} = $src_ip;
$network_info{$f}{'dst_ip'} = $dst_ip;
$network_info{$f}{'src_port'} = $src_port;
......@@ -938,6 +938,8 @@ sub eat_pcap { # process pcap packets
}
&pkt_stats($flow_key, $ip_payload->{data}, $us, $dlen);
}
#--------------------------------------------------------------------------------
sub init_stats {
my $f=shift;
$pinterval=0;
......@@ -1056,9 +1058,9 @@ sub xml_dump_rtmp_tcp {
if ($opt_tcp){
$f = $id;
my $bw_stats = $doc->createElement('bandwidth_stats');
my $avg_bw = $doc->createElement('avg_bandwidth');
my $max_bw = $doc->createElement('max_bandwidth_1s');
my $max_bw_100ms = $doc->createElement('max_bandwidth_100ms');
my $avg_bw = $doc->createElement('bandwidth_avg');
my $max_bw = $doc->createElement('bandwidth_max_1s');
my $max_bw_100ms = $doc->createElement('bandwidth_max_100ms');
my $sdv_bw = $doc->createElement('bandwidth_sdv');
$flow->appendChild($bw_stats);
$bw_stats->appendChild($avg_bw);
......@@ -1219,13 +1221,13 @@ sub xml_dump {
my $setuptimeXML = $doc->createElement('setuptime');
my $gap_avgXML = $doc->createElement('gap_avg');
my $gap_sdvXML = $doc->createElement('gap_sdv');
my $min_gapXML = $doc->createElement('min_gap');
my $max_gapXML = $doc->createElement('max_gap');
my $gap_minXML = $doc->createElement('gap_min');
my $gap_maxXML = $doc->createElement('gap_max');
$network_stats->appendChild($setuptimeXML);
$network_stats->appendChild($gap_avgXML);
$network_stats->appendChild($gap_sdvXML);
$network_stats->appendChild($min_gapXML);
$network_stats->appendChild($max_gapXML);
$network_stats->appendChild($gap_minXML);
$network_stats->appendChild($gap_maxXML);
$flow->appendChild($network_stats);
#packets_stats
my $packet_stats = $doc->createElement('packet_stats');
......@@ -1236,9 +1238,9 @@ sub xml_dump {
#bandwidth
my $bw_stats = $doc->createElement('bandwidth_stats');
my $avg_bw = $doc->createElement('avg_bandwidth');
my $max_bw = $doc->createElement('max_bandwidth');
my $max_bw_100ms = $doc->createElement('max_bandwidth_100ms');
my $avg_bw = $doc->createElement('bandwidth_avg');
my $max_bw = $doc->createElement('bandwidth_max');
my $max_bw_100ms = $doc->createElement('bandwidth_max_100ms');
my $sdv_bw = $doc->createElement('bandwidth_sdv');
$bw_stats->appendChild($avg_bw);
$bw_stats->appendChild($max_bw);
......@@ -1250,8 +1252,8 @@ sub xml_dump {
$setuptimeXML->addText(&format_numbers($setuptime{$f}));
$gap_avgXML->addText(&format_numbers(avg( $sumgap{$f}, $ngap{$f}) / 1000 ));
$gap_sdvXML->addText(&format_numbers(sdv($ngap{$f}, $sumgap{$f},$ssgap{$f})/1000));
$min_gapXML->addText(&format_numbers($mingap{$f}/1000));
$max_gapXML->addText(&format_numbers($mingap{$f}/1000));
$gap_minXML->addText(&format_numbers($mingap{$f}/1000));
$gap_maxXML->addText(&format_numbers($mingap{$f}/1000));
#Jitter / $opt_crue or $opt_rtp
if ($jitter_stat){
......@@ -1620,7 +1622,7 @@ sub do_math{
}
if($opt_tcp){
$tcp_packet_stats{$f}{'span'} = $span;
$tcp_packet_stats{$f}{'avg_bandwidth'} = (($tcp_packet_stats{$f}{'num_bytes'}*8)/$span);
$tcp_packet_stats{$f}{'bandwidth_avg'} = (($tcp_packet_stats{$f}{'num_bytes'}*8)/$span);
$tcp_packet_stats{$f}{'jitter_avg'} = avg($tcp_packet_stats{$f}{'jitter_sum'},$tcp_packet_stats{$f}{'num_packets'});
$tcp_packet_stats{$f}{'jitter_sdv'} = sdv($tcp_packet_stats{$f}{'num_packets'}, $tcp_packet_stats{$f}{'jitter_sum'}, $tcp_packet_stats{$f}{'jitter_square'});
$tcp_packet_stats{$f}{'gap_avg'} = (10**3)*avg($tcp_packet_stats{$f}{'gap_sum'},$tcp_packet_stats{$f}{'num_packets'});
......@@ -1698,11 +1700,12 @@ sub jitter_stats {
}
sub get_date_time{
my $f = shift;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($tstart{$f}->[0]);
my $flow = shift;
# $flow = $f if ! $flow; # current flow if not given
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($tstart{$flow}->[0]);
my $time=sprintf "%02d:%02d:%02d", $hour, $min, $sec;
if ($format eq "full"){
$time.=sprintf ".%06d", $tstart{$f}->[1];
$time.=sprintf ".%06d", $tstart{$flow}->[1];
} else {
my $time=sprintf "%02d:%02d:%02d", $hour, $min, $sec;
}
......@@ -1710,6 +1713,8 @@ sub get_date_time{
return ($date,$time);
}
#--------------------------------------------------------------------------------
sub display_stats{
@myflows=@streams if ($#myflows < 0); # no response
foreach $f (sort @myflows) {
......@@ -1727,6 +1732,8 @@ sub display_stats{
&print_out($f) if !$opt_q || $opt_rtmp;
}
}
sub print_out {
return 0 if $opt_rtmp;
my $f = shift;
......@@ -1782,7 +1789,7 @@ sub print_out {
}
my @output = (@dwell_head);
my $mos;
print "$npkt{$f} \n";
#ok print "$npkt{$f} \n";
if ($jitter_stat){
$mos=&mos_r($codec, $rtt, avg( $sumgap{$f}, $ngap{$f}) / 1000,
avg($sumjitter{$f}, $njitter)/1000,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment