-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopo_exam.py
69 lines (48 loc) · 1.69 KB
/
topo_exam.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
#!/usr/bin/python
"""
"""
from mininet.net import Mininet
from mininet.node import RemoteController, UserSwitch
from mininet.topo import Topo
from mininet.log import lg, info
from mininet.util import irange, quietRun
from mininet.link import TCLink
from mininet.cli import CLI
import sys
flush = sys.stdout.flush
class ExampleTestTopo( Topo ):
def __init__( self, **params ):
# Initialize topology
Topo.__init__( self, **params )
# Create switches and hosts
N = 6
hosts = [ self.addHost( 'h%s' % h ) for h in irange( 1, N ) ]
switches = [ self.addSwitch( 's%s' % s ) for s in irange( 1, N ) ]
# Wire up switches
self.addLink( switches[1], switches[0])
self.addLink( switches[1], switches[2])
self.addLink( switches[1], switches[4])
self.addLink( switches[3], switches[5])
self.addLink( switches[3], switches[2])
self.addLink( switches[3], switches[4])
# Wire up hosts
for host, switch in zip( hosts, switches ):
self.addLink( host, switch )
def bandwidthTest():
# Select TCP Reno
#output = quietRun( 'sysctl -w net.ipv4.tcp_congestion_control=reno' )
#assert 'reno' in output
# create network
print "*** creating network topology"
topo = ExampleTestTopo()
sw = UserSwitch
c0 = RemoteController( 'c0', ip='127.0.0.1', port=6633 )
net = Mininet( topo=topo, switch=sw, controller=c0,
autoSetMacs=True, autoStaticArp=False )
net.start()
CLI(net)
net.stop()
if __name__ == '__main__':
lg.setLogLevel( 'info' )
print "*** Run traffic demands in example topo"
bandwidthTest()