Experiment 1: SDN Topology Practice

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


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,

    info( '*** Adding controller\n' )

    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='', defaultRoute=None)
    h2 = net.addHost('h2', cls=Host, ip='', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='', 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')
    info( '*** Starting controllers\n')
    for controller in net.controllers:

    info( '*** Starting switches\n')

    info( '*** Post configure switches and hosts\n')


if __name__ == '__main__':
    setLogLevel( 'info' )

Question 2 a:

Question 2 b and 3:

Question 4:

Advanced questions:

212106662_ Running screenshot of fattree.py:

212106662_fattree.py code:

#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))
        # add links between core and aggregation ovs
        for i in range( L1 ):
                for j in range(L2):

        # add links between aggregation and edge ovs
        for i in range( L2 ):
                for j in range(4):
                    if(i < 2):
        #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() ) }

Personal summary:

The python code language is unfamiliar and takes some time to learn. After creating the visual graphical interface in the first topic, saving can not run until the method of searching on the Internet is successfully run, and the subsequent experiments are completed. Generally, the visual interface is easier to edit, while writing in python is a bit difficult, and code editing needs to be strengthened. (with a screenshot of the solution)

Posted by bivaughn on Fri, 23 Sep 2022 21:51:30 +0300