Search in sources :

Example 11 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class TsLoopPacket method copyPacketMatch.

/**
 * Creates and returns a new packet instance with the copied match fields.
 *
 * With hard-copied match fields, references to path flows and path links.
 *
 * @return new loop packet instance with the copied match fields
 */
public TsLoopPacket copyPacketMatch() {
    TsLoopPacket newOne = new TsLoopPacket();
    newOne.pathFlow = this.pathFlow;
    newOne.pathLink = this.pathLink;
    Map<Criterion.Type, Criterion> m = newOne.match;
    for (Map.Entry<Criterion.Type, Criterion> entry : this.match.entrySet()) {
        Criterion.Type k = entry.getKey();
        Criterion v = entry.getValue();
        switch(k) {
            case IN_PORT:
                m.put(k, matchInPort(((PortCriterion) v).port()));
                break;
            case // At present, not support Ethernet mask (ONOS?)
            ETH_SRC:
                m.put(k, matchEthSrc(((EthCriterion) v).mac()));
                break;
            case // At present, not support Ethernet mask (ONOS?)
            ETH_DST:
                m.put(k, matchEthDst(((EthCriterion) v).mac()));
                break;
            case ETH_TYPE:
                m.put(k, matchEthType(((EthTypeCriterion) v).ethType()));
                break;
            case // At present, not support VLAN mask (ONOS?)
            VLAN_VID:
                m.put(k, matchVlanId(((VlanIdCriterion) v).vlanId()));
                break;
            case VLAN_PCP:
                m.put(k, matchVlanPcp(((VlanPcpCriterion) v).priority()));
                break;
            case IPV4_SRC:
                m.put(k, matchIPSrc(((IPCriterion) v).ip()));
                break;
            case IPV4_DST:
                m.put(k, matchIPDst(((IPCriterion) v).ip()));
                break;
            case IP_PROTO:
                m.put(k, matchIPProtocol(((IPProtocolCriterion) v).protocol()));
                break;
            case // can't be supported by now
            IP_DSCP:
                m.put(k, matchIPDscp(((IPDscpCriterion) v).ipDscp()));
                break;
            case // can't be supported by now
            IP_ECN:
                m.put(k, matchIPEcn(((IPEcnCriterion) v).ipEcn()));
                break;
            case TCP_SRC:
                m.put(k, matchTcpSrc(((TcpPortCriterion) v).tcpPort()));
                break;
            case TCP_DST:
                m.put(k, matchTcpDst(((TcpPortCriterion) v).tcpPort()));
                break;
            case UDP_SRC:
                m.put(k, matchUdpSrc(((UdpPortCriterion) v).udpPort()));
                break;
            case UDP_DST:
                m.put(k, matchUdpDst(((UdpPortCriterion) v).udpPort()));
                break;
            default:
                // can't be supported by OF1.0
                log.debug("{} can't be supported by OF1.0", k);
                break;
        }
    }
    return newOne;
}
Also used : EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) IPDscpCriterion(org.onosproject.net.flow.criteria.IPDscpCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) IPDscpCriterion(org.onosproject.net.flow.criteria.IPDscpCriterion) HashMap(java.util.HashMap) Map(java.util.Map) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion)

Example 12 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerTest method singleHopNonTrivialForMp.

/**
 * We test the proper compilation of mp2sp with
 * selector, treatment, filtered
 * points and 1 hop.
 */
@Test
public void singleHopNonTrivialForMp() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(ipPrefixSelector).treatment(ethDstTreatment).links(ImmutableSet.of()).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector), new FilteredConnectPoint(d1p11, mpls100Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p0, vlan200Selector))).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    assertThat(rules, hasSize(2));
    Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS1, hasSize(2));
    FlowRule ruleS1 = rulesS1.stream().filter(rule -> {
        PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
        return inPort.port().equals(d1p10.port());
    }).findFirst().get();
    assertThat(ruleS1.selector(), Is.is(DefaultTrafficSelector.builder(ipPrefixSelector).matchVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId()).matchInPort(d1p10.port()).build()));
    assertThat(ruleS1.treatment(), Is.is(DefaultTrafficTreatment.builder().setEthDst(((ModEtherInstruction) ethDstTreatment.allInstructions().stream().filter(instruction -> instruction instanceof ModEtherInstruction).findFirst().get()).mac()).setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p0.port()).build()));
    ruleS1 = rulesS1.stream().filter(rule -> {
        PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
        return inPort.port().equals(d1p11.port());
    }).findFirst().get();
    assertThat(ruleS1.selector(), Is.is(DefaultTrafficSelector.builder(ipPrefixSelector).matchMplsLabel(((MplsCriterion) mpls100Selector.getCriterion(MPLS_LABEL)).label()).matchInPort(d1p11.port()).build()));
    assertThat(ruleS1.treatment(), Is.is(DefaultTrafficTreatment.builder().setEthDst(((ModEtherInstruction) ethDstTreatment.allInstructions().stream().filter(instruction -> instruction instanceof ModEtherInstruction).findFirst().get()).mac()).popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p0.port()).build()));
    sut.deactivate();
}
Also used : MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) DIRECT(org.onosproject.net.Link.Type.DIRECT) APP_ID(org.onosproject.net.NetTestTools.APP_ID) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Is(org.hamcrest.core.Is) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Type(org.onosproject.net.flow.criteria.Criterion.Type) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DomainService(org.onosproject.net.domain.DomainService) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) Intent(org.onosproject.net.intent.Intent) LOCAL(org.onosproject.net.domain.DomainId.LOCAL) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MockResourceService(org.onosproject.net.resource.MockResourceService) Before(org.junit.Before) DefaultLink(org.onosproject.net.DefaultLink) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) IPV4(org.onlab.packet.EthType.EtherType.IPV4) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) EasyMock(org.easymock.EasyMock) Collectors(java.util.stream.Collectors) PID(org.onosproject.net.NetTestTools.PID) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 13 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerTest method singleHopTestFilteredForSp.

