cohydra.network

A subnet.

Functions

network_address_helper

Classes

Network

A network connects many nodes together and assigns IP addresses.


cohydra.network.network_address_helper(network, base)[source]
class cohydra.network.Network(network_address, netmask=None, base=None)[source]

Bases: object

A network connects many nodes together and assigns IP addresses.

It can be compared to a subnet or so. It should also support IPv6 (untested!).

Parameters
  • network_address (str) – The network base address (and optional subnet mask). An example for this parameter could be "10.42.42.0/24".

  • netmask (str) – The networks subnet mask. It can be used to provide a mask if not already given in the network_address parameter.

  • base (str) – The base / start for the IP-addresses of this network. An IPv4 example for this parameter could be "0.0.0.50".

channels = None

All the channels in the network.

network = None

The network’s address (containing the subnet mask).

address_helper = None

A helper used to generate the neccessary IP addresses.

color = None

The color of the network’s nodes in a visualization.

connect(*nodes, channel_type=<class 'cohydra.channel.csma.CSMAChannel'>, **kwargs)[source]

Connects to or more nodes on a single conection.

This is comparable to inserting a cable between them. Necessary configuration can be passed to the channel creation with keyword arguments.

Parameters
  • nodes (list of Node) – The nodes to connect on one physical connection. These must be instances of subclasses of Node.

  • channel_type (class) – The channel to use. This can be one of CSMAChannel or WiFiChannel.

prepare(simulation, network_index)[source]

Prepares the network by building the docker containers.

Warning: Don’t call this function manually.

Parameters
  • simulation (Simulation) – The simulation to prepare the network for.

  • network_index (int) – The index of the network (needed for coloring).

Inheritance Diagramm

Inheritance diagram of cohydra.network