Search in sources :

Example 1 with UnreservedBandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth in project bgpcep by opendaylight.

the class AbstractPathComputation method pruneEdge.

/**
 * Check if Edge need to be prune regarding all constraints including
 * address family.
 *
 * @return True if Edge must be prune, False if Edge must be keep
 */
protected boolean pruneEdge(final ConnectedEdge edge, final CspfPath path) {
    /* Check that Constraints are initialized */
    if (constraints == null) {
        LOG.warn("Constraints not set");
        return true;
    }
    /* Edge could point to an unknown Vertex e.g. with inter-domain link */
    if (edge.getDestination() == null || edge.getDestination().getVertex() == null) {
        LOG.debug("No Destination");
        return true;
    }
    /* Check that Edge have attributes */
    EdgeAttributes attributes = edge.getEdge() != null ? edge.getEdge().getEdgeAttributes() : null;
    if (attributes == null) {
        LOG.debug("No attributes");
        return true;
    }
    /* Check that Edge belongs to the requested address family */
    switch(constraints.getAddressFamily()) {
        case Ipv4:
            if (attributes.getRemoteAddress() == null || attributes.getRemoteAddress().getIpv4Address() == null) {
                LOG.debug("No Ipv4 address");
                return true;
            }
            break;
        case Ipv6:
            if (attributes.getRemoteAddress() == null || attributes.getRemoteAddress().getIpv6Address() == null) {
                LOG.debug("No Ipv6 address");
                return true;
            }
            break;
        case SrIpv4:
            if (getIpv4NodeSid(edge.getDestination()) == null) {
                LOG.debug("No Node-SID for IPv4");
                return true;
            }
            if (attributes.getAdjSid() == null) {
                LOG.debug("No Adjacency-SID");
                return true;
            }
            break;
        case SrIpv6:
            if (getIpv6NodeSid(edge.getDestination()) == null) {
                LOG.debug("No Node-SID for IPv6");
                return true;
            }
            if (attributes.getAdjSid() == null) {
                LOG.debug("No SR Adjacency-SID");
                return true;
            }
            break;
        default:
            return true;
    }
    /* Skip checking other Constraints for simple SPF algorithm */
    if (this instanceof ShortestPathFirst) {
        LOG.trace("Edge {} is valid for Simple Path Computation", edge);
        return false;
    }
    /*
         * If specified, check that total TE Metric up to this edge respects the
         * initial constraints
         */
    if (constraints.getTeMetric() != null) {
        if (attributes.getTeMetric() == null) {
            return true;
        } else {
            int totalCost = attributes.getTeMetric().intValue() + path.getCost();
            if (totalCost > constraints.getTeMetric().intValue()) {
                LOG.debug("TeMetric {} exceed constraint {}", totalCost, constraints.getTeMetric().intValue());
                return true;
            }
        }
    }
    /*
         * If specified, check that total Delay up to this edge respects the
         * initial constraints
         */
    if (constraints.getDelay() != null) {
        if (attributes.getDelay() == null) {
            return true;
        } else {
            int totalDelay = attributes.getDelay().getValue().intValue() + path.getDelay();
            if (totalDelay > constraints.getDelay().getValue().intValue()) {
                LOG.debug("Delay {} exceed constraint {}", totalDelay, constraints.getDelay().getValue().intValue());
                return true;
            }
        }
    }
    /* Check that Edge respect Loss constraint */
    if (constraints.getLoss() != null) {
        if (attributes.getLoss() == null || attributes.getLoss().getValue().intValue() > constraints.getLoss().getValue().intValue()) {
            return true;
        }
    }
    /* Check that Edge meet Bandwidth constraint */
    int cos = 0;
    if (constraints.getClassType() != null) {
        cos = constraints.getClassType().intValue();
    }
    if (constraints.getBandwidth() != null) {
        if (attributes.getMaxLinkBandwidth() == null || attributes.getMaxResvLinkBandwidth() == null || attributes.getUnreservedBandwidth() == null || attributes.getUnreservedBandwidth().get(cos) == null) {
            return true;
        } else {
            Long bandwidth = constraints.getBandwidth().getValue().longValue();
            Long unrsv = 0L;
            for (UnreservedBandwidth unResBw : attributes.getUnreservedBandwidth()) {
                if (unResBw.getClassType().intValue() == cos) {
                    unrsv = unResBw.getBandwidth().getValue().longValue();
                    break;
                }
            }
            if (unrsv < bandwidth || attributes.getMaxLinkBandwidth().getValue().longValue() < bandwidth || attributes.getMaxResvLinkBandwidth().getValue().longValue() < bandwidth) {
                LOG.debug("Bandwidth constraint is not met");
                return true;
            }
        }
    }
    /* Check that Edge belongs to admin group */
    if (constraints.getAdminGroup() != null && !constraints.getAdminGroup().equals(attributes.getAdminGroup())) {
        LOG.debug("Not in the requested admin-group");
        return true;
    }
    /*
         * OK. All is fine. We can consider this Edge valid, so not to be prune
         */
    LOG.trace("Edge {} is valid for Constrained Path Computation", edge);
    return false;
}
Also used : UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth) EdgeAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributes)

