Skip to content

Network Configuration

Daniel Zappala edited this page Jan 26, 2016 · 4 revisions

Node and Link Configuration

To configure a network, use the following syntax:

net = Network('../networks/one-hop.txt')

This creates a network using a configuration file. The configuration file has the following format:

# n1 -- n2
#
n1 n2
n2 n1

# link configuration
n1 n2 10Mbps 10ms
n2 n1 10Mbps 10ms

The first set of lines is the node configuration, followed by a blank line, and then a set of lines for the link configuration. Comments start with a "#" character.

Node Configuration

The first set of lines configures the connectivity of the network. Each line lists a node and then a list of nodes it is adjacent to. In this case the line:

n1 n2

indicates node n1 is connected with a unidirectional link to n2. The following line indicates n2 is likewise connected to n1 with a unidirectional link. You can list more than one node, for example:

n1 n2 n3 n4 n5

indicates n1 is connected to n2, n3, n4, and n5, each with a separate unidirectional link.

The node configuration must end with a blank line to separate them from the link configuration.

Link Configuration

The next set of lines provides link configuration. By default, all links have a bandwidth of 1 Mbps, with a propagation delay of 1 ms, and infinite queue, and no random loss.

The line:

n1 n2 10Mbps 10ms

changes the bandwidth of the link from n1 to n2 to be 10 Mbps and changes the propagation delay to 10 ms. The bandwidth can be expressed in terms of Gbps, Mbps, Kbps, or bps. The delay must be in ms. You can also configure queue size by using "100packets" and the loss with "0.1loss". The queue size must be in terms of packets and the loss rate is a floating point number between 0 and 1.

Any link parameters can be given in any order, so this is also valid:

n1 n2 100packets 10ms 10Gbps

Lines starting with "#" are ignored.

Instances of nodes and links

To get an instance of a node from the network configuration:

n1 = net.get_node('n1')
n2 = net.get_node('n2')  

To get an instance of a link:

l=n1.links[0]

Link 0 is the first link listed in the adjacency list given in the network configuration file.

Every link is assigned an address automatically by the network configuration. To get th address for a link, use:

n2.get_address('n1')

This gets the address at n2 that is assigned to the link that goes from n1 to n2. A node will have multiple addresses, depending on how many links it has. For example:

n2.get_address('n3')

This gets the address at n2 that is assigned to the link that goes from n3 to n2. This is similar to the real world, where every network adapter in your computer has a separate IP address.

Forwarding Tables

After creating the network, use forwarding table entries to tell the simulator how to forward packets, using this syntax:

node.add_forwarding_entry(address,link)

The address is the identifier for a link, and the link parameter is an instance of a link. For example, assume a network configuration that has just two nodes with a link from n1 to n2 and a link from n2 to n1. (See simple.py in the examples folder.)

To add a forwarding entry from n1 to n2:

n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])

This uses the address from at n2 for the link from n1 to n2, and the link 0 from n1's adjacency list. This means that if n1 receives a packet going to "n2's address for the link n1->n2", then the simulator will send this packet to n2 using *n1's link at index zero in the adjacency list".

This lets you send packets from n1 to n2. You will likewise need:

n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])

to forward packets from n2 to n1.

Routing Errors

If packets are not being delivered as expected, this means you do not have the forwarding table entries setup properly. For example, if n1 receives a packet going to n2 (more specifically, one of its addresses),but n1 has no forwarding table entry for this address, it will drop the packet.

If packets are looping forever unexpectedly, this likely means you do not have the forwarding table entries setup properly. For example, if you tried to create a forwarding entry to send packets from n1 to n3, and used n3.get_address('n1'), but there is no link from n1 to n3, then the address will be set to zero. This is the same as the broadcast address, so packets will be broadcasted and will loop indefinitely.

Clone this wiki locally