Package net.floodlightcontroller.core

Examples of net.floodlightcontroller.core.IOFSwitch


        restApi.startUp(cntx);
        tp.startUp(cntx);
        routingEngine.startUp(cntx);
        ldm.startUp(cntx);

        IOFSwitch sw1 = createMockSwitch(1L);
        IOFSwitch sw2 = createMockSwitch(2L);
        Map<Long, IOFSwitch> switches = new HashMap<Long, IOFSwitch>();
        switches.put(1L, sw1);
        switches.put(2L, sw2);
        getMockFloodlightProvider().setSwitches(switches);
        replay(sw1, sw2);
View Full Code Here


        NodePortTuple dstNpt = new NodePortTuple(2L, 1);
        LinkInfo info = new LinkInfo(System.currentTimeMillis(),
                                     System.currentTimeMillis(), null);
        linkDiscovery.addOrUpdateLink(lt, info);

        IOFSwitch sw1 = getMockFloodlightProvider().getSwitch(1L);
        IOFSwitch sw2 = getMockFloodlightProvider().getSwitch(2L);
        // Mock up our expected behavior
        linkDiscovery.switchRemoved(sw1.getId());
        verify(sw1, sw2);

        // check invariants hold
View Full Code Here

    }

    @Test
    public void testRemovedSwitchSelf() {
        LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
        IOFSwitch sw1 = createMockSwitch(1L);
        replay(sw1);
        Link lt = new Link(1L, 2, 1L, 3);
        LinkInfo info = new LinkInfo(System.currentTimeMillis(),
                                     System.currentTimeMillis(), null);
        linkDiscovery.addOrUpdateLink(lt, info);

        // Mock up our expected behavior
        linkDiscovery.switchRemoved(sw1.getId());

        verify(sw1);
        // check invariants hold
        assertNull(linkDiscovery.switchLinks.get(lt.getSrc()));
        assertNull(linkDiscovery.portLinks.get(lt.getSrc()));
View Full Code Here

    }

    @Test
    public void testHARoleChange() throws Exception {
        LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
        IOFSwitch sw1 = createMockSwitch(1L);
        IOFSwitch sw2 = createMockSwitch(2L);
        replay(sw1, sw2);
        Link lt = new Link(1L, 2, 2L, 1);
        NodePortTuple srcNpt = new NodePortTuple(1L, 2);
        NodePortTuple dstNpt = new NodePortTuple(2L, 1);
        LinkInfo info = new LinkInfo(System.currentTimeMillis(),
View Full Code Here

        ofpp.setName("eth4242");
        ofpp.setPortNumber((short)4242);
        ofpp.setHardwareAddress(HexString.fromHexString("5c:16:c7:00:00:01"));
        ofpp.setCurrentFeatures(0);
        ImmutablePort p1 = ImmutablePort.fromOFPhysicalPort(ofpp);
        IOFSwitch sw1 = createMockSwitch(1L);

        // Set switch map in floodlightProvider.
        Map<Long, IOFSwitch> switches = new HashMap<Long, IOFSwitch>();
        switches.put(1L, sw1);
        getMockFloodlightProvider().setSwitches(switches);

        // Create the set of ports
        List<Short> ports = new ArrayList<Short>();
        for(short p=1; p<=20; ++p) {
            ports.add(p);
        }

        // Set the captures.
        wc = new Capture<OFMessage>(CaptureType.ALL);
        fc = new Capture<FloodlightContext>(CaptureType.ALL);

        // Expect switch to return those ports.
        expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes();
        expect(sw1.getPort(EasyMock.anyShort())).andReturn(p1).anyTimes();
        sw1.write(capture(wc), capture(fc));
        expectLastCall().anyTimes();
        replay(sw1);

        linkDiscovery.switchActivated(sw1.getId());
        verify(sw1);

        qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
        assertNotNull(qPorts);
        assertFalse(qPorts.isEmpty());

        Thread.sleep(100);
        qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
        assertNotNull(qPorts);
        assertFalse(qPorts.isEmpty());

        Thread.sleep(200);
        qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
        assertNotNull(qPorts);
        assertTrue(qPorts.isEmpty());

        // Ensure that through every switch port, an LLDP and BDDP
        // packet was sent out.  Total # of packets = # of ports * 2.
 
View Full Code Here

        String mac3 = "00:44:33:22:11:02";
        String srcIp = "192.168.1.1";
        String dstIp = "192.168.1.2";
        short vlan = 42;

        IOFSwitch mockSwitch = createMock(IOFSwitch.class);
        expect(mockSwitch.getId()).andReturn(1L).anyTimes();
        replay(mockSwitch);

        /* TEST1: See basic packet flow */
        OFPacketIn pi;
        pi = createPacketIn(mac1, mac2, srcIp, dstIp, vlan);
View Full Code Here

    * @throws Exception
    */
   @Test
   public void testOFStatisticsFuture() throws Exception {
       // Test for a single stats reply
       IOFSwitch sw = createMock(IOFSwitch.class);
       sw.cancelStatisticsReply(1);
       OFStatisticsFuture sf = new OFStatisticsFuture(tp, sw, 1);

       replay(sw);
       List<OFStatistics> stats;
       FutureFetcher<List<OFStatistics>> ff = new FutureFetcher<List<OFStatistics>>(sf);
       Thread t = new Thread(ff);
       t.start();
       sf.deliverFuture(sw, getStatisticsReply(1, 10, false));

       t.join();
       stats = ff.getValue();
       verify(sw);
       assertEquals(10, stats.size());

       // Test multiple stats replies
       reset(sw);
       sw.cancelStatisticsReply(1);

       sf = new OFStatisticsFuture(tp, sw, 1);

       replay(sw);
       ff = new FutureFetcher<List<OFStatistics>>(sf);
       t = new Thread(ff);
       t.start();
       sf.deliverFuture(sw, getStatisticsReply(1, 10, true));
       sf.deliverFuture(sw, getStatisticsReply(1, 5, false));
       t.join();

       stats = sf.get();
       verify(sw);
       assertEquals(15, stats.size());

       // Test cancellation
       reset(sw);
       sw.cancelStatisticsReply(1);
       sf = new OFStatisticsFuture(tp, sw, 1);

       replay(sw);
       ff = new FutureFetcher<List<OFStatistics>>(sf);
       t = new Thread(ff);
       t.start();
       sf.cancel(true);
       t.join();

       stats = sf.get();
       verify(sw);
       assertEquals(0, stats.size());

       // Test self timeout
       reset(sw);
       sw.cancelStatisticsReply(1);
       sf = new OFStatisticsFuture(tp, sw, 1, 75, TimeUnit.MILLISECONDS);

       replay(sw);
       ff = new FutureFetcher<List<OFStatistics>>(sf);
       t = new Thread(ff);
View Full Code Here

    public void testTwoSubsequentIcmpRequests() throws Exception {
     testCreateVip();
     testCreatePool();
     testCreateMember();

     IOFSwitch sw1;

     IPacket arpRequest1, arpReply1, icmpPacket1, icmpPacket2;

     byte[] arpRequest1Serialized;
     byte[] arpReply1Serialized;
     byte[] icmpPacket1Serialized, icmpPacket2Serialized;

     OFPacketIn arpRequestPacketIn1;
     OFPacketIn icmpPacketIn1, icmpPacketIn2;

     OFPacketOut arpReplyPacketOut1;

     Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
     Capture<FloodlightContext> bc1 =
             new Capture<FloodlightContext>(CaptureType.ALL);

     int fastWildcards =
             OFMatch.OFPFW_IN_PORT |
             OFMatch.OFPFW_NW_PROTO |
             OFMatch.OFPFW_TP_SRC |
             OFMatch.OFPFW_TP_DST |
             OFMatch.OFPFW_NW_SRC_ALL |
             OFMatch.OFPFW_NW_DST_ALL |
             OFMatch.OFPFW_NW_TOS;

     sw1 = EasyMock.createNiceMock(IOFSwitch.class);
     expect(sw1.getId()).andReturn(1L).anyTimes();
     expect(sw1.getStringId()).andReturn("00:00:00:00:00:01").anyTimes();
     expect(sw1.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).andReturn(fastWildcards).anyTimes();
     expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
     sw1.writeThrottled(capture(wc1), capture(bc1));
     expectLastCall().anyTimes();
     sw1.flush();
     expectLastCall().anyTimes();

     replay(sw1);
     sfp.switchAdded(1L);
     verify(sw1);
View Full Code Here

        expectLastCall().andReturn(false).anyTimes();
    }

    @Test
    public void testHandleMessagesNoListeners() throws Exception {
        IOFSwitch sw = createMock(IOFSwitch.class);
        expect(sw.getId()).andReturn(0L).anyTimes();
        expect(sw.getStringId()).andReturn("00:00:00:00:00:00:00").anyTimes();
        replay(sw);
        controller.handleMessage(sw, pi, null);
        verify(sw);
    }
View Full Code Here

     */
    @Test
    public void testHandleMessages() throws Exception {
        controller.removeOFMessageListeners(OFType.PACKET_IN);

        IOFSwitch sw = createMock(IOFSwitch.class);
        expect(sw.getId()).andReturn(0L).anyTimes();
        expect(sw.getStringId()).andReturn("00:00:00:00:00:00:00").anyTimes();

        // Setup listener orderings
        IOFMessageListener test1 = createMock(IOFMessageListener.class);
        expect(test1.getName()).andReturn("test1").anyTimes();
        setupListenerOrdering(test1);
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.core.IOFSwitch

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.