use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters in project bgpcep by opendaylight.
the class AbstractAddPathTest method createParameter.
static BgpParameters createParameter(final boolean addPath, final boolean addIpv6, final Map<TablesKey, Boolean> gracefulTables) {
final TablesKey ipv4Key = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
final List<TablesKey> advertisedTables = Lists.newArrayList(ipv4Key);
if (addIpv6) {
final TablesKey ipv6Key = new TablesKey(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
advertisedTables.add(ipv6Key);
}
final List<TablesKey> addPathTables = new ArrayList<>();
if (addPath) {
addPathTables.add(ipv4Key);
}
return PeerUtil.createBgpParameters(advertisedTables, addPathTables, gracefulTables, GRACEFUL_RESTART_TIME);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters in project bgpcep by opendaylight.
the class AbstractAddPathTest method createPeerSession.
BGPSessionImpl createPeerSession(final Ipv4AddressNoZone peer, final BgpParameters bgpParameters, final SimpleSessionListener sessionListener, final AsNumber remoteAsNumber) throws InterruptedException {
final StrictBGPPeerRegistry clientRegistry = new StrictBGPPeerRegistry();
final BGPDispatcherImpl clientDispatcher = new BGPDispatcherImpl(this.context, this.boss, this.worker, clientRegistry);
clientDispatchers.add(clientDispatcher);
clientRegistry.addPeer(new IpAddressNoZone(new Ipv4AddressNoZone(RIB_ID)), sessionListener, new BGPSessionPreferences(remoteAsNumber, HOLDTIMER, new BgpId(peer), AS_NUMBER, Lists.newArrayList(bgpParameters)));
return connectPeer(peer, clientDispatcher);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters in project bgpcep by opendaylight.
the class AbstractBGPDispatcherTest method createPreferences.
protected BGPSessionPreferences createPreferences(final InetSocketAddress socketAddress) {
final List<BgpParameters> tlvs = new ArrayList<>();
final List<OptionalCapabilities> capas = new ArrayList<>();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(IPV_4_TT.getAfi()).setSafi(IPV_4_TT.getSafi()).build()).build()).setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(Uint32.valueOf(30))).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
final BgpId bgpId = new BgpId(IetfInetUtil.INSTANCE.ipv4AddressFor(socketAddress.getAddress()));
return new BGPSessionPreferences(AS_NUMBER, HOLD_TIMER, bgpId, AS_NUMBER, tlvs);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters 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.3; p1, lp200] --(iBGP)--> | | [Peer://127.0.0.5; (p1, lp100), (p1, lp1200)]
* [peer://127.0.0.4; p1, lp50] --(iBGP)--> | | --(eBgp, non add-path) -->
* [peer://127.0.0.2; p1, lp20] --(iBGP)--> |___________________| [Peer://127.0.0.6; (p1, path-id1, lp100),
* p1 = 1.1.1.1/32 (p1, path-id2, pl50), (p1, path-id3, pl200)]
*/
@Test
public void testUseCase1() throws Exception {
final BgpParameters nonAddPathParams = createParameter(false);
configurePeer(this.tableRegistry, PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
final SimpleSessionListener listener4 = new SimpleSessionListener();
configurePeer(this.tableRegistry, PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
final SimpleSessionListener listener5 = new SimpleSessionListener();
configurePeer(this.tableRegistry, 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, 2);
checkReceivedMessages(listener5, 2);
assertEquals(UPD_NA_100, listener4.getListMsg().get(1));
assertEquals(UPD_NA_100_EBGP, listener5.getListMsg().get(1));
// the second best route
sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 100, 1);
checkReceivedMessages(listener4, 2);
checkReceivedMessages(listener5, 2);
// new best route
sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 1);
checkReceivedMessages(listener4, 3);
checkReceivedMessages(listener5, 3);
assertEquals(UPD_NA_200, listener4.getListMsg().get(2));
assertEquals(UPD_NA_200_EBGP, listener5.getListMsg().get(2));
final SimpleSessionListener listener6 = new SimpleSessionListener();
configurePeer(this.tableRegistry, PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
checkPeersPresentOnDataStore(6);
checkReceivedMessages(listener6, 2);
assertEquals(UPD_NA_200, listener6.getListMsg().get(1));
session6.close();
checkPeersPresentOnDataStore(5);
// best route updated to be the worse one
sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 20, 1);
checkReceivedMessages(listener4, 4);
checkReceivedMessages(listener5, 4);
assertEquals(UPD_NA_100, listener4.getListMsg().get(3));
assertEquals(UPD_NA_100_EBGP, listener5.getListMsg().get(3));
// Remove second best, no advertisement should be done
sendWithdrawalRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 1);
checkReceivedMessages(listener4, 4);
checkReceivedMessages(listener5, 4);
// Remove best, 1 advertisement
sendWithdrawalRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
checkReceivedMessages(listener4, 5);
checkReceivedMessages(listener5, 5);
// Remove best, 1 withdrawal
sendWithdrawalRouteAndCheckIsOnLocRib(session3, PREFIX1, 20, 0);
checkReceivedMessages(listener4, 6);
checkReceivedMessages(listener5, 6);
session1.close();
session2.close();
session3.close();
session4.close();
session5.close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters in project bgpcep by opendaylight.
the class APITest method testBgpExtendedMessageUtil.
@Test
public void testBgpExtendedMessageUtil() {
final List<BgpParameters> params = new ArrayList<>();
final List<OptionalCapabilities> capas = new ArrayList<>();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().build()).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
params.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
final Open open1 = new OpenBuilder().setBgpParameters(params).build();
assertTrue(BgpExtendedMessageUtil.advertizedBgpExtendedMessageCapability(open1));
}
Aggregations