-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathFake-Topo.py
39 lines (26 loc) · 1.03 KB
/
Fake-Topo.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
"""Custom topology example
3 switche plus 2 host :
switch linear conneted first swich and last swich connet to 1 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.
This topo used to test fake topology
"""
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
leftHost = self.addHost( 'h2',ip='10.0.0.4' )
rightHost = self.addHost( 'h3',ip='10.0.0.5' )
switch1 = self.addSwitch( 's1', ip='10.0.0.1')
switch2 = self.addSwitch( 's2', ip = '10.0.0.2')
switch3 = self.addSwitch( 's3', ip = '10.0.0.3')
# Add links
self.addLink( leftHost, switch1)
self.addLink( switch1, switch2 )
self.addLink( switch2, switch3 )
self.addLink( switch3, rightHost)
topos = { 'mytopo': ( lambda: MyTopo() ) }