DULAUNOY Fabrice

NAME

Data::Netflow - Module to process binary netflow data (v5 and v9)

VERSION

Version 0.02

SYNOPSIS

Module to create netflow binary data from text data

    use Data::Netflow;
    use IO::Socket;

    my $sock_udp = IO::Socket::INET->new(
        Proto    => 'udp',
        PeerPort => 9995,
        PeerAddr => '127.0.0.1',
    ) or die "Could not create UDP socket: $!\n";

    my $TemplateV9 = {
        'FlowSetId'      => 0,
        'TemplateId' => 300,
        'Fields'   => [
            { 'Length' => 4, 'Id' => 1  },    # octetDeltaCount
            { 'Length' => 4, 'Id' => 2  },    # packetDeltaCount
            { 'Length' => 1, 'Id' => 4  },    # protocolIdentifier
            { 'Length' => 1, 'Id' => 6  },    # tcp flags
            { 'Length' => 2, 'Id' => 7  },    # sourceTransportPort
            { 'Length' => 4, 'Id' => 8  },    # sourceIPv4Address
            { 'Length' => 2, 'Id' => 11 },    # destinationTransportPort
            { 'Length' => 4, 'Id' => 12 },    # destinationIPv4Address
            { 'Length' => 4, 'Id' => 21 },    # last switched
            { 'Length' => 4, 'Id' => 22 },    # first switched
    ],
}

    my $Header = {
                 Version => 9,
                 SysUptime => int ( uptime() *1000 ),
             };


    my @flow;
    my @tmp = qw( 5 8126 17 0 22 10.2.1.1 5365 10.2.1.254  ) ;
    my $uptime = int ( (uptime()- $back ) *1000 );
    push @tmp  , $uptime + 5;
    push @tmp  , $uptime;
    push @flow , \@tmp;

    my $encoded = Data::Netflow::encodeV9($Header, $TemplateV9 ,\@flow);
    $sock_udp->send( $encoded );

EXPORT

encodeV5 encodeV9

SUBROUTINES/METHODS

decode

decode netflow data

encodeV9

encode data for netflow version 9 with template

encodeV5

encode data for netflow version 5

AUTHOR

DULAUNOY Fabrice, <fabrice at dulaunoy.com>

BUGS

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

TODO

decode V9 for multiple data set (and multiple template ) decode V9 return by id or by name (if flag) like for V5 A single encode (detect version by the header) IPFIX (maybe)

SUPPORT

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

    perldoc Data::Netflow

For the netflow format:

Version 5:

Version 9:

https://www.ietf.org/rfc/rfc3954.txt

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2017 DULAUNOY Fabrice.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.