Commit b25e39a3 authored by paalmm's avatar paalmm

-test added and testsets for rtp and mpeg

parent 685f762c
......@@ -45,7 +45,7 @@ my ($rtmp,$period,$last,$debug,$swfurl,$pageurl,$flash_version,$reconnect);
require "newgetopt.pl";
@opts=('list', 'man','fullformat', 'net', 'rtp', 'mpeg', 'pcap', 'crude', 'bins=s', 'log', 'nperiod=s', 'period=s', 'last=s', 'packets=s', 'src=s', 'flow_key=s', 'flow_no=s', 'flow_min=s', 'nohead', 'dump=s', 'format=s', 'id=s', 'sum=s', 'ttl', 'rtt=s', 'codec=s', 'log', 'verbose', 'v', 'h', 'debug', 'av','xml=s', 'rtmp','tcp', 'port=s','swfurl=s','pageurl=s','flashversion=s','new','q','exclude=s','report=s', 'filename','test','ipv6','p=s','name=s');
@opts=('list', 'man','fullformat', 'net', 'rtp', 'mpeg', 'pcap', 'crude', 'bins=s', 'log', 'nperiod=s', 'period=s', 'last=s', 'packets=s', 'src=s', 'flow_key=s', 'flow_no=s', 'flow_min=s', 'nohead', 'dump=s', 'format=s', 'id=s', 'sum=s', 'ttl', 'rtt=s', 'codec=s', 'log', 'verbose', 'v', 'h', 'debug', 'av','xml=s', 'rtmp','tcp', 'port=s','swfurl=s','pageurl=s','flashversion=s','new','q','exclude=s','report=s', 'filename','test','ipv6','p=s','name=s','tcp_t');
&NGetOpt(@opts) || die pod2usage(1);
die pod2usage(1) if $opt_h;
......@@ -175,7 +175,14 @@ if ($opt_dump){
open DUMP, ">$opt_dump";
}
&unit_test 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;
......@@ -214,9 +221,12 @@ exit(0);
sub unit_test {
my $test_data = shift;
#streams = "rtp_158.38.130.110_6711_1.pcap";
@streams = "testing/testdata_mpeg.pcap" if $opt_mpeg;
@streams = "testing/testdata_rtp.pcap" if $opt_rtp;
@streams = "testing/testdata_tcp.pcap" if $opt_tcp;
if ($opt_mpeg){
@streams = "testing/pcap/testdata_mpeg.pcap";
@filter = qw "video audio";
}
@streams = "testing/pcap/testdata_rtp.pcap" if $opt_rtp;
@streams = "testing/pcap/testdata_tcp.pcap" if $opt_tcp_t;
$opt_xml = "tmp_testdata.xml";
$opt_q = 1;
$opt_v = 1;
......@@ -225,25 +235,35 @@ sub unit_test {
sub unit_test_2{
#my ($orgnial_test) = &feed_data("file",rtp_file.xml);
my $test_data;
$test_data = "mpeg_testdata.xml" if $opt_mpeg;
$test_data = "rtp_testdata.xml" if $opt_rtp;
$test_data = "testing/xml/testdata_mpeg.xml" if $opt_mpeg;
$test_data = "testing/xml/testdata_rtp.xml" if $opt_rtp;
#$test_data = "udp_testdata" if $opt_net;
$test_data = "tcp_testdata.xml" if $opt_tcp;
$test_data = "testing/xml/testdata_tcp.xml" if $opt_tcp;
my ($orginal_test) = &xml_parser($test_data);
my ($new_test) = &xml_parser("tmp_testdata.xml");
print Dumper($orginal_test), "\n", Dumper($new_test)if $opt_debug;
my $ignore_pattern = "jitter"; #PCR jitter is based on delta local time.
my $ignore_pattern2 = "dwell";
my $ignore_pattern3 ="delay_factor";
my $ignore_pattern4 ="gap";
print "Checking values ....\n";
for my $k1(keys %$orginal_test){
if ($orginal_test->{ $k1} != $new_test->{ $k1} and $orginal_test->{ $k1} !~ m/HASH/) {
print "different value @ $k1, value: $orginal_test->{$k1}, differs from value: $new_test->{$k1}\n";
}
else {
printf "%2s %2s\n", "OK @ ", "$k1 ";
}
for my $k2 ( keys %{$orginal_test->{ $k1}} ) {
if ( ($orginal_test->{ $k1}{$k2} != $new_test->{ $k1}{$k2}) and ($k2 !~ m/$ignore_pattern/)){
if ( ($orginal_test->{ $k1}{$k2} != $new_test->{ $k1}{$k2}) and ($k2 !~ m/$ignore_pattern/) and ($k2 !~ m/$ignore_pattern2/) and ($k2 !~ m/$ignore_pattern3/) and ($k2 !~ m/$ignore_pattern4/)){
print "different value @ $k1-> $k2, value: $orginal_test->{$k1}{$k2} differs from, value: $new_test->{$k1}{$k2}\n";
}
}
}
}
print "Test complete \n";
}
sub xml_parser {
my $file = shift;
my $parser = new XML::DOM::Parser;
......@@ -268,7 +288,6 @@ foreach my $child ($node->getChildNodes()) {
foreach my $grandchild ($child->getChildNodes()){
if ($grandchild->getNodeType == ELEMENT_NODE){
#print $grandchild->getNodeName(), "\n";
eval {
$test_hash{$child->getNodeName().$dup}{$grandchild->getNodeName()}= $grandchild->getFirstChild()->getData();
};
......@@ -1148,7 +1167,7 @@ sub xml_dump {
my $dateXML = $doc->createElement('date');
my $timeXML = $doc->createElement('time');
my $spanXML = $doc->createElement('span');
my $pcr_jitter_parrent = $doc->createElement('pcr_jitter');
my $pcr_jitter_parrent = $doc->createElement('pcr_jitter') if $opt_mpeg;
my $network_info_parrent = $doc->createElement('network_info');
$qstream->appendChild($flow);
$flow->appendChild($flow_id);
......@@ -1157,7 +1176,7 @@ sub xml_dump {
$flow->appendChild($timeXML);
$flow->appendChild($spanXML);
$flow->appendChild($network_info_parrent);
$flow->appendChild($pcr_jitter_parrent);
$flow->appendChild($pcr_jitter_parrent) if $opt_mpeg;
my $media="file";
$media = "host:port" if $opt_net;
my $id=$f;
......@@ -3861,6 +3880,10 @@ usage="$0 [option]... [file...|ip/|:port]...
=item B<-net> open network stream rather than file(s)
=item B<-ipv6> Listen to Ipv6 connections. Port needs to be defined with -p
=item B<-p> Set port.
=item B<-crude> the log is from crude
=item B<-bins> bins for gaps in ms : b1,b2,,,
......@@ -3897,6 +3920,8 @@ usage="$0 [option]... [file...|ip/|:port]...
=item B<-id name> - report name instead of flow_key in flows
=item B<-name name> - costume name for the tag flow_name in option -xml
=item B<-sum name> - make a summary of all flows to name rather than per flow
=item B<-ttl> - print ttl values for stream
......@@ -3913,6 +3938,8 @@ usage="$0 [option]... [file...|ip/|:port]...
=item B<-q> quiet, dont print anything to STDOUT.
=item B<-test> Run tests on different datasets. Needs to be used with option -rtp or -mpeg.
=back
=head2 MPEG-TS
......@@ -4011,10 +4038,14 @@ Dwell time is for audio and video are measure seperatly.
see also http://en.wikipedia.org/wiki/Presentation_time_stamp, PCR
=item B<Stream id>
=item B<PID>
The program id (PID) for the transport stream.
The packet id (PID) for the transport stream.
=item B<Stream id/Stream id type>
The id that represent stream type.
=item B<MPEG TS packets>
......@@ -4091,6 +4122,17 @@ Listen to a TCP while running -RTMP option.
=back
=head1 Test
mpeg test running: qstream testing/pcap/testdata_mpeg.pcap -mpeg -report audio,video -V
rtp tset running: qstream testing/pcap/testdata_rtp.pcap -rtp -V
Datasets for testing are found in testing/pcap and testing/xml.
=over
=back
=head1 Debian/Ubuntu dependecies
libnet-ipv6addr-perl
......
#!/usr/bin/perl
use strict;
use warnings;
#Test 1 -mpeg
system(".././qstream.pl testdata.pcap -mpeg -packets 5000 -new -report video");
#Test 2 -rtp
#Test 3 -rtmp
#Test 4 -tcp
#Test 5 -udp
<?xml version="1.0"?>
<qstream version="1.0">
<flow>
<flow_id>195.5.113.20:49152->233.155.107.220:57220</flow_id>
<flow_name>195.5.113.20:49152->233.155.107.220:57220</flow_name>
<date>2012-01-25</date>
<time>16:12:38</time>
<span>0.130303</span>
<network_info>
<src_port>233.155.107.220</src_port>
<dst_port>57220</dst_port>
<src_ip>195.5.113.20</src_ip>
<dst_ip>49152</dst_ip>
</network_info>
<pcr_jitter>
<pcr_jitter_avg>14.79562</pcr_jitter_avg>
<pcr_jitter_sdv>1.90662</pcr_jitter_sdv>
<pcr_jitter_min>12.51738</pcr_jitter_min>
<pcr_jitter_max>16.95829</pcr_jitter_max>
</pcr_jitter>
<network_stats>
<setuptime>0</setuptime>
<gap_avg>1.31619</gap_avg>
<gap_sdv>0.02242</gap_sdv>
<min_gap>1.20800</min_gap>
<max_gap>1.20800</max_gap>
</network_stats>
<packet_stats>
<packet_count>100</packet_count>
</packet_stats>
<bandwidth_stats>
<avg_bandwidth>8128746.07645</avg_bandwidth>
<max_bandwidth>0</max_bandwidth>
<max_bandwidth_100ms>16307929.17629</max_bandwidth_100ms>
<bandwidth_sdv>0</bandwidth_sdv>
</bandwidth_stats>
<transport_stream>
<pid>265</pid>
<stream_id>224</stream_id>
<stream_id_type>video</stream_id_type>
<mpeg_packets>470</mpeg_packets>
<mpeg_lost_packets>0</mpeg_lost_packets>
<media_loss_rate>0</media_loss_rate>
<media_bandwidth>5424894.28485914</media_bandwidth>
<dwell_avg>322.38479</dwell_avg>
<dwell_sdv>0</dwell_sdv>
<dwell_min>322.38479</dwell_min>
<dwell_max>322.38479</dwell_max>
<delay_factor>4.02981</delay_factor>
</transport_stream>
</flow>
</qstream>
<?xml version="1.0"?>
<qstream version="1.0">
<flow>
<flow_id>158.38.8.167:16388->158.38.130.110:16400</flow_id>
<flow_name>158.38.58.167:16388->158.38.130.110:16400</flow_name>
<date>2011-10-25</date>
<time>13:30:21</time>
<span>7.019646</span>
<network_info>
<src_port>158.38.130.110</src_port>
<dst_port>16400</dst_port>
<src_ip>158.38.58.167</src_ip>
<dst_ip>16388</dst_ip>
</network_info>
<network_stats>
<setuptime>0</setuptime>
<gap_avg>29.99849</gap_avg>
<gap_sdv>0.80499</gap_sdv>
<min_gap>25.10300</min_gap>
<max_gap>25.10300</max_gap>
</network_stats>
<packet_stats>
<packet_count>233</packet_count>
</packet_stats>
<bandwidth_stats>
<avg_bandwidth>69633.14104</avg_bandwidth>
<max_bandwidth>142849.99475</max_bandwidth>
<max_bandwidth_100ms>172562.55393</max_bandwidth_100ms>
<bandwidth_sdv>4248.52026</bandwidth_sdv>
</bandwidth_stats>
</flow>
</qstream>
<?xml version="1.0"?>
<qstream version="1.0">
<flow>
<flow_id>158.38.48.12:52004->158.38.62.155:42595</flow_id>
<date>2011-11-24</date>
<time>15:42:56</time>
<bandwidth_stats>
<avg_bandwidth>2466515.23535</avg_bandwidth>
<max_bandwidth_1s>5564972.27599</max_bandwidth_1s>
<max_bandwidth_100ms>196419235.51171</max_bandwidth_100ms>
<bandwidth_sdv>35614545.02650</bandwidth_sdv>
</bandwidth_stats>
<tcp_packet_stats>
<avg_bandwidth>2500116.23847</avg_bandwidth>
<gap_avg>0.20383</gap_avg>
<gap_max>0.23007</gap_max>
<gap_min>0.20504</gap_min>
<gap_sdv>0.05610</gap_sdv>
<gap_square>0.00022</gap_square>
<gap_sum>1.01915</gap_sum>
<jitter_avg>0.20383</jitter_avg>
<jitter_max>2.85602</jitter_max>
<jitter_min>0.18811</jitter_min>
<jitter_sdv>0.05610</jitter_sdv>
<jitter_square>223.47188</jitter_square>
<jitter_sum>1019.15383</jitter_sum>
<num_bytes>7440600</num_bytes>
<num_packets>5000</num_packets>
<pkt_dup>0</pkt_dup>
<pkt_late>2</pkt_late>
<pkt_lost>4</pkt_lost>
<pkt_retrans>0</pkt_retrans>
<span>23.80881</span>
</tcp_packet_stats>
</flow>
</qstream>
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