Esempio n. 1
0
 def test_to_mininet(self):
     t = fnss.Topology()
     t.add_path([1, 2, 3, 4])
     for n in (1, 4):
         t.node[n]['type'] = 'host'
     for n in (2, 3):
         t.node[n]['type'] = 'switch'
     fnss.set_capacities_constant(t, 10, 'Mbps')
     fnss.set_delays_constant(t, 10, 'ms')
     mn_topo = fnss.to_mininet(t, relabel_nodes=False)
     self.assertIsNotNone(mn_topo)
     hosts = mn_topo.hosts()
     switches = mn_topo.switches()
     for h in '1', '4':
         self.assertIn(h, hosts)
     for s in '2', '3':
         self.assertIn(s, switches)
     mn_topo = fnss.to_mininet(t, relabel_nodes=True)
     # Relabeling should be:
     # 1 -> h1
     # 2 -> s1
     # 3 -> s2
     # 4 -> h2
     self.assertIsNotNone(mn_topo)
     hosts = mn_topo.hosts()
     switches = mn_topo.switches()
     for h in 'h1', 'h2':
         self.assertIn(h, hosts)
     for s in 's1', 's2':
         self.assertIn(s, switches)
Esempio n. 2
0
 def test_to_mininet(self):
     t = fnss.Topology()
     t.add_path([1, 2, 3, 4])
     for n in (1, 4):
         t.node[n]['type'] = 'host'
     for n in (2, 3):
         t.node[n]['type'] = 'switch'
     fnss.set_capacities_constant(t, 10, 'Mbps')
     fnss.set_delays_constant(t, 10, 'ms')
     mn_topo = fnss.to_mininet(t, relabel_nodes=False)
     self.assertIsNotNone(mn_topo)
     hosts = mn_topo.hosts()
     switches = mn_topo.switches()
     for h in '1', '4':
         self.assertIn(h, hosts)
     for s in '2', '3':
         self.assertIn(s, switches)
     mn_topo = fnss.to_mininet(t, relabel_nodes=True)
     # Relabeling should be:
     # 1 -> h1
     # 2 -> s1
     # 3 -> s2
     # 4 -> h2
     self.assertIsNotNone(mn_topo)
     hosts = mn_topo.hosts()
     switches = mn_topo.switches()
     for h in 'h1', 'h2':
         self.assertIn(h, hosts)
     for s in 's1', 's2':
         self.assertIn(s, switches)
Esempio n. 3
0
 def test_to_mininet(self):
     t = fnss.Topology()
     t.add_path([1, 2, 3, 4])
     for n in (1, 4):
         t.node[n]['type'] = 'host'
     for n in (2, 3):
         t.node[n]['type'] = 'switch'
     fnss.set_capacities_constant(t, 10, 'Mbps')
     fnss.set_delays_constant(t, 10, 'ms')
     mn_topo = fnss.to_mininet(t)
     self.assertIsNotNone(mn_topo)
     hosts = mn_topo.hosts()
     switches = mn_topo.switches()
     for h in '1', '4':
         self.assertIn(h, hosts)
     for s in '2', '3':
         self.assertIn(s, switches)
def main():
    G = nx.Graph()
    G = nx.read_gpickle("mendocino.gpickle")

    fnss_topo = from_autonetkit(G)

    node_types = nx.get_node_attributes(fnss_topo, 'type')

    hosts = []
    switches = []

    for node in fnss_topo.nodes():
        nodetype = G.node[node]['type']
        if nodetype == 'cpe':
            hosts.append(node)
        else:
            switches.append(node)

    mn_topo = fnss.to_mininet(fnss_topo,
                              switches=switches,
                              hosts=hosts,
                              relabel_nodes=True)

    net = Mininet(topo=mn_topo, link=TCLink, controller=None)
    c0 = net.addController(name='c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           protocol='tcp',
                           port=6653)

    net.start()

    # Dump host connections
    dumpNodeConnections(net.hosts)

    # Test network connectivity
    #net.pingAll()

    # Test bandwidth between nodes
    #h1, h8 = net.get('h1', 'h8')
    #net.iperf((h1, h8))

    # Stop Mininet
    CLI(net)
    net.stop()
