Topology

Address

Handles addresses of interfaces

class nest.topology.address.Address(addr_str: str)

Bases: object

Validate IP addresses and provide some basic APIs to obtain information about the IP address.

static allowed_type_cast()

Indicate str can be typecasted into Address type

get_addr(with_subnet=True)

Getter for ip_addr

Parameters:

with_subnet – (Default value = True)

Returns:

IP address as string

Return type:

str

get_subnet()

Get the subnet of the given address

is_ipv6()

Check if the address is IPv6 or not Note: This takes care of ‘DEFAULT’ also

is_subnet()

Check if the address is a subnet or not

class nest.topology.address.Subnet(address: Address)

Bases: object

For generating sequential addresses in a subnet

property counter

Getter for counter

get_next_addr()

Get next address in sequence in the subnet

property network_address

Getter for network address

Interface

This folders contains implementation for various interfaces which will be used by NeST users.

Node

API related to node creation in topology

class nest.topology.node.Node(name: str)

Bases: object

Abstraction for a network namespace.

name

User given name for the node.

Type:

str

add_mptcp_monitor()

Run MPTCP Monitor on node

add_route(dest_addr: Address, via_interface: BaseInterface, next_hop_addr: Address = None)

Add a route to the routing table of Node.

Parameters:
  • dest_addr (Address/str) – Destination IP address of node to route to. ‘DEFAULT’ is for all addresses

  • via_interface (BaseInterface) – Interface in Node to route via

  • next_hop_addr (Address/str, optional) – IP address of next hop Node (or router), by default ‘’

add_route_mpls_pop(incoming_label: int, next_hop_addr: Address)
Parameters:
  • incoming_label (THe label that the packet carries when entering the interface)

  • next_hop_addr (IP address of the next hop)

add_route_mpls_push(dest_addr: Address, next_hop_addr: Address, label: int)

Add a route to the routing table of Node.

Parameters:
  • dest_addr (Address/str) – Destination ip address of node to route to. ‘DEFAULT’ is for all addresses

  • next_hop_addr (Address/str, optional) – IP address of next hop Node (or router), by default ‘’

  • label (the MPLS label pushed onto the packet)

add_route_mpls_switch(incoming_label: int, next_hop_addr: Address, outgoing_label: int)
Parameters:
  • incoming_label (The label that the packet carries when entering the interface)

  • next_hop_addr (IP address of the next hop)

  • outgoing_label (The label that is pushed onto the packet)

capture_packets(interface: BaseInterface = None, packet_count: int = None, timeout: int = None, output_file: str = None, output_format: str = None, **kwargs)

Packets are captured from this node

Parameters:

interface (BaseInterface) – If the packets need to be captured from only one specific interface

configure_tcp_param(param, value)

Configure TCP parameters of Node available at /proc/sys/net/ipv4/tcp_*.

Example: ‘window_scaling’, ‘wmem’, ‘ecn’, etc.

If TCP Parameter param is valid, then new value is set for this param.

Parameters:
  • param (str) – TCP parameter to be configured

  • value (str) – New value of TCP parameter param

configure_udp_param(param, value)

Configure UDP parameters of Node available at /proc/sys/net/ipv4/udp_*.

Example: ‘early_demux’, ‘l3mdev_accept’, ‘rmem_min’, ‘wmem_min’

If UDP Parameter param is valid, then new value is set for this param.

Parameters:
  • param (str) – TCP parameter to be configured

  • value (str) – New value of TCP parameter param

delete_arp_entry(ip_address: Address)

Delete an ARP table entry for a specified IP address from the current Node

Parameters:

ip_address (Address) – The IP address of the ARP table entry to be deleted.

Returns:

Returns True if the ARP table entry for the specified IP address is successfully deleted from the Node. Else False

Return type:

bool

disable_ip_dad()

Disables Duplicate addresses Detection (DAD) for all interfaces of Node.

disable_mptcp()

Disable MPTCP sysctl on Node

enable_ip_forwarding(ipv4=True, ipv6=True)

Enable IP forwarding in Node.

After this method runs, the Node can be used as a router.

enable_mptcp()

Enable MPTCP sysctl on Node

flush_arp_table()

Delete all ARP table entries for the current Node.

Returns:

Returns True if all entries were deleted successfully. Else False

Return type:

bool

get_arp_entry(ip_address: Address)

Retrieve the ARP table entry for a specified IP address from the current Node.

Parameters:

ip_address (Address) – The IP address for which to retrieve the ARP table entry.

Returns:

Returns True if the entry for the specified IP address was received successfully. Else False

Return type:

bool

get_arp_table()

Retrieve the ARP table for the current Node

Returns:

Returns True if the ARP table is successfully retrieved from the Node. Else False.

Return type:

bool

get_interface(node: Node, connection_number: int = 1)

Get the interface in self connected to node. By default, this returns a veth interface.

connection_number is an optional argument used when there multiple connections between self and node.

Parameters:
  • node (Node) – The other end point of the veth interface

  • connection_number (int) – If there are multiple connections, then this argument uniquely identifies the connection

Returns:

Return the interface between self and node. Use connection_number to uniquly identify an interface if there are multiple connections. If no interface is found, then return None.

Return type:

Interface

get_mptcp_endpoints()

Gets the MPTCP endpoints of all interfaces on the Node

property id

Value used by engine to create the emulated Node entity

Type:

str

property interfaces

List of interfaces in this node

Type:

list(Interface)

is_mptcp_supported()

Is MPTCP Supported?

An MPTCP connection can be setup only if either of the TCP hosts are multihomed and multiaddressed. This function returns whether this condition is satisfied by the current node (self).

property name

User given name for Node

Type:

str

ping(destination_address: Address, preload: int = 1, packets: int = 5, verbose: int = 2)

Ping from current Node to destination address if there is a route.

Parameters:
  • destination_address (Address/str) – IP address to ping to

  • preload (int (Default is 1)) – Number of packets sent as fast as possible without waiting for reply.

  • packets (int) – Number of ping packets sent

  • verbose (int) – If verbose = ‘0’, no output is printed to stdout. If verbose = ‘1’, output if ping succeeded or failed. If verbose = ‘2’, output details of each ping packet.

Returns:

True if Node can successfully ping destination_address. Else False.

Return type:

bool

print_routes_to_file(*args)

Get the routes from the routing table of a Node.

Parameters *args: Interface object

read_tcp_param(param)

Read TCP parameters of Node available at /proc/sys/net/ipv4/tcp_*.

Example: ‘window_scaling’, ‘wmem’, ‘ecn’, etc.

Parameters:

param (str) – TCP parameter to be read

Returns:

If TCP Parameter param is valid, then corresponding value is returned.

Return type:

str

read_udp_param(param)

Read UDP parameters of Node`available at `/proc/sys/net/ipv4/udp_*.

Example: ‘early_demux’, ‘l3mdev_accept’, ‘rmem_min’, ‘wmem_min’

Parameters:

param (str) – UDP parameter to be read

Returns:

If UDP Parameter param is valid, then corresponding value is returned.

Return type:

str

set_arp_entry(ip_address: Address, mac_address: str)

Set the ARP table entry for a specified IP address and MAC address from the given Node.

Parameters:
  • ip_address (Address) – The IP address for which to retrieve the ARP table entry.

  • mac_address (string) – The MAC address for which to set the ARP table entry.

Returns:

Returns True if the entry for the specified IP address was received successfully. Else False

Return type:

bool

set_mptcp_parameters(max_subflows: int, max_add_addr_accepted: int)

Set MPTCP node parameters

Parameters:
  • max_subflows (int)

  • max_add_addr_accepted (int)

Traffic Control