GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Net::BGP::ASPath(3) User Contributed Perl Documentation Net::BGP::ASPath(3)

"Net::BGP::ASPath" - Class encapsulating BGP-4 AS Path information

    use Net::BGP::ASPath;

    # Constructor
    $aspath  = Net::BGP::ASPath->new(undef, { as4 => 1 });
    $aspath2 = Net::BGP::ASPath->new([65001,65002]);
    $aspath3 = Net::BGP::ASPath->new("(65001 65002) 65010");
    $aspath4 = Net::BGP::ASPath->new("65001 {65011,65010}");

    # Object Copy
    $clone   = $aspath->clone();

    # Modifiers;
    $aspath  = $aspath->prepend(64999);
    $aspath  = $aspath->prepend("64999 65998");
    $aspath  = $aspath->prepend([64999,65998]);

    $aspath  = $aspath->prepend("(64999 65998)");
    $aspath  = $aspath->prepend_confed("64999 65998");

    $aspath += "65001 65002";    # Same as $aspath->prepend("65001 65002")

    $aspath5 = $aspath->striped; # New object
    $aspath  = $aspath->strip;   # Same modified

    $aspath  = $aspath->cleanup  # Same modified

    # Aggregation
    $aspath  = $aspath1->aggregate($aspath2,$aspath3);
    $aspath  = Net::BGP::ASPath->aggregate($aspath1,$aspath2,$aspath3);


    # Accessor Methods
    $length    = $aspath->length;
    $string    = $aspath->as_string;
    $array_ref = $aspath->asarray

    # In context
    $string    = "The AS path is: " . $aspath;
    $firstas   = $aspath[0];

    # Length comparisons
    if ($aspath < $aspath2) { ... };
    if ($aspath > $aspath2) { ... };
    if ($aspath == $aspath2) { ... };
    if ($aspath != $aspath2) { ... };
    @sorted = sort { $a <=> $b } ($aspath, $aspath2, $aspath3, $aspath4);

    # Path comparisons
    if ($aspath eq $aspath2) { ... };
    if ($aspath ne $aspath2) { ... };

This module encapsulates the data contained in a BGP-4 AS_PATH, including confederation extensions.

new() - create a new "Net::BGP::ASPath" object
    $aspath = Net::BGP::ASPath->new( PATHDATA, OPTIONS );
    

This is the constructor for "Net::BGP::ASPath" objects. It returns a reference to the newly created object. The first parameter may be either:

ARRAY_REF
An array ref containing AS numbers interpreted as an AS_PATH_SEQUENCE.
SCALAR
A string with AS numbers separated by spaces (AS_PATH_SEQUANCE). AS_PATH_SETs are written using "{}" with "," to separate AS numbers. AS_PATH_CONFED_* is written similarly, but encapsulated in "()".
"Net::BGP::ASPath"
Another ASPath object, in which case a clone is constructed.
"undef"
This will create the ASPath object with empty contents.

Following the PATHDATA, the OPTIONS may be specified. Currently the only valid option is c<as4>, which, if true, builds ASPath objects usable for talking to a peer that supports 32 bit ASNs. False, or the default value, assumes that the peer does not support 32 bit ASNs, which affects the decode routines. Note that the encode routines are not dependent upon this option.

Basically, if as4 is true, AS_PATH is populated from messages assuming 4 byte ASNs and AS4_PATH is not used. Encoded AS_PATH attributes also assume a 4 byte ASN.

If as4 is false, AS_PATH is populated from messages assuming 2 byte ASNs, and, if available, AS4_PATH is used to replace occurences of 23456 when possible when outputing to user-readable formats. Encoding routines will also allow output of AS4_PATH objects when appropriate.

clone() - clone a "Net::BGP::ASPath" object
    $clone = $aspath->clone();
    

This method creates an exact copy of the "Net::BGP::ASPath" object.

length()
Return the path-length used in BGP path selection. This is the sum of the lengths of all AS_PATH elements. This does however not include AS_PATH_CONFED_* elements and AS_SEGMENTS which count as one BGP hop.
as_string()
Returns the path as a string in same notation that the constructor accepts.
cleanup()
Reduce the path by removing meaningless AS_PATH elements (empty sets or sequences) and joining neighbor elements of the same _SET type.
strip()
Strips AS_CONFED_* segments from the path.
striped()
Returns a strip() 'ed clone() of the path.
prepend(ARRAY)
prepend(SCALAR)
Strips AS_CONFED_* segments from the path and prepends one or more AS numbers to the path as given as arguments, either as an array of AS numbers or as a string with space separated AS numbers. If the string has "()" surrounding it, prepend_confed will be used instead.
prepend_confed(ARRAY)
prepend_confed(SCALAR)
Prepends one or more confederation AS numbers to the path as given as arguments, either as an array of AS numbers or as a string with space separated AS numbers. "()" around the string is ignored.
aggregate(ASPath)
aggregate(ARRAY)
Aggregates the current ASPath with the ASPath(s) given as argument. If invoked as a class method, aggregate all ASPaths given as argument.

To aggregate means to find the longest common substring (of the paths of all objects that should be aggregated) and keep them, but replacing the non-common substrings with AS_SET segments. Currently only the longest common normal and confederation head will be found and the remaining will be left as an AS_SET and AS_CONFED_SET.

Returns the aggregated object. The objects themselves are not modified.

Net::BGP
Net::BGP::Process
Net::BGP::Peer
Net::BGP::Update
Net::BGP::Refresh
Net::BGP::NLRI
Net::BGP::Notification

Martin Lorensen <bgp@martin.lorensen.dk>
2021-12-01 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.