ipmininet.srv6 module

This modules defines classes to create IPv6 Segment Routing (SRv6) Routes For more information about SRv6, see https://segment-routing.org

class ipmininet.srv6.LocalSIDTable(node: ipmininet.router.__router.IPNode, matching: Iterable[Union[str, ipaddress.IPv6Network, ipmininet.router.__router.IPNode, ipmininet.link.IPIntf]] = ('::/0', ))

Bases: object

A class representing a LocalSID routing table

Parameters:
  • node – The node on which the table is added
  • matching – The list of destinations whose processing is delegated to the table; destinations can be raw prefixes, interfaces (implying all networks on the interface) or nodes (implying all networks on its loopback interface)
clean()
create()
class ipmininet.srv6.SRv6Encap(net: ipmininet.ipnet.IPNet, node: Union[ipmininet.router.__router.IPNode, str], to: Union[str, ipaddress.IPv6Network, ipmininet.router.__router.IPNode, ipmininet.link.IPIntf] = '::/0', through: List[Union[str, ipaddress.IPv6Address, ipmininet.router.__router.IPNode, ipmininet.link.IPIntf]] = (), mode='encap', cost=1)

Bases: ipmininet.srv6.SRv6Route

The SRv6Encap class, which enables to create an IPv6 Segment Routing encapsulation in a router.

The instantiation of these tunnels should happen after the network has been built and its addresses has been allocated. You can leverage the IPTopo.post_build method to do it.

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed or the name of this node
  • to – Either directly the prefix, an IPNode, a name of an IPNode or an IPIntf object so that it matches all its addresses.
  • through – A list of nexthops to set in the IPv6 Segment Routing Header. Each element of the list can either be an IPv6 address, an IPIntf or an IPNode. In both later cases, the default IPv6 address is selected.
  • mode – Either SRv6Encap.ENCAP or SRv6Encap.INLINE whether the route should encapsulate packets in an outer IPv6 packet with the SRH or insert the SRH directly inside the packet.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
ENCAP = 'encap'
INLINE = 'inline'
build_commands() → List[str]
is_available() → bool

Check the compatibility with this encapsulation method

class ipmininet.srv6.SRv6EndB6EncapsFunction(segments: List[Union[str, ipaddress.IPv6Address, ipmininet.router.__router.IPNode, ipmininet.link.IPIntf]], *args, **kwargs)

Bases: ipmininet.srv6.SRv6EndB6Function

This class represents an SRv6 End.B6.Encaps function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed
  • to – Either directly the prefix, an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
  • segments – A list of segments to set in the IPv6 Segment Routing Header. Each element of the list can either be an IPv6 address, an IPIntf or an IPNode. In both later cases, the default IPv6 address is selected.
ACTION = 'End.B6.Encaps'
class ipmininet.srv6.SRv6EndB6Function(segments: List[Union[str, ipaddress.IPv6Address, ipmininet.router.__router.IPNode, ipmininet.link.IPIntf]], *args, **kwargs)

Bases: ipmininet.srv6.SRv6EndFunction

This class represents an SRv6 End.B6 function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed
  • to – Either directly the prefix, an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
  • segments – A list of segments to set in the IPv6 Segment Routing Header. Each element of the list can either be an IPv6 address, an IPIntf or an IPNode. In both later cases, the default IPv6 address is selected.
ACTION = 'End.B6'
params
class ipmininet.srv6.SRv6EndDT6Function(lookup_table: str, *args, **kwargs)

Bases: ipmininet.srv6.SRv6EndTFunction

This class represents an SRv6 End.DT6 function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed
  • to – Either directly the prefix, an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
  • lookup_table – The packet is forwarded to the nexthop looked up in this specified routing table
ACTION = 'End.DT6'
class ipmininet.srv6.SRv6EndDX2Function(interface: Union[str, ipmininet.link.IPIntf], *args, **kwargs)

Bases: ipmininet.srv6.SRv6EndFunction

This class represents an SRv6 End.DX2 function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed
  • to – Either directly the prefix, an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
  • interface – The packet is forwarded to this specific interface
ACTION = 'End.DX2'
params
class ipmininet.srv6.SRv6EndDX4Function(nexthop: Union[str, ipaddress.IPv4Address, ipmininet.link.IPIntf, ipmininet.router.__router.IPNode], *args, **kwargs)

Bases: ipmininet.srv6.SRv6EndFunction

This class represents an SRv6 End.DX4 function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed
  • to – Either directly the prefix, an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
  • nexthop – The nexthop to consider when forwarding the packet. It can be an IPv4 address, an IPIntf or an IPNode. In both later cases, the default IPv4 address is selected.