Example 2 with UnreservedBandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth in project bgpcep by opendaylight.

the class LinkAttributesParser method serializeUnreservedBw.

private static void serializeUnreservedBw(final Map<UnreservedBandwidthKey, UnreservedBandwidth> ubList, final ByteBuf byteAggregator) {
    // this sub-TLV contains eight 32-bit IEEE floating point numbers
    if (ubList != null) {
        final ByteBuf unreservedBandwithBuf = Unpooled.buffer();
        for (final UnreservedBandwidth unreservedBandwidth : ubList.values()) {
            unreservedBandwithBuf.writeBytes(unreservedBandwidth.getBandwidth().getValue());
        }
        TlvUtil.writeTLV(UNRESERVED_BANDWIDTH, unreservedBandwithBuf, byteAggregator);
    }
}
Also used : UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidth) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with UnreservedBandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method createEdgeAttributes.

/**
 * Create Edge Attributes from Link attributes.
 *
 * @param la         Linkstate Attributes
 * @param linkDesc   Linkstate Descriptors
 *
 * @return EdgeAttributes
 */
private static EdgeAttributes createEdgeAttributes(final LinkAttributes la, final LinkDescriptors linkDesc) {
    EdgeAttributesBuilder builder = new EdgeAttributesBuilder();
    if (linkDesc.getIpv4InterfaceAddress() != null) {
        builder.setLocalAddress(new IpAddress(linkDesc.getIpv4InterfaceAddress()));
    }
    if (linkDesc.getIpv6InterfaceAddress() != null) {
        builder.setLocalAddress(new IpAddress(linkDesc.getIpv6InterfaceAddress()));
    }
    if (linkDesc.getIpv4NeighborAddress() != null) {
        builder.setRemoteAddress(new IpAddress(linkDesc.getIpv4NeighborAddress()));
    }
    if (linkDesc.getIpv6NeighborAddress() != null) {
        builder.setRemoteAddress(new IpAddress(linkDesc.getIpv6NeighborAddress()));
    }
    if (linkDesc.getLinkLocalIdentifier() != null) {
        builder.setLocalIdentifier(linkDesc.getLinkLocalIdentifier());
    }
    if (linkDesc.getLinkRemoteIdentifier() != null) {
        builder.setRemoteIdentifier(linkDesc.getLinkRemoteIdentifier());
    }
    if (la.getMetric() != null) {
        builder.setMetric(la.getMetric().getValue());
    }
    if (la.getTeMetric() != null) {
        builder.setTeMetric(la.getTeMetric().getValue());
    }
    if (la.getMaxLinkBandwidth() != null) {
        builder.setMaxLinkBandwidth(bandwithToDecimalBandwidth(la.getMaxLinkBandwidth()));
    }
    if (la.getMaxReservableBandwidth() != null) {
        builder.setMaxResvLinkBandwidth(bandwithToDecimalBandwidth(la.getMaxReservableBandwidth()));
    }
    if (la.getUnreservedBandwidth() != null) {
        int upperBound = Math.min(la.getUnreservedBandwidth().size(), MAX_PRIORITY);
        final List<UnreservedBandwidth> unRsvBw = new ArrayList<>(upperBound);
        for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.UnreservedBandwidth bandwidth : la.nonnullUnreservedBandwidth().values()) {
            unRsvBw.add(new UnreservedBandwidthBuilder().setBandwidth(bandwithToDecimalBandwidth(bandwidth.getBandwidth())).withKey(new UnreservedBandwidthKey(bandwidth.getPriority())).build());
        }
        builder.setUnreservedBandwidth(unRsvBw);
    }
    if (la.getAdminGroup() != null) {
        builder.setAdminGroup(la.getAdminGroup().getValue());
    }
    if (la.getLinkDelay() != null) {
        builder.setDelay(new Delay(la.getLinkDelay().getValue()));
    }
    if (la.getLinkMinMaxDelay() != null && la.getLinkMinMaxDelay() != null) {
        MinMaxDelay mmDelay = new MinMaxDelayBuilder().setMaxDelay(new Delay(la.getLinkMinMaxDelay().getMaxDelay().getValue())).setMinDelay(new Delay(la.getLinkMinMaxDelay().getMinDelay().getValue())).build();
        builder.setMinMaxDelay(mmDelay);
    }
    if (la.getDelayVariation() != null) {
        builder.setJitter(new Delay(la.getDelayVariation().getValue()));
    }
    if (la.getLinkLoss() != null) {
        builder.setLoss(new Loss(la.getLinkLoss().getValue()));
    }
    if (la.getAvailableBandwidth() != null) {
        builder.setAvailableBandwidth(bandwithToDecimalBandwidth(la.getAvailableBandwidth()));
    }
    if (la.getResidualBandwidth() != null) {
        builder.setResidualBandwidth(bandwithToDecimalBandwidth(la.getResidualBandwidth()));
    }
    if (la.getUtilizedBandwidth() != null) {
        builder.setUtilizedBandwidth(bandwithToDecimalBandwidth(la.getUtilizedBandwidth()));
    }
    if (la.getSharedRiskLinkGroups() != null) {
        List<Uint32> srlgs = new ArrayList<>();
        for (SrlgId srlg : la.getSharedRiskLinkGroups()) {
            srlgs.add(srlg.getValue());
        }
        builder.setSrlgs(srlgs);
    }
    for (SrAdjIds adj : la.nonnullSrAdjIds()) {
        if (adj.getSidLabelIndex() instanceof LocalLabelCase) {
            boolean backup = false;
            if (adj.getFlags() instanceof OspfAdjFlags) {
                backup = ((OspfAdjFlags) adj.getFlags()).getBackup();
            }
            if (adj.getFlags() instanceof IsisAdjFlags) {
                backup = ((IsisAdjFlags) adj.getFlags()).getBackup();
            }
            if (!backup) {
                builder.setAdjSid(((LocalLabelCase) adj.getSidLabelIndex()).getLocalLabel().getValue());
            } else {
                builder.setBackupAdjSid(((LocalLabelCase) adj.getSidLabelIndex()).getLocalLabel().getValue());
            }
        }
    }
    return builder.build();
}
Also used : EdgeAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributesBuilder) OspfAdjFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.ospf.adj.flags._case.OspfAdjFlags) ArrayList(java.util.ArrayList) Delay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay) MinMaxDelay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelay) SrAdjIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds) LocalLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase) Uint32(org.opendaylight.yangtools.yang.common.Uint32) UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth) UnreservedBandwidthKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidthKey) MinMaxDelayBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelayBuilder) Loss(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Loss) MinMaxDelay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelay) SrlgId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId) UnreservedBandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidthBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) IsisAdjFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlags)

