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