Andrew S. Kennedy > IPDR-0.40 > IPDR::Collection::Client

Download:
IPDR-0.40.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  2
View/Report Bugs
Module Version: 0.40   Source   Latest Release: IPDR-0.41_2

NAME ^

IPDR::Collection::Client - IPDR Collection Client

VERSION ^

Version 0.40

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::Client;

    my $ipdr_client = new IPDR::Collection::Client (
                        [
                        VendorID => 'IPDR Client',
                        ServerIP => '192.168.1.1',
                        ServerPort => '5000',
                        KeepAlive => 60,
                        Capabilities => 0x01,
                        DataHandler => \&display_data,
                        Timeout => 2,
                        ]
                        );

    # We send a connect message to the IPDR server
    $ipdr_client->connect();

    # If we do not connect stop.
    if ( !$ipdr_client->connected )
        {
        print "Can not connect to destination.\n";
        exit(0);
        }

    # We now send a connect message
    $ipdr_client->check_data_available();

    print "Error was '".$ipdr_client->get_error()."'\n";

    exit(0);

    sub display_data
    {
    my ( $remote_ip ) = shift;
    my ( $remote_port ) = shift;
    my ( $data ) = shift;
    my ( $self ) = shift;

    foreach my $sequence ( sort { $a<=>$b } keys %{$data} )
        {
        print "Sequence  is '$sequence'\n";
        foreach my $attribute ( keys %{${$data}{$sequence}} )
                {
                print "Sequence '$sequence' attribute '$attribute'";
                print " value '${$data}{$sequence}{$attribute}'\n";
                }
        }

    }

This is the most basic way to access the data. There are multiple scripts in the examples directory which will allow you to collect and process the IPDR data.

FUNCTIONS ^

new

The new construct builds an object ready to used by the rest of the module and can be passed the following varaibles

    VendorID - This defaults to 'Generic Client' but can be set to any string

    ServerIP - 

         Client: This is the IP address of the destination exporter.
         Cisco: This is the IP address of the local server to receive the data

    ServerPort - 

         Client: This is the port of the destination exporter.
         Cisco: This is the port on the local server which will be used to 
                receive data

    KeepAlive - This defaults to 60, but can be set to any value.
    Capabilities - This defaults to 0x01 and should not be set to much else.
    TimeOut - This defaults to 5 and is passed to IO::Socket (usefulness ?!)
    DataHandler - This MUST be set and a pointer to a function (see example)
    DEBUG - Set at your peril, 5 being the highest value.

An example of using new is

    my $ipdr_client = new IPDR::Collection::Client (
                        [
                        VendorID => 'IPDR Client',
                        ServerIP => '192.168.1.1',
                        ServerPort => '5000',
                        KeepAlive => 60,
                        Capabilities => 0x01,
                        DataHandler => \&display_data,
                        Timeout => 2,
                        ]
                        );

connect

This uses the information set with new and attempts to connect/setup a client/server configuration. The function returns 1 on success, 0 on failure. It should be called with

    $ipdr_client->connect();

connected

You can check if the connect function succeeded. It should return 0 on not connected and 1 if the socket/connection was opened. It can be checked with

    if ( !$ipdr_client->connected )
        {
        print "Can not connect to destination.\n";
        exit(0);
        }

check_data_available

This function controls all the communication for IPDR. It will, when needed, send data to the DataHandler function. It should be called with

    $ipdr_client->check_data_available();

ALL OTHER FUNCTIONs

The remaining of the functions should never be called and are considered internal only. They do differ between Client and Cisco however both module provide the same generic methods, high level, so the internal workings should not concern the casual user.

XDR File Location http://www.ipdr.org/public/DocumentMap/XDR3.6.pdf

AUTHOR ^

Andrew S. Kennedy, <shamrock at cpan.org>

BUGS ^

Please report any bugs or feature requests to bug-ipdr-cisco at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPDR-Collection-Client. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc IPDR::Collection::Client

You can also look for information at:

ACKNOWLEDGEMENTS ^

Thanks to http://www.streamsolutions.co.uk/ for my Flash Streaming Server

COPYRIGHT & LICENSE ^

Copyright 2011 Andrew S. Kennedy, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: