-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathFatTree_4.py
53 lines (46 loc) · 1.5 KB
/
FatTree_4.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
"""Custom topology example
Two directly connected switches plus a host for each switch:
host --- switch --- switch --- host
Adding the 'topos' dict with a key/value pair to generate our newly defined
topology enables one to pass in '--topo=mytopo' from the command line.
"""
from mininet.topo import Topo
class MyTopo( Topo ):
def build( self ):
"Create custom topo."
# Add hosts
h1 = self.addHost( 'h1' )
h2 = self.addHost( 'h2' )
h3 = self.addHost( 'h3' )
h4 = self.addHost( 'h4' )
h5 = self.addHost( 'h5' )
h6 = self.addHost( 'h6' )
h7 = self.addHost( 'h7' )
h8 = self.addHost( 'h8' )
# Add Switches
s1 = self.addSwitch( 's1' )
s2 = self.addSwitch( 's2' )
s3 = self.addSwitch( 's3' )
s4 = self.addSwitch( 's4' )
s5 = self.addSwitch( 's5' )
s6 = self.addSwitch( 's6'
# Add links hosts--switches
self.addLink(h1, s3)
self.addLink(h2, s3)
self.addLink(h3, s4)
self.addLink(h4, s4)
self.addLink(h5, s5)
self.addLink(h6, s5)
self.addLink(h7, s6)
self.addLink(h8, s6)
#add links s1--All Switches
self.addLink(s1, s3)
self.addLink(s1, s4)
self.addLink(s1, s5)
self.addLink(s1, s6)
#addlinks s2--All Switches
self.addLink(s2, s3)
self.addLink(s2, s4)
self.addLink(s2, s5)
self.addLink(s2, s6)
topos = { 'mytopo': ( lambda: MyTopo() ) }