-
Notifications
You must be signed in to change notification settings - Fork 2
/
topo_for_vlan_dot1q_test.py
39 lines (29 loc) · 1.01 KB
/
topo_for_vlan_dot1q_test.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
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
h1 = self.addHost( 'h1' )
h2 = self.addHost( 'h2' )
h3 = self.addHost( 'h3' )
h4 = self.addHost( 'h4' )
h5 = self.addHost( 'h5' )
s1 = self.addSwitch( 's1', dpid="1" )
s2 = self.addSwitch( 's2', dpid="2" )
# Add links
self.addLink( h1, s1 )
self.addLink( h2, s1 )
self.addLink( h3, s1 )
self.addLink( s1, s2 )
self.addLink( s2, h4 )
self.addLink( s2, h5 )
topos = { 'mytopo': ( lambda: MyTopo() ) }