IPDR
view release on metacpan or search on metacpan
lib/IPDR/Collection/Cisco.pm view on Meta::CPAN
package IPDR::Collection::Cisco;
use warnings;
use strict;
use IO::Select;
use IO::Socket;
use IO::Socket::SSL;
use POSIX;
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval clock_gettime clock_getres );
$SIG{CHLD}="IGNORE";
=head1 NAME
IPDR::Collection::Cisco - IPDR Collection Client (Cisco Specification)
=head1 VERSION
Version 0.40
=cut
our $VERSION = '0.40';
=head1 SYNOPSIS
This is a IPDR module primarily written to connect and collect data
using IPDR from a Motorola BSR6400 CMTS. Some work is still required.
It is not very pretty code, nor perhaps the best approach for some of
the code, but it does work and will hopefully save time for other people
attempting to decode the IPDR protocol (even using the specification it
is hard work).
An example configuration for Cisco is
cable metering destination 192.168.1.1 5000 192.168.1.2 4000 1 15 non-secure
The IP addresses and ports specified are those of a collector that
the CMTS will send data to. The Cisco implementation does not provide
all IPDR functionality. Setting up a secure connection is not too difficult
(this release does not support it) from a collector point of view however
the Cisco implementation for secure keys is somewhat painful.
This Cisco module opens a socket on the local server waiting for a connection
from a Cisco router.
An example configuration for Motorola BSR is
ipdr enable
ipdr collector 192.168.1.1 5000 3
ipdr collector 192.168.1.2 4000 2
The IP addresses and ports specicified are those of a collector that will
connect to the CMTS. You can have multiple collectors connected but only
the highest priority collector will receive data, all others will received
keep alives.
The Client module makes a connection to the destination IP/Port specified.
An example on how to use this module is shown below. It is relatively simple
use the different module for Cisco, all others use Client.
#!/usr/local/bin/perl
use strict;
use IPDR::Collection::Cisco;
my $ipdr_client = new IPDR::Collection::Cisco (
[
VendorID => 'IPDR Client',
ServerIP => '192.168.1.1',
ServerPort => '5000',
Timeout => 2,
Type => 'docsis',
DataHandler => \&display_data,
]
);
# Check for data from the IPDR server.
my $status = $ipdr_client->connect();
if ( !$status )
{
print "Status was '".$ipdr_client->return_status()."'\n";
print "Error was '".$ipdr_client->return_error()."'\n";
exit(0);
}
$ipdr_client->check_data_available();
exit(0);
sub display_data
{
my ( $remote_ip ) = shift;
my ( $remote_port ) = shift;
my ( $data ) = shift;
my ( $self ) = shift;
foreach my $host ( sort { $a<=> $b } keys %{$data} )
{
print "Host is '$host' \n";
foreach my $document_attribute ( keys %{${$data}{$host}{'document'}} )
{
print "Document id '$document_attribute' ";
print "value is '${$data}{$host}{'document'}{$document_attribute}'\n";
}
foreach my $sequence ( keys %{${$data}{$host}} )
{
next if $sequence=~/^document$/i;
foreach my $attribute ( keys %{${$data}{$host}{$sequence}} )
{
print "Sequence is '$sequence' Attribute is '$attribute' ";
print "value is '${$data}{$host}{$sequence}{$attribute}'\n";
}
( run in 1.181 second using v1.01-cache-2.11-cpan-39bf76dae61 )