Esempio n. 5
0
def main(n):
    # generate_topo(n)
    topo = fnss.read_topology('topo_'+'ft'+'.xml') # return fnss.Topology
    # plot_topo(topo,'ft')
    # addition_for_pl(topo)
    mn_topo = fnss.to_mininet(topo,relabel_nodes=True)
    # add_hosts_for_pl(topo,mn_topo)
    net = Mininet(topo=mn_topo,
                  link=TCLink,
                  switch=CustomSwitch,
                  controller=None,
                  cleanup=True)
    net.addController( controller=RemoteController,
                       ip=CONTROLLER_IP,
                       port=CONTROLLER_PORT)
    net.start()
    CLI(net)
    net.stop()
Esempio n. 6
0
def topology():

    fnss_topology = fnss.parse_topology_zoo('AttMpls.gml')
    #fnss.two_tier_topology(1, 2, 2)
    "Create a network with some docker containers acting as hosts."

    # Set link attributes
    # https://fnss.github.io/doc/core/apidoc/fnss.functions.html
    #fnss.set_capacities_constant(fnss_topology, 10, 'Mbps')
    #fnss.set_delays_constant(fnss_topology, 2, 'ms')
    #fnss.set_buffer_sizes_constant(fnss_topology, 50, 'packets')
    fnss.set_delays_geo_distance(fnss_topology,
                                 specific_delay=fnss.PROPAGATION_DELAY_FIBER)

    mn_topo = fnss.to_mininet(fnss_topology, relabel_nodes=True)
    for node in mn_topo.hosts():
        mn_topo.setNodeInfo(
            node, {
                "dcmd": ["/bin/bash", "/ndn-entrypoint.sh"],
                "dimage": "ndnrepo_ndn:latest",
                "privileged": True,
                "cls": Docker
            })
        #mn_topo.setNodeInfo(node, "privileged", True )
        #mn_topo.setNodeInfo(node, "dimage", "ndnrepo_ndn:latest" )
        #node.dcmd=["/bin/bash", "/ndn-entrypoint.sh"]
        # = Docker('{0}'.format(node), ip='10.0.0.{0}'.format(node), , privileged=True, dimage="ndnrepo_ndn:latest")
        #node.type='host'
        #print node
        #nodes.append(node)

    net = NDNContainernet(topo=mn_topo, link=TCLink, controller=Controller)

    dumpNodeConnections(net.hosts)
    dumpNodeConnections(net.switches)
    fnss_topology.edges()
    info('*** Starting network\n')
    net.start()
    embed()

    #TODO Add NDN Links for all
    #fnss_topology.edges()
    #[(0, 1), (0, 2), (1, 3), (1, 4), (2, 5), (2, 6)]
    #addNDNRoute(d1, d2)

    #net = Containernet(controller=Controller)

    info('*** Adding controller\n')
    #net.addController('c0')

    info('*** Adding docker containers\n')
    #d1 = net.addDocker('d1', ip='10.0.0.251', dcmd=["/bin/bash", "/ndn-entrypoint.sh"], privileged=True, dimage="ndnrepo_ndn:latest")
    #d2 = net.addDocker('d2', ip='10.0.0.250', dcmd=["/bin/bash", "/ndn-entrypoint.sh"], privileged=True, dimage="ndnrepo_ndn:latest")

    #s1 = net.addSwitch('s1')

    info('*** Creating links\n')
    #net.addLink(d1, s1)
    #net.addLink(s1, d2)

    time.sleep(5)
    print addNDNRoute(d1, d2)
    #TODO create file when inserting is done
    while not (checkRepoNGInitDone(d1) and checkRepoNGInitDone(d2)):
        time.sleep(5)

    print listFilesInRepo(d1)
    print listFilesInRepo(d2)

    info('*** Running CLI\n')
    dumpNodeConnections(net.hosts)

    CLI(net)

    info('*** Stopping network')
    net.stop()
Esempio n. 7
0
def get_fattree_topo(k):
    fnss_topo = fnss.fat_tree_topology(k)
    return fnss.to_mininet(fnss_topo)
from mininet.cli import CLI
from mininet.node import RemoteController
from mininet.node import OVSController


# Create FNSS topology -- FatTree with k = 4
fnss_topo = fnss.fat_tree_topology(k=4)
# Set link attributes  10Mbps bandwidth
fnss.set_capacities_constant(fnss_topo, 10, "Mbps")
# Set link delay to be 2ms
fnss.set_delays_constant(fnss_topo, 2, "ms")
# Set switch buffer to be 50 packets size
fnss.set_buffer_sizes_constant(fnss_topo, 50, "packets")

