How to import a graphml topology in mininet
If you want to load topologies in your network emulation with mininet, the best option is use grahpml format. I compared a lot extesions available from Gephi and Cytoscape (software for work with topologies) and graphml is one of the extensions that gives more information about the topology.
You can export your topologies and save information like label, geolocalization, delay, bw, loss, etc.
If you want real topologies, you can get them from Topology Zoo website.
To import these topologies to mininet, you can use Auto-Mininet (for mininet 2.0.0):
git clone https://github.com/uniba-ktr/assessing-mininet.git
cd assessing-mininet/parser
wget http://topology-zoo.org/files/Chinanet.graphml
./GraphML-Topo-to-Mininet-Network-Generator.py -f Chinanet.graphml -o chinaNet.py
python chinaNet.py
File "test", line 44
Xi'an = self.addSwitch( 's18' )
^
SyntaxError: invalid syntax
As you see, the script has incompatibility with names with special characters. If you try to convert a graphml generated with Gephi, you will get this error:
Traceback (most recent call last):
File "GraphML-Topo-to-Mininet-Network-Generator.py", line 340, in <module>
latitude_src = math.radians(float(id_latitude_dict[src_id]))
ValueError: could not convert string to float:
For this reason I created a new script to parse any graphml file throught python networkx library.
Here I put the most common issues to work with this library:
If you want to create links (edges) with tc properties like delay, bw, loss, etc. You must declarate this on your main.py script or when you call mininet from command line to avoid the following error:
TypeError: __init__() got an unexpected keyword argument 'loss'
TypeError: __init__() got an unexpected keyword argument 'bw'
TypeError: __init__() got an unexpected keyword argument 'delay'
If you call it from a python file you must add these lines:
net = Mininet(topo=topo, link=TCLink)
from mininet.link import TCLink
If you call it from mininet, you must add link Traffic Control option:
sudo mn --custom custom.py --topo customtopo --link tc
Now, If you want create a node variable without using the canonical switch name, you will see this error:
Caught exception. Cleaning up...
Exception: Unable to derive default datapath ID - please either specify a dpid or use a canonical switch name such as s23.
To avoid it, you must specify a dpid to the switch like this:
s1 = self.addSwitch('test',dpid='0000000000000001')
It's important check no spaces or commas in switches names to avoid this error by example:
KeyError: 'Washington,DC'
Also, no names over 10 characters (is better truncate them) to avoid this error:
Exception: Error creating interface pair (Chicago-eth2,Minneapolis-eth1): Error: argument "peer" is wrong: "name" too long
If you want to try my script (Alpha version) visit https://github.com/dragonxtek/mininet_tools
You can export your topologies and save information like label, geolocalization, delay, bw, loss, etc.
If you want real topologies, you can get them from Topology Zoo website.
To import these topologies to mininet, you can use Auto-Mininet (for mininet 2.0.0):
git clone https://github.com/uniba-ktr/assessing-mininet.git
cd assessing-mininet/parser
wget http://topology-zoo.org/files/Chinanet.graphml
./GraphML-Topo-to-Mininet-Network-Generator.py -f Chinanet.graphml -o chinaNet.py
python chinaNet.py
File "test", line 44
Xi'an = self.addSwitch( 's18' )
^
SyntaxError: invalid syntax
As you see, the script has incompatibility with names with special characters. If you try to convert a graphml generated with Gephi, you will get this error:
Traceback (most recent call last):
File "GraphML-Topo-to-Mininet-Network-Generator.py", line 340, in <module>
latitude_src = math.radians(float(id_latitude_dict[src_id]))
ValueError: could not convert string to float:
For this reason I created a new script to parse any graphml file throught python networkx library.
Here I put the most common issues to work with this library:
If you want to create links (edges) with tc properties like delay, bw, loss, etc. You must declarate this on your main.py script or when you call mininet from command line to avoid the following error:
TypeError: __init__() got an unexpected keyword argument 'loss'
TypeError: __init__() got an unexpected keyword argument 'bw'
TypeError: __init__() got an unexpected keyword argument 'delay'
If you call it from a python file you must add these lines:
net = Mininet(topo=topo, link=TCLink)
from mininet.link import TCLink
If you call it from mininet, you must add link Traffic Control option:
sudo mn --custom custom.py --topo customtopo --link tc
Now, If you want create a node variable without using the canonical switch name, you will see this error:
Caught exception. Cleaning up...
Exception: Unable to derive default datapath ID - please either specify a dpid or use a canonical switch name such as s23.
To avoid it, you must specify a dpid to the switch like this:
s1 = self.addSwitch('test',dpid='0000000000000001')
It's important check no spaces or commas in switches names to avoid this error by example:
KeyError: 'Washington,DC'
Also, no names over 10 characters (is better truncate them) to avoid this error:
Exception: Error creating interface pair (Chicago-eth2,Minneapolis-eth1): Error: argument "peer" is wrong: "name" too long
If you want to try my script (Alpha version) visit https://github.com/dragonxtek/mininet_tools
Comments
Post a Comment