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


Java LsAcknowledge.setRouterId方法代码示例

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


在下文中一共展示了LsAcknowledge.setRouterId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例5: 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.setRouterId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。