Package net.floodlightcontroller.core

Examples of net.floodlightcontroller.core.FloodlightContext


    @Test
    public void testDhcp() {
        IOFMessageListener listener = getVirtualNetworkListener();
        Ethernet dhcpPacket = PacketFactory.DhcpDiscoveryRequestEthernet(mac1);
        OFPacketIn dhcpPacketOf = PacketFactory.DhcpDiscoveryRequestOFPacketIn(mac1);
        cntx = new FloodlightContext();
        IFloodlightProviderService.bcStore.put(cntx,
                           IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                           dhcpPacket);
        Command ret = listener.receive(sw1, dhcpPacketOf, cntx);
        assertTrue(ret == Command.CONTINUE);
View Full Code Here


    @Override
    @Before
    public void setUp() throws Exception {
        super.setUp();
        cntx = new FloodlightContext();
        mockFloodlightProvider = getMockFloodlightProvider();
        firewall = new Firewall();
        IStorageSourceService storageService = new MemoryStorageSource();
        RestApiServer restApi = new RestApiServer();
View Full Code Here

    @Override
    public void setUp() throws Exception {
        super.setUp();

        cntx = new FloodlightContext();

        // Module loader setup
        /*
        Collection<Class<? extends IFloodlightModule>> mods = new ArrayList<Class<? extends IFloodlightModule>>();
        Collection<IFloodlightService> mockedServices = new ArrayList<IFloodlightService>();
View Full Code Here

        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);

        // Verify the device
        rdevice = (Device)
                deviceManager.findDevice(Ethernet.toLong(deviceMac),
                        (short)5, null, null, null);
        verifyDevice(rdevice, Ethernet.toLong(deviceMac),
                     (short)5, ipaddr, 5L, 2);
        cntxSrcDev = IDeviceService.fcStore.get(cntx,
                IDeviceService.CONTEXT_SRC_DEVICE);
        assertEquals(rdevice, cntxSrcDev);
        cntxDstDev = IDeviceService.fcStore.get(cntx,
                IDeviceService.CONTEXT_DST_DEVICE);
        assertNull(cntxDstDev);
        // There can be only one device
        assertEquals(1, deviceManager.getAllDevices().size());

        //----------------------------
        // Test packetIn with a different packet going the reverse direction.
        // We should now get source and dest device in the context
        //==> The destination device in this step has been learned just before
        long srcMac = Ethernet.toLong(testUDPPacket.getSourceMACAddress());
        long dstMac = Ethernet.toLong(deviceMac);
        reset(mockTopology);
        mockTopologyForPacketInTests(mockTopology);
        replay(mockTopology);
        // trigger the packet in
        cntx = new FloodlightContext();
        cmd = dispatchPacketIn(1L, testUDPPacketIn, cntx);
        verify(mockTopology);

        assertEquals(Command.CONTINUE, cmd);
        IDevice srcDev =
View Full Code Here

        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 for the sender HW address
        Device senderDev = (Device)
View Full Code Here

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

        testUDPPacket.setSourceMACAddress(Ethernet.toByteArray(0L));
        updateUDPPacketIn();
        Command cmd = dispatchPacketIn(1L, testUDPPacketIn, cntx);
        assertEquals(Command.STOP, cmd);
View Full Code Here

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

        long srcMac = Ethernet.toLong(testUDPPacket.getSourceMACAddress());
        long dstMac = Ethernet.toLong(testUDPPacket.getDestinationMACAddress());

        // Prime device manager with the source device
        Command cmd = dispatchPacketIn(1L, testUDPPacketIn, cntx);
        assertEquals(Command.CONTINUE, cmd);
        IDevice cntxSrcDev = IDeviceService.fcStore.get(cntx,
                IDeviceService.CONTEXT_SRC_DEVICE);
        verifyDevice(cntxSrcDev, srcMac, (short)5, null,
                     1L, testUDPPacketIn.getInPort());
        IDevice cntxDstDev = IDeviceService.fcStore.get(cntx,
                IDeviceService.CONTEXT_DST_DEVICE);
        assertNull(cntxDstDev);
        IDevice expectedSrcDev = cntxSrcDev;

        // Create a device for the destination. We can use testARPPacketIn_1
        // for that.
        cntx = new FloodlightContext();
        // Prime device manager with the source device
        cmd = dispatchPacketIn(1L, testARPReplyPacketIn_1, cntx);
        assertEquals(Command.CONTINUE, cmd);
        cntxSrcDev = IDeviceService.fcStore.get(cntx,
                IDeviceService.CONTEXT_SRC_DEVICE);
        // yes: we check that cntxSrcDev matched dstMAC because we are
        // just adding the dest device
        int ip = IPv4.toIPv4Address("192.168.1.1");
        verifyDevice(cntxSrcDev, dstMac, (short)5, ip,
                     1L, testARPReplyPacketIn_1.getInPort());
        // yes: we set the expected dst device to the current srcDev
        IDevice expectedDstDev = cntxSrcDev;

        //-------------------------------
        // Let the real tests begin

        cntx = new FloodlightContext();
        testUDPPacket.setDestinationMACAddress(Ethernet.toByteArray(0L));
        updateUDPPacketIn();
        cmd = dispatchPacketIn(1L, testUDPPacketIn, cntx);
        assertEquals(Command.STOP, cmd);
        cntxDstDev = IDeviceService.fcStore.get(cntx,
                IDeviceService.CONTEXT_DST_DEVICE);
        assertNull(cntxDstDev);

        // use a real dest mac
        cntx = new FloodlightContext();
        testUDPPacket.setDestinationMACAddress(Ethernet.toByteArray(dstMac));
        updateUDPPacketIn();
        cmd = dispatchPacketIn(1L, testUDPPacketIn, cntx);
        assertEquals(Command.CONTINUE, cmd);
        cntxSrcDev = IDeviceService.fcStore.get(cntx,
View Full Code Here

    public void removeOFSwitchListener(IOFSwitchListener listener) {
        switchListeners.remove(listener);
    }

    public void dispatchMessage(IOFSwitch sw, OFMessage msg) {
        dispatchMessage(sw, msg, new FloodlightContext());
    }
View Full Code Here

        lds = createMock(ILinkDiscoveryService.class);
        entityClassifier = new DefaultEntityClassifier();
        tps = new MockThreadPoolService();
        flowReconcileMgr = new FlowReconcileManager();
        topology = createMock(ITopologyService.class);
        cntx = new FloodlightContext();
        statsReply = new ArrayList<OFStatistics>();

        fmc.addService(IThreadPoolService.class, tps);
        fmc.addService(IFloodlightProviderService.class,
                       getMockFloodlightProvider());
View Full Code Here

   
   
    @Before
    public void setUp() throws IOException {
        factory = BasicFactory.getInstance();
        cntx = new FloodlightContext();
       
        sw1 = new OFMessageDamperMockSwitch();
        sw2 = new OFMessageDamperMockSwitch();
       
        echoRequst1 = (OFEchoRequest)factory.getMessage(OFType.ECHO_REQUEST);
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.core.FloodlightContext

Copyright © 2018 www.massapicom. 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.