Search in sources :

Example 11 with OduSignalId

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

the class CriterionJsonMatcher method matchCriterion.

/**
 * Matches an ODU signal ID criterion object.
 *
 * @param criterion criterion to match
 * @return true if the JSON matches the criterion, false otherwise.
 */
private boolean matchCriterion(OduSignalIdCriterion criterion) {
    final OduSignalId oduSignal = criterion.oduSignalId();
    final JsonNode jsonOduSignal = jsonCriterion.get(CriterionCodec.ODU_SIGNAL_ID);
    int jsonTpn = jsonOduSignal.get(CriterionCodec.TRIBUTARY_PORT_NUMBER).intValue();
    int jsonTsLen = jsonOduSignal.get(CriterionCodec.TRIBUTARY_SLOT_LEN).intValue();
    byte[] jsonTributaryBitMap = HexString.fromHexString(jsonOduSignal.get(CriterionCodec.TRIBUTARY_SLOT_BITMAP).asText());
    OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, jsonTributaryBitMap);
    if (!oduSignal.equals(jsonOduSignalId)) {
        description.appendText("oduSignalId was " + criterion);
        return false;
    }
    return true;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) OduSignalId(org.onosproject.net.OduSignalId)

Example 12 with OduSignalId

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

the class InstructionCodecTest method modOduSignalIdInstructionTest.

/**
 * Tests the encoding of mod ODU signal ID instructions.
 */
@Test
public void modOduSignalIdInstructionTest() {
    OduSignalId oduSignalId = OduSignalId.oduSignalId(1, 8, new byte[] { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
    L1ModificationInstruction.ModOduSignalIdInstruction instruction = (L1ModificationInstruction.ModOduSignalIdInstruction) Instructions.modL1OduSignalId(oduSignalId);
    ObjectNode instructionJson = instructionCodec.encode(instruction, context);
    assertThat(instructionJson, matchesInstruction(instruction));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) L1ModificationInstruction(org.onosproject.net.flow.instructions.L1ModificationInstruction) OduSignalId(org.onosproject.net.OduSignalId) Test(org.junit.Test)

Example 13 with OduSignalId

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

the class OpticalCircuitIntentCompilerTest method test1GbeMultiplexOverOdu2.

/**
 * Tests compile of OpticalCircuitIntent with allocation of TributarySlots.
 * Compile two ODUCLT ports (with CLT_1GBE), over OCH ports (with ODU2):
 *   - only one TributarySlot is used
 */
@Test
public void test1GbeMultiplexOverOdu2() {
    // Use driver with TributarySlotQuery Behaviour
    sut.driverService = new MockDriverServiceWithTs();
    ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P1.number());
    ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P1.number());
    ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
    ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
    intent = OpticalCircuitIntent.builder().appId(APP_ID).key(KEY1).src(oduCltSrcCP).dst(oduCltDstCP).signalType(D1P1.signalType()).bidirectional(false).build();
    sut.activate(null);
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
    // validate SRC selector
    TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
    selectorBuilder1.matchInPort(oduCltSrcCP.port());
    selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    assertThat(rule1.selector(), is(selectorBuilder1.build()));
    // validate SRC treatment  (with OduSignalId, where 1 TributarySlot is used)
    TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
    Set<TributarySlot> slots = new HashSet<>();
    slots.add(TributarySlot.of(1));
    OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(D1P2.signalType(), slots);
    treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
    treatmentBuilder1.setOutput(ochSrcCP.port());
    assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
    FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
    // validate DST selector (with OduSignalId, where the same TributarySlot is used)
    TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
    selectorBuilder2.matchInPort(ochDstCP.port());
    selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
    assertThat(rule2.selector(), is(selectorBuilder2.build()));
    // validate DST treatment
    assertThat(rule2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()));
    rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
    sut.deactivate();
}
Also used : OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) TributarySlot(org.onosproject.net.TributarySlot) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) FlowRule(org.onosproject.net.flow.FlowRule) OduSignalId(org.onosproject.net.OduSignalId) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 14 with OduSignalId

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

the class OpticalOduIntentCompilerTest method test1GbeMultiplexOverOdu2.

/**
 * Tests compile of OpticalOduIntent with allocation of TributarySlots.
 * Compile two ODUCLT ports (with CLT_1GBE), over OTU ports (with OTU2):
 *   - only one TributarySlot is used
 */
@Test
public void test1GbeMultiplexOverOdu2() {
    intent = OpticalOduIntent.builder().appId(APP_ID).key(KEY1).src(d1p1).dst(d3p2).signalType(D1P1.signalType()).bidirectional(false).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    // 1st Device
    FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
    // validate SRC selector
    TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
    selectorBuilder1.matchInPort(d1p1.port());
    selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    assertThat(rule1.selector(), is(selectorBuilder1.build()));
    // validate SRC treatment  (with OduSignalId, where 1 TributarySlot is used)
    TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
    Set<TributarySlot> slots = new HashSet<>();
    slots.add(TributarySlot.of(1));
    OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(OduSignalType.ODU2, slots);
    treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
    treatmentBuilder1.setOutput(d1p2.port());
    assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
    // 2nd Device
    FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
    // validate SRC selector
    TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
    selectorBuilder2.matchInPort(d2p1.port());
    selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
    assertThat(rule2.selector(), is(selectorBuilder2.build()));
    // validate SRC treatment  (with OduSignalId, where 1 TributarySlot is used)
    TrafficTreatment.Builder treatmentBuilder2 = DefaultTrafficTreatment.builder();
    treatmentBuilder2.add(Instructions.modL1OduSignalId(oduSignalId));
    treatmentBuilder2.setOutput(d2p2.port());
    assertThat(rule2.treatment(), is(treatmentBuilder2.build()));
    // 3rd Device
    FlowRule rule3 = rules.stream().filter(x -> x.deviceId().equals(device3.id())).findFirst().get();
    // validate DST selector (with OduSignalId, where the same TributarySlot is used)
    TrafficSelector.Builder selectorBuilder3 = DefaultTrafficSelector.builder();
    selectorBuilder3.matchInPort(d3p1.port());
    selectorBuilder3.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
    selectorBuilder3.add(Criteria.matchOduSignalId(oduSignalId));
    assertThat(rule3.selector(), is(selectorBuilder3.build()));
    // validate DST treatment
    assertThat(rule3.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d3p2.port()).build()));
    rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
    sut.deactivate();
}
Also used : FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) OpticalOduIntent(org.onosproject.net.intent.OpticalOduIntent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) TributarySlot(org.onosproject.net.TributarySlot) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) FlowRule(org.onosproject.net.flow.FlowRule) OduSignalId(org.onosproject.net.OduSignalId) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

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