-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.mn
executable file
·52 lines (40 loc) · 1.11 KB
/
driver.mn
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
48
49
50
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.topolib import TreeTopo
from mininet.util import dumpNodeConnections
from mininet.cli import CLI
from mininet.node import RemoteController
class MyTopo(Topo):
def __init__(self):
# Initialize topology
Topo.__init__(self)
hosts = []
switches = []
# hosts
hosts.append(self.addHost('h1'))
hosts.append(self.addHost('h2'))
hosts.append(self.addHost('h3'))
hosts.append(self.addHost('h4'))
# switchs
switches.append(self.addSwitch('s1'))
# links
self.addLink(hosts[0], switches[0])
self.addLink(hosts[1], switches[0])
self.addLink(hosts[2], switches[0])
self.addLink(hosts[3], switches[0])
def main():
my_topo = MyTopo()
# ONOS_IP = '127.0.0.1'
# ONOS_PORT = 6633
# controller = RemoteController('c0', ip=ONOS_IP, port=ONOS_PORT)
controller = None
net = Mininet(topo=my_topo, controller=controller, cleanup=True)
print 'total hosts: %d' % len(net.hosts)
print 'total switches: %d' % len(net.switches)
net.start()
CLI(net)
net.stop()
if __name__ == '__main__':
main()