/**
 * We test the proper compilation of sp2mp with
 * trivial selector, trivial treatment and 1 hop.
 */
@Test
public void singleHopTestFilteredForSp() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of()).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector), new FilteredConnectPoint(d1p11, mpls80Selector))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p0, vlan200Selector))).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    assertThat(rules, hasSize(1));
    Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS1, hasSize(1));
    FlowRule ruleS1 = rulesS1.stream().filter(rule -> {
        PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
        return inPort.port().equals(d1p0.port());
    }).findFirst().get();
    assertThat(ruleS1.selector(), Is.is(DefaultTrafficSelector.builder(vlan200Selector).matchInPort(d1p0.port()).build()));
    assertThat(ruleS1.treatment(), Is.is(DefaultTrafficTreatment.builder().setVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p10.port()).popVlan().pushMpls().setMpls(((MplsCriterion) mpls80Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d1p11.port()).build()));
    sut.deactivate();
}
Also used : MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) DIRECT(org.onosproject.net.Link.Type.DIRECT) APP_ID(org.onosproject.net.NetTestTools.APP_ID) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Is(org.hamcrest.core.Is) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Type(org.onosproject.net.flow.criteria.Criterion.Type) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DomainService(org.onosproject.net.domain.DomainService) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) Intent(org.onosproject.net.intent.Intent) LOCAL(org.onosproject.net.domain.DomainId.LOCAL) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MockResourceService(org.onosproject.net.resource.MockResourceService) Before(org.junit.Before) DefaultLink(org.onosproject.net.DefaultLink) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) IPV4(org.onlab.packet.EthType.EtherType.IPV4) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) EasyMock(org.easymock.EasyMock) Collectors(java.util.stream.Collectors) PID(org.onosproject.net.NetTestTools.PID) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 14 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerTest method singleHopTestFilteredForMp.

/**
 * We test the proper compilation of mp2sp with
 * trivial selector, trivial treatment, filtered
 * points and 1 hop.
 */
@Test
public void singleHopTestFilteredForMp() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).links(ImmutableSet.of()).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector), new FilteredConnectPoint(d1p11, mpls69Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p0, vlan200Selector))).build();
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    assertThat(rules, hasSize(2));
    Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS1, hasSize(2));
    FlowRule ruleS1 = rulesS1.stream().filter(rule -> {
        PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
        return inPort.port().equals(d1p10.port());
    }).findFirst().get();
    assertThat(ruleS1.selector(), Is.is(DefaultTrafficSelector.builder(vlan100Selector).matchInPort(d1p10.port()).build()));
    assertThat(ruleS1.treatment(), Is.is(DefaultTrafficTreatment.builder().setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p0.port()).build()));
    ruleS1 = rulesS1.stream().filter(rule -> {
        PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
        return inPort.port().equals(d1p11.port());
    }).findFirst().get();
    assertThat(ruleS1.selector(), Is.is(DefaultTrafficSelector.builder(mpls69Selector).matchInPort(d1p11.port()).build()));
    assertThat(ruleS1.treatment(), Is.is(DefaultTrafficTreatment.builder().popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p0.port()).build()));
    sut.deactivate();
}
Also used : MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) DIRECT(org.onosproject.net.Link.Type.DIRECT) APP_ID(org.onosproject.net.NetTestTools.APP_ID) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Is(org.hamcrest.core.Is) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Type(org.onosproject.net.flow.criteria.Criterion.Type) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DomainService(org.onosproject.net.domain.DomainService) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) Intent(org.onosproject.net.intent.Intent) LOCAL(org.onosproject.net.domain.DomainId.LOCAL) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MockResourceService(org.onosproject.net.resource.MockResourceService) Before(org.junit.Before) DefaultLink(org.onosproject.net.DefaultLink) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) IPV4(org.onlab.packet.EthType.EtherType.IPV4) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) EasyMock(org.easymock.EasyMock) Collectors(java.util.stream.Collectors) PID(org.onosproject.net.NetTestTools.PID) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 15 with VlanIdCriterion

use of org.onosproject.net.flow.criteria.VlanIdCriterion in project onos by opennetworkinglab.

