from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.cli import CLI
from mininet.log import setLogLevel, info
import time
def assignmentTopo():
net = Mininet( controller=RemoteController)
info( ‘*** Adding controller\n’ )
net.addController(‘c0’)
### Code here to add hosts switches and links ###############
#############################################################
info( ‘*** Starting network\n’)
net.start()
h1, h2, h3, h4 = net.hosts[0],net.hosts[1],net.hosts[2],net.hosts[3]
### Add code here to add QoS commands using hte ovs-vsctl primitive #################
### Yuo shuld use the command os.system(“….”) to run the ovsctl commands ########
########################################################################################
### Add code here to run iperf tests to verify that your solutions respects the given performance ##############
### You should use iperf commands to check data rate and connectivity among all nodes ##############
###The example is shown here for one iperf conection####
info( ‘\n\n\n\n*** Testing PIR to H1 to H3\n’)
h3.cmd(‘iperf -s &’) # this creates a listener for iperf in H3 – the & let’s it run in the backgorund, so that the function returns and the code execution can proceed to the next line.
print(h1.cmd(‘iperf -c %s’ % h3.IP())) #this starts the transmission from H1 to H3
#### Here you can add the other iperf tests ######
info( ‘\n\n\n\n*** Testing PIR from H1 to H2\n’)
###……….######
### ………………..
##############################################################################################################
CLI( net )
#### the following commands delete all Qos entries before quitting mininet #################
os.system(‘sudo ovs-vsctl clear Port s1-eth3 qos’)
os.system(‘sudo ovs-vsctl clear Port s1-eth4 qos’)
os.system(‘sudo ovs-vsctl –all destroy qos’)
os.system(‘sudo ovs-vsctl –all destroy queue’)
net.stop()
if __name__ == ‘__main__’:
setLogLevel( ‘info’ )
assignmentTopo()