Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
51 views

Python 2

This Python script defines a function called myNet() that creates a Mininet network topology with 4 hosts, 4 switches, and connects each host to a switch and connects all switches in a full mesh configuration. It then starts the network, runs the CLI, and stops the network.

Uploaded by

Ngọc Thái
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Python 2

This Python script defines a function called myNet() that creates a Mininet network topology with 4 hosts, 4 switches, and connects each host to a switch and connects all switches in a full mesh configuration. It then starts the network, runs the CLI, and stops the network.

Uploaded by

Ngọc Thái
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#!

/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController
from mininet.cli import CLI
from mininet.log import setLogLevel, info
def myNet():
net = Mininet( controller=RemoteController)
info('***Adding controller\n')
net.addController('c0',controller=RemoteController,ip="10.0.0.11",port=6633)
# Create nodes
h1 = net.addHost( 'h1')
h2 = net.addHost( 'h2')
h3 = net.addHost( 'h3')
h4 = net.addHost( 'h4')
# Create switches
s1 = net.addSwitch( 's1')
s2 = net.addSwitch( 's2')
s3 = net.addSwitch( 's3')
s4 = net.addSwitch( 's4')
print "*** Creating links"
net.addLink(h1, s1)
net.addLink(h2, s2)
net.addLink(h3, s3)
net.addLink(h4, s4)
SwitchList = (s1,s2,s3,s4)
for index in range (0, len(SwitchList)):
for index2 in range(index+1, len(SwitchList)):
net.addLink(SwitchList[index],SwitchList[index2])
info('***Strarting network\n')
net.start()
info('****Running CLI\n')
CLI(net)
info('***Stopping Network')
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNet()

You might also like