# Convert FNSS topology to Mininet
mn_topo = fnss.to_mininet(fnss_topo, relabel_nodes=True)
# Create a remote controller object in local host
RemoteCon = RemoteController("RemoteCon1", ip="127.0.0.1")
# Create a Mininet instance and start it
# Use TCLink to implement links enables Linux Traffic Container (TC) for rate
# limitation
net = Mininet(topo=mn_topo, link=TCLink, controller=RemoteCon)
net.start()
# Dump host connections
dumpNodeConnections(net.hosts)
# Start CommandLine Interface
CLI(net)

# Test network connectivity
# net.pingAll()
# Test bandwidth between nodes
Esempio n. 9
0
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
from mininet.cli import CLI


# Create FNSS topology. Let's create a simple datacenter topology
fnss_topo = fnss.two_tier_topology(n_core=2, n_edge=2, n_hosts=2)

# Set link attributes
fnss.set_capacities_constant(fnss_topo, 10, 'Mbps')
fnss.set_delays_constant(fnss_topo, 2, 'ms')
fnss.set_buffer_sizes_constant(fnss_topo, 50, 'packets')

# Convert FNSS topology to Mininet
mn_topo = fnss.to_mininet(fnss_topo)

# Create a Mininet instance and start it
# Using TCLink to implement links enables Linux Traffic Container (TC) for rate
# limitation
net = Mininet(topo=mn_topo, link=TCLink)
net.start()

# Dumping host connections
dumpNodeConnections(net.hosts)

# Test network connectivity
net.pingAll()

# Test bandwidth between nodes"
# h1, h4 = net.get('1', '4')
Esempio n. 10
0
# Set nodes on bells to be hosts and nodes on bottleneck path to be switches.
# Differently from datacenter topologies, which already provide annotation of
# what nodes are hosts and switches, we need to explicitly tell which nodes
# are switches and which are hosts to deploy the topology in Mininet
hosts = left_nodes + right_nodes
switches = core_nodes

# Convert FNSS topology to Mininet
# If argument relabel_nodes is set to False, node labels are not changed when
# converting an FNSS topology to a Mininet one, except converting the type to
# string (e.g. 1 -> '1'). If relabel_nodes is set to True (default option)
# then nodes are label according to Mininet conventions, e.g. hosts are
# prepended an h (e.g. 1 -> 'h1') and switches are prepended an s
# (e.g. 2 -> 's2')
mn_topo = fnss.to_mininet(fnss_topo,
                          switches=switches,
                          hosts=hosts,
                          relabel_nodes=True)

# Create a Mininet instance and start it
# Use TCLink to implement links enables Linux Traffic Container (TC) for rate
# limitation
net = Mininet(topo=mn_topo, link=TCLink, controller=OVSController)
net.start()

# Dump host connections
dumpNodeConnections(net.hosts)

# Test network connectivity
net.pingAll()

# Test bandwidth between nodes
Esempio n. 11
0
# Set nodes on bells to be hosts and nodes on bottleneck path to be switches.
# Differently from datacenter topologies, which already provide annotation of
# what nodes are hosts and switches, we need to explicitly tell which nodes
# are switches and which are hosts to deploy the topology in Mininet 
hosts = left_nodes + right_nodes
switches = core_nodes

# Convert FNSS topology to Mininet
# If argument relabel_nodes is set to False, node labels are not changed when
# converting an FNSS topology to a Mininet one, except converting the type to
# string (e.g. 1 -> '1'). If relabel_nodes is set to True (default option)
# then nodes are label according to Mininet conventions, e.g. hosts are 
# prepended an h (e.g. 1 -> 'h1') and switches are prepended an s
# (e.g. 2 -> 's2') 
mn_topo = fnss.to_mininet(fnss_topo,
                          switches=switches, 
                          hosts=hosts,
                          relabel_nodes=True)

# Create a Mininet instance and start it
# Use TCLink to implement links enables Linux Traffic Container (TC) for rate
# limitation
net = Mininet(topo=mn_topo, link=TCLink, controller=OVSController)
net.start()

# Dump host connections
dumpNodeConnections(net.hosts)

# Test network connectivity
net.pingAll()

