uk.py
3.36 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
"""
"""
from mininet.topo import Topo
class UkTopo( Topo ):
"""Switches projected onto the UK map"""
def __init__( self ):
"""Create a topology."""
# Initialize Topology
Topo.__init__( self )
# add nodes, switches first...
LONDON = self.addSwitch( 's1' )
BRISTL = self.addSwitch( 's2' )
BIRMHM = self.addSwitch( 's3' )
PLYMTH = self.addSwitch( 's4' )
DOVER = self.addSwitch( 's5' )
BRGHTN = self.addSwitch( 's6' )
LIVRPL = self.addSwitch( 's7' )
YORK = self.addSwitch( 's8' )
NWCSTL = self.addSwitch( 's9' )
NRWICH = self.addSwitch( 's10' )
EDBUGH = self.addSwitch( 's11' )
ABYSTW = self.addSwitch( 's12' )
# ... and now hosts
LONDON_host = self.addHost( 'h1' )
BRISTL_host = self.addHost( 'h2' )
BIRMHM_host = self.addHost( 'h3' )
PLYMTH_host = self.addHost( 'h4' )
DOVER_host = self.addHost( 'h5' )
BRGHTN_host = self.addHost( 'h6' )
LIVRPL_host = self.addHost( 'h7' )
YORK_host = self.addHost( 'h8' )
NWCSTL_host = self.addHost( 'h9' )
NRWICH_host = self.addHost( 'h10' )
EDBUGH_host = self.addHost( 'h11' )
ABYSTW_host = self.addHost( 'h12' )
# add edges between switch and corresponding host
self.addLink( LONDON, LONDON_host )
self.addLink( BRISTL, BRISTL_host )
self.addLink( BIRMHM, BIRMHM_host )
self.addLink( PLYMTH, PLYMTH_host )
self.addLink( DOVER, DOVER_host )
self.addLink( BRGHTN, BRGHTN_host )
self.addLink( LIVRPL, LIVRPL_host )
self.addLink( YORK, YORK_host )
self.addLink( NWCSTL, NWCSTL_host )
self.addLink( NRWICH, NRWICH_host )
self.addLink( EDBUGH, EDBUGH_host )
self.addLink( ABYSTW, ABYSTW_host )
# add edges between switches
self.addLink( BIRMHM, LIVRPL, bw=10, delay='1.0ms')
self.addLink( BIRMHM, YORK, bw=10, delay='1.0ms')
self.addLink( BRISTL, ABYSTW, bw=10, delay='1.0ms')
self.addLink( BRISTL, BIRMHM, bw=10, delay='1.0ms')
self.addLink( BRISTL, PLYMTH, bw=10, delay='1.0ms')
self.addLink( DOVER, BRGHTN, bw=10, delay='1.0ms')
self.addLink( DOVER, NRWICH, bw=10, delay='1.0ms')
self.addLink( LIVRPL, ABYSTW, bw=10, delay='1.0ms')
self.addLink( LIVRPL, EDBUGH, bw=10, delay='1.0ms')
self.addLink( LONDON, BIRMHM, bw=10, delay='1.0ms')
self.addLink( LONDON, BRGHTN, bw=10, delay='1.0ms')
self.addLink( LONDON, BRISTL, bw=10, delay='1.0ms')
self.addLink( LONDON, BRISTL, bw=10, delay='1.0ms')
self.addLink( LONDON, DOVER, bw=10, delay='1.0ms')
self.addLink( LONDON, NRWICH, bw=10, delay='1.0ms')
self.addLink( LONDON, PLYMTH, bw=10, delay='1.0ms')
self.addLink( LONDON, YORK, bw=10, delay='1.0ms')
self.addLink( LONDON, YORK, bw=10, delay='1.0ms')
self.addLink( NWCSTL, EDBUGH, bw=10, delay='1.0ms')
self.addLink( NWCSTL, LIVRPL, bw=10, delay='1.0ms')
self.addLink( NWCSTL, YORK, bw=10, delay='1.0ms')
self.addLink( YORK, LIVRPL, bw=10, delay='1.0ms')
self.addLink( YORK, NRWICH, bw=10, delay='1.0ms')
topos = { 'uk': ( lambda: UkTopo() ) }
if __name__ == '__main__':
from onosnet import run
run( UkTopo() )