-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmini2.py
130 lines (59 loc) · 2.63 KB
/
mini2.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
from mininet.node import Controller
from mininet.cli import CLI
from functools import partial
from mininet.node import RemoteController
import os
class MyTopo(Topo):
"Single switch connected to n hosts."
def __init__(self):
Topo.__init__(self)
s1=self.addSwitch('s1')
s2=self.addSwitch('s2')
s3=self.addSwitch('s3')
s4=self.addSwitch('s4')
s5=self.addSwitch('s5')
h1=self.addHost('h1')
h2=self.addHost('h2')
h3=self.addHost('h3')
h4=self.addHost('h4')
h5=self.addHost('h5')
h6=self.addHost('h6')
self.addLink(h1, s1, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(h2, s1, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(h3, s1, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s1, s2, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s1, s3, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s1, s4, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s2, s5, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s3, s5, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s4, s5, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s5, h4, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s5, h5, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
self.addLink(s5, h6, bw=1, delay='10ms', loss=0, max_queue_size=1000, use_htb=True)
def perfTest():
"Create network and run simple performance test"
topo = MyTopo()
net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink, controller=partial(RemoteController, ip='192.168.226.141', port=6633))
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)
h1,h2,h3=net.get('h1','h2','h3')
h4,h5,h6=net.get('h4','h5','h6')
h1.setMAC("0:0:0:0:0:1")
h2.setMAC("0:0:0:0:0:2")
h3.setMAC("0:0:0:0:0:3")
h4.setMAC("0:0:0:0:0:4")
h5.setMAC("0:0:0:0:0:5")
h6.setMAC("0:0:0:0:0:6")
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel('info')
perfTest()