Examples of OFMessage


Examples of org.openflow.protocol.OFMessage

        assertCollectionEqualsNoOrder(ports, sw.getPorts());
    }

    @Test
    public void testSubHandshake() {
        OFMessage m = BasicFactory.getInstance().getMessage(OFType.VENDOR);
        // test execptions before handshake is started
        try {
            sw.processDriverHandshakeMessage(m);
            fail("expected exception not thrown");
        } catch (SwitchDriverSubHandshakeNotStarted e) { /* expected */ }
View Full Code Here

Examples of org.openflow.protocol.OFMessage

    public void testFlowMod() throws Exception {
        // tweak the test packet in since we need a bufferId
        this.packetIn.setBufferId(50);

        // build expected flow mods
        OFMessage fm1 = ((OFFlowMod) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD))
            .setActions(Arrays.asList(new OFAction[] {
                    new OFActionOutput().setPort((short) 2).setMaxLength((short) -1)}))
            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
            .setCommand(OFFlowMod.OFPFC_ADD)
            .setIdleTimeout((short) 5)
            .setMatch(new OFMatch()
                .loadFromPacket(testPacketSerialized, (short) 1)
                .setWildcards(OFMatch.OFPFW_NW_PROTO | OFMatch.OFPFW_TP_SRC | OFMatch.OFPFW_TP_DST
                        | OFMatch.OFPFW_NW_TOS))
            .setOutPort(OFPort.OFPP_NONE.getValue())
            .setCookie(1L << 52)
            .setPriority((short) 100)
            .setFlags((short)(1 << 0))
            .setLengthU(OFFlowMod.MINIMUM_LENGTH+OFActionOutput.MINIMUM_LENGTH);
        OFMessage fm2 = ((OFFlowMod) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD))
            .setActions(Arrays.asList(new OFAction[] {
                    new OFActionOutput().setPort((short) 1).setMaxLength((short) -1)}))
            .setBufferId(-1)
            .setCommand(OFFlowMod.OFPFC_ADD)
            .setIdleTimeout((short) 5)
View Full Code Here

Examples of org.openflow.protocol.OFMessage

                assertEquals(fm1, m);
            else if (m instanceof OFPacketOut)
                assertEquals(packetOut, m);
        }

        OFMessage m = wc2.getValue();
        assert (m instanceof OFFlowMod);
        assertTrue(m.equals(fm2));
    }
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        verifyExceptionCaptured(ClassCastException.class);
        */

        // We don't expect to receive /any/ messages in init state since
        // channelConnected moves us to a different state
        OFMessage m = BasicFactory.getInstance().getMessage(OFType.HELLO);
        sendMessageToHandlerWithControllerReset(Collections.singletonList(m));

        verifyExceptionCaptured(SwitchStateException.class);
        assertEquals(OFChannelHandler.ChannelState.INIT,
                     handler.getStateForTesting());
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        resetChannel();
        channel.write(capture(writeCapture));
        expectLastCall().andReturn(null).atLeastOnce();
        replay(channel);

        OFMessage hello = BasicFactory.getInstance().getMessage(OFType.HELLO);
        sendMessageToHandlerWithControllerReset(Collections.singletonList(hello));

        List<OFMessage> msgs = getMessagesFromCapture();
        assertEquals(1, msgs.size());
        assertEquals(OFType.FEATURES_REQUEST, msgs.get(0).getType());
View Full Code Here

Examples of org.openflow.protocol.OFMessage


        //-------------------------------------------------
        // Send a message to the handler, it should be passed to the
        // switch's sub-handshake handling.
        OFMessage m = BasicFactory.getInstance().getMessage(OFType.HELLO);
        resetToStrict(sw);
        expect(sw.inputThrottled(anyObject(OFMessage.class)))
                .andReturn(false).anyTimes();
        sw.processDriverHandshakeMessage(m);
        expectLastCall().once();
        expect(sw.isDriverHandshakeComplete()).andReturn(false).once();
        replay(sw);

        sendMessageToHandlerWithControllerReset(Collections.singletonList(m));
        assertEquals(OFChannelHandler.ChannelState.WAIT_SWITCH_DRIVER_SUB_HANDSHAKE,
                     handler.getStateForTesting());
        assertFalse("Unexpected message captured", writeCapture.hasCaptured());
        verify(sw);

        //-------------------------------------------------
        // Send a ECHO_REQUEST. This should be handled by the OFChannelHandler
        // and *not* passed to switch sub-handshake
        // TODO: should this be also passed to the switch handshake instead?
        m = BasicFactory.getInstance().getMessage(OFType.ECHO_REQUEST);
        m.setXid(0x042042);

        reset(sw);
        expect(sw.inputThrottled(anyObject(OFMessage.class)))
                .andReturn(false).anyTimes();
        replay(sw);
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        verify(controller);
        reset(controller);
        controller.switchActivated(sw);
        expectLastCall().once();
        OFMessage reply = getRoleReply(xid, Role.MASTER);
        // sendMessageToHandler will verify and rest controller mock
        sendMessageToHandlerNoControllerReset(Collections.singletonList(reply));

        assertEquals(OFChannelHandler.ChannelState.MASTER,
                     handler.getStateForTesting());
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        verify(controller);
        reset(controller);
        controller.switchDeactivated(sw);
        expectLastCall().once();
        OFMessage reply = getRoleReply(xid, Role.SLAVE);
        // sendMessageToHandler will verify and rest controller mock
        sendMessageToHandlerNoControllerReset(Collections.singletonList(reply));

        assertEquals(OFChannelHandler.ChannelState.SLAVE,
                     handler.getStateForTesting());
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        replay(sw);

        // FIXME: shouldn't use ordinal(), but OFError is broken

        // Error with incorrect xid and type. Should be ignored.
        OFMessage err = getErrorMessage(OFErrorType.OFPET_BAD_ACTION,
                                        0,
                                        xid+1);
        // sendMessageToHandler will verify and rest controller mock
        sendMessageToHandlerWithControllerReset(Collections.singletonList(err));
        assertEquals(OFChannelHandler.ChannelState.WAIT_INITIAL_ROLE,
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        expectLastCall().once();
        sw.setHARole(Role.MASTER);
        expectLastCall().once();
        replay(sw);

        OFMessage m = BasicFactory.getInstance().getMessage(OFType.ECHO_REPLY);

        Thread.sleep(timeout+5);

        verify(controller);
        reset(controller);
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.