Search in sources :

Example 36 with Peer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.Peer in project bgpcep by opendaylight.

the class AbstractAddPathTest method createPeerSession.

BGPSessionImpl createPeerSession(final Ipv4Address peer, final BgpParameters bgpParameters, final SimpleSessionListener sessionListener) throws InterruptedException {
    final StrictBGPPeerRegistry clientRegistry = new StrictBGPPeerRegistry();
    final BGPDispatcherImpl clientDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker, clientRegistry);
    clientRegistry.addPeer(new IpAddress(new Ipv4Address(RIB_ID)), sessionListener, new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(peer), AS_NUMBER, Lists.newArrayList(bgpParameters)));
    return connectPeer(peer, clientDispatcher);
}
Also used : BGPSessionPreferences(org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 37 with Peer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.Peer in project bgpcep by opendaylight.

the class AddPathBasePathsTest method testUseCase1.

/*
    * Base-Paths
    *                                            ___________________
    *                                           | ODL BGP 127.0.0.1 |
    * [peer://127.0.0.2; p1, lp100] --(iBGP)--> |                   | --(RR-client, non add-path) --> [Peer://127.0.0.5; (p1, lp100), (p1, lp1200)]
    * [peer://127.0.0.3; p1, lp200] --(iBGP)--> |                   |
    * [peer://127.0.0.4; p1, lp50] --(iBGP)-->  |                   | --(eBgp, non add-path) --> [Peer://127.0.0.6; (p1, path-id1, lp100), (p1, path-id2, pl50), (p1, path-id3, pl200)]
    * [peer://127.0.0.2; p1, lp20] --(iBGP)-->  |___________________|
    * p1 = 1.1.1.1/32
    */
@Test
public void testUseCase1() throws Exception {
    final BgpParameters nonAddPathParams = createParameter(false);
    configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
    configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
    configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
    final SimpleSessionListener listener4 = new SimpleSessionListener();
    configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
    final SimpleSessionListener listener5 = new SimpleSessionListener();
    configurePeer(PEER5, this.ribImpl, nonAddPathParams, PeerRole.Ebgp, this.serverRegistry);
    final BGPSessionImpl session5 = createPeerSession(PEER5, nonAddPathParams, listener5);
    checkPeersPresentOnDataStore(5);
    // new best route so far
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 1);
    assertEquals(UPD_NA_100, listener4.getListMsg().get(0));
    assertEquals(UPD_NA_100_EBGP, listener5.getListMsg().get(0));
    // the second best route
    sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 1);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 1);
    // new best route
    sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 1);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 2);
    assertEquals(UPD_NA_200, listener4.getListMsg().get(1));
    assertEquals(UPD_NA_200_EBGP, listener5.getListMsg().get(1));
    final SimpleSessionListener listener6 = new SimpleSessionListener();
    configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
    checkPeersPresentOnDataStore(6);
    checkReceivedMessages(listener6, 1);
    assertEquals(UPD_NA_200, listener6.getListMsg().get(0));
    session6.close();
    checkPeersPresentOnDataStore(5);
    // best route updated to be the worse one
    sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 20, 1);
    checkReceivedMessages(listener4, 3);
    checkReceivedMessages(listener5, 3);
    assertEquals(UPD_NA_100, listener4.getListMsg().get(2));
    assertEquals(UPD_NA_100_EBGP, listener5.getListMsg().get(2));
    // Remove second best, no advertisement should be done
    sendWithdrawalRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 1);
    checkReceivedMessages(listener4, 3);
    checkReceivedMessages(listener5, 3);
    // Remove best, 1 advertisement
    sendWithdrawalRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
    checkReceivedMessages(listener4, 4);
    checkReceivedMessages(listener5, 4);
    // Remove best, 1 withdrawal
    sendWithdrawalRouteAndCheckIsOnLocRib(session3, PREFIX1, 20, 0);
    checkReceivedMessages(listener4, 5);
    checkReceivedMessages(listener5, 5);
    session1.close();
    session2.close();
    session3.close();
    session4.close();
    session5.close();
}
Also used : BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) Test(org.junit.Test)

Example 38 with Peer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.Peer in project bgpcep by opendaylight.

the class PeerGroupStateCliUtilsTest method testEmptyPeerGroupStateCli.

@Test
public void testEmptyPeerGroupStateCli() throws IOException {
    final PeerGroupBuilder peerGroup = new PeerGroupBuilder().setPeerGroupName(TEST_GROUP);
    PeerGroupStateCliUtils.displayPeerOperationalState(Collections.singletonList(peerGroup.build()), this.stream);
    final String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("empty-peer-group.txt"), UTF8);
    assertEquals(expected, this.output.toString());
}
Also used : PeerGroupBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder) Test(org.junit.Test)

Example 39 with Peer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.Peer in project bgpcep by opendaylight.

the class AppPeerBenchmark method start.

public void start() {
    LOG.debug("Instantiating App Peer Benchmark : {}", this.appRibId);
    final ApplicationRib appRib = new ApplicationRibBuilder().setId(new ApplicationRibId(new ApplicationRibId(this.appRibId))).setTables(EMPTY_TABLES).build();
    final WriteTransaction wTx = this.txChain.newWriteOnlyTransaction();
    wTx.put(LogicalDatastoreType.CONFIGURATION, this.appIID, appRib);
    Futures.addCallback(wTx.submit(), new FutureCallback<Void>() {

        @Override
        public void onSuccess(final Void result) {
            LOG.info("Empty Structure created for Application Peer Benchmark {}", AppPeerBenchmark.this.appRibId);
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error("Failed to create Empty Structure for Application Peer Benchmark {}", AppPeerBenchmark.this.appRibId, throwable);
        }
    }, MoreExecutors.directExecutor());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ApplicationRibBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.ApplicationRibBuilder) ApplicationRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.ApplicationRib) ApplicationRibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.ApplicationRibId)

Example 40 with Peer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.peers.Peer in project bgpcep by opendaylight.

the class BGPPeer method addBgp4Support.

// try to add a support for old-school BGP-4, if peer did not advertise IPv4-Unicast MP capability
private synchronized void addBgp4Support() {
    final TablesKey key = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
    if (!this.tables.contains(key)) {
        final HashSet<TablesKey> newSet = new HashSet<>(this.tables);
        newSet.add(key);
        this.tables = ImmutableSet.copyOf(newSet);
        createAdjRibOutListener(key, false);
    }
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) HashSet(java.util.HashSet)

Aggregations

Test (org.junit.Test)23 ByteBuf (io.netty.buffer.ByteBuf)12 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)9 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)6 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)6 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)6 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 ArrayList (java.util.ArrayList)4 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)4 BGPSessionPreferences (org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4 PortStatusMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)4 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)4 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)4 Preconditions (com.google.common.base.Preconditions)3 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)3 BGPSessionListener (org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener)3 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)3