本文整理汇总了Java中org.onosproject.ospf.protocol.util.OspfInterfaceState.DROTHER属性的典型用法代码示例。如果您正苦于以下问题:Java OspfInterfaceState.DROTHER属性的具体用法?Java OspfInterfaceState.DROTHER怎么用?Java OspfInterfaceState.DROTHER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.onosproject.ospf.protocol.util.OspfInterfaceState
的用法示例。
在下文中一共展示了OspfInterfaceState.DROTHER属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRefreshLsa
/**
* Process refresh LSA.
*
* @param wrapper LSA wrapper instance
*/
private void processRefreshLsa(LsaWrapper wrapper) throws Exception {
if (wrapper.isSelfOriginated()) { //self originated
//set the destination
OspfInterface ospfInterface = wrapper.ospfInterface();
if (ospfInterface != null) {
LsaHeader header = ((LsaWrapperImpl) wrapper).lsaHeader();
header.setAge(wrapper.currentAge());
if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR) {
if (header.lsType() == OspfLsaType.ROUTER.value()) {
RouterLsa routerLsa = ((OspfAreaImpl) ospfArea).buildRouterLsa(ospfInterface);
((OspfAreaImpl) ospfArea).addLsa(routerLsa, true, ospfInterface);
((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(routerLsa);
} else if (header.lsType() == OspfLsaType.NETWORK.value()) {
if (ospfInterface.listOfNeighbors().size() > 0) {
NetworkLsa networkLsa = ((OspfAreaImpl) ospfArea).buildNetworkLsa(
ospfInterface.ipAddress(), ospfInterface.ipNetworkMask());
ospfArea.addLsa(networkLsa, true, ospfInterface);
((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(networkLsa);
}
}
}
if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR ||
((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT ||
((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
ospfArea.refreshArea(ospfInterface);
}
log.debug("LSAQueueConsumer: processRefreshLsa - Flooded SelfOriginated LSA {}",
((LsaWrapperImpl) wrapper).lsaHeader());
}
}
}
示例2: neighborChange
/**
* Neighbor change event is triggered when the router priority gets changed.
*
* @throws Exception might throws exception
*/
public void neighborChange() throws Exception {
log.debug("OSPFInterfaceChannelHandler::neighborChange ");
if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR ||
state() == OspfInterfaceState.DROTHER) {
electRouter(channel);
}
}
示例3: processRefreshLsa
/**
* Process refresh LSA.
*
* @param wrapper LSA wrapper instance
*/
private void processRefreshLsa(LsaWrapper wrapper) throws OspfParseException {
if (wrapper.isSelfOriginated()) { //self originated
//set the destination
OspfInterface ospfInterface = wrapper.ospfInterface();
if (ospfInterface != null) {
LsaHeader header = ((LsaWrapperImpl) wrapper).lsaHeader();
header.setAge(wrapper.currentAge());
if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR) {
if (header.lsType() == OspfLsaType.ROUTER.value()) {
RouterLsa routerLsa = ((OspfAreaImpl) ospfArea).buildRouterLsa(ospfInterface);
((OspfAreaImpl) ospfArea).addLsa(routerLsa, true, ospfInterface);
((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(routerLsa);
} else if (header.lsType() == OspfLsaType.NETWORK.value()) {
if (ospfInterface.listOfNeighbors().size() > 0) {
NetworkLsa networkLsa = ((OspfAreaImpl) ospfArea).buildNetworkLsa(
ospfInterface.ipAddress(), ospfInterface.ipNetworkMask());
ospfArea.addLsa(networkLsa, true, ospfInterface);
((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(networkLsa);
}
}
}
if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR ||
((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT ||
((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
ospfArea.refreshArea(ospfInterface);
}
log.debug("LSAQueueConsumer: processRefreshLsa - Flooded SelfOriginated LSA {}",
((LsaWrapperImpl) wrapper).lsaHeader());
}
}
}
示例4: neighborChange
/**
* Neighbor change event is triggered when the router priority gets changed.
*/
public void neighborChange() {
log.debug("OSPFInterfaceChannelHandler::neighborChange ");
if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR ||
state() == OspfInterfaceState.DROTHER) {
electRouter(channel);
}
}
示例5: processLsRequestMessage
/**
* Process the Ls Request message.
*
* @param ospfMessage OSPF message instance.
* @param ctx channel handler context instance.
* @throws Exception might throws exception
*/
void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
Channel channel = ctx.getChannel();
LsRequest lsrPacket = (LsRequest) ospfMessage;
OspfNbr nbr = neighbouringRouter(lsrPacket.routerId().toString());
if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
nbr.getState() == OspfNeighborState.FULL) {
LsRequest reqMsg = (LsRequest) ospfMessage;
if (reqMsg.getLinkStateRequests().isEmpty()) {
log.debug("Received Link State Request Vector is Empty ");
return;
} else {
//Send the LsUpdate back
ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
while (listItr.hasNext()) {
LsUpdate lsupdate = new LsUpdate();
lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
lsupdate.setRouterId(ospfArea.routerId());
lsupdate.setAreaId(ospfArea.areaId());
lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
//limit to mtu
int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
int maxSize = mtu() -
OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
int noLsa = 0;
while (listItr.hasNext()) {
LsRequestPacket lsRequest = (LsRequestPacket) listItr.next();
// to verify length of the LSA
LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
lsRequest.ownRouterId());
OspfLsa ospflsa = wrapper.ospfLsa();
if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
listItr.previous();
break;
}
if (ospflsa != null) {
lsupdate.addLsa(ospflsa);
noLsa++;
currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
} else {
nbr.badLSReq(channel);
}
}
lsupdate.setNumberOfLsa(noLsa);
//set the destination
if (state() == OspfInterfaceState.DR ||
state() == OspfInterfaceState.BDR ||
state() == OspfInterfaceState.POINT2POINT) {
lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
} else if (state() == OspfInterfaceState.DROTHER) {
lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
}
byte[] messageToWrite = getMessage(lsupdate);
ctx.getChannel().write(messageToWrite);
}
}
}
}
示例6: electRouter
/**
* Performs DR election.
*
* @param ch Netty Channel instance.
* @throws Exception might throws exception
*/
public void electRouter(Channel ch) throws Exception {
Ip4Address currentDr = dr();
Ip4Address currentBdr = bdr();
OspfInterfaceState oldState = state();
OspfInterfaceState newState;
log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
currentDr, currentBdr);
List<OspfEligibleRouter> eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
OspfEligibleRouter electedBdr = electBdr(eligibleRouters);
OspfEligibleRouter electedDr = electDr(eligibleRouters, electedBdr);
setBdr(electedBdr.getIpAddress());
setDr(electedDr.getIpAddress());
if (electedBdr.getIpAddress().equals(ipAddress()) &&
!electedBdr.getIpAddress().equals(currentBdr)) {
setState(OspfInterfaceState.BDR);
}
if (electedDr.getIpAddress().equals(ipAddress()) &&
!electedDr.getIpAddress().equals(currentDr)) {
setState(OspfInterfaceState.DR);
}
if (state() != oldState &&
!(state() == OspfInterfaceState.DROTHER &&
oldState.value() < OspfInterfaceState.DROTHER.value())) {
log.debug("Recalculating as the State is changed ");
log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
currentDr, currentBdr);
eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
electedBdr = electBdr(eligibleRouters);
electedDr = electDr(eligibleRouters, electedBdr);
setBdr(electedBdr.getIpAddress());
setDr(electedDr.getIpAddress());
}
if (electedBdr.getIpAddress().equals(ipAddress()) &&
!electedBdr.getIpAddress().equals(currentBdr)) {
setState(OspfInterfaceState.BDR);
ospfArea.refreshArea(this);
}
if (electedDr.getIpAddress().equals(ipAddress()) &&
!electedDr.getIpAddress().equals(currentDr)) {
setState(OspfInterfaceState.DR);
//Refresh Router Lsa & Network Lsa
ospfArea.refreshArea(this);
}
if (currentDr != electedDr.getIpAddress() || currentBdr != electedBdr.getIpAddress()) {
Set<String> negibhorIdList;
negibhorIdList = listOfNeighbors().keySet();
for (String routerid : negibhorIdList) {
OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(routerid);
if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue()) {
nbr.adjOk(ch);
}
}
}
log.debug("OSPFInterfaceChannelHandler::electRouter -> ElectedDR: {}, ElectedBDR: {}",
electedDr.getIpAddress(), electedBdr.getIpAddress());
}
示例7: run
@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));
}
}
}
}
}
示例8: processLsRequestMessage
/**
* Process the Ls Request message.
*
* @param ospfMessage OSPF message instance.
* @param ctx channel handler context instance.
*/
void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
Channel channel = ctx.getChannel();
LsRequest lsrPacket = (LsRequest) ospfMessage;
OspfNbr nbr = neighbouringRouter(lsrPacket.routerId().toString());
if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
nbr.getState() == OspfNeighborState.FULL) {
LsRequest reqMsg = (LsRequest) ospfMessage;
if (reqMsg.getLinkStateRequests().isEmpty()) {
log.debug("Received Link State Request Vector is Empty ");
return;
} else {
//Send the LsUpdate back
ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
while (listItr.hasNext()) {
LsUpdate lsupdate = new LsUpdate();
lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
lsupdate.setRouterId(ospfArea.routerId());
lsupdate.setAreaId(ospfArea.areaId());
lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
//limit to mtu
int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
int maxSize = mtu() -
OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
int noLsa = 0;
while (listItr.hasNext()) {
LsRequestPacket lsRequest = listItr.next();
// to verify length of the LSA
LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
lsRequest.ownRouterId());
if (wrapper != null) {
OspfLsa ospflsa = wrapper.ospfLsa();
if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
listItr.previous();
break;
}
if (ospflsa != null) {
lsupdate.addLsa(ospflsa);
noLsa++;
currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
} else {
nbr.badLSReq(channel);
}
}
}
lsupdate.setNumberOfLsa(noLsa);
//set the destination
if (state() == OspfInterfaceState.DR ||
state() == OspfInterfaceState.BDR ||
state() == OspfInterfaceState.POINT2POINT) {
lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
} else if (state() == OspfInterfaceState.DROTHER) {
lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
}
byte[] messageToWrite = getMessage(lsupdate);
ctx.getChannel().write(messageToWrite);
}
}
}
}
示例9: electRouter
/**
* Performs DR election.
*
* @param ch Netty Channel instance.
*/
public void electRouter(Channel ch) {
Ip4Address currentDr = dr();
Ip4Address currentBdr = bdr();
OspfInterfaceState oldState = state();
OspfInterfaceState newState;
log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
currentDr, currentBdr);
List<OspfEligibleRouter> eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
OspfEligibleRouter electedBdr = electBdr(eligibleRouters);
OspfEligibleRouter electedDr = electDr(eligibleRouters, electedBdr);
setBdr(electedBdr.getIpAddress());
setDr(electedDr.getIpAddress());
if (electedBdr.getIpAddress().equals(ipAddress()) &&
!electedBdr.getIpAddress().equals(currentBdr)) {
setState(OspfInterfaceState.BDR);
}
if (electedDr.getIpAddress().equals(ipAddress()) &&
!electedDr.getIpAddress().equals(currentDr)) {
setState(OspfInterfaceState.DR);
}
if (state() != oldState &&
!(state() == OspfInterfaceState.DROTHER &&
oldState.value() < OspfInterfaceState.DROTHER.value())) {
log.debug("Recalculating as the State is changed ");
log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
currentDr, currentBdr);
eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
electedBdr = electBdr(eligibleRouters);
electedDr = electDr(eligibleRouters, electedBdr);
setBdr(electedBdr.getIpAddress());
setDr(electedDr.getIpAddress());
}
if (electedBdr.getIpAddress().equals(ipAddress()) &&
!electedBdr.getIpAddress().equals(currentBdr)) {
setState(OspfInterfaceState.BDR);
ospfArea.refreshArea(this);
}
if (electedDr.getIpAddress().equals(ipAddress()) &&
!electedDr.getIpAddress().equals(currentDr)) {
setState(OspfInterfaceState.DR);
//Refresh Router Lsa & Network Lsa
ospfArea.refreshArea(this);
}
if (currentDr != electedDr.getIpAddress() || currentBdr != electedBdr.getIpAddress()) {
Set<String> negibhorIdList;
negibhorIdList = listOfNeighbors().keySet();
for (String routerid : negibhorIdList) {
OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(routerid);
if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue()) {
nbr.adjOk(ch);
}
}
}
log.debug("OSPFInterfaceChannelHandler::electRouter -> ElectedDR: {}, ElectedBDR: {}",
electedDr.getIpAddress(), electedBdr.getIpAddress());
}