def test_to_ns2_directed(self): t = fnss.DirectedTopology() t.add_path([1,2,3,4]) fnss.set_capacities_constant(t, 10, 'Gbps') fnss.set_delays_constant(t, 2, 'us') fnss.set_buffer_sizes_constant(t, 20, 'packets') fnss.to_ns2(t, path.join(TMP_DIR,'ns2-dir.tcl'), stacks=False)
def test_to_ns2_directed(self): t = fnss.DirectedTopology() t.add_path([1, 2, 3, 4]) fnss.set_capacities_constant(t, 10, 'Gbps') fnss.set_delays_constant(t, 2, 'us') fnss.set_buffer_sizes_constant(t, 20, 'packets') fnss.to_ns2(t, path.join(TMP_DIR, 'ns2-dir.tcl'), stacks=False)
def test_to_omnetpp_directed(self): t = fnss.DirectedTopology() t.add_path([1, 2, 3, 4]) fnss.set_capacities_constant(t, 10, 'Gbps') fnss.set_delays_constant(t, 2, 'us') fnss.set_buffer_sizes_constant(t, 20, 'packets') fnss.to_omnetpp(t, path.join(TMP_DIR, 'omnetpp-dir.ned'))
def test_buffers_size_constant_unit_mismatch(self): # If I try to set buffer sizes to some interfaces using a unit and some # other interfaces already have buffer sizes assigned using a different # unit, then raise an error and ask to use the unit previously used topo = fnss.line_topology(3) fnss.set_buffer_sizes_constant(topo, 10, 'packets', [(0, 1)]) self.assertRaises(ValueError, fnss.set_buffer_sizes_constant, topo, 200, 'bytes', [(1, 2)])
def parse(topo_path, xml_path, delay, buffer_type): topology = fnss.parse_topology_zoo(topo_path) topology = topology.to_undirected() fnss.set_capacities_edge_betweenness(topology, [200, 500, 1000], 'Mbps') # TODO: hardcode now fnss.set_weights_constant(topology, 1) fnss.set_delays_constant(topology, delay, 'ms') if buffer_type == 'bdp': fnss.set_buffer_sizes_bw_delay_prod(topology, 'packet', 1500) elif buffer_type == 'bw': fnss.set_buffer_sizes_link_bandwidth(topology, buffer_unit='packet') else: fnss.set_buffer_sizes_constant(topology, 1500, 'packet') fnss.write_topology(topology, xml_path)
def test_base_topology_class(self): weight = 2 capacity = 3 delay = 4 buffer_size = 5 topology = fnss.Topology() topology.add_path([1, 2, 3]) fnss.set_weights_constant(topology, weight) fnss.set_capacities_constant(topology, capacity) fnss.set_delays_constant(topology, delay) fnss.set_buffer_sizes_constant(topology, buffer_size) weights = topology.weights() capacities = topology.capacities() delays = topology.delays() buffer_sizes = topology.buffers() for e in topology.edges_iter(): self.assertEqual(weight, weights[e]) self.assertEqual(capacity, capacities[e]) self.assertEqual(delay, delays[e]) self.assertEqual(buffer_size, buffer_sizes[e])
def test_base_topology_class(self): weight = 2 capacity = 3 delay = 4 buffer_size = 5 topology = fnss.Topology() topology.add_path([1, 2, 3]) fnss.set_weights_constant(topology, weight) fnss.set_capacities_constant(topology, capacity) fnss.set_delays_constant(topology, delay) fnss.set_buffer_sizes_constant(topology, buffer_size) weights = topology.weights() capacities = topology.capacities() delays = topology.delays() buffer_sizes = topology.buffers() for e in topology.edges(): self.assertEqual(weight, weights[e]) self.assertEqual(capacity, capacities[e]) self.assertEqual(delay, delays[e]) self.assertEqual(buffer_size, buffer_sizes[e])
def test_buffers_size_constant(self): fnss.set_buffer_sizes_constant(self.topo, 65000, buffer_unit='bytes') self.assertTrue( all(self.topo.edge[u][v]['buffer'] == 65000 for (u, v) in self.topo.edges_iter()))
def test_get_buffer_sizes(self): fnss.set_buffer_sizes_constant(self.topo, 65000, buffer_unit='bytes') buffers = fnss.get_buffer_sizes(self.topo) self.assertTrue(all(buffers[(u, v)] == 65000 for (u, v) in buffers))
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) net.start() # Dump host connections dumpNodeConnections(net.hosts) # Start CommandLine Interface CLI(net)
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 import time # 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 time.sleep(20)
def test_buffers_size_constant(self): fnss.set_buffer_sizes_constant(self.topo, 65000, buffer_unit='bytes') self.assertTrue(all(self.topo.adj[u][v]['buffer'] == 65000 for (u, v) in self.topo.edges()))
core_links = [links for links in link_types if link_types[links] == 'core'] edge_links = [ links for links in link_types if link_types[links] == 'right_bell' or link_types[links] == 'left_bell' ] # set delay equal to 1 ms in edge links and equal to 2 ms in core links fnss.set_delays_constant(fnss_topo, 1, 'ms', edge_links) fnss.set_delays_constant(fnss_topo, 2, 'ms', core_links) # set capacity of 10 Mbps in edge links and 40 Mbps in core links fnss.set_capacities_constant(fnss_topo, 10, 'Mbps', edge_links) fnss.set_capacities_constant(fnss_topo, 40, 'Mbps', core_links) # Set buffer size constant to all interfaces fnss.set_buffer_sizes_constant(fnss_topo, 50, 'packets') # Now we deploy a traffic sources on right bell and traffic receivers on left # bell node_types = nx.get_node_attributes(fnss_topo, 'type') core_nodes = [nodes for nodes in node_types if node_types[nodes] == 'core'] left_nodes = [ nodes for nodes in node_types if node_types[nodes] == 'left_bell' ] right_nodes = [ nodes for nodes in node_types if node_types[nodes] == 'right_bell' ] # 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