Search in sources :

Example 1 with NodeDescriptors

use of org.onosproject.bgpio.protocol.linkstate.NodeDescriptors in project onos by opennetworkinglab.

the class BgpUpdateMsgTest method bgpUpdateMessageTest19.

/**
 * This test case checks update message with prefix NLRI.
 */
@Test
public void bgpUpdateMessageTest19() throws BgpParseException {
    byte[] updateMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x00, (byte) 0xd6, 0x02, 0x00, 0x04, // withdrawn routes
    0x18, // withdrawn routes
    0x0a, // withdrawn routes
    0x01, // withdrawn routes
    0x01, // path attribute len
    0x00, // path attribute len
    (byte) 0xbb, // origin
    0x04, // origin
    0x01, // origin
    0x01, // origin
    0x00, // as_path
    0x40, // as_path
    0x02, // as_path
    0x04, // as_path
    0x02, // as_path
    0x01, // as_path
    (byte) 0xfd, // as_path
    (byte) 0xe9, // med
    (byte) 0x80, // med
    0x04, // med
    0x04, // med
    0x00, // med
    0x00, // med
    0x00, // med
    0x00, // mpreach
    (byte) 0x90, // mpreach
    0x0e, // mpreach
    0x00, // mpreach
    (byte) 0xa5, // mpreach
    0x40, // mpreach
    0x04, // mpreach
    0x47, // nexthop
    0x04, // nexthop
    0x04, // nexthop
    0x00, // nexthop
    0x00, // nexthop
    0x01, // reserved
    0x00, 0x00, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x06, 0x19, 0x21, 0x68, 0x07, 0x70, 0x01, 0x01, 0x09, 0x00, 0x05, 0x20, (byte) 0xc0, (byte) 0xa8, 0x4d, 0x01, 0x00, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21, 0x01, 0x09, 0x00, 0x05, 0x20, 0x15, 0x15, 0x15, 0x15, 0x00, 0x03, 0x00, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x06, 0x02, 0x20, 0x22, 0x02, 0x20, 0x22, 0x01, 0x09, 0x00, 0x05, 0x20, 0x16, 0x16, 0x16, // prefix nlri
    0x16 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);
    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message;
    BgpHeader bgpHeader = new BgpHeader();
    message = reader.readFrom(buffer, bgpHeader);
    assertThat(message, instanceOf(BgpUpdateMsg.class));
    BgpUpdateMsg other = (BgpUpdateMsg) message;
    assertThat(other.getHeader().getMarker(), is(MARKER));
    assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
    assertThat(other.getHeader().getLength(), is((short) 214));
    ListIterator<IpPrefix> listIterator1 = other.withdrawnRoutes().listIterator();
    byte[] prefix = new byte[] { 0x0a, 0x01, 0x01, 0x00 };
    IpPrefix testPrefixValue = listIterator1.next();
    assertThat(testPrefixValue.prefixLength(), is((int) 24));
    assertThat(testPrefixValue.address().toOctets(), is(prefix));
    BgpValueType testPathAttribute;
    Origin origin;
    AsPath asPath;
    Med med;
    MpReachNlri mpReach;
    List<BgpValueType> pathAttributes = new LinkedList<>();
    BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
    pathAttributes = actualpathAttribute.pathAttributes();
    ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
    OriginType originValue = OriginType.IGP;
    testPathAttribute = listIterator.next();
    origin = (Origin) testPathAttribute;
    assertThat(origin.origin(), is(originValue));
    testPathAttribute = listIterator.next();
    asPath = (AsPath) testPathAttribute;
    ListIterator<Short> listIterator2 = asPath.asPathSeq().listIterator();
    assertThat(listIterator2.next(), is((short) 65001));
    testPathAttribute = listIterator.next();
    med = (Med) testPathAttribute;
    assertThat(med.med(), is(0));
    testPathAttribute = listIterator.next();
    mpReach = (MpReachNlri) testPathAttribute;
    assertThat(mpReach.mpReachNlriLen(), is((int) 165));
    assertThat(mpReach.getType(), is((short) 14));
    List<BgpLSNlri> testMpReachNlri = new LinkedList<>();
    testMpReachNlri = mpReach.mpReachNlri();
    ListIterator<BgpLSNlri> list1 = testMpReachNlri.listIterator();
    BgpLSNlri testnlri = list1.next();
    NlriType nlriType = org.onosproject.bgpio.protocol.NlriType.PREFIX_IPV4;
    ProtocolType protocolId = org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO;
    assertThat(testnlri.getIdentifier(), is((long) 0));
    assertThat(testnlri.getNlriType(), is(nlriType));
    assertThat(testnlri.getProtocolId(), is(protocolId));
    BgpPrefixLSNlri testprefixnlri = (BgpPrefixLSNlri) testnlri;
    NodeDescriptors testLocalNodeDescriptors = testprefixnlri.getLocalNodeDescriptors();
    List<BgpValueType> testSubTlvs = new LinkedList<>();
    testSubTlvs = testLocalNodeDescriptors.getSubTlvs();
    ListIterator<BgpValueType> subtlvlist1 = testSubTlvs.listIterator();
    AutonomousSystemTlv testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist1.next();
    assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
    assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
    BgpLSIdentifierTlv testBgpLsIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist1.next();
    assertThat(testBgpLsIdentifierTlv.getBgpLsIdentifier(), is(33686018));
    assertThat(testBgpLsIdentifierTlv.getType(), is((short) 513));
    IsIsNonPseudonode testIsIsNonPseudonode = (IsIsNonPseudonode) subtlvlist1.next();
    byte[] expIsoNodeId = new byte[] { 0x19, 0x21, 0x68, 0x07, 0x70, 0x01 };
    assertThat(testIsIsNonPseudonode.getIsoNodeId(), is(expIsoNodeId));
    assertThat(testIsIsNonPseudonode.getType(), is((short) 515));
    List<BgpValueType> testPrefixDescriptors = new LinkedList<>();
    testPrefixDescriptors = testprefixnlri.getPrefixdescriptor();
    ListIterator<BgpValueType> subtlvlist2 = testPrefixDescriptors.listIterator();
    IPReachabilityInformationTlv testIPReachabilityInformationTlv = (IPReachabilityInformationTlv) subtlvlist2.next();
    byte[] address = new byte[] { (byte) 0xc0, (byte) 0xa8, 0x4d, 0x01 };
    IpPrefix prefix1 = IpPrefix.valueOf(IpAddress.Version.INET, address, 32);
    assertThat(testIPReachabilityInformationTlv.getPrefixValue(), is(prefix1));
    assertThat(testIPReachabilityInformationTlv.getPrefixLen(), is((byte) 32));
}
Also used : Origin(org.onosproject.bgpio.types.Origin) BgpHeader(org.onosproject.bgpio.types.BgpHeader) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) IPReachabilityInformationTlv(org.onosproject.bgpio.types.IPReachabilityInformationTlv) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) IpPrefix(org.onlab.packet.IpPrefix) BgpValueType(org.onosproject.bgpio.types.BgpValueType) OriginType(org.onosproject.bgpio.types.Origin.OriginType) BgpLSIdentifierTlv(org.onosproject.bgpio.types.BgpLSIdentifierTlv) Med(org.onosproject.bgpio.types.Med) LinkedList(java.util.LinkedList) IsIsNonPseudonode(org.onosproject.bgpio.types.IsIsNonPseudonode) AsPath(org.onosproject.bgpio.types.AsPath) BgpPathAttributes(org.onosproject.bgpio.protocol.ver4.BgpPathAttributes) AutonomousSystemTlv(org.onosproject.bgpio.types.AutonomousSystemTlv) ProtocolType(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType) MpReachNlri(org.onosproject.bgpio.types.MpReachNlri) Test(org.junit.Test)

