-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_topo.py
47 lines (32 loc) · 1.11 KB
/
basic_topo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
"""
This example shows how to create an empty Mininet object
(without a topology object) and add nodes to it manually.
This example has been taken from here and slightly modified: https://github.com/mininet/mininet/blob/master/examples/emptynet.py
"""
from mininet.net import Mininet
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.node import OVSController
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( controller=OVSController, waitConnected=True )
info( '*** Adding controller\n' )
net.addController( 'c0' )
info( '*** Adding hosts\n' )
h1 = net.addHost( 'h1', ip='10.0.0.1' )
h2 = net.addHost( 'h2', ip='10.0.0.2' )
info( '*** Adding switch\n' )
s3 = net.addSwitch( 's3' )
info( '*** Creating links\n' )
net.addLink( h1, s3 )
net.addLink( h2, s3 )
info( '*** Starting network\n')
net.start()
info( '*** Running CLI\n' )
CLI( net )
info( '*** Stopping network' )
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
emptyNet()