-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelay_topo.py
executable file
·37 lines (26 loc) · 985 Bytes
/
delay_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
"""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
from mininet.link import TCLink
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' )
switch1 = self.addSwitch( 's1' )
switch2 = self.addSwitch( 's2' )
switch3 = self.addSwitch( 's3' )
# Add links
self.addLink( host1, switch1 )
self.addLink( switch1, switch2, delay='2ms' )
self.addLink( switch2, switch3, delay='3ms' )
self.addLink( switch3, host2 )
topos = { 'mytopo': ( lambda: MyTopo() ) }