-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject_topo.py
41 lines (30 loc) · 1.1 KB
/
project_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
40
41
"""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 ):
"Simple topology example."
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
Host1 = self.addHost( 'h1' )
Host2 = self.addHost( 'h2' )
Host3 = self.addHost( 'h3' )
Host4 = self.addHost( 'h4' )
Host5 = self.addHost( 'h5' )
Switch1 = self.addSwitch( 's1' )
Switch2 = self.addSwitch( 's2' )
# Add links
self.addLink( Host1, Switch1 )
self.addLink( Switch2, Switch1 )
self.addLink( Host2, Switch1 )
self.addLink( Host3, Switch2 )
self.addLink( Host4, Switch2 )
self.addLink( Switch1, Host5 )
self.addLink( Switch2, Host5 )
topos = { 'mytopo': ( lambda: MyTopo() ) }