Example 4 with UnreservedBandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth in project bgpcep by opendaylight.

the class LinkAttributesParser method serializeUnreservedBw.

private static void serializeUnreservedBw(final List<UnreservedBandwidth> ubList, final ByteBuf byteAggregator) {
    // this sub-TLV contains eight 32-bit IEEE floating point numbers
    if (ubList != null) {
        final ByteBuf unreservedBandwithBuf = Unpooled.buffer();
        for (final UnreservedBandwidth unreservedBandwidth : ubList) {
            unreservedBandwithBuf.writeBytes(unreservedBandwidth.getBandwidth().getValue());
        }
        TlvUtil.writeTLV(UNRESERVED_BANDWIDTH, unreservedBandwithBuf, byteAggregator);
    }
}
Also used : UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.UnreservedBandwidth) ByteBuf(io.netty.buffer.ByteBuf)

Example 5 with UnreservedBandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth in project bgpcep by opendaylight.

the class LinkAttributesParser method parseUnreservedBandwidth.

private static void parseUnreservedBandwidth(final ByteBuf value, final LinkAttributesBuilder builder) {
    final var unreservedBandwidth = BindingMap.<UnreservedBandwidthKey, UnreservedBandwidth>orderedBuilder(UNRESERVED_BW_COUNT);
    for (int i = 0; i < UNRESERVED_BW_COUNT; i++) {
        final ByteBuf v = value.readSlice(BANDWIDTH_LENGTH);
        unreservedBandwidth.add(new UnreservedBandwidthBuilder().setBandwidth(new Bandwidth(ByteArray.readAllBytes(v))).setPriority(Uint8.valueOf(i)).build());
    }
    builder.setUnreservedBandwidth(unreservedBandwidth.build());
    LOG.debug("Parsed Unreserved Bandwidth {}", builder.getUnreservedBandwidth());
}
Also used : UnreservedBandwidthKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidthKey) UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidth) UnreservedBandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidthBuilder) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidth) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)3 UnreservedBandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidth)2 UnreservedBandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth)2 ArrayList (java.util.ArrayList)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 UnreservedBandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.attribute.UnreservedBandwidth)1 SrAdjIds (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds)1 UnreservedBandwidthBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidthBuilder)1 UnreservedBandwidthKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.UnreservedBandwidthKey)1 IsisAdjFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlags)1 OspfAdjFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.ospf.adj.flags._case.OspfAdjFlags)1 LocalLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase)1 Delay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay)1 Loss (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Loss)1 EdgeAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributes)1 EdgeAttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributesBuilder)1 MinMaxDelay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelay)1 MinMaxDelayBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelayBuilder)1 UnreservedBandwidthBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidthBuilder)1 UnreservedBandwidthKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidthKey)1