Example 2 with NodeDescriptors

use of org.onosproject.bgpio.protocol.linkstate.NodeDescriptors in project onos by opennetworkinglab.

the class BgpUpdateMsgTest method bgpUpdateMessageTest31.

/**
 * This test case checks update message with MPUnreach.
 */
@Test
public void bgpUpdateMessageTest31() throws BgpParseException {
    byte[] updateMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, // withdrawn routes
    (byte) 0xff, // withdrawn routes
    (byte) 0xff, // withdrawn routes
    0x00, // withdrawn routes
    0x5e, // withdrawn routes
    0x02, // withdrawn routes
    0x00, // withdrawn routes
    0x04, // withdrawn routes
    0x18, // withdrawn routes
    0x0a, // withdrawn routes
    0x01, // withdrawn routes
    0x01, // path attribute len
    0x00, // path attribute len
    0x43, // origin
    0x04, // origin
    0x01, // origin
    0x01, // origin
    0x00, // as_path
    0x40, // as_path
    0x02, // as_path
    0x04, // as_path
    0x02, // as_path
    0x01, // as_path
    (byte) 0xfd, // as_path
    (byte) 0xe9, // med
    (byte) 0x80, // med
    0x04, // med
    0x04, // med
    0x00, // med
    0x00, // med
    0x00, // med
    0x00, // mpunreach with safi = 71
    (byte) 0x80, // mpunreach with safi = 71
    0x0f, // mpunreach with safi = 71
    0x2e, // mpunreach with safi = 71
    0x40, // mpunreach with safi = 71
    0x04, // mpunreach with safi = 71
    0x47, 0x00, 0x01, 0x00, 0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, // node nlri
    0x58 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);
    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message;
    BgpHeader bgpHeader = new BgpHeader();
    message = reader.readFrom(buffer, bgpHeader);
    assertThat(message, instanceOf(BgpUpdateMsg.class));
    BgpUpdateMsg other = (BgpUpdateMsg) message;
    assertThat(other.getHeader().getMarker(), is(MARKER));
    assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
    assertThat(other.getHeader().getLength(), is((short) 94));
    ListIterator<IpPrefix> listIterator1 = other.withdrawnRoutes().listIterator();
    byte[] prefix = new byte[] { 0x0a, 0x01, 0x01, 0x00 };
    IpPrefix testPrefixValue = listIterator1.next();
    assertThat(testPrefixValue.prefixLength(), is((int) 24));
    assertThat(testPrefixValue.address().toOctets(), is(prefix));
    BgpValueType testPathAttribute;
    Origin origin;
    AsPath asPath;
    Med med;
    MpUnReachNlri mpUnReach;
    List<BgpValueType> pathAttributes = new LinkedList<>();
    BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
    pathAttributes = actualpathAttribute.pathAttributes();
    ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
    OriginType originValue = OriginType.IGP;
    testPathAttribute = listIterator.next();
    origin = (Origin) testPathAttribute;
    assertThat(origin.origin(), is(originValue));
    testPathAttribute = listIterator.next();
    asPath = (AsPath) testPathAttribute;
    ListIterator<Short> listIterator2 = asPath.asPathSeq().listIterator();
    assertThat(listIterator2.next(), is((short) 65001));
    testPathAttribute = listIterator.next();
    med = (Med) testPathAttribute;
    assertThat(med.med(), is(0));
    testPathAttribute = listIterator.next();
    mpUnReach = (MpUnReachNlri) testPathAttribute;
    assertThat(mpUnReach.mpUnReachNlriLen(), is((int) 46));
    assertThat(mpUnReach.getType(), is((short) 15));
    List<BgpLSNlri> testMpUnReachNlri = new LinkedList<>();
    testMpUnReachNlri = mpUnReach.mpUnReachNlri();
    ListIterator<BgpLSNlri> list1 = testMpUnReachNlri.listIterator();
    BgpLSNlri testnlri = list1.next();
    NlriType nlriType = org.onosproject.bgpio.protocol.NlriType.NODE;
    ProtocolType protocolId = org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO;
    assertThat(testnlri.getIdentifier(), is((long) 0));
    assertThat(testnlri.getNlriType(), is(nlriType));
    assertThat(testnlri.getProtocolId(), is(protocolId));
    BgpNodeLSNlriVer4 testNodenlri = (BgpNodeLSNlriVer4) testnlri;
    BgpNodeLSIdentifier testLocalNodeDescriptors = testNodenlri.getLocalNodeDescriptors();
    List<BgpValueType> testSubTlvs = new LinkedList<>();
    NodeDescriptors localNodeDescriptors = testLocalNodeDescriptors.getNodedescriptors();
    testSubTlvs = localNodeDescriptors.getSubTlvs();
    ListIterator<BgpValueType> subtlvlist1 = testSubTlvs.listIterator();
    AutonomousSystemTlv testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist1.next();
    assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
    assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
    BgpLSIdentifierTlv testBgpLsIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist1.next();
    assertThat(testBgpLsIdentifierTlv.getBgpLsIdentifier(), is(33686018));
    assertThat(testBgpLsIdentifierTlv.getType(), is((short) 513));
    IsIsNonPseudonode testIsIsNonPseudonode = (IsIsNonPseudonode) subtlvlist1.next();
    byte[] expIsoNodeId = new byte[] { 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58 };
    assertThat(testIsIsNonPseudonode.getIsoNodeId(), is(expIsoNodeId));
    assertThat(testIsIsNonPseudonode.getType(), is((short) 515));
}
Also used : Origin(org.onosproject.bgpio.types.Origin) MpUnReachNlri(org.onosproject.bgpio.types.MpUnReachNlri) BgpHeader(org.onosproject.bgpio.types.BgpHeader) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) IpPrefix(org.onlab.packet.IpPrefix) BgpNodeLSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4) BgpValueType(org.onosproject.bgpio.types.BgpValueType) OriginType(org.onosproject.bgpio.types.Origin.OriginType) BgpLSIdentifierTlv(org.onosproject.bgpio.types.BgpLSIdentifierTlv) Med(org.onosproject.bgpio.types.Med) LinkedList(java.util.LinkedList) IsIsNonPseudonode(org.onosproject.bgpio.types.IsIsNonPseudonode) AsPath(org.onosproject.bgpio.types.AsPath) BgpPathAttributes(org.onosproject.bgpio.protocol.ver4.BgpPathAttributes) AutonomousSystemTlv(org.onosproject.bgpio.types.AutonomousSystemTlv) ProtocolType(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType) Test(org.junit.Test)

