当前位置: 首页>>代码示例>>Java>>正文


Java LsAcknowledge类代码示例

本文整理汇总了Java中org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge的典型用法代码示例。如果您正苦于以下问题:Java LsAcknowledge类的具体用法?Java LsAcknowledge怎么用?Java LsAcknowledge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LsAcknowledge类属于org.onosproject.ospf.protocol.ospfpacket.types包,在下文中一共展示了LsAcknowledge类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: directAcknowledge

import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; //导入依赖的package包/类
/**
 * Sends a direct Acknowledgment for a particular LSA to the Neighbor.
 *
 * @param ackLsa   LSA instance
 * @param ch       netty channel instance
 * @param sourceIp source IP address
 */
public void directAcknowledge(LsaHeader ackLsa, Channel ch, Ip4Address sourceIp) {
    log.debug("OSPFNbr::directAcknowledge...!!!");

    LsAcknowledge ackContent = new LsAcknowledge();
    // seting OSPF Header
    ackContent.setOspfVer(OspfUtil.OSPF_VERSION);
    ackContent.setOspftype(OspfPacketType.LSAACK.value());
    ackContent.setRouterId(ospfArea.routerId());
    ackContent.setAreaId(ospfArea.areaId());
    ackContent.setAuthType(OspfUtil.NOT_ASSIGNED);
    ackContent.setAuthentication(OspfUtil.NOT_ASSIGNED);
    ackContent.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
    ackContent.setChecksum(OspfUtil.NOT_ASSIGNED);
    ackContent.addLinkStateHeader(ackLsa);
    //setting the destination IP
    ackContent.setDestinationIp(sourceIp);
    byte[] messageToWrite = getMessage(ackContent);
    ch.write(messageToWrite);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:OspfNbrImpl.java

示例2: testGetMessage2

import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; //导入依赖的package包/类
@Test(expected = Exception.class)
public void testGetMessage2() throws Exception {

    lsAck = new LsAcknowledge();
    lsAck.setAuthType(1);
    lsAck.setOspftype(5);
    lsAck.setRouterId(Ip4Address.valueOf("10.226.165.164"));
    lsAck.setAreaId(Ip4Address.valueOf("10.226.165.100"));
    lsAck.setChecksum(201);
    lsAck.setAuthentication(2);
    lsAck.setOspfPacLength(48);
    lsAck.setOspfVer(2);
    ospfMessageWriter.getMessage(lsAck, 1, 1);
    assertThat(ospfMessageWriter, is(notNullValue()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:OspfMessageWriterTest.java

示例3: testGetMessage5

import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; //导入依赖的package包/类
/**
 * Tests getMessage() method.
 */
@Test(expected = Exception.class)
public void testGetMessage5() throws Exception {
    lsAck = new LsAcknowledge();
    lsAck.setAuthType(1);
    lsAck.setOspftype(5);
    lsAck.setRouterId(Ip4Address.valueOf("10.226.165.164"));
    lsAck.setAreaId(Ip4Address.valueOf("10.226.165.100"));
    lsAck.setChecksum(201);
    lsAck.setAuthentication(2);
    lsAck.setOspfPacLength(48);
    lsAck.setOspfVer(2);
    ospfMessageWriter.getMessage(lsAck, 1, 1);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:OspfMessageWriterTest.java

示例4: processLsAckMessage

import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; //导入依赖的package包/类
/**
 * Process the ls acknowledge message.
 *
 * @param ospfMessage OSPF message instance.
 * @param ctx         channel handler context instance.
 * @throws Exception might throws exception
 */
void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
    log.debug("OspfChannelHandler::processLsAckMessage");
    LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage;
    //check it is present in listOfNeighbors
    OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString());
    if (nbr != null) {
        if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) {
            // discard the packet.
            return;
        } else {
            // process ls acknowledgements
            Iterator itr = lsAckPacket.getLinkStateHeaders().iterator();
            while (itr.hasNext()) {
                LsaHeader lsRequest = (LsaHeader) itr.next();

                OspfLsa ospfLsa =
                        (OspfLsa) nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
                if (lsRequest != null && ospfLsa != null) {
                    String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa(
                            lsRequest, (LsaHeader) ospfLsa);
                    if (isSame.equals("same")) {
                        nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
                    }
                }
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:OspfInterfaceImpl.java

示例5: testProcessLSAckMessage

import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; //导入依赖的package包/类
@Test(expected = Exception.class)
public void testProcessLSAckMessage() throws Exception {
    ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
    ospfInterface.setInterfaceType(2);
    ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
    ospfInterface.setHelloIntervalTime(10);
    ospfInterface.setRouterDeadIntervalTime(10);
    ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
    channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
    OspfMessage message;
    lsAck = new LsAcknowledge();
    lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
    lsAck.setOspfVer(2);
    lsAck.setAreaId(Ip4Address.valueOf("12.12.12.12"));
    LsaHeader lsaHeader = new LsaHeader();
    lsAck.addLinkStateHeader(lsaHeader);
    message = lsAck;
    ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
                              Ip4Address.valueOf("10.226.165.100"), 2,
                              topologyForDeviceAndLink);
    ospfNbr.setLastDdPacket(createDdPacket());
    ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
    ospfNbr.setState(OspfNeighborState.FULL);
    ospfNbr.setRouterPriority(0);
    ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
    ospfNbr.setDdSeqNum(123);
    channelHandlerContext = null;
    channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
    ospfInterface.processLsAckMessage(message, channelHandlerContext);
    assertThat(ospfInterfaceChannelHandler, is(notNullValue()));

}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:OspfInterfaceImplTest.java

示例6: processLsAckMessage

import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; //导入依赖的package包/类
/**
 * Process the ls acknowledge message.
 *
 * @param ospfMessage OSPF message instance.
 * @param ctx         channel handler context instance.
 */
void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
    log.debug("OspfChannelHandler::processLsAckMessage");
    LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage;
    //check it is present in listOfNeighbors
    OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString());
    if (nbr != null) {
        if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) {
            // discard the packet.
            return;
        } else {
            // process ls acknowledgements
            Iterator itr = lsAckPacket.getLinkStateHeaders().iterator();
            while (itr.hasNext()) {
                LsaHeader lsRequest = (LsaHeader) itr.next();

                OspfLsa ospfLsa =
                        nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
                if (ospfLsa != null) {
                    String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa(
                            lsRequest, (LsaHeader) ospfLsa);
                    if (isSame.equals("same")) {
                        nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
                    }
                }
            }
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:35,代码来源:OspfInterfaceImpl.java

示例7: testIsValidOspfCheckSum

import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; //导入依赖的package包/类
/**
 * Tests isValidOspfCheckSum() method.
 */
@Test
public void testIsValidOspfCheckSum() throws Exception {
    hello = new HelloPacket();
    hello.setOspfVer(2);
    hello.setOspftype(1);
    hello.setOspfPacLength(172);
    hello.setRouterId(Ip4Address.valueOf("192.168.170.3"));
    hello.setAreaId(Ip4Address.valueOf("0.0.0.1"));
    hello.setChecksum(5537);
    hello.setAuthType(0);
    hello.setAuthentication(0);
    validate = checksumCalculator.isValidOspfCheckSum(hello, ospfChecksumPos1, ospfChecksumPos2);
    assertThat(validate, is(false));
    lsack = new LsAcknowledge();
    lsack.setOspfVer(2);
    lsack.setOspftype(5);
    lsack.setOspfPacLength(172);
    lsack.setRouterId(Ip4Address.valueOf("192.168.170.3"));
    lsack.setAreaId(Ip4Address.valueOf("0.0.0.1"));
    lsack.setChecksum(37537);
    lsack.setAuthType(0);
    lsack.setAuthentication(0);
    validate = checksumCalculator.isValidOspfCheckSum(lsack, ospfChecksumPos1, ospfChecksumPos2);
    assertThat(validate, is(true));
    message = new LsUpdate();
    message.setOspfVer(2);
    message.setOspftype(5);
    message.setOspfPacLength(172);
    message.setRouterId(Ip4Address.valueOf("192.168.170.3"));
    message.setAreaId(Ip4Address.valueOf("0.0.0.1"));
    message.setChecksum(37537);
    message.setAuthType(0);
    message.setAuthentication(0);
    validate = checksumCalculator.isValidOspfCheckSum(message, ospfChecksumPos1, ospfChecksumPos2);
    assertThat(validate, is(true));
    message1 = new DdPacket();
    message1.setOspfVer(2);
    message1.setOspftype(5);
    message1.setOspfPacLength(172);
    message1.setRouterId(Ip4Address.valueOf("192.168.170.3"));
    message1.setAreaId(Ip4Address.valueOf("0.0.0.1"));
    message1.setChecksum(37537);
    message1.setAuthType(0);
    message1.setAuthentication(0);
    validate = checksumCalculator.isValidOspfCheckSum(message1, ospfChecksumPos1, ospfChecksumPos2);
    assertThat(validate, is(true));
    message2 = new LsRequest();
    message2.setOspfVer(2);
    message2.setOspftype(5);
    message2.setOspfPacLength(172);
    message2.setRouterId(Ip4Address.valueOf("192.168.170.3"));
    message2.setAreaId(Ip4Address.valueOf("0.0.0.1"));
    message2.setChecksum(37537);
    message2.setAuthType(0);
    message2.setAuthentication(0);
    validate = checksumCalculator.isValidOspfCheckSum(message2, ospfChecksumPos1, ospfChecksumPos2);
    assertThat(validate, is(true));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:62,代码来源:ChecksumCalculatorTest.java

示例8: run

import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge; //导入依赖的package包/类
@Override
public void run() {
    if (!linkStateHeaders().isEmpty()) {
        isDelayedAckTimerScheduled = true;
        if (ch != null && ch.isConnected()) {

            List<LsaHeader> listOfLsaHeadersAcknowledged = new ArrayList<>();
            List<LsaHeader> listOfLsaHeaders = linkStateHeaders();
            log.debug("Delayed Ack, Number of Lsa's to Ack {}", listOfLsaHeaders.size());
            Iterator itr = listOfLsaHeaders.iterator();
            while (itr.hasNext()) {
                LsAcknowledge ackContent = new LsAcknowledge();
                //Setting OSPF Header
                ackContent.setOspfVer(OspfUtil.OSPF_VERSION);
                ackContent.setOspftype(OspfPacketType.LSAACK.value());
                ackContent.setRouterId(ospfArea.routerId());
                ackContent.setAreaId(ospfArea.areaId());
                ackContent.setAuthType(OspfUtil.NOT_ASSIGNED);
                ackContent.setAuthentication(OspfUtil.NOT_ASSIGNED);
                ackContent.setOspfPacLength(OspfUtil.NOT_ASSIGNED);
                ackContent.setChecksum(OspfUtil.NOT_ASSIGNED);
                //limit to mtu
                int currentLength = OspfUtil.OSPF_HEADER_LENGTH;
                int maxSize = mtu() -
                        OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
                while (itr.hasNext()) {
                    if ((currentLength + OspfUtil.LSA_HEADER_LENGTH) >= maxSize) {
                        break;
                    }
                    LsaHeader lsaHeader = (LsaHeader) itr.next();
                    ackContent.addLinkStateHeader(lsaHeader);
                    currentLength = currentLength + OspfUtil.LSA_HEADER_LENGTH;
                    listOfLsaHeadersAcknowledged.add(lsaHeader);
                    log.debug("Delayed Ack, Added Lsa's to Ack {}", lsaHeader);
                }

                log.debug("Delayed Ack, Number of Lsa's in LsAck packet {}",
                          ackContent.getLinkStateHeaders().size());

                //set the destination
                if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR
                        || state() == OspfInterfaceState.POINT2POINT) {
                    ackContent.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
                } else if (state() == OspfInterfaceState.DROTHER) {
                    ackContent.setDestinationIp(OspfUtil.ALL_DROUTERS);
                }
                byte[] messageToWrite = getMessage(ackContent);
                ch.write(messageToWrite);

                for (LsaHeader lsa : listOfLsaHeadersAcknowledged) {
                    linkStateHeaders().remove(lsa);
                    removeLsaFromNeighborMap(((OspfAreaImpl) ospfArea).getLsaKey(lsa));
                }
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:58,代码来源:OspfInterfaceImpl.java


注:本文中的org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。