本文整理汇总了Java中org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib类的典型用法代码示例。如果您正苦于以下问题:Java PathAttrNlriDetailsLocalRib类的具体用法?Java PathAttrNlriDetailsLocalRib怎么用?Java PathAttrNlriDetailsLocalRib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathAttrNlriDetailsLocalRib类属于org.onosproject.bgpio.protocol.linkstate包,在下文中一共展示了PathAttrNlriDetailsLocalRib类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: comparePeerDetails
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* Compares EBGP over IBGP, BGP identifier value and peer address.
*
* @param pathNlriDetails1 PathAttrNlriDetailsLocalRib object1
* @param pathNlriDetails2 PathAttrNlriDetailsLocalRib object2
* @return object which as EBGP over IBGP, lowest BGP identifier value and lowest peer address
*/
int comparePeerDetails(PathAttrNlriDetailsLocalRib pathNlriDetails1, PathAttrNlriDetailsLocalRib pathNlriDetails2) {
// consider EBGP over IBGP
if (pathNlriDetails1.isLocalRibIbgpSession() != pathNlriDetails2.isLocalRibIbgpSession()) {
if (pathNlriDetails1 == null || pathNlriDetails1.isLocalRibIbgpSession()) {
return -1;
}
if (pathNlriDetails2 == null || pathNlriDetails2.isLocalRibIbgpSession()) {
return 1;
}
}
// prefer lowest BGP identifier value.
if (pathNlriDetails1.localRibIdentifier() != pathNlriDetails2.localRibIdentifier()) {
return ((Integer) pathNlriDetails2.localRibIdentifier())
.compareTo(pathNlriDetails1.localRibIdentifier());
}
//prefer lowest peer address
if (pathNlriDetails1.localRibIpAddress() != pathNlriDetails2.localRibIpAddress()) {
return pathNlriDetails2.localRibIpAddress().compareTo(pathNlriDetails1.localRibIpAddress());
}
return 0;
}
示例2: comparePeerDetails
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* Compares EBGP over IBGP, BGP identifier value and peer address.
*
* @param pathNlriDetails1 PathAttrNlriDetailsLocalRib object1
* @param pathNlriDetails2 PathAttrNlriDetailsLocalRib object2
* @return object which as EBGP over IBGP, lowest BGP identifier value and lowest peer address
*/
private int comparePeerDetails(PathAttrNlriDetailsLocalRib pathNlriDetails1,
PathAttrNlriDetailsLocalRib pathNlriDetails2) {
// consider EBGP over IBGP
if (pathNlriDetails1.isLocalRibIbgpSession() != pathNlriDetails2.isLocalRibIbgpSession()) {
if (pathNlriDetails1.isLocalRibIbgpSession()) {
return -1;
}
if (pathNlriDetails2.isLocalRibIbgpSession()) {
return 1;
}
}
// prefer lowest BGP identifier value.
if (pathNlriDetails1.localRibIdentifier() != pathNlriDetails2.localRibIdentifier()) {
return Integer.compare(pathNlriDetails2.localRibIdentifier(),
pathNlriDetails1.localRibIdentifier());
}
//prefer lowest peer address
if (pathNlriDetails1.localRibIpAddress() != pathNlriDetails2.localRibIpAddress()) {
return pathNlriDetails2.localRibIpAddress().compareTo(pathNlriDetails1.localRibIpAddress());
}
return 0;
}
示例3: displayPrefix
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
private void displayPrefix() {
try {
this.bgpController = get(BgpController.class);
bgpLocalRib = bgpController.bgpLocalRib();
Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixmap = bgpLocalRib.prefixTree();
Set<BgpPrefixLSIdentifier> prefixkeySet = prefixmap.keySet();
for (BgpPrefixLSIdentifier prefix : prefixkeySet) {
pathAttrNlriDetailsLocalRib = prefixmap.get(prefix);
pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
print("No of entries = %d", prefixmap.size());
System.out.print(pathAttrNlriDetailsLocalRib.toString());
}
} catch (Exception e) {
log.debug("Error occurred while displaying BGP prefixes: {}", e.getMessage());
}
}
示例4: displayVpnNodes
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
private void displayVpnNodes() {
try {
this.bgpController = get(BgpController.class);
bgpLocalRib = bgpController.bgpLocalRib();
Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNode =
bgpLocalRib.vpnNodeTree();
Set<RouteDistinguisher> vpnNodekeySet = vpnNode.keySet();
for (RouteDistinguisher vpnNodes : vpnNodekeySet) {
boolean invalidProcess = true;
if (vpnId != null && Integer.parseInt(vpnId.trim()) == vpnNodes.hashCode()) {
invalidProcess = false;
displayNodes();
}
if (invalidProcess) {
print("%s\n", "Id " + vpnId + "does not exist...!!!");
}
}
} catch (Exception e) {
log.debug("Error occurred while displaying BGP nodes based on VPN : {}", e.getMessage());
}
}
示例5: displayVpnLinks
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
private void displayVpnLinks() {
try {
this.bgpController = get(BgpController.class);
bgpLocalRib = bgpController.bgpLocalRib();
Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLink =
bgpLocalRib.vpnLinkTree();
Set<RouteDistinguisher> vpnLinkkeySet = vpnLink.keySet();
for (RouteDistinguisher vpnLinks : vpnLinkkeySet) {
boolean invalidProcess = true;
if (vpnId != null && Integer.parseInt(vpnId.trim()) == vpnLinks.hashCode()) {
invalidProcess = false;
displayLinks();
}
if (invalidProcess) {
print("%s\n", "Id " + vpnId + "does not exist...!!!");
}
}
} catch (Exception e) {
log.debug("Error occurred while displaying BGP links based on VPN : {}", e.getMessage());
}
}
示例6: displayVpnPrefix
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
private void displayVpnPrefix() {
try {
this.bgpController = get(BgpController.class);
bgpLocalRib = bgpController.bgpLocalRib();
Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefix =
bgpLocalRib.vpnPrefixTree();
Set<RouteDistinguisher> vpnPrefixkeySet = vpnPrefix.keySet();
for (RouteDistinguisher vpnprefixId : vpnPrefixkeySet) {
boolean invalidProcess = true;
if (vpnId != null && Integer.parseInt(vpnId.trim()) == vpnprefixId.hashCode()) {
invalidProcess = false;
displayPrefix();
}
if (invalidProcess) {
print("%s\n", "Id " + vpnId + "does not exist...!!!");
}
}
} catch (Exception e) {
log.debug("Error occurred while displaying BGP prefixes based on VPN : {}", e.getMessage());
}
}
示例7: compare
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
@Override
public int compare(PathAttrNlriDetailsLocalRib pathNlriDetails1, PathAttrNlriDetailsLocalRib pathNlriDetails2) {
if (pathNlriDetails1 == null) {
return -1;
}
if (pathNlriDetails2 == null) {
return 1;
}
if (pathNlriDetails1.equals(pathNlriDetails2)) {
return 0;
}
List<BgpValueType> o1 = pathNlriDetails1.localRibNlridetails().pathAttributes();
List<BgpValueType> o2 = pathNlriDetails2.localRibNlridetails().pathAttributes();
ListIterator<BgpValueType> listIteratorObj1 = o1.listIterator();
ListIterator<BgpValueType> listIteratorObj2 = o2.listIterator();
storeAttr(listIteratorObj1, listIteratorObj2);
// prefer attribute with higher local preference
if (obj1LocPref != null || obj2LocPref != null && (obj1LocPref != null && !obj1LocPref.equals(obj2LocPref))) {
return compareLocalPref(obj1LocPref, obj2LocPref);
}
// prefer attribute with shortest Aspath
if (!obj1Aspath.equals(obj2Aspath)) {
Integer obj1Size = countASSize(obj1Aspath);
Integer obj2Size = countASSize(obj2Aspath);
if (obj1Size != obj2Size) {
return compareAsPath(obj1Size, obj2Size);
}
}
// prefer attribute with lowest origin type
if (!obj1Origin.equals(obj2Origin)) {
return compareOrigin(obj1Origin, obj2Origin);
}
// prefer attribute with lowest MED
if (obj1Med != null || obj2Med != null && (obj1Med != null && !obj1Med.equals(obj2Med))) {
return compareMed(obj1Med, obj2Med);
}
if ((pathNlriDetails1 != null || pathNlriDetails2 != null) && (pathNlriDetails1 != null && !pathNlriDetails1
.equals(pathNlriDetails2))) {
return comparePeerDetails(pathNlriDetails1, pathNlriDetails2);
}
return 0;
}
示例8: selectionProcessNode
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* Selection process for local RIB node.
*
* @param nlri NLRI to update
* @param isVpnRib true if VPN local RIB, otherwise false
* @throws BgpParseException throws BGP parse exception
*/
public void selectionProcessNode(BgpLSNlri nlri, boolean isVpnRib) throws BgpParseException {
BgpPeerImpl peer;
BgpSessionInfo sessionInfo;
int decisionResult;
boolean containsKey;
BgpNodeLSIdentifier nodeLsIdentifier = ((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors();
if (nodeTree.containsKey(nodeLsIdentifier)) {
for (BgpNodeListener l : bgpController.listener()) {
l.deleteNode((BgpNodeLSNlriVer4) nlri);
}
log.debug("Local RIB delete node: {}", nodeLsIdentifier.toString());
nodeTree.remove(nodeLsIdentifier);
}
for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
if (nodeTree.containsKey(nodeLsIdentifier)) {
containsKey = (!isVpnRib) ? (peer.adjacencyRib().nodeTree().containsKey(nodeLsIdentifier)) :
(peer.vpnAdjacencyRib().nodeTree().containsKey(nodeLsIdentifier));
if (!containsKey) {
continue;
}
sessionInfo = peer.sessionInfo();
PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(
sessionInfo.remoteBgpId().ipAddress(),
sessionInfo.remoteBgpIdentifier(),
sessionInfo.remoteBgpASNum(),
sessionInfo.isIbgpSession(),
(!isVpnRib) ?
(peer.adjacencyRib().nodeTree()
.get(nodeLsIdentifier)) :
(peer.vpnAdjacencyRib().nodeTree()
.get(nodeLsIdentifier)));
BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib);
if (decisionResult < 0) {
nodeTree.replace(nodeLsIdentifier, detailsLocRib);
log.debug("Local RIB node updated: {}", detailsLocRib.toString());
}
} else {
if (!isVpnRib) {
if (peer.adjacencyRib().nodeTree().containsKey(nodeLsIdentifier)) {
add(peer.sessionInfo(), nlri, peer.adjacencyRib().nodeTree().get(nodeLsIdentifier));
}
} else {
if (peer.vpnAdjacencyRib().nodeTree().containsKey(nodeLsIdentifier)) {
add(peer.sessionInfo(), nlri, peer.vpnAdjacencyRib().nodeTree().get(nodeLsIdentifier));
}
}
}
}
}
示例9: selectionProcessLink
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* Selection process for local RIB link.
*
* @param nlri NLRI to update
* @param isVpnRib true if VPN local RIB, otherwise false
* @throws BgpParseException BGP parse exception
*/
public void selectionProcessLink(BgpLSNlri nlri, boolean isVpnRib) throws BgpParseException {
BgpPeerImpl peer;
BgpSessionInfo sessionInfo;
int decisionResult;
boolean containsKey;
BgpLinkLSIdentifier linkLsIdentifier = ((BgpLinkLsNlriVer4) nlri).getLinkIdentifier();
if (linkTree.containsKey(linkLsIdentifier)) {
log.debug("Local RIB remove link: {}", linkLsIdentifier.toString());
for (BgpLinkListener l : bgpController.linkListener()) {
l.deleteLink((BgpLinkLsNlriVer4) nlri);
}
linkTree.remove(linkLsIdentifier);
}
for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
if (linkTree.containsKey(linkLsIdentifier)) {
containsKey = (!isVpnRib) ? (peer.adjacencyRib().linkTree().containsKey(linkLsIdentifier)) :
(peer.vpnAdjacencyRib().linkTree().containsKey(linkLsIdentifier));
if (!containsKey) {
continue;
}
sessionInfo = peer.sessionInfo();
PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(
sessionInfo.remoteBgpId().ipAddress(),
sessionInfo.remoteBgpIdentifier(),
sessionInfo.remoteBgpASNum(),
sessionInfo.isIbgpSession(),
((!isVpnRib) ?
(peer.adjacencyRib().linkTree().get(linkLsIdentifier)) :
(peer.vpnAdjacencyRib().linkTree()
.get(linkLsIdentifier))));
BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib);
if (decisionResult < 0) {
linkTree.replace(linkLsIdentifier, detailsLocRib);
log.debug("Local RIB link updated: {}", detailsLocRib.toString());
}
} else {
if (!isVpnRib) {
if (peer.adjacencyRib().linkTree().containsKey(linkLsIdentifier)) {
add(peer.sessionInfo(), nlri, peer.adjacencyRib().linkTree().get(linkLsIdentifier));
}
} else {
if (peer.vpnAdjacencyRib().linkTree().containsKey(linkLsIdentifier)) {
add(peer.sessionInfo(), nlri, peer.vpnAdjacencyRib().linkTree().get(linkLsIdentifier));
}
}
}
}
}
示例10: selectionProcessPrefix
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* Selection process for local RIB prefix.
*
* @param nlri NLRI to update
* @param isVpnRib true if VPN local RIB, otherwise false
* @throws BgpParseException BGP parse exception
*/
public void selectionProcessPrefix(BgpLSNlri nlri, boolean isVpnRib) throws BgpParseException {
BgpPeerImpl peer;
BgpSessionInfo sessionInfo;
int decisionResult;
boolean containsKey;
BgpPrefixLSIdentifier prefixIdentifier = ((BgpPrefixIPv4LSNlriVer4) nlri).getPrefixIdentifier();
if (prefixTree.containsKey(prefixIdentifier)) {
log.debug("Local RIB remove prefix: {}", prefixIdentifier.toString());
prefixTree.remove(prefixIdentifier);
}
for (BgpId bgpId : bgpController.connectedPeers().keySet()) {
peer = (BgpPeerImpl) (bgpController.getPeer(bgpId));
if (prefixTree.containsKey(prefixIdentifier)) {
containsKey = (!isVpnRib) ? (peer.adjacencyRib().prefixTree().containsKey(prefixIdentifier)) :
(peer.vpnAdjacencyRib().prefixTree().containsKey(prefixIdentifier));
if (!containsKey) {
continue;
}
sessionInfo = peer.sessionInfo();
PathAttrNlriDetailsLocalRib detailsLocRib = new PathAttrNlriDetailsLocalRib(
sessionInfo.remoteBgpId().ipAddress(),
sessionInfo.remoteBgpIdentifier(),
sessionInfo.remoteBgpASNum(),
sessionInfo.isIbgpSession(),
((!isVpnRib) ?
(peer.adjacencyRib().prefixTree()
.get(prefixIdentifier)) :
(peer.vpnAdjacencyRib().prefixTree()
.get(prefixIdentifier))));
BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo();
decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib);
if (decisionResult < 0) {
prefixTree.replace(prefixIdentifier, detailsLocRib);
log.debug("local RIB prefix updated: {}", detailsLocRib.toString());
}
} else {
if (!isVpnRib) {
if (peer.adjacencyRib().prefixTree().containsKey(prefixIdentifier)) {
add(peer.sessionInfo(), nlri, peer.adjacencyRib().prefixTree().get(prefixIdentifier));
} else {
if (peer.vpnAdjacencyRib().prefixTree().containsKey(prefixIdentifier)) {
add(peer.sessionInfo(), nlri, peer.vpnAdjacencyRib().prefixTree().get(prefixIdentifier));
}
}
}
}
}
}
示例11: selectionAlgoTest1
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* firstPathAttribute and secondPathAttribute has same AS count and firstPathAttribute
* has shortest Origin value than secondPathAttribute.
*/
@Test
public void selectionAlgoTest1() throws BgpParseException {
byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
//origin with IGP
byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute1 = Origin.read(buffer);
pathAttributes1.add(pathAttribute1);
//AsPath with AS_SEQ with one AS
byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xea };
buffer.writeBytes(asPath);
pathAttribute1 = AsPath.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
//origin with INCOMPLETE
origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute2 = Origin.read(buffer);
pathAttributes2.add(pathAttribute2);
//AsPath with AS_SEQ with one AS
asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute2 = AsPath.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(1));
}
示例12: selectionAlgoTest2
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* firstPathAttribute has 1 AS count and secondPathAttribute has 2 AS count
* and firstPathAttribute has shortest Origin value than secondPathAttribute.
*/
@Test
public void selectionAlgoTest2() throws BgpParseException {
byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute1 = Origin.read(buffer);
pathAttributes1.add(pathAttribute1);
byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute1 = AsPath.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute2 = Origin.read(buffer);
pathAttributes2.add(pathAttribute2);
asPath = new byte[] {0x40, 0x02, 0x08, 0x02, 0x01, (byte) 0xfd,
(byte) 0xea, 0x02, 0x01, (byte) 0xfd, (byte) 0xea };
buffer.writeBytes(asPath);
pathAttribute2 = AsPath.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(-1));
}
示例13: selectionAlgoTest3
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* firstPathAttribute and secondPathAttribute has same AS value
* and firstPathAttribute has shortest Origin value than secondPathAttribute.
*/
@Test
public void selectionAlgoTest3() throws BgpParseException {
byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute1 = Origin.read(buffer);
pathAttributes1.add(pathAttribute1);
byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute1 = AsPath.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute2 = Origin.read(buffer);
pathAttributes2.add(pathAttribute2);
asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute2 = AsPath.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(1));
}
示例14: selectionAlgoTest4
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* firstPathAttribute has lowest med than secondPathAttribute.
*/
@Test
public void selectionAlgoTest4() throws BgpParseException {
byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute1 = Origin.read(buffer);
pathAttributes1.add(pathAttribute1);
byte[] med = new byte[] {(byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00,
0x00 };
buffer.writeBytes(med);
pathAttribute1 = Med.read(buffer);
pathAttributes1.add(pathAttribute1);
byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute1 = AsPath.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(origin);
pathAttribute2 = Origin.read(buffer);
pathAttributes2.add(pathAttribute2);
med = new byte[] {(byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x01 };
buffer.writeBytes(med);
pathAttribute2 = Med.read(buffer);
pathAttributes2.add(pathAttribute2);
asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
(byte) 0xe9 };
buffer.writeBytes(asPath);
pathAttribute2 = AsPath.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(1));
}
示例15: selectionAlgoTest5
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib; //导入依赖的package包/类
/**
* secondPathAttribute has higher local preference than firstPathAttribute.
*/
@Test
public void selectionAlgoTest5() throws BgpParseException {
byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
BgpValueType pathAttribute1;
byte[] locPref = new byte[] {(byte) 0x00, 0x05, 0x04, 0x00, 0x00,
0x00, 0x01 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(locPref);
pathAttribute1 = LocalPref.read(buffer);
pathAttributes1.add(pathAttribute1);
IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
int bgpId = 168427777;
short locRibAsNum = 100;
boolean isIbgp = false;
PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
attrList1.setIdentifier(0);
attrList1.setPathAttribute(pathAttributes1);
attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);
peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
BgpValueType pathAttribute2;
locPref = new byte[] {(byte) 0x00, 0x05, 0x04, 0x00, 0x00, 0x00, 0x0a };
buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(locPref);
pathAttribute2 = LocalPref.read(buffer);
pathAttributes2.add(pathAttribute2);
ipAddress = IpAddress.valueOf(Version.INET, peerIp);
bgpId = 536936448;
locRibAsNum = 200;
isIbgp = true;
PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
attrList2.setIdentifier(0);
attrList2.setPathAttribute(pathAttributes2);
attrList2.setProtocolID(ProtocolType.OSPF_V2);
PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
BgpSelectionAlgo algo = new BgpSelectionAlgo();
int result = algo.compare(list1, list2);
assertThat(result, is(-1));
}