Search in sources :

Example 11 with MultiProtocolExtnCapabilityTlv

use of org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv in project onos by opennetworkinglab.

the class BgpControllerImplTest method bgpOpenMessageTest8.

@Test
public void bgpOpenMessageTest8() throws InterruptedException {
    // Open message with route policy distribution capability
    short afi = Constants.AFI_FLOWSPEC_RPD_VALUE;
    byte res = 0;
    byte safi = Constants.SAFI_FLOWSPEC_RPD_VALUE;
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    bgpControllerImpl.getConfig().setFlowSpecRpdCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer1.connect(connectToSocket);
    boolean result;
    result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
    assertThat(result, is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) Test(org.junit.Test)

Example 12 with MultiProtocolExtnCapabilityTlv

use of org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv in project onos by opennetworkinglab.

the class BgpControllerImplTest method bgpOpenMessageTest7.

@Test
public void bgpOpenMessageTest7() throws InterruptedException {
    // Open message with both LS capability and as4 capability
    short afi = 16388;
    byte res = 0;
    byte safi = 71;
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    peer1.peerChannelHandler.isLargeAsCapabilitySet = true;
    bgpControllerImpl.getConfig().setLargeASCapability(true);
    BgpValueType tempTlv = new FourOctetAsNumCapabilityTlv(200);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv);
    bgpControllerImpl.getConfig().setLsCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer1.connect(connectToSocket);
    boolean result;
    result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
    assertThat(result, is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) FourOctetAsNumCapabilityTlv(org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv) Test(org.junit.Test)

Example 13 with MultiProtocolExtnCapabilityTlv

use of org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv in project onos by opennetworkinglab.

the class BgpControllerImplTest method testBgpUpdateMessage1.

/**
 * Peer1 has Node NLRI (MpReach).
 */
@Test
public void testBgpUpdateMessage1() throws InterruptedException {
    // Initiate the connections
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    short afi = 16388;
    byte res = 0;
    byte safi = 71;
    bgpControllerImpl.getConfig().setLsCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.9", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer1
    BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.9"));
    BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    BgpValueType tlv = AutonomousSystemTlv.of(2478);
    subTlvs.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    subTlvs.add(tlv);
    NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x10, (short) 256);
    BgpNodeLSIdentifier key = new BgpNodeLSIdentifier(nodeDes);
    AdjRibIn adj = peer.adjRib();
    // In Adj-RIB, nodeTree should contains specified key
    assertThat(adj.nodeTree().containsKey(key), is(true));
    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
    // In Local-RIB, nodeTree should contains specified key
    assertThat(obj.nodeTree().containsKey(key), is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) BgpPeerImpl(org.onosproject.bgp.controller.impl.BgpPeerImpl) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) BgpLocalRibImpl(org.onosproject.bgp.controller.impl.BgpLocalRibImpl) InetSocketAddress(java.net.InetSocketAddress) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier) LinkedList(java.util.LinkedList) BgpId(org.onosproject.bgp.controller.BgpId) VpnAdjRibIn(org.onosproject.bgp.controller.impl.VpnAdjRibIn) AdjRibIn(org.onosproject.bgp.controller.impl.AdjRibIn) Test(org.junit.Test)

Example 14 with MultiProtocolExtnCapabilityTlv

use of org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv in project onos by opennetworkinglab.

the class BgpControllerImplTest method testBgpUpdateMessage2.

/**
 * Peer1 has Node NLRI (MpReach) and Peer2 has Node NLRI with same MpReach and MpUnReach.
 */
@Test
public void testBgpUpdateMessage2() throws InterruptedException, TestUtilsException {
    // Initiate the connections
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    short afi = 16388;
    byte res = 0;
    byte safi = 71;
    bgpControllerImpl.getConfig().setLsCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer2.peerChannelHandler.capabilityTlv.add(tempTlv1);
    Channel channel = peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.95", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer1
    BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.95"));
    BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    BgpValueType tlv = AutonomousSystemTlv.of(2478);
    subTlvs.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    subTlvs.add(tlv);
    NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x10, (short) 256);
    BgpNodeLSIdentifier key = new BgpNodeLSIdentifier(nodeDes);
    TimeUnit.MILLISECONDS.sleep(500);
    AdjRibIn adj = peer.adjRib();
    // In Adj-RIB, nodeTree should contains specified key
    assertThat(adj.nodeTree().containsKey(key), is(true));
    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
    // In Local-RIB, nodeTree should contains specified key
    assertThat(obj.nodeTree().containsKey(key), is(true));
    peer2.peerChannelHandler.asNumber = 200;
    peer2.peerChannelHandler.version = 4;
    peer2.peerChannelHandler.holdTime = 120;
    bgpControllerImpl.getConfig().setLsCapability(true);
    tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer2.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer2.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.70", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer2
    bgpId = new BgpId(IpAddress.valueOf("127.0.0.70"));
    peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    TimeUnit.MILLISECONDS.sleep(200);
    adj = peer.adjRib();
    // In Adj-RIB, nodetree should be empty
    assertThat(adj.nodeTree().isEmpty(), is(true));
    // Disconnect peer1
    channel.disconnect();
    channel.close();
    obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
    TimeUnit.MILLISECONDS.sleep(200);
    // In Local-RIB, nodetree should be empty
    assertThat(obj.nodeTree().isEmpty(), is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) BgpPeerImpl(org.onosproject.bgp.controller.impl.BgpPeerImpl) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) BgpLocalRibImpl(org.onosproject.bgp.controller.impl.BgpLocalRibImpl) InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.netty.channel.Channel) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier) LinkedList(java.util.LinkedList) BgpId(org.onosproject.bgp.controller.BgpId) VpnAdjRibIn(org.onosproject.bgp.controller.impl.VpnAdjRibIn) AdjRibIn(org.onosproject.bgp.controller.impl.AdjRibIn) Test(org.junit.Test)

