コード例 #1
0
 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')
     self.addLink(as1r1, as2r1)
     self.addLink(as2r1, as2r2)
     self.addLink(as3r1, as2r2)
     # Set AS-ownerships
     self.addOverlay(AS(1, (as1r1,)))
     self.addOverlay(iBGPFullMesh(2, (as2r1, as2r2)))
     self.addOverlay(AS(3, (as3r1,)))
     # Add eBGP peering
     bgp_peering(self, as1r1, as2r1)
     bgp_peering(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)
コード例 #2
0
 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')
     self.addLink(as1r1, as2r1)
     self.addLink(as2r1, as2r2)
     self.addLink(as3r1, as2r2)
     # Set AS-ownerships
     self.addOverlay(AS(1, (as1r1, )))
     self.addOverlay(iBGPFullMesh(2, (as2r1, as2r2)))
     self.addOverlay(AS(3, (as3r1, )))
     # Add eBGP peering
     bgp_peering(self, as1r1, as2r1)
     bgp_peering(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)
コード例 #3
0
    def build(self, *args, **kwargs):
        """
           +----------+                                   +--------+
                      |                                   |
         AS1          |                  AS2              |        AS3
                      |                                   |
                      |                  iBGP             |
    +-------+   eBGP  |  +-------+             +-------+  |  eBGP   +-------+
    | as1r1 +------------+ as2r1 +--X-as2r3-Y--+ as2r2 +------------+ as3r1 |
    +-------+         |  +-------+      OSPF   +-------+  |         +-------+
    1.2.3.0/24        |                                   |         1.2.3.0/24
                      |                                   |
                      |                                   |
         +------------+                                   +--------+
        """
        # Add all routers
        as1r1 = self.addRouter('as1r1')
        as1r1.addDaemon(BGP, address_families=(
            _bgp.AF_INET(networks=('1.2.3.0/24',)),))

        as2r1 = self.addRouter('as2r1')
        as2r1.addDaemon(BGP, routerid='1.1.1.1')
        as2r1.addDaemon(OSPF)

        as2r2 = self.addRouter('as2r2')
        as2r2.addDaemon(BGP, routerid='1.1.1.2')
        as2r2.addDaemon(OSPF)

        as2r3 = self.addRouter('as2r3')
        as2r3.addDaemon(BGP)
        as2r3.addDaemon(OSPF)

        x = self.addRouter('x')
        x.addDaemon(OSPF)

        y = self.addRouter('y')
        y.addDaemon(OSPF)

        as3r1 = self.addRouter('as3r1')
        as3r1.addDaemon(BGP, address_families=(
            _bgp.AF_INET(networks=('1.2.3.0/24',)),))

        self.addLink(as1r1, as2r1)
        self.addLink(as2r1, x, igp_metric=1)
        self.addLink(x, as2r3, igp_metric=10)
        # as2r1 has preferred routerid but higher IGP cost
        self.addLink(as2r3, y, igp_metric=1)
        self.addLink(y, as2r2, igp_metric=self.other_cost)
        self.addLink(as3r1, as2r2)
        # Set AS-ownerships
        self.addOverlay(AS(1, (as1r1,)))
        self.addOverlay(iBGPFullMesh(2, (as2r1, as2r2, as2r3)))
        self.addOverlay(AS(3, (as3r1,)))
        # Add eBGP peering
        ebgp_session(self, as1r1, as2r1)
        ebgp_session(self, as3r1, as2r2)
        super(BGPDecisionProcess, self).build(*args, **kwargs)