ACTION = 'End.DX4'
params
class ipmininet.srv6.SRv6EndDX6Function(nexthop: Union[str, ipaddress.IPv6Address, ipmininet.link.IPIntf, ipmininet.router.__router.IPNode], *args, **kwargs)

Bases: ipmininet.srv6.SRv6EndXFunction

This class represents an SRv6 End.DX6 function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed
  • to – Either directly the prefix, an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
  • nexthop – The nexthop to consider when forwarding the packet. It can be an IPv6 address, an IPIntf or an IPNode. In both later cases, the default IPv6 address is selected.
ACTION = 'End.DX6'
class ipmininet.srv6.SRv6EndFunction(net: ipmininet.ipnet.IPNet, node: Union[ipmininet.router.__router.IPNode, str], to: Union[str, ipaddress.IPv6Network, ipmininet.router.__router.IPNode, ipmininet.link.IPIntf] = '::/0', cost=1, table: Optional[ipmininet.srv6.LocalSIDTable] = None)

Bases: ipmininet.srv6.SRv6Route

This class represents an SRv6 End function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed or the name of this node
  • to – Either directly the prefix, an IPNode, a name of an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
ACTION = 'End'
build_commands() → List[str]
is_available() → bool

Check the compatibility with this advanced SRv6 routes

params
class ipmininet.srv6.SRv6EndTFunction(lookup_table: str, *args, **kwargs)

Bases: ipmininet.srv6.SRv6EndFunction

This class represents an SRv6 End.T function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed
  • to – Either directly the prefix, an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
  • lookup_table – The packet is forwarded to the nexthop looked up in this specified routing table
ACTION = 'End.T'
params
class ipmininet.srv6.SRv6EndXFunction(nexthop: Union[str, ipaddress.IPv6Address, ipmininet.link.IPIntf, ipmininet.router.__router.IPNode], *args, **kwargs)

Bases: ipmininet.srv6.SRv6EndFunction

This class represents an SRv6 End.X function

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed
  • to – Either directly the prefix, an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
  • nexthop – The nexthop to consider when forwarding the packet. It can be an IPv6 address, an IPIntf or an IPNode. In both later cases, the default IPv6 address is selected.
ACTION = 'End.X'
params
class ipmininet.srv6.SRv6Route(net: ipmininet.ipnet.IPNet, node: Union[ipmininet.router.__router.IPNode, str], to: Union[str, ipaddress.IPv6Network, ipmininet.router.__router.IPNode, ipmininet.link.IPIntf] = '::/0', cost=1, table: Optional[ipmininet.srv6.LocalSIDTable] = None)

Bases: object

The SRv6Route abstract class, which enables to create an SRv6 route

Parameters:
  • net – The IPNet instance
  • node – The IPNode object on which the route has to be installed or the name of this node
  • to – Either directly the prefix, an IPNode, a name of an IPNode or an IPIntf object so that it matches all its addresses.
  • cost – The cost of using the route: routes with lower cost is preferred if the destination prefix is the same.
  • table – Install the route into the specified table instead of the main one.
build_commands() → List[str]
cleanup()
dest_prefixes() → List[str]
install()
is_available() → bool

Check the compatibility with this encapsulation method

nexthops_to_ips(nexthops: List[Union[str, ipmininet.router.__router.IPNode, ipmininet.link.IPIntf, ipaddress.IPv6Address, ipaddress.IPv4Address]], v6=True) → List[str]
Parameters:
  • nexthops – Each element of the list can either be an IP or IPv6 address, an IPIntf, an IPNode or the name of an IPNode. In the last 3 cases, the default IPv6 address is selected.
  • v6 – Whether we return IPv6 or IPv4 addresses
Returns:

a list of addresses

ipmininet.srv6.check_srv6_compatibility() → bool
Returns:True if the distribution supports SRv6
ipmininet.srv6.enable_srv6(node: ipmininet.router.__router.IPNode)

Enable IPv6 Segment Routing parsing on all interfaces of the node

ipmininet.srv6.srv6_segment_space(node: Union[str, ipmininet.router.__router.IPNode, None] = None, intf: Union[str, ipmininet.link.IPIntf] = 'lo') → List[ipaddress.IPv6Network]
Parameters:
  • node – The IPNode object representing the node
  • intf – Either the interface name (in which case the node parameter has to be filled) or the IPIntf object representing the interface
Returns:

The segment space of the interface of the node