The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::CIDR::ORTC - CIDR map compression

SYNOPSIS

  use Net::CIDR::ORTC;

  my $map = Net::CIDR::ORTC->new();

  $map->add('0.0.0.0/0', 0);
  $map->add('192.168.0.0/24', 'value1');
  $map->add('192.168.1.0/24', 'value1');

  $map->compress();

  my $prefixes = $map->list;

  foreach (@$prefixes) {
    say $_->[0] . "\t" . $_->[1];
  }

DESCRIPTION

This module implements Optimal Routing Table Compressor (ORTC) algorithm as described in Technical Report MSR-TR-98-59.

This module intended for offline data processing and not optimal in terms of CPU time and memory usage, but output table should have smallest number of prefixes whits same behaviour (with longest-prefix match lookup).

Sometimes this algorithm makes unnecessary changes to input data (prefixes changed, but number of prefixes in output is same as in input), but it is not easy to fix this without making algorithm non-optimal (increasing number of output prefixes in general case).

METHODS

new

create a Net::CIDR::ORTC object

Arguments: none Returns: new object

add

Add prefix -> value pair to internal tree.

Arguments: net - prefix in ip/len form, e. g. 192.0.2.0/24 value - any defined scalar

Returns: none

remove

Remove exactly matches prefix from tree.

Arguments: net - prefix in ip/len form, e. g. 192.0.2.0/24

Returns: true if prefix found and removed, undef if prefix is not found

compress

Compress tree using ORTC algorithm

Arguments: none Returns: none

list

Return list of current prefixes with values

Arguments: none Returns: reference to array like:

    [ ['0.0.0.0/0', 'default'], ['64.0.0.0/2', 2], ['192.0.0.0/2', 3]

LIMITATIONS

Only IPv4 currently supported.

BUGS

Please report bugs to https://bitbucket.org/citrin/p5-net-cidr-ortc/issues

AUTHORS

Anton Yuzhaninov <ayuzhaninov@openstat.ru>, Denis Pokataev <dpokataev@openstat.ru>. Initial version was sponsored by Openstat.

LICENCE

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.16.2 or, at your option, any later version of Perl 5 you may have available.