Experiment 1: SDN Topology Practice
1. Experimental Purpose
Ability to install Mininet using source code;
Ability to use Mininet's visualization tools to generate topologies;
Ability to use Mininet's command line to generate a specific topology;
Ability to manage SDN topology using Mininet interactive interface;
Ability to build SDN topologies using Python scripts.
2. Experimental Environment
Ubuntu 20.04 Desktop amd64
3. Experimental Requirements
(1) Basic requirements
Using the Mininet visualization tool, generate the topology shown in the figure below and save the topology file named student number.py.
Use Mininet's command line to generate the following topology:
A) Three switches, each connected to one host and three connected to one line.
b) 3 hosts, each connected to the same switch.
On the basis of 2b), add a new host on the Mininet interactive interface and connect to the switch, then test the connectivity of the new topology.
Edit the Python script saved in step 1 of the Basic Requirements, add the following network performance limitations, and generate the topology:
A) The maximum cpu for H1 is not more than 50%;
B) The link bandwidth between H1 and s1 is 10, the delay is 5 ms, the maximum queue size is 1000, and the loss rate is 50.
(2) Advanced requirements
Write a Python script to generate the following data center network topology, requiring:
Write a.Py topology file named fattree.py;
These files must be loaded through the Mininet custom parameter, not directly using the.Py file generated by miniedit.py;
The device name must be the same as the figure below.
Using Python's looping capabilities, you cannot add devices and links directly into your code by hand.
Reference material
IV. EXPERIMENTAL REPORT
Mininet Run Screenshot:
Code 212106662.py:
#!/usr/bin/env python from mininet.net import Mininet from mininet.node import Controller, RemoteController, OVSController from mininet.node import CPULimitedHost, Host, Node from mininet.node import OVSKernelSwitch, UserSwitch from mininet.node import IVSSwitch from mininet.cli import CLI from mininet.log import setLogLevel, info from mininet.link import TCLink, Intf from subprocess import call def myNetwork(): net = Mininet( topo=None, build=False, ipBase='10.0.0.0/8') info( '*** Adding controller\n' ) c0=net.addController(name='c0', controller=Controller, protocol='tcp', port=6633) info( '*** Add switches\n') s1 = net.addSwitch('s1', cls=OVSKernelSwitch) s2 = net.addSwitch('s2', cls=OVSKernelSwitch) info( '*** Add hosts\n') h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None) info( '*** Add links\n') net.addLink(h1, s1) net.addLink(h2, s1) net.addLink(s1, s2) net.addLink(s2, h4) net.addLink(s2, h3) info( '*** Starting network\n') net.build() info( '*** Starting controllers\n') for controller in net.controllers: controller.start() info( '*** Starting switches\n') net.get('s1').start([c0]) net.get('s2').start([c0]) info( '*** Post configure switches and hosts\n') CLI(net) net.stop() if __name__ == '__main__': setLogLevel( 'info' ) myNetwork()
Question 2 a:
Question 2 b and 3:
Question 4:
Advanced questions:
212106662_ Running screenshot of fattree.py:
212106662_fattree.py code:
#!/usr/bin/python #Creating a network topology """Custom topology example Adding the 'topos' dict with a key/value pair to generate our newly defined topology enables one to pass in '--topo=mytopo' from the command line. """ from mininet.topo import Topo from mininet.net import Mininet from mininet.node import RemoteController,CPULimitedHost from mininet.link import TCLink from mininet.util import dumpNodeConnections class MyTopo( Topo ): "Simple topology example." def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) L1 = 2 L2 = L1 * 2 L3 = L2 * 2 H1 = L3 * 2 c = [] a = [] e = [] h = [] # add core ovs for i in range( L1 ): sw = self.addSwitch( 's{}'.format( i + 1 ) ) c.append( sw ) # add aggregation ovs for i in range( L2 ): sw = self.addSwitch( 's{}'.format( L1 + i + 1 ) ) a.append( sw ) # add edge ovs for i in range( L3 ): sw = self.addSwitch( 's{}'.format( L1 + L2 + i + 1 ) ) e.append( sw ) #add Host for i in range(H1): h1 = self.addHost('h{}'.format(i+1)) h.append(h1) # add links between core and aggregation ovs for i in range( L1 ): for j in range(L2): self.addLink(c[i],a[j]) # add links between aggregation and edge ovs for i in range( L2 ): for j in range(4): if(i < 2): self.addLink(a[i],e[j]) else: self.addLink(a[i],e[j+4]) #add hosts and its links with edge ovs count = 0 for i in range(L3): for j in range(2): self.addLink( e[i],h[count] ) count += 1 topos = { 'mytopo': ( lambda: MyTopo() ) }