# Test bandwidth between nodes
Esempio n. 12
0
def build_topology():

	# We use fat tree topology for datacenters
	kval = 0
	edgeLinkCapacity = [10, 'Mbps']
	aggrLinkCapacity = [100,'Mbps']
	coreLinkCapacity = [1,  'Gbps']
	linkDelay		 = [10, 'ns']

	# Get the value from the network.config file
	lines = open('./network.config', 'r').readlines()
	for line in lines:
		val = line.split()
		if val[0] == "K_VALUE":
			kval = int(val[1])
		elif val[0] == "EDGE_LINK_SPEED":
			edgeLinkCapacity[0] = val[1]
			edgeLinkCapacity[1] = val[2]
		elif val[0] == "AGGR_LINK_SPEED":
			aggrLinkCapacity[0] = val[1]
			aggrLinkCapacity[1] = val[2]
		elif val[0] == "CORE_LINK_SPEED":
			coreLinkCapacity[0] = val[1]
			coreLinkCapacity[1] = val[2]
		elif val[0] == "LINK_DELAY":
			linkDelay[0] = val[1]
			linkDelay[1] = val[2]

	if kval == 0:
		print "ERROR: Wrong value of K for a fat tree topo, exiting"
		sys.exit(0)

	# Build the topology using fnss
	topology = fnss.fat_tree_topology(kval)

	# Get link types
	link_types = nx.get_edge_attributes(topology, 'type')

	edge_leaf_links = [link for link in link_types
                if link_types[link] == 'edge_leaf']

	aggregation_edge_links = [link for link in link_types
                if link_types[link] == 'aggregation_edge']

	core_edge_links = [link for link in link_types
                if link_types[link] == 'core_edge']

	# Set the link speeds
	fnss.set_capacities_constant(topology, edgeLinkCapacity[0], edgeLinkCapacity[1], edge_leaf_links)
	fnss.set_capacities_constant(topology, aggrLinkCapacity[0], aggrLinkCapacity[1], aggregation_edge_links)
	fnss.set_capacities_constant(topology, coreLinkCapacity[0], coreLinkCapacity[1], core_edge_links)

	# Set default weight of 1 to all links
	fnss.set_weights_constant(topology, 1)

	# Set link delay to be 10 ns
	fnss.set_delays_constant(topology, linkDelay[0], linkDelay[1])

	# Generate the topology.xml file
	fnss.write_topology(topology, 'topology.xml')

	# Create mininet topology from fnss with renaming to mininet format
	mn_topo = fnss.to_mininet(topology, relabel_nodes=True)

	net = Mininet(topo=mn_topo, link=TCLink, controller=None)

	net.addController('floodlight', controller=RemoteController, ip="127.0.0.1", port=6653)

	net.start()

	# Dump host connections
	dumpNodeConnections(net.hosts)

	# Test network connectivity
	net.pingAll()
Esempio n. 13
0
# https://github.com/mininet/mininet/wiki/Introduction-to-Mininet#multipath-routing
fnss_topo = fnss.two_tier_topology(n_core=1, n_edge=2, n_hosts=2)

# Set link attributes
fnss.set_capacities_constant(fnss_topo, 10, 'Mbps')
fnss.set_delays_constant(fnss_topo, 2, 'ms')
fnss.set_buffer_sizes_constant(fnss_topo, 50, 'packets')

# Convert FNSS topology to Mininet
# If argument relabel_nodes is set to False, node labels are not changed when
# converting an FNSS topology to a Mininet one, except converting the type to
# string (e.g. 1 -> '1'). If relabel_nodes is set to True (default option)
# then nodes are label according to Mininet conventions, e.g. hosts are
# prepended an h (e.g. 1 -> 'h1') and switches are prepended an s
# (e.g. 2 -> 's2')
mn_topo = fnss.to_mininet(fnss_topo, relabel_nodes=True)

# Create a Mininet instance and start it
# Use TCLink to implement links enables Linux Traffic Container (TC) for rate
# limitation
net = Mininet(topo=mn_topo, link=TCLink, controller=RemoteController)
c1 = net.addController('c1',
                       controller=RemoteController,
                       ip='127.0.0.1',
                       port=6633)
net.start()

# Dump host connections
dumpNodeConnections(net.hosts)

# Test network connectivity
Esempio n. 14
0
def get_fattree_topo(k):
    fnss_topo = fnss.fat_tree_topology(k)
    return fnss.to_mininet(fnss_topo)