use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Weight in project lispflowmapping by opendaylight.
the class LispSouthboundHandlerTest method mapRegister__TwoRlocs.
@Test
public void mapRegister__TwoRlocs() throws Exception {
// P Bit & M Bit set
// EID prefix: 172.1.1.2/32, TTL: 10, Authoritative, No-Action
// Local RLOC: 10.1.0.110, Reachable, Priority/Weight: 1/100, Multicast
// Priority/Weight: 255/0
// Local RLOC: 192.168.136.51, Reachable, Priority/Weight: 6/100,
// Multicast Priority/Weight: 255/0
mapRegisterPacket = extractWSUdpByteArray("0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 " + "0010 00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 " + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 " + "0030 00 00 00 00 00 00 00 01 00 14 ae d8 7b d4 9c 59 " + "0040 e9 35 75 6e f1 29 27 a3 45 20 96 06 c2 e1 00 00 " + "0050 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 01 64 " + "0060 ff 00 00 05 00 01 0a 01 00 6e 06 64 ff 00 00 05 " + "0070 00 01 c0 a8 88 33");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(mapRegisterPacket);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
List<MappingRecordItem> eidRecords = captor.getValue().getMapRegister().getMappingRecordItem();
assertEquals(1, eidRecords.size());
MappingRecord eidRecord = eidRecords.get(0).getMappingRecord();
assertEquals(2, eidRecord.getLocatorRecord().size());
assertEquals(LispAddressUtil.asIpv4Rloc("10.1.0.110"), eidRecord.getLocatorRecord().get(0).getRloc());
assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.51"), eidRecord.getLocatorRecord().get(1).getRloc());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Weight in project lispflowmapping by opendaylight.
the class MultiSiteScenario method provideLocatorRecord.
private LocatorRecord provideLocatorRecord(final Rloc rloc, final String rlocStr, final short weight, final short priority) {
final LocatorRecordBuilder locatorRecordBuilder = new LocatorRecordBuilder();
locatorRecordBuilder.setRloc(rloc);
locatorRecordBuilder.setLocatorId(rlocStr);
locatorRecordBuilder.setPriority(priority);
locatorRecordBuilder.setWeight(weight);
locatorRecordBuilder.setMulticastPriority(DEFAULT_MULTICAST_PRIORITY);
locatorRecordBuilder.setMulticastWeight(DEFAULT_MULTICAST_WEIGHT);
locatorRecordBuilder.setLocalLocator(DEFAULT_LOCAL_LOCATOR);
locatorRecordBuilder.setRlocProbed(DEFAULT_RLOC_PROBED);
locatorRecordBuilder.setRouted(DEFAULT_ROUTED);
return locatorRecordBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Weight in project bgpcep by opendaylight.
the class Samcra method computeP2pPath.
/* Samcra Algo:
*
* To limit the modification outside the Samcra method the same set of parameters as
* the CSPF method is used (related to pseudo code, the path length is computed inside
* the method based on the individual constraint parameters).
*
* On contrast to a simple CSPF algo, with Samcra a connected vertex might be associated to several
* metric vectors from which different path lengths are computed. However a connected vertex is only
* present once in the priority queue, associated to the minimal path weight, which is used as key
* to address the priority queue.
*
* For a given metric the path weight is an integer value computed as the entire part of
* the quantity:
* 100 * (vector_path_metric/target_metric)
* The path weight correspond to the maximum length computed from either the delay or TE metric.
*
* To maintain the priority queue behavior unchanged, a "SamcraPath" classes is created to manage
* the set of possible paths associated to a given vertex (see above).
*
*/
@Override
public ConstrainedPath computeP2pPath(final VertexKey src, final VertexKey dst, final PathConstraints cts) {
ConstrainedPathBuilder cpathBuilder;
List<ConnectedEdge> edges;
CspfPath currentPath;
LOG.info("Start SAMCRA Path Computation from {} to {} with constraints {}", src, dst, cts);
/* Initialize SAMCRA variables */
this.constraints = cts;
cpathBuilder = initializePathComputation(src, dst);
if (cpathBuilder.getStatus() == ComputationStatus.Failed) {
return cpathBuilder.build();
}
cpathBuilder.setBandwidth(cts.getBandwidth()).setClassType(cts.getClassType());
samcraPaths.clear();
samcraPaths.put(pathSource.getVertexKey(), new SamcraPath(pathSource.getVertex()));
samcraPaths.put(pathDestination.getVertexKey(), new SamcraPath(pathDestination.getVertex()));
/* Exploration of the priority queue:
* Each connected vertex is represented only once in the priority queue associated to the path
* with the minimal length (other path are stored in the SamcraPath object).
* The top of the queue, i.e. the element with the minimal key( path weight), is processed at each loop
*/
while (priorityQueue.size() != 0) {
currentPath = priorityQueue.poll();
LOG.debug(" - Process path up to Vertex {} from Priority Queue", currentPath.getVertex());
/* Prepare Samcra Path from current CSP Path except for the source */
if (!currentPath.equals(pathSource)) {
SamcraPath currentSamcraPath = samcraPaths.get(currentPath.getVertexKey());
CspfPath currentCspfPath = currentSamcraPath.getCurrentPath();
float queuePathLength = currentCspfPath.getPathLength();
LOG.trace(" - Priority Queue output SamcraPaths {} CurrentPath {} with PathLength {}", currentSamcraPath.currentPath, currentCspfPath, queuePathLength);
}
edges = currentPath.getVertex().getOutputConnectedEdges();
float currentPathLength = 1.0F;
for (ConnectedEdge edge : edges) {
/* Connected Vertex's edges processing:
* Prune the connected edges that do not satisfy the constraints (Bandwidth, TE Metric, Delay, Loss)
* For each remaining edge process the path to the remote vertex using the "relaxSamcra" procedure
*
* If the return path length is positive, the destination is reached and the
* obtained route satisfies the requested constraints.
* The path length is checked to record only the optimal route (i.e. the route with
* the minimal path length) info obtained from the destination vertex
*/
if (pruneEdge(edge, currentPath)) {
LOG.trace(" - Prune Edge {}", edge);
continue;
}
float pathLength = relaxSamcra(edge, currentPath, pathSource);
/* Check if we found a valid and better path */
if (pathLength > 0F && pathLength <= currentPathLength) {
final SamcraPath finalPath = samcraPaths.get(pathDestination.getVertexKey());
cpathBuilder.setPathDescription(getPathDescription(finalPath.getCurrentPath().getPath())).setMetric(Uint32.valueOf(finalPath.getCurrentPath().getCost())).setDelay(new Delay(Uint32.valueOf(finalPath.getCurrentPath().getDelay()))).setStatus(ComputationStatus.Active);
LOG.debug(" - Path to destination found and registered {}", cpathBuilder.getPathDescription());
currentPathLength = pathLength;
}
}
/* The connected vertex that has been removed from the priority queue may have to be re-inserted with
* the minimal length non-dominated path associated to the connected vertex if it exists (to be done
* except for the source). Otherwise, the current path associated to the connected vertex is reset to
* null to allow the connected vertex addition to the priority queue later on with a new path
* (refer to "relaxSamcra" for addition of a connected vertex to the priority queue).
*/
float previousLength = 1.0F;
CspfPath selectedPath = null;
if (!currentPath.equals(pathSource)) {
LOG.debug(" - Processing current path {} up to {} from Priority Queue", currentPath, currentPath.getVertex());
SamcraPath currentSamcraPath = samcraPaths.get(currentPath.getVertexKey());
currentSamcraPath.decrementPathCount();
/*
* The list of paths associated to the connected vertex is retrieved
* The path used to represent the connected vertex in the Priority Queue is marked from "selected"
* to "processed". The list of paths is analyzed to check if other "active" path(s) exist(s).
* If it is the case the shortest length is used to re-inject the connected vertex in the Priority Queue
*/
for (CspfPath testedPath : currentSamcraPath.getPathList()) {
LOG.debug(" - Testing path {} with status {} ", testedPath, testedPath.getPathStatus());
if (testedPath.getPathStatus() == CspfPath.SELECTED) {
testedPath.setPathStatus(CspfPath.PROCESSED);
} else if (testedPath.getPathStatus() == CspfPath.ACTIVE && testedPath.getPathLength() < previousLength) {
selectedPath = testedPath;
previousLength = testedPath.getPathLength();
}
}
/* If a path is found it is marked as "selected", used as "current path" for the connected vertex
* and added to the priority queue
*/
if (selectedPath != null) {
selectedPath.setPathStatus(CspfPath.SELECTED);
currentSamcraPath.setCurrentPath(selectedPath);
priorityQueue.add(selectedPath);
LOG.debug(" - Add path {} to Priority Queue. New path count {} ", selectedPath, currentSamcraPath.getPathCount());
} else {
currentSamcraPath.setCurrentPath(null);
}
}
}
/* The priority queue is empty => all the possible (vertex, path) elements have been explored
* The "ConstrainedPathBuilder" object contains the optimal path if it exists
* Otherwise an empty path with status failed is returned
*/
if (cpathBuilder.getStatus() == ComputationStatus.InProgress || cpathBuilder.getPathDescription().size() == 0) {
cpathBuilder.setStatus(ComputationStatus.Failed);
} else {
cpathBuilder.setStatus(ComputationStatus.Completed);
}
return cpathBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Weight in project bgpcep by opendaylight.
the class SrAttributeParserTest method addSubTlvs.
private static void addSubTlvs(final List<SubTlvs> rangeSubTlvs) {
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new SidLabelTlvCaseBuilder().setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(16909060L)).build()).build()).build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new PrefixSidTlvCaseBuilder().setPrefixSidTlv(new PrefixSidTlvBuilder().setFlags(ISIS_PREFIX_FLAGS).setAlgorithm(Algorithm.StrictShortestPathFirst).setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(Uint32.valueOf(66048))).build()).build()).build()).build());
final List<BindingSubTlvs> bindingSubTlvs = new ArrayList<>();
addBindingSubTlvs(bindingSubTlvs);
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new BindingSidTlvCaseBuilder().setWeight(new Weight(Uint8.valueOf(5))).setFlags(BINDING_FLAGS).setBindingSubTlvs(bindingSubTlvs).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.Weight in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrAdjId.
// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.2.1
@Test
public void testSrAdjId() {
final byte[] tested = { (byte) 0x60, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final byte[] testedOspf = { (byte) 0xc0, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final byte[] sidLabel = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final SrAdjIds srAdjId = new SrAdjIdsBuilder().setFlags(ISIS_ADJ_FLAGS).setWeight(new Weight(Uint8.TEN)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
final SrAdjIds ospfAdj = new SrAdjIdsBuilder().setFlags(OSPF_ADJ_FLAGS).setWeight(new Weight(Uint8.TEN)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
assertEquals(srAdjId, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1)).build());
assertEquals(ospfAdj, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(testedOspf), ProtocolId.Ospf)).build());
final ByteBuf serializedData = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(srAdjId);
final ByteBuf serializedOspf = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(ospfAdj);
assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
assertArrayEquals(testedOspf, ByteArray.readAllBytes(serializedOspf));
}
Aggregations