-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_topology.py
37 lines (26 loc) · 927 Bytes
/
custom_topology.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
"""Custom topology example
Two directly connected switches plus a host for each switch:
h1 --- s1 --- s2 --- h2
h3 ----^
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 ):
"Simple topology example."
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
h1 = self.addHost('h1', ip='172.16.10.9/24')
h2 = self.addHost('h2', ip='172.16.20.9/24')
h3 = self.addHost('h3', ip='172.16.30.9/24')
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
# Add links
self.addLink(h1, s1)
self.addLink(h3, s1)
self.addLink(s1, s2)
self.addLink(h2, s2)
topos = { 'mytopo': ( lambda: MyTopo() ) }