Assignment 2
Assignment 2
Overview
The network you'll use in this exercise includes hosts and switches connected in a linear
topology, as shown in the figure below.
Creating Topology
Mininet supports parametrized topologies. With a few lines of Python code, you can create a
flexible topology which can be configured based on the parameters you pass into it, and reused
for multiple experiments.
For example, here is a simple network topology (based on Figure 1) which consists of a
specified number of hosts (h1 through hN) connected to their individual switches (s1 through
sN):
Linear Topology (without Performance Settings)
#!/usr/bin/python
class LinearTopo(Topo):
"Linear topology of k switches, with one host per switch."
super(LinearTopo, self).__init__(**opts)
self.k = k
lastSwitch = None
for i in irange(1, k):
host = self.addHost('h%s' % i)
switch = self.addSwitch('s%s' % i)
self.addLink( host, switch)
if lastSwitch:
self.addLink( switch, lastSwitch)
lastSwitch = switch
def simpleTest():
"Create and test a simple network"
topo = LinearTopo(k=4)
net = Mininet(topo)
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)
print "Testing network connectivity"
net.pingAll()
net.stop()
if __name__ == '__main__':
# Tell mininet to print useful information
setLogLevel('info')
simpleTest()
The important classes, methods, functions and variables in the above code include:
class LinearTopo(Topo):
"Linear topology of k switches, with one host per switch."
super(LinearTopo, self).__init__(**opts)
self.k = k
lastSwitch = None
for i in irange(1, k):
host = self.addHost('h%s' % i, cpu=.5/k)
switch = self.addSwitch('s%s' % i)
# 10 Mbps, 5ms delay, 1% loss, 1000 packet queue
self.addLink( host, switch, bw=10, delay='5ms', loss=1,
max_queue_size=1000, use_htb=True)
if lastSwitch:
self.addLink(switch, lastSwitch, bw=10, delay='5ms', loss=1,
max_queue_size=1000, use_htb=True)
lastSwitch = switch
def perfTest():
"Create network and run simple performance test"
topo = LinearTopo(k=4)
net = Mininet(topo=topo,
host=CPULimitedHost, link=TCLink)
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)
print "Testing network connectivity"
net.pingAll()
print "Testing bandwidth between h1 and h4"
h1, h4 = net.get('h1', 'h4')
net.iperf((h1, h4))
net.stop()
if __name__ == '__main__':
setLogLevel('info')
perfTest()
Running in Mininet
To run the custom topology you have created above, follow the instructions below:
$ sudo ./LinearTopo.py
Output
Assignment
Background
Data center networks typically have a tree-like topology. End-hosts connect to top-of-rack
switches, which form the leaves (edges) of the tree; one or more core switches form the root;
and one or more layers of aggregation switches form the middle of the tree. In a basic tree
topology, each switch (except the core switch) has a single parent switch. Additional switches
and links may be added to construct more complex tree topologies (e.g., fat tree) in an effort to
improve fault tolerance or increase inter-rack bandwidth.
In this assignment, your task is to create a simple tree topology. You will assume each level i.e.,
core, aggregation, edge and host to be composed of a single layer of switches/hosts with a
configurable fanout value (k). For example, a simple tree network having a single layer per each
level and a fanout of 2 looks like:
CustomTopo.py
The skeleton class takes following arguments as input:
Your logic should support setting at least bw and delay parameters for each link.