Examples of OFMatch


Examples of org.openflow.protocol.OFMatch

    public void clearAllFlowMods() {
        if (channel == null || !isConnected())
            return;
        // Delete all pre-existing flows
        log.info("Clearing all flows on switch {}", this);
        OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
        OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
            .getMessage(OFType.FLOW_MOD))
                .setMatch(match)
            .setCommand(OFFlowMod.OFPFC_DELETE)
            .setOutPort(OFPort.OFPP_NONE)
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        }

        // Create flow-mod based on packet-in and src-switch
        OFFlowMod fm =
            (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
        OFMatch match = new OFMatch();
        match.loadFromPacket(pi.getPacketData(), pi.getInPort());
        List<OFAction> actions = new ArrayList<OFAction>(); // no actions = drop
        long cookie = AppCookie.makeCookie(APP_ID, 0);
        fm.setCookie(cookie)
        .setIdleTimeout(ForwardingBase.FLOWMOD_DEFAULT_IDLE_TIMEOUT)
        .setHardTimeout(ForwardingBase.FLOWMOD_DEFAULT_HARD_TIMEOUT)
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        }

        // Now we are in the slow path where we need to do filtering
        // First filter based on OFMatch
        OFPacketIn pin = (OFPacketIn)ofm;
        OFMatch match = new OFMatch();
        match.loadFromPacket(pin.getPacketData(), pin.getInPort());
        if (ofMatchCache.update(match)) {
           ctrSwitchPktinDrops.updateCounterNoFlush();
            return true;
        }
View Full Code Here