Example 3 with NodeDescriptors

use of org.onosproject.bgpio.protocol.linkstate.NodeDescriptors in project onos by opennetworkinglab.

the class BgpUpdateMsgTest method bgpUpdateMessageTest20.

/**
 * This test case checks update message with link NLRI.
 */
@Test
public void bgpUpdateMessageTest20() throws BgpParseException {
    byte[] updateMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x00, (byte) 0x83, 0x02, 0x00, 0x04, // withdrawn routes
    0x18, // withdrawn routes
    0x0a, // withdrawn routes
    0x01, // withdrawn routes
    0x01, // path attribute len
    0x00, // path attribute len
    0x68, // origin
    0x04, // origin
    0x01, // origin
    0x01, // origin
    0x00, // as_path
    0x40, // as_path
    0x02, // as_path
    0x04, // as_path
    0x02, // as_path
    0x01, // as_path
    (byte) 0xfd, // as_path
    (byte) 0xe9, // med
    (byte) 0x80, // med
    0x04, // med
    0x04, // med
    0x00, // med
    0x00, // med
    0x00, // med
    0x00, // mpreach
    (byte) 0x80, // mpreach
    0x0e, // mpreach
    0x53, // mpreach
    0x40, // mpreach
    0x04, // mpreach
    0x47, // nexthop
    0x04, // nexthop
    0x04, // nexthop
    0x00, // nexthop
    0x00, // nexthop
    0x01, // reserved
    0x00, 0x00, 0x02, 0x00, 0x46, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1b, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x07, 0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21, 0x03, 0x01, 0x01, 0x00, 0x1a, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x00, 0x06, 0x19, // link nlri
    0x00, // link nlri
    (byte) 0x95, // link nlri
    0x02, // link nlri
    0x50, // link nlri
    0x21 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);
    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message = null;
    BgpHeader bgpHeader = new BgpHeader();
    message = reader.readFrom(buffer, bgpHeader);
    assertThat(message, instanceOf(BgpUpdateMsg.class));
    BgpUpdateMsg other = (BgpUpdateMsg) message;
    assertThat(other.getHeader().getMarker(), is(MARKER));
    assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
    assertThat(other.getHeader().getLength(), is((short) 131));
    ListIterator<IpPrefix> listIterator1 = other.withdrawnRoutes().listIterator();
    byte[] prefix = new byte[] { 0x0a, 0x01, 0x01, 0x00 };
    IpPrefix testPrefixValue = listIterator1.next();
    assertThat(testPrefixValue.prefixLength(), is((int) 24));
    assertThat(testPrefixValue.address().toOctets(), is(prefix));
    BgpValueType testPathAttribute;
    Origin origin;
    AsPath asPath;
    Med med;
    MpReachNlri mpReach;
    List<BgpValueType> pathAttributes = new LinkedList<>();
    BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
    pathAttributes = actualpathAttribute.pathAttributes();
    ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
    OriginType originValue = OriginType.IGP;
    testPathAttribute = listIterator.next();
    origin = (Origin) testPathAttribute;
    assertThat(origin.origin(), is(originValue));
    testPathAttribute = listIterator.next();
    asPath = (AsPath) testPathAttribute;
    ListIterator<Short> listIterator2 = asPath.asPathSeq().listIterator();
    assertThat(listIterator2.next(), is((short) 65001));
    testPathAttribute = listIterator.next();
    med = (Med) testPathAttribute;
    assertThat(med.med(), is(0));
    testPathAttribute = listIterator.next();
    mpReach = (MpReachNlri) testPathAttribute;
    assertThat(mpReach.mpReachNlriLen(), is((int) 83));
    assertThat(mpReach.getType(), is((short) 14));
    List<BgpLSNlri> testMpReachNlri = new LinkedList<>();
    testMpReachNlri = mpReach.mpReachNlri();
    ListIterator<BgpLSNlri> list1 = testMpReachNlri.listIterator();
    BgpLSNlri testnlri = list1.next();
    NlriType nlriType = org.onosproject.bgpio.protocol.NlriType.LINK;
    ProtocolType protocolId = org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO;
    assertThat(testnlri.getIdentifier(), is((long) 0));
    assertThat(testnlri.getNlriType(), is(nlriType));
    assertThat(testnlri.getProtocolId(), is(protocolId));
    BgpLinkLsNlriVer4 testlinknlri = (BgpLinkLsNlriVer4) testnlri;
    NodeDescriptors testLocalNodeDescriptors = testlinknlri.localNodeDescriptors();
    List<BgpValueType> testSubTlvs = new LinkedList<>();
    testSubTlvs = testLocalNodeDescriptors.getSubTlvs();
    ListIterator<BgpValueType> subtlvlist1 = testSubTlvs.listIterator();
    AutonomousSystemTlv testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist1.next();
    assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
    assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
    BgpLSIdentifierTlv testBgpLsIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist1.next();
    assertThat(testBgpLsIdentifierTlv.getBgpLsIdentifier(), is(33686018));
    assertThat(testBgpLsIdentifierTlv.getType(), is((short) 513));
    IsIsPseudonode testIsIsPseudonode = (IsIsPseudonode) subtlvlist1.next();
    assertThat(testIsIsPseudonode.getPsnIdentifier(), is((byte) 3));
    assertThat(testIsIsPseudonode.getType(), is((short) 515));
    NodeDescriptors testRemoteNodeDescriptors = testlinknlri.remoteNodeDescriptors();
    testSubTlvs = testRemoteNodeDescriptors.getSubTlvs();
    ListIterator<BgpValueType> subtlvlist2 = testSubTlvs.listIterator();
    testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist2.next();
    assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
    assertThat(testAutonomousSystemTlv.getType(), is((short) 512));
    testBgpLsIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist2.next();
    assertThat(testBgpLsIdentifierTlv.getBgpLsIdentifier(), is(33686018));
    assertThat(testBgpLsIdentifierTlv.getType(), is((short) 513));
    IsIsNonPseudonode testIsIsNonPseudonode = (IsIsNonPseudonode) subtlvlist2.next();
    byte[] expIsoNodeId = new byte[] { 0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21 };
    assertThat(testIsIsNonPseudonode.getIsoNodeId(), is(expIsoNodeId));
    assertThat(testIsIsNonPseudonode.getType(), is((short) 515));
}
Also used : Origin(org.onosproject.bgpio.types.Origin) IsIsPseudonode(org.onosproject.bgpio.types.IsIsPseudonode) BgpHeader(org.onosproject.bgpio.types.BgpHeader) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) IpPrefix(org.onlab.packet.IpPrefix) BgpValueType(org.onosproject.bgpio.types.BgpValueType) OriginType(org.onosproject.bgpio.types.Origin.OriginType) BgpLSIdentifierTlv(org.onosproject.bgpio.types.BgpLSIdentifierTlv) Med(org.onosproject.bgpio.types.Med) LinkedList(java.util.LinkedList) BgpLinkLsNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4) IsIsNonPseudonode(org.onosproject.bgpio.types.IsIsNonPseudonode) AsPath(org.onosproject.bgpio.types.AsPath) BgpPathAttributes(org.onosproject.bgpio.protocol.ver4.BgpPathAttributes) AutonomousSystemTlv(org.onosproject.bgpio.types.AutonomousSystemTlv) ProtocolType(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType) MpReachNlri(org.onosproject.bgpio.types.MpReachNlri) Test(org.junit.Test)