コード例 #4
0
ファイル: test_bgp.py プロジェクト: Ananas120/ipmininet
    def build(self, *args, **kwargs):
        """
           +----------+                                   +--------+
                      |                                   |
         AS1          |                  AS2              |        AS3
                      |                                   |
                      |                                   |
    +-------+   eBGP  |  +-------+     iBGP    +-------+  |  eBGP   +-------+
    | as1r1 +------------+ as2r1 +-------------+ as2r2 +------------+ as3r1 |
    +-------+         |  +-------+             +-------+  |         +-------+
                      |                                   |
                      |                                   |
                      |                                   |
         +------------+                                   +--------+
        """
        # Add all routers
        as1r1 = self.addRouter('as1r1', config=RouterConfig)
        as1r1.addDaemon(BGP,
                        address_families=[AF_INET(redistribute=["connected"]),
                                          AF_INET6(redistribute=["connected"])])
        as2r1 = self.addRouter('as2r1', config=RouterConfig)
        as2r1.addDaemon(BGP, **self.as2r1_params)
        as2r2 = self.addRouter('as2r2', config=RouterConfig)
        as2r2.addDaemon(BGP,
                        address_families=[AF_INET(redistribute=["connected"]),
                                          AF_INET6(redistribute=["connected"])])
        as3r1 = self.addRouter('as3r1', config=RouterConfig)
        as3r1.addDaemon(BGP,
                        address_families=[AF_INET(redistribute=["connected"]),
                                          AF_INET6(redistribute=["connected"])])

        self.addLink(as1r1, as2r1,
                     params1={"ip": ("10.1.1.1/24", "fd00:1:1::1/64")},
                     params2={"ip": ("10.1.1.2/24", "fd00:1:1::2/64")})
        self.addLink(as2r1, as2r2,
                     params1={"ip": ("10.2.1.1/24", "fd00:2:1::1/64")},
                     params2={"ip": ("10.2.1.2/24", "fd00:2:1::2/64")})
        self.addLink(as3r1, as2r2,
                     params1={"ip": ("10.3.1.1/24", "fd00:3:1::1/64")},
                     params2={"ip": ("10.3.1.2/24", "fd00:3:1::2/64")})

        # Set AS-ownerships
        self.addOverlay(AS(1, (as1r1,)))
        self.addOverlay(iBGPFullMesh(2, (as2r1, as2r2)))
        self.addOverlay(AS(3, (as3r1,)))
        # Add eBGP peering
        bgp_peering(self, as1r1, as2r1)
        bgp_peering(self, as3r1, as2r2)

        # Add test hosts
        self.addLink(as1r1, self.addHost('h%s' % as1r1),
                     params1={"ip": ("10.1.0.1/24", "fd00:1::1/64")},
                     params2={"ip": ("10.1.0.2/24", "fd00:1::2/64")})
        self.addLink(as3r1, self.addHost('h%s' % as3r1),
                     params1={"ip": ("10.3.0.1/24", "fd00:3::1/64")},
                     params2={"ip": ("10.3.0.2/24", "fd00:3::2/64")})
        super().build(*args, **kwargs)
コード例 #5
0
    def build(self, *args, **kwargs):
        """
           +----------+                                   +--------+
                      |                                   |
         AS1          |                  AS2              |        AS3
                      |                                   |
                      |                  iBGP             |
    +-------+   eBGP  |  +-------+             +-------+  |  eBGP   +-------+
    | as1r1 +------------+ as2r1 +--X-as2r3-Y--+ as2r2 +------------+ as3r1 |
    +-------+         |  +-------+      OSPF   +-------+  |         +-------+
    1.2.3.0/24        |                                   |         1.2.3.0/24
                      |                                   |
                      |                                   |
         +------------+                                   +--------+
        """
        # Add all routers
        as1r1 = self.addRouter('as1r1')
        as1r1.addDaemon(
            BGP, address_families=(_bgp.AF_INET(networks=('1.2.3.0/24', )), ))

        as2r1 = self.addRouter('as2r1')
        as2r1.addDaemon(BGP, routerid='1.1.1.1')
        as2r1.addDaemon(OSPF)

        as2r2 = self.addRouter('as2r2')
        as2r2.addDaemon(BGP, routerid='1.1.1.2')
        as2r2.addDaemon(OSPF)

        as2r3 = self.addRouter('as2r3')
        as2r3.addDaemon(BGP)
        as2r3.addDaemon(OSPF)

        x = self.addRouter('x')
        x.addDaemon(OSPF)

        y = self.addRouter('y')
        y.addDaemon(OSPF)

        as3r1 = self.addRouter('as3r1')
        as3r1.addDaemon(
            BGP, address_families=(_bgp.AF_INET(networks=('1.2.3.0/24', )), ))

        self.addLink(as1r1, as2r1)
        self.addLink(as2r1, x, igp_metric=1)
        self.addLink(x, as2r3, igp_metric=10)
        # as2r1 has preferred routerid but higher IGP cost
        self.addLink(as2r3, y, igp_metric=1)
        self.addLink(y, as2r2, igp_metric=self.other_cost)
        self.addLink(as3r1, as2r2)
        # Set AS-ownerships
        self.addOverlay(AS(1, (as1r1, )))
        self.addOverlay(iBGPFullMesh(2, (as2r1, as2r2, as2r3)))
        self.addOverlay(AS(3, (as3r1, )))
        # Add eBGP peering
        ebgp_session(self, as1r1, as2r1)
        ebgp_session(self, as3r1, as2r2)
        super(BGPDecisionProcess, self).build(*args, **kwargs)
