Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maalepaaler
qstream
Commits
bf1644a0
Commit
bf1644a0
authored
Jun 04, 2009
by
Olav Kvittem
Browse files
support for Crude packet log format
parent
229b2cf4
Changes
2
Show whitespace changes
Inline
Side-by-side
README
View file @
bf1644a0
Qstream Computes packet stream quality statistics for UDP/RTP from network or captured files(pcap)
see http://software.uninett.no/qstream
revision 3
support for Crude packet log format
qstream
View file @
bf1644a0
...
...
@@ -16,6 +16,7 @@ use Net::RTP;
use
Net::RTP::
Packet
;
use
Time::
HiRes
qw/ sleep time tv_interval gettimeofday/
;
use
Data::
Dumper
;
use
Carp
;
use
constant
MTU
=>
1580
;
...
...
@@ -46,7 +47,7 @@ $usage="$0 [option]... [file...|ip/|:port]...
-debug - print debugging info
-help/h this message
\n
";
@opts
=
('
list
',
'
fullformat
',
'
net
',
'
rtp
',
'
mpeg
',
'
pcap
',
'
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
',
'
verbose
',
'
v
',
'
help
',
'
h
',
'
debug
');
@opts
=
('
list
',
'
fullformat
',
'
net
',
'
rtp
',
'
mpeg
',
'
pcap
',
'
crude
',
'
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
',
'
verbose
',
'
v
',
'
help
',
'
h
',
'
debug
');
&NGetOpt
(
@opts
)
||
die
$usage
;
die
$usage
if
$opt_h
or
$opt_help
;
$continous
=
!
$opt_packets
;
...
...
@@ -64,6 +65,9 @@ my $nint=0;
my
$n_packets
=
0
;
my
$endstream
=
0
;
$SIG
{
USR2
}
=
sub
{
confess
"
Caught by SIGUSR2
";
};
$SIG
{
INT
}
=
sub
{
$uninterrupted
=
0
;
# return if $nint++ < 1;
&display_stats
();
die
"
End after interrupt.
\n
";
exit
(
0
)
};
$SIG
{
KILL
}
=
sub
{
$uninterrupted
=
0
;
# return if $nkill++ < 1;
...
...
@@ -266,6 +270,37 @@ sub eat_stream {
$pcap_file
=
$tmp_file
;
system
(
"
/bin/zcat
$f
>
$tmp_file
")
;
# rc code ? || die "Could not unpack $f to $tmp_file : $!";
}
if
(
$opt_crude
){
my
$flow_key
;
open
CRUDE
,
"
<
",
$pcap_file
||
die
"
Could not open
$f
:
$err
";
while
(
<
CRUDE
>
){
# crude.sourceforge.net
if
((
$fid
,
$seq
,
$src
,
$dst
,
$tx
,
$rx
,
$size
)
=
/ID=(\d+)\s+SEQ=(\d+)\s+SRC=([\d.:]+)\s+DST=([\d.:]+)\s+Tx=([\d.,]+)\s+Rx=([\d.,]+)\s+SIZE=(\d+)/
){
$flow_key
=
"
$src
->
$dst
";
$flow_pkts
{
$flow_key
}
++
;
if
(
$flow_pkts
{
$flow_key
}
<=
1
)
{
# new flow
push
(
@flows
,
$flow_key
);
#
$flow_no
++
;
$file
{
$flow_key
}
=
$f
;
$source
{
$flow_key
}
=
$src
;
}
next
if
$opt_list
;
# just count packets per flow
next
if
$opt_flow_key
&&
$flow_key
!~
$wanted_flow
;
next
if
$opt_flow_no
&&
$opt_flow_no
!~
/\b$flow_no\b/
;
if
(
$flow_pkts
{
$flow_key
}
<=
1
)
{
#
&init_stats
(
$flow_key
);
push
(
@myflows
,
$flow_key
);
}
$us
=
(
$rc
-
$tc
)
*
10
^
6
;
# us
&pkt_stats
(
$flow_key
,
,
$us
,
$size
);
}
}
}
else
{
if
(
$pcap
=
Net::Pcap::
open_offline
(
$pcap_file
,
\
$err
)){
# my $select=IO::Select->new(Net::Pcap::fileno($pcap));
...
...
@@ -279,6 +314,7 @@ sub eat_stream {
die
"
Could not open
$f
:
$err
";
}
}
}
undef
$t0
;
unlink
$tmpfile
if
$tmp_file
;
}
# of files
...
...
@@ -432,7 +468,6 @@ sub init_file {
sub
pkt_stats
{
my
$f
=
shift
;
# file or stream name
my
$packet
=
shift
;
my
$rtp
;
my
$us
=
shift
;
my
$dlen
=
shift
;
my
$rtp
=
new
Net::RTP::
Packet
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment