#!/usr/bin/perl
#
# Net::RTP example file
#
# Display details of RTP packets recieved
#
use Net::RTP;
use Data::Dumper;
use strict;
my $DEFAULT_PORT = 5004; # Default RTP port
# Create RTP socket
my ($address, $port) = @ARGV;
usage() unless (defined $address);
$port = $DEFAULT_PORT unless (defined $port);
my $rtp = new Net::RTP(
LocalPort=>$port,
LocalAddr=>$address
) || die "Failed to create RTP socket: $!";
my $count = 0;
while (my $packet = $rtp->recv()) {
# Parse the packet
printf("COUNT=%u".$count);
printf(", SRC=[%s]:%u", $packet->source_ip(), $packet->source_port());
printf(", LEN=%u", $packet->payload_size());
printf(", PT=%u", $packet->payload_type());
printf(", SSRC=%x", $packet->ssrc());
printf(", SEQ=%u", $packet->seq_num());
printf(", TIME=%u", $packet->timestamp());
printf(", MARK") if ($packet->marker());
printf("\n");
$count++;
}
sub usage {
print "usage: rtpdump.pl
[]\n";
exit -1;
}
__END__
=pod
=head1 NAME
rtpdump.pl - Parse and display incoming RTP packet headers
=head1 SYNOPSIS
rtpdump.pl []
=head1 DESCRIPTION
rtpdump.pl displays the RTP header of packets sent to a multicast group.
If no port is specified, then port 5004 is assumed.
For each packet recieved, the following fields are displayed:
=over
=item
B - the number of packets recieved.
=item
B - the source IP address and port.
=item
B - the length of the payload (in bytes).
=item
B - the payload type number.
=item
B - the source indentifier unique to this session.
=item
B - the packet's contiguous sequence number.
=item
B