ipmininet.ipnet module

IPNet: The Mininet that plays nice with IP networks. This modules will auto-generate all needed configuration properties if unspecified by the user

class ipmininet.ipnet.BroadcastDomain(interfaces: Union[None, List[ipmininet.link.IPIntf], ipmininet.link.IPIntf] = None)

Bases: object

An IP broadcast domain in the network. This class stores the set of interfaces belonging to the same broadcast domain, as well as the associated IP prefix if any

Initialize the broadcast domain and optionally explore a set of interfaces

Parameters:interfaces – one Intf or a list of Intf
BOUNDARIES = (<class 'mininet.node.Host'>, <class 'ipmininet.host.__host.IPHost'>, <class 'ipmininet.router.__router.Router'>)
explore(itfs: List[ipmininet.link.IPIntf])

Explore a new list of interfaces and add them and their neighbors to this broadcast domain

Parameters:itfs – a list of Intf
static is_domain_boundary(node: mininet.node.Node)

Check whether the node is a L3 broadcast domain boundary

Parameters:node – a Node instance
len_v4() → int

The number of IPv4 addresses in this broadcast domain

len_v6() → int

The number of IPv6 addresses in this broadcast domain

max_v4prefixlen

Return the maximal IPv4 prefix suitable for this domain

max_v6prefixlen

Return the maximal IPv6 prefix suitable for this domain

next_ipv4() → ipaddress.IPv4Interface

Allocate and return the next available IPv4 address in this domain

Return ip_interface:
 
next_ipv6() → ipaddress.IPv6Interface

Allocate and return the next available IPv6 address in this domain

Return ip_interface:
 
routers

List all interfaces in this domain belonging to a L3 router

use_ip_version(ip_version) → bool

Checks whether there are nodes using this IP version

Parameters:ip_version – either 4 or 6
Returns:True iif there is more than one interface on the domain enabling this IP version
class ipmininet.ipnet.IPNet(router: Type[ipmininet.router.__router.Router] = <class 'ipmininet.router.__router.Router'>, config: Type[ipmininet.router.config.base.RouterConfig] = <class 'ipmininet.router.config.base.BasicRouterConfig'>, use_v4=True, ipBase='192.168.0.0/16', max_v4_prefixlen=24, use_v6=True, ip6Base='fc00::/7', allocate_IPs=True, max_v6_prefixlen=48, igp_metric=1, igp_area='0.0.0.0', host: Type[ipmininet.host.__host.IPHost] = <class 'ipmininet.host.__host.IPHost'>, link: Type[ipmininet.link.IPLink] = <class 'ipmininet.link.IPLink'>, intf: Type[ipmininet.link.IPIntf] = <class 'ipmininet.link.IPIntf'>, switch: Type[ipmininet.ipswitch.IPSwitch] = <class 'ipmininet.ipswitch.IPSwitch'>, controller: Optional[Type[mininet.node.Controller]] = None, *args, **kwargs)

Bases: mininet.net.Mininet

IPNet: An IP-aware Mininet

Extends Mininet by adding IP-related ivars/functions and configuration knobs.

Parameters:
  • router – The class to use to build routers
  • config – The default configuration for the routers
  • use_v4 – Enable IPv4
  • max_v4_prefixlen – The maximal IPv4 prefix for the auto-allocated broadcast domains
  • use_v6 – Enable IPv6
  • ip6Base – Base prefix to use for IPv6 allocations
  • max_v6_prefixlen – Maximal IPv6 prefixlen to auto-allocate
  • allocate_IPs – whether to auto-allocate subnets in the network
  • igp_metric – The default IGP metric for the links
  • igp_area – The default IGP area for the links
addHost(name: str, **params) → ipmininet.host.__host.IPHost

Prevent Mininet from forcing the allocation of IPv4 addresses on hosts. We delegate it to the address auto-allocation of IPNet.

Register a link with additional properties

Parameters:
  • igp_metric – the associated igp metric for this link
  • igp_area – the associated igp area for this link
  • igp_passive – whether IGP should create adjacencies over this link or not
  • v4_width – the number of IPv4 addresses to allocate on the interfaces
  • v6_width – the number of IPv6 addresses to allocate on the interfaces
  • ra – list of AdvPrefix objects, each one representing an advertised prefix
  • rdnss – list of AdvRDNSS objects, each one representing an advertised DNS server
addRouter(name: str, cls=None, **params) → ipmininet.router.__router.Router

Add a router to the network

Parameters:
  • name – the node name
  • cls – the class to use to instantiate it
build()

Build mininet.

buildFromTopo(topo)

Build mininet from a topology object At the end of this function, everything should be connected and up.

node_for_ip(ip: Union[str, ipaddress.IPv4Address, ipaddress.IPv6Address]) → mininet.node.Node

Return the node owning a given IP address

Parameters:ip – an IP address
Returns:a node name
ping(hosts: Optional[List[mininet.node.Node]] = None, timeout: Optional[str] = None, use_v4=True, use_v6=True) → float

Ping between all specified hosts. If use_v4 is true, pings over IPv4 are used between any pair of hosts having at least one IPv4 address on one of their interfaces (loopback excluded). If use_v6 is true, pings over IPv6 are used between any pair of hosts having at least one non-link-local IPv6 address on one of their interfaces (loopback excluded).

Parameters:
  • hosts – list of hosts or None if all must be pinged
  • timeout – time to wait for a response, as string
  • use_v4 – whether IPv4 addresses can be used
  • use_v6 – whether IPv6 addresses can be used
Returns:

the packet loss percentage of IPv4 connectivity if self.use_v4 is set the loss percentage of IPv6 connectivity otherwise

ping4All(timeout: Optional[str] = None)

Ping (IPv4-only) between all hosts. return: ploss packet loss percentage

ping4Pair()

Ping (IPv4-only) between first two hosts, useful for testing. return: ploss packet loss percentage

ping6All(timeout: Optional[str] = None)

Ping (IPv6-only) between all hosts. return: ploss packet loss percentage

ping6Pair()

Ping (IPv6-only) between first two hosts, useful for testing. return: ploss packet loss percentage

pingAll(timeout: Optional[str] = None, use_v4=True, use_v6=True)

Ping between all hosts. return: ploss packet loss percentage

pingPair(use_v4=True, use_v6=True)

Ping between first two hosts, useful for testing. return: ploss packet loss percentage

randomFailure(n: int, weak_links: Optional[List[ipmininet.link.IPLink]] = None) → List[ipmininet.link.IPIntf]

Randomly down ‘n’ link

Parameters:
  • n – the number of link to be downed
  • weak_links – the list of links that can be downed; if set to None, every network link can be downed
Returns:

the list of interfaces which were downed

static restoreIntfs(interfaces: List[ipmininet.link.IPIntf])

Restore interfaces

Parameters:interfaces – the list of interfaces to restore
runFailurePlan(failure_plan: List[Tuple[str, str]]) → List[ipmininet.link.IPIntf]

Run a failure plan

Param:A list of pairs of node names: links connecting these two links will be downed
Returns:A list of interfaces that were downed
start()

Start controller and switches.

stop()

Stop the controller(s), switches and hosts