|
|
@ -1,22 +1,13 @@
|
|
|
|
#!/usr/bin/env python
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from sys import argv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
|
|
|
|
|
|
|
|
from mininet.topo import Topo
|
|
|
|
from mininet.topo import Topo
|
|
|
|
from mininet.link import TCLink
|
|
|
|
from mininet.link import TCLink
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# It would be nice if we didn't have to do this:
|
|
|
|
|
|
|
|
# pylint: disable=arguments-differ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GraphmlTopo(Topo):
|
|
|
|
class GraphmlTopo(Topo):
|
|
|
|
|
|
|
|
|
|
|
|
def build(self, filename='topology.graphml'):
|
|
|
|
def build(self, filename='topology.graphml'):
|
|
|
|
|
|
|
|
|
|
|
|
positions = dict()
|
|
|
|
positions = dict()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -27,10 +18,9 @@ class GraphmlTopo(Topo):
|
|
|
|
|
|
|
|
|
|
|
|
for node in graph.iter('{http://graphml.graphdrawing.org/xmlns}node'):
|
|
|
|
for node in graph.iter('{http://graphml.graphdrawing.org/xmlns}node'):
|
|
|
|
node_id = int(node.get('id')) + 1
|
|
|
|
node_id = int(node.get('id')) + 1
|
|
|
|
privateDirs = ['/var/log','/var/run']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.addHost('h%i' % node_id, privateDirs=privateDirs) #,
|
|
|
|
privateDirs = ['/var/log','/var/run']
|
|
|
|
#cls=LinuxRouter)
|
|
|
|
self.addHost('h%i' % node_id, privateDirs=privateDirs)
|
|
|
|
|
|
|
|
|
|
|
|
x_pos = node.find('.//data[@key="x"]')
|
|
|
|
x_pos = node.find('.//data[@key="x"]')
|
|
|
|
y_pos = node.find('.//data[@key="y"]')
|
|
|
|
y_pos = node.find('.//data[@key="y"]')
|
|
|
@ -43,22 +33,41 @@ class GraphmlTopo(Topo):
|
|
|
|
source = int(link.get('source')) + 1
|
|
|
|
source = int(link.get('source')) + 1
|
|
|
|
target = int(link.get('target')) + 1
|
|
|
|
target = int(link.get('target')) + 1
|
|
|
|
|
|
|
|
|
|
|
|
intfName_s, addr1, params_s = self.format_intf_params(link_id, source)
|
|
|
|
linkopts = self.format_intf_params(source, target, link_id)
|
|
|
|
intfName_t, addr2, params_t = self.format_intf_params(link_id, target)
|
|
|
|
# dict(bw=10, delay='5ms', loss=20, max_queue_size=1000, use_htb=True)
|
|
|
|
|
|
|
|
# linkopts.update(self.)
|
|
|
|
linkopts = dict() # dict(bw=10, delay='5ms', loss=20, max_queue_size=1000, use_htb=True)
|
|
|
|
|
|
|
|
# to implement a function which from nodes positions return linkopts
|
|
|
|
# to implement a function which from nodes positions return linkopts
|
|
|
|
self.addLink('h%i' % source, 'h%i' % target, key=link_id, cls=TCLink,
|
|
|
|
self.addLink('h%i' % source, 'h%i' % target, cls=TCLink, **linkopts)
|
|
|
|
intfName1=intfName_s, addr1=addr1, params1=params_s,
|
|
|
|
|
|
|
|
intfName2=intfName_t, addr2=addr2 ,params2=params_t,
|
|
|
|
def format_intf_params(self, source_id, target_id, link_id):
|
|
|
|
**linkopts)
|
|
|
|
return dict()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GraphmlTopoUniqueSubnet(GraphmlTopo):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_intf_params(self, source_id, target_id, link_id):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
intf_name_s = 'h%i-eth%i' % (source_id, link_id)
|
|
|
|
|
|
|
|
intf_name_t = 'h%i-eth%i' % (target_id, link_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addr_s = '00:00:00:00:%02i:%02i' % (source_id, link_id)
|
|
|
|
|
|
|
|
addr_t = '00:00:00:00:%02i:%02i' % (target_id, link_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ip_s = '10.0.%i.%i/16' % (source_id, link_id)
|
|
|
|
|
|
|
|
ip_t = '10.0.%i.%i/16' % (target_id, link_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {'addr1' : addr_s, 'params1' : {'ip': ip_s},
|
|
|
|
|
|
|
|
'addr2' : addr_t, 'params2' : {'ip': ip_t}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GraphmlTopoDifferentSubnet(GraphmlTopo):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_intf_params(self, source_id, target_id, link_id):
|
|
|
|
|
|
|
|
|
|
|
|
def format_intf_params(self, link_id, node_id):
|
|
|
|
addr_s = '00:00:00:00:%02i:%02i' % (source_id, link_id)
|
|
|
|
intf_name = 'h%i-eth%i' % (node_id, link_id)
|
|
|
|
addr_t = '00:00:00:00:%02i:%02i' % (target_id, link_id)
|
|
|
|
addr = '00:00:00:00:%02i:%02i' % (link_id, node_id)
|
|
|
|
|
|
|
|
ip = '10.0.%i.%i/24' % (link_id, node_id)
|
|
|
|
|
|
|
|
params = {'ip': ip}
|
|
|
|
|
|
|
|
return intf_name, addr, params
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ip_s = '10.0.%i.%i/24' % (link_id, source_id)
|
|
|
|
|
|
|
|
ip_t = '10.0.%i.%i/24' % (link_id, target_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {'addr1' : addr_s, 'params1' : {'ip': ip_s},
|
|
|
|
|
|
|
|
'addr2' : addr_t, 'params2' : {'ip': ip_t}}
|
|
|
|