forked from Maxmawt/LINGI2142-IPMininet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple_bgp_network.py
52 lines (49 loc) · 2.15 KB
/
simple_bgp_network.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
42
43
44
45
46
47
48
49
50
51
52
from ipmininet.iptopo import IPTopo
from ipmininet.router.config import RouterConfig, BGP, ebgp_session
import ipmininet.router.config.bgp as _bgp
class SimpleBGPTopo(IPTopo):
"""This topology builds a 3-AS network exchanging BGP reachability
information"""
def build(self, *args, **kwargs):
"""
+----------+ +--------+
| |
AS1 | AS2 | AS3
| |
| |
+-------+ eBGP | +-------+ iBGP +-------+ | eBGP +-------+
| as1r1 +------------+ as2r1 +-------------+ as2r2 +------------+ as3r1 |
+-------+ | +-------+ +-------+ | +-------+
| |
| |
| |
+------------+ +--------+
"""
# Add all routers
as1r1 = self.bgp('as1r1')
as2r1 = self.bgp('as2r1')
as2r2 = self.bgp('as2r2')
as3r1 = self.bgp('as3r1')
# as2r3 = self.addRouter('as2r3')
# as2r3.addDaemon(BGP, route_reflector_client=True)
self.addLink(as1r1, as2r1)
self.addLink(as2r1, as2r2)
self.addLink(as3r1, as2r2)
# Set AS-ownerships
self.addAS(1, (as1r1,))
# self.addAS(2, (as2r1, as2r2, as2r3))
self.addiBGPFullMesh(2, (as2r1, as2r2))
self.addAS(3, (as3r1,))
# Add eBGP peering
ebgp_session(self, as1r1, as2r1)
ebgp_session(self, as3r1, as2r2)
# Add test hosts
for r in self.routers():
self.addLink(r, self.addHost('h%s' % r))
super(SimpleBGPTopo, self).build(*args, **kwargs)
def bgp(self, name):
r = self.addRouter(name)
r.addDaemon(BGP, address_families=(
_bgp.AF_INET(redistribute=('connected',)),
_bgp.AF_INET6(redistribute=('connected',))))
return r