Search in sources :

Example 1 with OduSignalId

use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.

the class OpticalOduIntentCompiler method createRules.

/**
 * Create rules for the forward (or the reverse) path of the intent.
 *
 * @param intent OpticalOduIntent intent
 * @param path path found for intent
 * @param slotsMap Map of LinkKey and TributarySlots resources
 * @return list of flow rules
 */
private List<FlowRule> createRules(OpticalOduIntent intent, ConnectPoint src, ConnectPoint dst, Path path, Map<LinkKey, Set<TributarySlot>> slotsMap, boolean reverse) {
    // Build the ingress OTN rule
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchInPort(src.port());
    OduSignalType oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
    selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
    List<FlowRule> rules = new LinkedList<>();
    ConnectPoint current = src;
    List<Link> links = ((!reverse) ? path.links() : Lists.reverse(path.links()));
    for (Link link : links) {
        Set<TributarySlot> slots = slotsMap.get(linkKey(link));
        OtuPort otuPort = (OtuPort) (deviceService.getPort(link.src().deviceId(), link.src().port()));
        OduSignalType otuPortOduSignalType = OduSignalUtils.mappingOtuSignalTypeToOduSignalType(otuPort.signalType());
        TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
        OduSignalId oduSignalId = null;
        // use Instruction of OduSignalId only in case of ODU Multiplexing
        if (oduCltPortOduSignalType != otuPortOduSignalType) {
            oduSignalId = OduSignalUtils.buildOduSignalId(otuPortOduSignalType, slots);
            treat.add(Instructions.modL1OduSignalId(oduSignalId));
        }
        ConnectPoint next = ((!reverse) ? link.src() : link.dst());
        treat.setOutput(next.port());
        FlowRule rule = createFlowRule(intent, current.deviceId(), selector.build(), treat.build());
        rules.add(rule);
        current = ((!reverse) ? link.dst() : link.src());
        selector = DefaultTrafficSelector.builder();
        selector.matchInPort(current.port());
        selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
        // use Criteria of OduSignalId only in case of ODU Multiplexing
        if (oduCltPortOduSignalType != otuPortOduSignalType) {
            selector.add(Criteria.matchOduSignalId(oduSignalId));
        }
    }
    // Build the egress OTN rule
    TrafficTreatment.Builder treatLast = DefaultTrafficTreatment.builder();
    treatLast.setOutput(dst.port());
    FlowRule rule = createFlowRule(intent, dst.deviceId(), selector.build(), treatLast.build());
    rules.add(rule);
    return rules;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) OtuPort(org.onosproject.net.optical.OtuPort) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) LinkedList(java.util.LinkedList) TributarySlot(org.onosproject.net.TributarySlot) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) OduSignalId(org.onosproject.net.OduSignalId) Link(org.onosproject.net.Link)

Example 2 with OduSignalId

use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.

the class OpticalCircuitIntentCompiler method connectPorts.

/**
 * Builds flow rule for mapping between two ports.
 *
 * @param src source port
 * @param dst destination port
 * @param priority
 * @param slots Set of TributarySlots
 * @return flow rules
 */
private FlowRule connectPorts(ConnectPoint src, ConnectPoint dst, int priority, Set<TributarySlot> slots) {
    checkArgument(src.deviceId().equals(dst.deviceId()));
    TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
    selectorBuilder.matchInPort(src.port());
    if (!slots.isEmpty()) {
        Port srcPort = deviceService.getPort(src.deviceId(), src.port());
        Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
        OduSignalType oduCltPortOduSignalType;
        OduSignalType ochPortOduSignalType;
        if (srcPort instanceof OduCltPort) {
            oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) srcPort).signalType());
            ochPortOduSignalType = ((OchPort) dstPort).signalType();
            selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
            // use Instruction of OduSignalId only in case of ODU Multiplexing
            if (oduCltPortOduSignalType != ochPortOduSignalType) {
                OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots);
                treatmentBuilder.add(Instructions.modL1OduSignalId(oduSignalId));
            }
        } else {
            // srcPort is OchPort
            oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) dstPort).signalType());
            ochPortOduSignalType = ((OchPort) srcPort).signalType();
            selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
            // use Criteria of OduSignalId only in case of ODU Multiplexing
            if (oduCltPortOduSignalType != ochPortOduSignalType) {
                OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots);
                selectorBuilder.add(Criteria.matchOduSignalId(oduSignalId));
            }
        }
    }
    treatmentBuilder.setOutput(dst.port());
    FlowRule flowRule = DefaultFlowRule.builder().forDevice(src.deviceId()).withSelector(selectorBuilder.build()).withTreatment(treatmentBuilder.build()).withPriority(priority).fromApp(appId).makePermanent().build();
    return flowRule;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OduCltPort(org.onosproject.net.optical.OduCltPort) OduCltPort(org.onosproject.net.optical.OduCltPort) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OduSignalId(org.onosproject.net.OduSignalId) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 3 with OduSignalId