Example 15 with MultiProtocolExtnCapabilityTlv

use of org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv in project onos by opennetworkinglab.

the class BgpControllerImplTest method testBgpUpdateMessage7.

/**
 * Peer1 has Node NLRI (MpReach) and peer2 has Node NLRI with same MpReach and MpUnReach with IsIsNonPseudonode.
 */
@Test
public void testBgpUpdateMessage7() throws InterruptedException, TestUtilsException {
    // Initiate the connections
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    short afi = 16388;
    byte res = 0;
    byte safi = 71;
    bgpControllerImpl.getConfig().setLsCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    Channel channel = peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.91", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer1
    BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.91"));
    BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    LinkedList<BgpValueType> subTlvs1 = new LinkedList<>();
    BgpValueType tlv = null;
    tlv = AutonomousSystemTlv.of(2478);
    subTlvs.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    subTlvs.add(tlv);
    subTlvs1.add(tlv);
    NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x10, (short) 256);
    BgpNodeLSIdentifier key = new BgpNodeLSIdentifier(nodeDes);
    AdjRibIn adj = peer.adjRib();
    // In Adj-RIB, nodeTree should contains specified key
    assertThat(adj.nodeTree().containsKey(key), is(true));
    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
    // In Local-RIB, nodeTree should contains specified key
    assertThat(obj.nodeTree().containsKey(key), is(true));
    peer2.peerChannelHandler.asNumber = 200;
    peer2.peerChannelHandler.version = 4;
    peer2.peerChannelHandler.holdTime = 120;
    bgpControllerImpl.getConfig().setLsCapability(true);
    tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer2.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer2.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.90", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer2
    bgpId = new BgpId(IpAddress.valueOf("127.0.0.90"));
    peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    tlv = AutonomousSystemTlv.of(2222);
    subTlvs1.add(tlv);
    byte[] isoNodeID = new byte[] { 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58 };
    tlv = IsIsNonPseudonode.of(isoNodeID);
    subTlvs1.add(tlv);
    nodeDes = new NodeDescriptors(subTlvs1, (short) 0x1a, (short) 256);
    key = new BgpNodeLSIdentifier(nodeDes);
    adj = peer.adjRib();
    // In Adj-RIB, nodeTree should contains specified key
    log.info("key " + key.toString());
    log.info("adj.nodeTree() " + adj.nodeTree().toString());
    assertThat(adj.nodeTree().containsKey(key), is(true));
    // peer1 disconnects
    channel.disconnect();
    channel.close();
    obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
    TimeUnit.MILLISECONDS.sleep(200);
    // In Local-RIB, nodeTree should contains specified key
    assertThat(obj.nodeTree().containsKey(key), is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) BgpPeerImpl(org.onosproject.bgp.controller.impl.BgpPeerImpl) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) BgpLocalRibImpl(org.onosproject.bgp.controller.impl.BgpLocalRibImpl) InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.netty.channel.Channel) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier) LinkedList(java.util.LinkedList) BgpId(org.onosproject.bgp.controller.BgpId) VpnAdjRibIn(org.onosproject.bgp.controller.impl.VpnAdjRibIn) AdjRibIn(org.onosproject.bgp.controller.impl.AdjRibIn) Test(org.junit.Test)

Aggregations

BgpValueType (org.onosproject.bgpio.types.BgpValueType)16 MultiProtocolExtnCapabilityTlv (org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv)16 Test (org.junit.Test)13 LinkedList (java.util.LinkedList)10 InetSocketAddress (java.net.InetSocketAddress)9 BgpId (org.onosproject.bgp.controller.BgpId)9 BgpLocalRibImpl (org.onosproject.bgp.controller.impl.BgpLocalRibImpl)9 BgpPeerImpl (org.onosproject.bgp.controller.impl.BgpPeerImpl)9 VpnAdjRibIn (org.onosproject.bgp.controller.impl.VpnAdjRibIn)9 NodeDescriptors (org.onosproject.bgpio.protocol.linkstate.NodeDescriptors)9 AdjRibIn (org.onosproject.bgp.controller.impl.AdjRibIn)7 BgpNodeLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier)7 Channel (org.jboss.netty.channel.Channel)6 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)3 FourOctetAsNumCapabilityTlv (org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv)3 RpdCapabilityTlv (org.onosproject.bgpio.types.RpdCapabilityTlv)3 BgpParseException (org.onosproject.bgpio.exceptions.BgpParseException)2 PathAttrNlriDetails (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails)2 PathAttrNlriDetailsLocalRib (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib)2 RouteDistinguisher (org.onosproject.bgpio.types.RouteDistinguisher)2