Example 4 with NodeDescriptors

use of org.onosproject.bgpio.protocol.linkstate.NodeDescriptors in project onos by opennetworkinglab.

the class BgpControllerImplTest method testBgpUpdateMessage4.

/**
 * Peer1 has Node NLRI and Peer2 has Node NLRI with different MpReach and MpUnReach with VPN.
 */
@Test
public void testBgpUpdateMessage4() 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 = (byte) 0x80;
    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.35", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer1
    IpAddress ipAddress = IpAddress.valueOf("127.0.0.35");
    BgpId bgpId = new BgpId(ipAddress);
    BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    LinkedList<BgpValueType> subTlvs1 = new LinkedList<>();
    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);
    RouteDistinguisher rd = new RouteDistinguisher((long) 0x0A);
    VpnAdjRibIn vpnAdj = peer.vpnAdjRib();
    // In Adj-RIB, vpnNodeTree should contain rd
    assertThat(vpnAdj.vpnNodeTree().containsKey(rd), is(true));
    Map<BgpNodeLSIdentifier, PathAttrNlriDetails> treeValue = vpnAdj.vpnNodeTree().get(rd);
    // In Adj-RIB, vpnNodeTree should contain rd key which contains specified value
    assertThat(treeValue.containsKey(key), is(true));
    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRibVpn();
    // In Local-RIB, vpnNodeTree should contain rd
    assertThat(obj.vpnNodeTree().containsKey(rd), is(true));
    Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> value = obj.vpnNodeTree().get(rd);
    // In Local-RIB, vpnNodeTree should contain rd key which contains specified value
    assertThat(value.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);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer2.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.40", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer2
    bgpId = new BgpId(IpAddress.valueOf("127.0.0.40"));
    peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    tlv = AutonomousSystemTlv.of(686);
    subTlvs1.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    subTlvs1.add(tlv);
    nodeDes = new NodeDescriptors(subTlvs1, (short) 0x10, (short) 256);
    key = new BgpNodeLSIdentifier(nodeDes);
    vpnAdj = peer.vpnAdjRib();
    // In Adj-RIB, vpnNodeTree should contain rd
    assertThat(vpnAdj.vpnNodeTree().containsKey(rd), is(true));
    treeValue = vpnAdj.vpnNodeTree().get(rd);
    // In Adj-RIB, vpnNodeTree should contain rd key which contains specified value
    assertThat(treeValue.containsKey(key), is(true));
    // Disconnect peer1
    channel.disconnect();
    channel.close();
    obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRibVpn();
    // In Local-RIB, vpnNodeTree should contain rd
    assertThat(obj.vpnNodeTree().containsKey(rd), is(true));
    value = obj.vpnNodeTree().get(rd);
    // In Local-RIB, vpnNodeTree should contain rd key which contains specified value
    assertThat(value.containsKey(key), is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) PathAttrNlriDetailsLocalRib(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib) 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) RouteDistinguisher(org.onosproject.bgpio.types.RouteDistinguisher) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier) LinkedList(java.util.LinkedList) VpnAdjRibIn(org.onosproject.bgp.controller.impl.VpnAdjRibIn) BgpId(org.onosproject.bgp.controller.BgpId) PathAttrNlriDetails(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails) IpAddress(org.onlab.packet.IpAddress) Test(org.junit.Test)