Examples of org.openflow.protocol.OFMatch

            OFStatisticsRequest req = new OFStatisticsRequest();
            req.setStatisticType(statType);
            int requestLength = req.getLengthU();
            if (statType == OFStatisticsType.FLOW) {
                OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
                OFMatch match = new OFMatch();
                match.setWildcards(0xffffffff);
                specificReq.setMatch(match);
                specificReq.setOutPort(OFPort.OFPP_NONE.getValue());
                specificReq.setTableId((byte) 0xff);
                req.setStatistics(Collections.singletonList((OFStatistics)specificReq));
                requestLength += specificReq.getLength();
            } else if (statType == OFStatisticsType.AGGREGATE) {
                OFAggregateStatisticsRequest specificReq = new OFAggregateStatisticsRequest();
                OFMatch match = new OFMatch();
                match.setWildcards(0xffffffff);
                specificReq.setMatch(match);
                specificReq.setOutPort(OFPort.OFPP_NONE.getValue());
                specificReq.setTableId((byte) 0xff);
                req.setStatistics(Collections.singletonList((OFStatistics)specificReq));
                requestLength += specificReq.getLength();
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        // Create flow-mod based on packet-in and src-switch
        OFFlowMod fm =
                (OFFlowMod) floodlightProvider.getOFMessageFactory()
                                              .getMessage(OFType.FLOW_MOD);
        OFMatch match = new OFMatch();
        List<OFAction> actions = new ArrayList<OFAction>(); // Set no action to
                                                            // drop
        match.setInputPort((short)inputPort);
        if (host_mac != -1L) {
            match.setDataLayerSource(Ethernet.toByteArray(host_mac))
                .setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_DL_SRC
                               & ~OFMatch.OFPFW_IN_PORT);
        } else {
            match.setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_IN_PORT);
        }
        fm.setCookie(cookie)
          .setHardTimeout(hardTimeout)
          .setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
          .setBufferId(OFPacketOut.BUFFER_ID_NONE)
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        // Verify the message is a flowmod with a hard timeout and srcMac
        assertTrue(blockMessage != null);
        assertTrue(blockMessage instanceof OFFlowMod);
        OFFlowMod fm = (OFFlowMod) blockMessage;
        assertTrue(fm.getHardTimeout() == 5);
        OFMatch match = fm.getMatch();
        assertTrue((match.getWildcards() & OFMatch.OFPFW_DL_SRC) == 0);
        assertTrue(Arrays.equals(match.getDataLayerSource(),
                HexString.fromHexString(srcMac)));

        // Verify non-unique OFMatches are throttled
        assertTrue(sw.inputThrottled(pi));
    }
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        // Verify the message is a flowmod with a hard timeout and per port
        assertTrue(blockMessage != null);
        assertTrue(blockMessage instanceof OFFlowMod);
        OFFlowMod fm = (OFFlowMod) blockMessage;
        assertTrue(fm.getHardTimeout() == 5);
        OFMatch match = fm.getMatch();
        assertTrue((match.getWildcards() & OFMatch.OFPFW_DL_SRC) != 0);
        assertTrue((match.getWildcards() & OFMatch.OFPFW_IN_PORT) == 0);
        assertTrue(match.getInputPort() == 1);

        // Verify non-unique OFMatches are throttled
        assertTrue(sw.inputThrottled(pi));
    }
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        // The STATS_REQUEST object used when querying the switches for flows
        OFStatisticsRequest req = new OFStatisticsRequest();
        req.setStatisticType(OFStatisticsType.FLOW);
        int requestLength = req.getLengthU();
        OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
        specificReq.setMatch(new OFMatch().setWildcards(0xffffffff));
        specificReq.setOutPort((short) 3);
        specificReq.setTableId((byte) 0xff);
        req.setStatistics(Collections.singletonList((OFStatistics) specificReq));
        requestLength += specificReq.getLength();
        req.setLengthU(requestLength);

        // Actions for the STATS_REPLY object
        OFActionOutput action = new OFActionOutput((short) 3, (short) 0xffff);
        List<OFAction> actions = new ArrayList<OFAction>();
        actions.add(action);

        // Match for the STATS_REPLY object
        OFMatch m = new OFMatch();
        // Set the incoming port to 1 so that it will find the connected
        m.setInputPort((short) 1);

        // STATS_REPLY object
        OFFlowStatisticsReply reply = new OFFlowStatisticsReply();
        reply.setActions(actions);
        reply.setMatch(m);
        // Add the reply to the list of OFStatistics
        statsReply.add(reply);

        // Create the STATS_REPLY asynchronous reply object
        Callable<List<OFStatistics>> replyFuture = new ReplyFuture();
        // Assign the callable object to a Futuretask so that it will produce
        // future results
        FutureTask<List<OFStatistics>> futureStats = new FutureTask<List<OFStatistics>>(
                                                                                        replyFuture);

        // Assign the results of calling the object (the asynchronous reply)
        Future<List<OFStatistics>> results = getResults(futureStats);

        // SW1 -- Mock switch for base and multiple switch test case
        sw1 = EasyMock.createNiceMock(IOFSwitch.class);
        // Expect that the switch's ID is 1
        expect(sw1.getId()).andReturn(1L).anyTimes();
        expect(sw1.queryStatistics(req)).andReturn(results).once();
        // Captures to hold resulting flowmod delete messages
        wc1 = new Capture<List<OFMessage>>(CaptureType.ALL);
        bc1 = new Capture<FloodlightContext>(CaptureType.ALL);
        // Capture the parameters passed when sw1.write is invoked
        sw1.write(capture(wc1), capture(bc1));
        expectLastCall().once();
        replay(sw1);

        // SW2 -- Mock switch for extended test cases
        sw2 = EasyMock.createNiceMock(IOFSwitch.class);
        // Expect that the switch's ID is 2
        expect(sw2.getId()).andReturn(2L).anyTimes();
        expect(sw2.queryStatistics(req)).andReturn(results).once();
        wc2 = new Capture<List<OFMessage>>(CaptureType.ALL);
        bc2 = new Capture<FloodlightContext>(CaptureType.ALL);
        // Capture the parameters passwed when sw1.write is invoked
        sw2.write(capture(wc2), capture(bc2));
        expectLastCall().anyTimes();
        replay(sw2);

        // SW3 -- Mock switch for extended test cases
        sw3 = EasyMock.createNiceMock(IOFSwitch.class);
        // Expect that the switch's ID is 3
        expect(sw3.getId()).andReturn(3L).anyTimes();
        expect(sw3.queryStatistics(req)).andReturn(results).once();
        wc3 = new Capture<List<OFMessage>>(CaptureType.ALL);
        bc3 = new Capture<FloodlightContext>(CaptureType.ALL);
        // Capture the parameters passwed when sw1.write is invoked
        sw3.write(capture(wc3), capture(bc3));
        expectLastCall().anyTimes();
        replay(sw3);

        // SW4 -- Mock switch for extended test cases
        sw4 = EasyMock.createNiceMock(IOFSwitch.class);
        // Expect that the switch's ID is 4
        expect(sw4.getId()).andReturn(4L).anyTimes();
        expect(sw4.queryStatistics(req)).andReturn(results).once();
        wc4 = new Capture<List<OFMessage>>(CaptureType.ALL);
        bc4 = new Capture<FloodlightContext>(CaptureType.ALL);
        // Capture the parameters passed when sw1.write is invoked
        sw4.write(capture(wc4), capture(bc4));
        expectLastCall().anyTimes();
        replay(sw4);

        // Here we create the OFMatch Reconcile list we wish to pass
        lofmr = new ArrayList<OFMatchReconcile>();

        // Create the only OFMatch Reconcile object that will be in the list
        ofmr = new OFMatchReconcile();
        long affectedSwitch = sw1.getId();
        OFMatchWithSwDpid ofmatchsw = new OFMatchWithSwDpid(new OFMatch().setWildcards(OFMatch.OFPFW_ALL),
                                                            affectedSwitch);
        ofmr.rcAction = OFMatchReconcile.ReconcileAction.UPDATE_PATH;
        ofmr.ofmWithSwDpid = ofmatchsw;

        // We'll say port 3 went down
        ofmr.outPort = 3;

        // Add the OFMatch Reconcile object to the list
        lofmr.add(ofmr);

        // Expected Flow Mod Deletes Messages
        // Flow Mod Delete for base switch
        fm = ((OFFlowMod) mockFloodlightProvider.getOFMessageFactory()
                                                 .getMessage(OFType.FLOW_MOD)).setMatch(new OFMatch().setWildcards(OFMatch.OFPFW_ALL))
                                                                              .setCommand(OFFlowMod.OFPFC_DELETE)
                                                                              // Notice
                                                                              // we
                                                                              // specify
                                                                              // an
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        nptList.add(new NodePortTuple(2L, (short)3));
        route.setPath(nptList);
        expect(routingEngine.getRoute(1L, (short)1, 2L, (short)3, 0)).andReturn(route).atLeastOnce();

        // Expected Flow-mods
        OFMatch match = new OFMatch();
        match.loadFromPacket(testPacketSerialized, (short) 1);
        OFActionOutput action = new OFActionOutput((short)3, (short)0xffff);
        List<OFAction> actions = new ArrayList<OFAction>();
        actions.add(action);

        OFFlowMod fm1 =
                (OFFlowMod) mockFloodlightProvider.getOFMessageFactory().
                    getMessage(OFType.FLOW_MOD);
        fm1.setIdleTimeout((short)5)
            .setMatch(match.clone()
                    .setWildcards(expected_wildcards))
            .setActions(actions)
            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
            .setCookie(2L << 52)
            .setLengthU(OFFlowMod.MINIMUM_LENGTH+OFActionOutput.MINIMUM_LENGTH);
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        route.getPath().add(new NodePortTuple(1L, (short)1));
        route.getPath().add(new NodePortTuple(1L, (short)3));
        expect(routingEngine.getRoute(1L, (short)1, 1L, (short)3, 0)).andReturn(route).atLeastOnce();

        // Expected Flow-mods
        OFMatch match = new OFMatch();
        match.loadFromPacket(testPacketSerialized, (short) 1);
        OFActionOutput action = new OFActionOutput((short)3, (short)0xffff);
        List<OFAction> actions = new ArrayList<OFAction>();
        actions.add(action);

        OFFlowMod fm1 =
                (OFFlowMod) mockFloodlightProvider.getOFMessageFactory().
                    getMessage(OFType.FLOW_MOD);
        fm1.setIdleTimeout((short)5)
            .setMatch(match.clone()
                    .setWildcards(expected_wildcards))
            .setActions(actions)
            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
            .setCookie(2L << 52)
            .setLengthU(OFFlowMod.MINIMUM_LENGTH +
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.