コード例 #6
0
ファイル: test_bgp.py プロジェクト: oliviertilmans/ipmininet
    def build(self, *args, **kwargs):
        """
           +----------+                                   +--------+
                      |                                   |
         AS1          |                  AS2              |        AS3
                      |                                   |
                      |                                   |
    +-------+   eBGP  |  +-------+     iBGP    +-------+  |  eBGP   +-------+
    | as1r1 +------------+ as2r1 +-------------+ as2r2 +------------+ as3r1 |
    +-------+         |  +-------+             +-------+  |         +-------+
                      |                                   |
                      |                                   |
                      |                                   |
         +------------+                                   +--------+
        """
        # Add all routers
        as1r1 = self.addRouter('as1r1', config=RouterConfig)
        as1r1.addDaemon(BGP, address_families=[AF_INET(redistribute=["connected"]),
                                               AF_INET6(redistribute=["connected"])])
        as2r1 = self.addRouter('as2r1', config=RouterConfig)
        as2r1.addDaemon(BGP, **self.as2r1_params)
        as2r2 = self.addRouter('as2r2', config=RouterConfig)
        as2r2.addDaemon(BGP, address_families=[AF_INET(redistribute=["connected"]),
                                               AF_INET6(redistribute=["connected"])])
        as3r1 = self.addRouter('as3r1', config=RouterConfig)
        as3r1.addDaemon(BGP, address_families=[AF_INET(redistribute=["connected"]),
                                               AF_INET6(redistribute=["connected"])])

        self.addLink(as1r1, as2r1, params1={"ip": ["10.1.1.1/24", "fd00:1:1::1/64"]},
                     params2={"ip": ["10.1.1.2/24", "fd00:1:1::2/64"]})
        self.addLink(as2r1, as2r2, params1={"ip": ["10.2.1.1/24", "fd00:2:1::1/64"]},
                     params2={"ip": ["10.2.1.2/24", "fd00:2:1::2/64"]})
        self.addLink(as3r1, as2r2, params1={"ip": ["10.3.1.1/24", "fd00:3:1::1/64"]},
                     params2={"ip": ["10.3.1.2/24", "fd00:3:1::2/64"]})

        # Set AS-ownerships
        self.addOverlay(AS(1, (as1r1,)))
        self.addOverlay(iBGPFullMesh(2, (as2r1, as2r2)))
        self.addOverlay(AS(3, (as3r1,)))
        # Add eBGP peering
        bgp_peering(self, as1r1, as2r1)
        bgp_peering(self, as3r1, as2r2)

        # Add test hosts
        self.addLink(as1r1, self.addHost('h%s' % as1r1), params1={"ip": ["10.1.0.1/24", "fd00:1::1/64"]},
                     params2={"ip": ["10.1.0.2/24", "fd00:1::2/64"]})
        self.addLink(as3r1, self.addHost('h%s' % as3r1), params1={"ip": ["10.3.0.1/24", "fd00:3::1/64"]},
                     params2={"ip": ["10.3.0.2/24", "fd00:3::2/64"]})
        super(BGPTopo, self).build(*args, **kwargs)
コード例 #7
0
 def build(self, *args, **kwargs):
     """
        +----------+                                   +--------+
                   |                                   |
      AS1          |                  AS2              |        AS3
                   |                                   |
                   |                  iBGP             |
 +-------+   eBGP  |  +-------+             +-------+  |  eBGP   +-------+
 | as1r1 +------------+ as2r1 +--X-as2r3-Y--+ as2r2 +------------+ as3r1 |
 +-------+         |  +-------+      OSPF   +-------+  |         +-------+
 1.2.3.0/24        |                                   |         1.2.3.0/24
                   |                                   |
                   |                                   |
      +------------+                                   +--------+
     """
     # Add all routers
     as1r1 = self.addRouter(
         'as1r1',
         config=(RouterConfig, {
             'daemons': [(BGP, {
                 'address_families':
                 (_bgp.AF_INET(networks=('1.2.3.0/24', )), )
             })]
         }))
     as2r1 = self.addRouter('as2r1',
                            config=(RouterConfig, {
                                'daemons': [(BGP, {
                                    'routerid': '1.1.1.1'
                                }), OSPF]
                            }))
     as2r2 = self.addRouter('as2r2',
                            config=(RouterConfig, {
                                'daemons': [(BGP, {
                                    'routerid': '1.1.1.2'
                                }), OSPF]
                            }))
     as2r3 = self.addRouter('as2r3',
                            config=(RouterConfig, {
                                'daemons': [OSPF, BGP]
                            }))
     x = self.addRouter('x', config=(RouterConfig, {'daemons': [OSPF]}))
     y = self.addRouter('y', config=(RouterConfig, {'daemons': [OSPF]}))
     as3r1 = self.addRouter(
         'as3r1',
         config=(RouterConfig, {
             'daemons': [(BGP, {
                 'address_families':
                 (_bgp.AF_INET(networks=('1.2.3.0/24', )), )
             })]
         }))
     self.addLink(as1r1, as2r1)
     self.addLink(as2r1, x, igp_metric=1)
     self.addLink(x, as2r3, igp_metric=10)
     # as2r1 has preferred routerid but higher IGP cost
     self.addLink(as2r3, y, igp_metric=1)
     self.addLink(y, as2r2, igp_metric=self.other_cost)
     self.addLink(as3r1, as2r2)
     # Set AS-ownerships
     self.addOverlay(AS(1, (as1r1, )))
     self.addOverlay(iBGPFullMesh(2, (as2r1, as2r2, as2r3)))
     self.addOverlay(AS(3, (as3r1, )))
     # Add eBGP peering
     ebgp_session(self, as1r1, as2r1)
     ebgp_session(self, as3r1, as2r2)
     super(BGPDecisionProcess, self).build(*args, **kwargs)