Example 5 with NodeDescriptors

use of org.onosproject.bgpio.protocol.linkstate.NodeDescriptors in project onos by opennetworkinglab.

the class BgpControllerImplTest method testBgpUpdateMessage6.

/**
 * Peer2 has Prefix NLRI (MpReach).
 */
@Test
public void testBgpUpdateMessage6() 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);
    Channel channel = peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.94", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer1
    BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.94"));
    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 contain specified key
    assertThat(adj.nodeTree().containsKey(key), is(true));
    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
    // In Local-RIB, nodeTree should contain 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.80", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer2
    bgpId = new BgpId(IpAddress.valueOf("127.0.0.80"));
    peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    TimeUnit.MILLISECONDS.sleep(500);
    adj = peer.adjRib();
    // In Adj-RIB, nodeTree should contain specified key
    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 contain 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

LinkedList (java.util.LinkedList)13 Test (org.junit.Test)13 NodeDescriptors (org.onosproject.bgpio.protocol.linkstate.NodeDescriptors)13 BgpValueType (org.onosproject.bgpio.types.BgpValueType)13 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 BgpNodeLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier)9 MultiProtocolExtnCapabilityTlv (org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv)9 AdjRibIn (org.onosproject.bgp.controller.impl.AdjRibIn)7 Channel (org.jboss.netty.channel.Channel)6 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)5 ProtocolType (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType)4 BgpPathAttributes (org.onosproject.bgpio.protocol.ver4.BgpPathAttributes)4 AsPath (org.onosproject.bgpio.types.AsPath)4 AutonomousSystemTlv (org.onosproject.bgpio.types.AutonomousSystemTlv)4 BgpHeader (org.onosproject.bgpio.types.BgpHeader)4 BgpLSIdentifierTlv (org.onosproject.bgpio.types.BgpLSIdentifierTlv)4