Ejemplo n.º 1
0
def fat_tree(k):
    """
    Generates a fat tree topology using: https://fnss.readthedocs.io/en/latest/apidoc/generated/fnss.topologies.datacenter.fat_tree_topology.html
    
    Parameters
    ----------
    k: int
      Number of ports per switch

    Returns
    -------
    fnss.DatacenterTopology
    """
    
    # Hacky patch to get fnss to work with networkx 2.3. a better
    # patch is submitted to fnss https://github.com/fnss/fnss/pull/27
    fnss.DatacenterTopology.node = property(lambda self: self.nodes)
    
    return fnss.fat_tree_topology(k)
Ejemplo n.º 2
0
def get_fattree_topo(k):
    fnss_topo = fnss.fat_tree_topology(k)
    return fnss.to_mininet(fnss_topo)
This requires FNSS and Mininet to be installed on the machine.
"""
import fnss
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
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)
Ejemplo n.º 4
0
 def test_fat_tree(self):
     topology = fnss.fat_tree_topology(8)
     self.assertEqual(len(topology), 208)
Ejemplo n.º 5
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()
Ejemplo n.º 6
0
 def test_fat_tree(self):
     topology = fnss.fat_tree_topology(8)
     self.assertEqual(len(topology), 208)
Ejemplo n.º 7
0
def get_fattree_topo(k):
    fnss_topo = fnss.fat_tree_topology(k)
    return fnss.to_mininet(fnss_topo)