Examples of OFPacketIn


Examples of org.openflow.protocol.OFPacketIn

    @Test
    public void testMessageDispatchMaster() throws Exception {
        testInitialMoveToMasterWithRole();

        // Send packet in. expect dispatch
        OFPacketIn pi = (OFPacketIn)
                BasicFactory.getInstance().getMessage(OFType.PACKET_IN);
        reset(controller);
        controller.handleMessage(sw, pi, null);
        expectLastCall().once();
        sendMessageToHandlerNoControllerReset(
View Full Code Here

Examples of org.openflow.protocol.OFPacketIn

    @Test
    public void testPacketInBasic() throws Exception {
        byte[] deviceMac =
                ((Ethernet)this.testARPReplyPacket_1).getSourceMACAddress();
        OFPacketIn packetIn = testARPReplyPacketIn_1;
        Integer ipaddr = IPv4.toIPv4Address("192.168.1.1");

        // Mock up our expected behavior
        ITopologyService mockTopology = createMock(ITopologyService.class);
        deviceManager.topology = mockTopology;
        mockTopologyForPacketInTests(mockTopology);
        replay(mockTopology);

        FloodlightContext cntx = new FloodlightContext();
        Command cmd = dispatchPacketIn(1L, packetIn, cntx);
        verify(mockTopology);
        assertEquals(Command.CONTINUE, cmd);
        // Verify the device
        Device rdevice = (Device)
                deviceManager.findDevice(Ethernet.toLong(deviceMac),
                        (short)5, null, null, null);
        verifyDevice(rdevice, Ethernet.toLong(deviceMac),
                     (short)5, ipaddr, 1L, 1);
        IDevice cntxSrcDev = IDeviceService.fcStore.get(cntx,
                IDeviceService.CONTEXT_SRC_DEVICE);
        assertEquals(rdevice, cntxSrcDev);
        IDevice cntxDstDev = IDeviceService.fcStore.get(cntx,
                IDeviceService.CONTEXT_DST_DEVICE);
        assertNull(cntxDstDev);

        Device result = null;
        Iterator<? extends IDevice> dstiter =
                deviceManager.queryDevices(null, null, ipaddr,
                        null, null);
        if (dstiter.hasNext()) {
            result = (Device)dstiter.next();
        }
        assertFalse("There shouldn't be more than 1 device", dstiter.hasNext());
        assertEquals(rdevice, result);


        //-----------------
        // Test packetIn again with a different source port. Should be
        // the same device
        reset(mockTopology);
        mockTopologyForPacketInTests(mockTopology);
        replay(mockTopology);

        // trigger the packet in
        cntx = new FloodlightContext();
        packetIn.setInPort((short)2);
        cmd = dispatchPacketIn(5L, packetIn, cntx);
        verify(mockTopology);
        // Verify the replay matched our expectations
        assertEquals(Command.CONTINUE, cmd);
View Full Code Here

Examples of org.openflow.protocol.OFPacketIn

        long senderMac = Ethernet.toLong(arp.getSenderHardwareAddress());
        long sourceMac =
                Ethernet.toLong(((Ethernet)this.testARPReplyPacket_2)
                                .getSourceMACAddress());
        Integer ipaddr = IPv4.toIPv4Address("192.168.1.1");
        OFPacketIn packetIn = testARPReplyPacketIn_2;

        // Mock up our expected behavior
        ITopologyService mockTopology = createMock(ITopologyService.class);
        deviceManager.topology = mockTopology;
        mockTopologyForPacketInTests(mockTopology);
View Full Code Here

Examples of org.openflow.protocol.OFPacketIn

                .setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
                .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
        byte[] testPacketSerialized = testPacket.serialize();

        // Build the PacketIn
        OFPacketIn pi = ((OFPacketIn) BasicFactory.getInstance().getMessage(OFType.PACKET_IN))
                .setBufferId(-1)
                .setInPort((short) 1)
                .setPacketData(testPacketSerialized)
                .setReason(OFPacketInReason.NO_MATCH)
                .setTotalLength((short) testPacketSerialized.length);

        // Mock Packet-out
        OFPacketOut packetOut =
                (OFPacketOut) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT);
        packetOut.setBufferId(pi.getBufferId())
        .setInPort(pi.getInPort());
        List<OFAction> poactions = new ArrayList<OFAction>();
        poactions.add(new OFActionOutput(OFPort.OFPP_TABLE.getValue(), (short) 0));
        packetOut.setActions(poactions)
        .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
        .setPacketData(testPacketSerialized)
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.