from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import OVSController
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.log import setLogLevel
class CustomTopo(Topo):
def build(self):
h1 = self.addHost('h1')
h2 = self.addHost('h2')
h3 = self.addHost('h3')
h4 = self.addHost('h4')
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
s3 = self.addSwitch('s3')
self.addLink(s1, s2, bw=15)
self.addLink(s2, s3, bw=15)
self.addLink(s1, h1)
self.addLink(s2, h2)
self.addLink(s3, h3)
self.addLink(s3, h4)
def runIperf(net):
h1, h2, h3, h4 = net.get('h1', 'h2', 'h3', 'h4')
h3.cmd('iperf3 -s -D')
h4.cmd('iperf3 -s -D')
print("Testing TCP bandwidth between h1 and h3")
net.iperf((h1, h3))
print("Testing TCP bandwidth between h2 and h4")
net.iperf((h2, h4))
if __name__ == '__main__':
setLogLevel('info')
topo = CustomTopo()
net = Mininet(topo=topo, controller=OVSController, link=TCLink)
net.start()
runIperf(net)
CLI(net)
net.stop()