the class LinkCollectionOptimizationTest method testOptimizationMplsEncapNonTrivial.

/**
 * We test the proper optimization of sp2mp with the MPLS
 * encapsulation, filtered selectors, intent selector, and
 * intent treatment.
 */
@Test
public void testOptimizationMplsEncapNonTrivial() {
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(ipPrefixSelector).treatment(ethDstTreatment).constraints(constraintsForMPLS).links(linksForSp2Mp).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, vlan69Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector), new FilteredConnectPoint(d1p11, vlan200Selector), new FilteredConnectPoint(d2p10, vlan300Selector))).build();
    sut.activate();
    /*
         * We use the FIRST_FIT to simplify tests.
         */
    LinkCollectionCompiler.labelAllocator.setLabelSelection(LABEL_SELECTION);
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    assertThat(rules, hasSize(3));
    Collection<FlowRule> rulesS3 = rules.stream().filter(rule -> rule.deviceId().equals(d3p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS3, hasSize(1));
    FlowRule ruleS3 = rulesS3.iterator().next();
    assertThat(ruleS3.selector(), is(DefaultTrafficSelector.builder(ipPrefixSelector).matchInPort(d3p10.port()).matchVlanId(((VlanIdCriterion) vlan69Selector.getCriterion(VLAN_VID)).vlanId()).build()));
    assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().popVlan().pushMpls().copyTtlOut().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d3p0.port()).build()));
    Collection<FlowRule> rulesS2 = rules.stream().filter(rule -> rule.deviceId().equals(d2p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS2, hasSize(1));
    FlowRule ruleS2 = rulesS2.iterator().next();
    assertThat(ruleS2.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p1.port()).matchMplsLabel(MplsLabel.mplsLabel(LABEL)).matchEthType(Ethernet.MPLS_UNICAST).build()));
    assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d2p0.port()).setEthDst(((ModEtherInstruction) ethDstTreatment.allInstructions().stream().filter(instruction -> instruction instanceof ModEtherInstruction).findFirst().get()).mac()).copyTtlIn().popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan300Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d2p10.port()).build()));
    Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
    assertThat(rulesS1, hasSize(1));
    FlowRule ruleS1 = rulesS1.iterator().next();
    assertThat(ruleS1.selector(), is(DefaultTrafficSelector.builder().matchInPort(d1p0.port()).matchMplsLabel(MplsLabel.mplsLabel(LABEL)).matchEthType(Ethernet.MPLS_UNICAST).build()));
    assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().setEthDst(((ModEtherInstruction) ethDstTreatment.allInstructions().stream().filter(instruction -> instruction instanceof ModEtherInstruction).findFirst().get()).mac()).copyTtlIn().popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p10.port()).setEthDst(((ModEtherInstruction) ethDstTreatment.allInstructions().stream().filter(instruction -> instruction instanceof ModEtherInstruction).findFirst().get()).mac()).setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p11.port()).build()));
    sut.deactivate();
}
Also used : MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) APP_ID(org.onosproject.net.NetTestTools.APP_ID) CoreService(org.onosproject.core.CoreService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Ethernet(org.onlab.packet.Ethernet) DomainService(org.onosproject.net.domain.DomainService) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) Is.is(org.hamcrest.core.Is.is) Intent(org.onosproject.net.intent.Intent) Matchers.hasSize(org.hamcrest.Matchers.hasSize) LOCAL(org.onosproject.net.domain.DomainId.LOCAL) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MockResourceService(org.onosproject.net.resource.MockResourceService) Before(org.junit.Before) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) MplsLabel(org.onlab.packet.MplsLabel) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) IPV4(org.onlab.packet.EthType.EtherType.IPV4) VLAN_VID(org.onosproject.net.flow.criteria.Criterion.Type.VLAN_VID) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Test(org.junit.Test) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) EasyMock(org.easymock.EasyMock) Collectors(java.util.stream.Collectors) List(java.util.List) FlowRule(org.onosproject.net.flow.FlowRule) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) MPLS_LABEL(org.onosproject.net.flow.criteria.Criterion.Type.MPLS_LABEL) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) Test(org.junit.Test)

Aggregations

VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)65 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)48 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)45 FlowRule (org.onosproject.net.flow.FlowRule)41 VlanId (org.onlab.packet.VlanId)37 MplsCriterion (org.onosproject.net.flow.criteria.MplsCriterion)35 List (java.util.List)32 DeviceId (org.onosproject.net.DeviceId)30 TrafficSelector (org.onosproject.net.flow.TrafficSelector)30 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)30 EthCriterion (org.onosproject.net.flow.criteria.EthCriterion)28 Collection (java.util.Collection)27 Collections (java.util.Collections)27 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)27 Collectors (java.util.stream.Collectors)26 Criterion (org.onosproject.net.flow.criteria.Criterion)26 Test (org.junit.Test)25 ImmutableSet (com.google.common.collect.ImmutableSet)24 CoreService (org.onosproject.core.CoreService)24 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)24