use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.

the class CriteriaTest method testMatchOduSignalIdMethod.

/**
 * Test the OduSignalId method.
 */
@Test
public void testMatchOduSignalIdMethod() {
    OduSignalId odu = oduSignalId(1, 80, new byte[] { 2, 1, 1, 3, 1, 1, 3, 1, 1, 3 });
    Criterion matchoduSignalId = Criteria.matchOduSignalId(odu);
    OduSignalIdCriterion oduSignalIdCriterion = checkAndConvert(matchoduSignalId, Criterion.Type.ODU_SIGID, OduSignalIdCriterion.class);
    assertThat(oduSignalIdCriterion.oduSignalId(), is(equalTo(odu)));
}
Also used : OduSignalId(org.onosproject.net.OduSignalId) Test(org.junit.Test)

Example 4 with OduSignalId

use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.

the class EncodeInstructionCodecHelper method encodeL1.

/**
 * Encode an L1 modification instruction.
 *
 * @param result json node that the instruction attributes are added to
 */
private void encodeL1(ObjectNode result) {
    L1ModificationInstruction l1Instruction = (L1ModificationInstruction) instruction;
    result.put(InstructionCodec.SUBTYPE, l1Instruction.subtype().name());
    switch(l1Instruction.subtype()) {
        case ODU_SIGID:
            final L1ModificationInstruction.ModOduSignalIdInstruction oduSignalIdInstruction = (L1ModificationInstruction.ModOduSignalIdInstruction) l1Instruction;
            OduSignalId oduSignalId = oduSignalIdInstruction.oduSignalId();
            ObjectNode child = result.putObject("oduSignalId");
            child.put(InstructionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber());
            child.put(InstructionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength());
            child.put(InstructionCodec.TRIBUTARY_SLOT_BITMAP, HexString.toHexString(oduSignalId.tributarySlotBitmap()));
            break;
        default:
            log.info("Cannot convert L1 subtype of {}", l1Instruction.subtype());
            break;
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) L1ModificationInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction) OduSignalId(org.onosproject.net.OduSignalId)

Example 5 with OduSignalId

use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.

the class InstructionJsonMatcher method matchModOduSingalIdInstruction.

/**
 * Matches the contents of a mod ODU singal Id instruction.
 *
 * @param instructionJson JSON instruction to match
 * @param description Description object used for recording errors
 * @return true if contents matches, false otherwise
 */
private boolean matchModOduSingalIdInstruction(JsonNode instructionJson, Description description) {
    ModOduSignalIdInstruction instructionToMatch = (ModOduSignalIdInstruction) instruction;
    String jsonSubType = instructionJson.get("subtype").textValue();
    if (!instructionToMatch.subtype().name().equals(jsonSubType)) {
        description.appendText("subtype was " + jsonSubType);
        return false;
    }
    String jsonType = instructionJson.get("type").textValue();
    if (!instructionToMatch.type().name().equals(jsonType)) {
        description.appendText("type was " + jsonType);
        return false;
    }
    final JsonNode jsonOduSignal = instructionJson.get("oduSignalId");
    int jsonTpn = jsonOduSignal.get("tributaryPortNumber").intValue();
    int jsonTsLen = jsonOduSignal.get("tributarySlotLength").intValue();
    byte[] tributaryBitMap = HexString.fromHexString(jsonOduSignal.get("tributarySlotBitmap").asText());
    OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, tributaryBitMap);
    if (!instructionToMatch.oduSignalId().equals(jsonOduSignalId)) {
        description.appendText("oduSignalId was " + instructionToMatch);
        return false;
    }
    return true;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) HexString(org.onlab.util.HexString) OduSignalId(org.onosproject.net.OduSignalId) ModOduSignalIdInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction)

Aggregations

OduSignalId (org.onosproject.net.OduSignalId)14 Test (org.junit.Test)5 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)5 TrafficSelector (org.onosproject.net.flow.TrafficSelector)5 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)4 FlowRule (org.onosproject.net.flow.FlowRule)4 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 TributarySlot (org.onosproject.net.TributarySlot)3 L1ModificationInstruction (org.onosproject.net.flow.instructions.L1ModificationInstruction)3 OFOxm (org.projectfloodlight.openflow.protocol.oxm.OFOxm)3 CircuitSignalID (org.projectfloodlight.openflow.types.CircuitSignalID)3 IPv4Address (org.projectfloodlight.openflow.types.IPv4Address)3 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)3 OduSignalID (org.projectfloodlight.openflow.types.OduSignalID)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 HashSet (java.util.HashSet)2 Ip4Address (org.onlab.packet.Ip4Address)2 Ip4Prefix (org.onlab.packet.Ip4Prefix)2 Ip6Address (org.onlab.packet.Ip6Address)2