Examples of Ethernet


Examples of net.floodlightcontroller.packet.Ethernet

        switches.put(1L, sw1);
        switches.put(2L, sw2);
        mockFloodlightProvider.setSwitches(switches);

        // Build test packet
        testPacket = new Ethernet()
            .setDestinationMACAddress("00:11:22:33:44:55")
            .setSourceMACAddress("00:44:33:22:11:00")
            .setEtherType(Ethernet.TYPE_IPv4)
            .setPayload(
                new IPv4()
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

        learningSwitch = (LearningSwitch) fml.getModuleByName(LearningSwitch.class);
        mockFloodlightProvider =
                (MockFloodlightProvider) fml.getModuleByName(MockFloodlightProvider.class);

        // Build our test packet
        this.testPacket = new Ethernet()
            .setDestinationMACAddress("00:11:22:33:44:55")
            .setSourceMACAddress("00:44:33:22:11:00")
            .setVlanID((short) 42)
            .setEtherType(Ethernet.TYPE_IPv4)
            .setPayload(
                new IPv4()
                .setTtl((byte) 128)
                .setSourceAddress("192.168.1.1")
                .setDestinationAddress("192.168.1.2")
                .setPayload(new UDP()
                            .setSourcePort((short) 5000)
                            .setDestinationPort((short) 5001)
                            .setPayload(new Data(new byte[] {0x01}))));
        this.testPacketSerialized = testPacket.serialize();
        // Build a broadcast packet
        this.broadcastPacket = new Ethernet()
            .setDestinationMACAddress("FF:FF:FF:FF:FF:FF")
            .setSourceMACAddress("00:44:33:22:11:00")
            .setVlanID((short) 42)
            .setEtherType(Ethernet.TYPE_IPv4)
            .setPayload(
                new IPv4()
                .setTtl((byte) 128)
                .setSourceAddress("192.168.1.1")
                .setDestinationAddress("192.168.255.255")
                .setPayload(new UDP()
                        .setSourcePort((short) 5000)
                        .setDestinationPort((short) 5001)
                        .setPayload(new Data(new byte[] {0x01}))));

        this.broadcastPacketSerialized = broadcastPacket.serialize();
        this.testPacketReply = new Ethernet()
            .setDestinationMACAddress("00:44:33:22:11:00")
            .setSourceMACAddress("00:11:22:33:44:55")
            .setVlanID((short) 42)
            .setEtherType(Ethernet.TYPE_IPv4)
            .setPayload(
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

            lldp.getOptionalTLVList().add(reverseTLV);
        } else {
            lldp.getOptionalTLVList().add(forwardTLV);
        }

        Ethernet ethernet;
        if (isStandard) {
            ethernet = new Ethernet().setSourceMACAddress(ofpPort.getHardwareAddress())
                                     .setDestinationMACAddress(LLDP_STANDARD_DST_MAC_STRING)
                                     .setEtherType(Ethernet.TYPE_LLDP);
            ethernet.setPayload(lldp);
        } else {
            BSN bsn = new BSN(BSN.BSN_TYPE_BDDP);
            bsn.setPayload(lldp);

            ethernet = new Ethernet().setSourceMACAddress(ofpPort.getHardwareAddress())
                                     .setDestinationMACAddress(LLDP_BSN_DST_MAC_STRING)
                                     .setEtherType(Ethernet.TYPE_BSN);
            ethernet.setPayload(bsn);
        }

        // serialize and wrap in a packet out
        byte[] data = ethernet.serialize();
        OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory()
                                                         .getMessage(OFType.PACKET_OUT);
        po.setBufferId(OFPacketOut.BUFFER_ID_NONE);
        po.setInPort(OFPort.OFPP_NONE);
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

    //  Internal Methods - Packet-in Processing Related
    //***********************************

    protected Command handlePacketIn(long sw, OFPacketIn pi,
                                     FloodlightContext cntx) {
        Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
                           IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

        if (eth.getPayload() instanceof BSN) {
            BSN bsn = (BSN) eth.getPayload();
            if (bsn == null) return Command.STOP;
            if (bsn.getPayload() == null) return Command.STOP;
            // It could be a packet other than BSN LLDP, therefore
            // continue with the regular processing.
            if (bsn.getPayload() instanceof LLDP == false)
                return Command.CONTINUE;
            return handleLldp((LLDP) bsn.getPayload(), sw, pi.getInPort(), false, cntx);
        } else if (eth.getPayload() instanceof LLDP) {
            return handleLldp((LLDP) eth.getPayload(), sw, pi.getInPort(), true, cntx);
        } else if (eth.getEtherType() < 1500) {
            long destMac = eth.getDestinationMAC().toLong();
            if ((destMac & LINK_LOCAL_MASK) == LINK_LOCAL_VALUE) {
                ctrLinkLocalDrops.updateCounterNoFlush();
                if (log.isTraceEnabled()) {
                    log.trace("Ignoring packet addressed to 802.1D/Q "
                              + "reserved address.");
                }
                return Command.STOP;
            }
        }

        if (ignorePacketInFromSource(eth.getSourceMAC().toLong())) {
            ctrIgnoreSrcMacDrops.updateCounterNoFlush();
            return Command.STOP;
        }

        // If packet-in is from a quarantine port, stop processing.
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

        optionList.add(msgTypeOption);
        optionList.add(reqParamOption);
        optionList.add(clientIdOption);
        optionList.add(endOption);
       
        Ethernet requestPacket = new Ethernet();
        requestPacket.setSourceMACAddress(hostMac.toBytes())
        .setDestinationMACAddress(broadcastMac)
        .setEtherType(Ethernet.TYPE_IPv4)
        .setPayload(
                new IPv4()
                .setVersion((byte)4)
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

        assertTrue(msgList.size() == ports.size() * 2);
    }

    private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                      String srcIp, String dstIp, short vlan) {
        IPacket testPacket = new Ethernet()
        .setDestinationMACAddress(dstMAC)
        .setSourceMACAddress(srcMAC)
        .setVlanID(vlan)
        .setEtherType(Ethernet.TYPE_IPv4)
        .setPayload(
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

        /* TEST1: See basic packet flow */
        OFPacketIn pi;
        pi = createPacketIn(mac1, mac2, srcIp, dstIp, vlan);
        FloodlightContext cntx = new FloodlightContext();
        Ethernet eth = new Ethernet();
        eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length);
        IFloodlightProviderService.bcStore.put(cntx,
                IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                eth);
        Command ret;
        ret = ldm.receive(mockSwitch, pi, cntx);
        assertEquals(Command.CONTINUE, ret);

        /* TEST2: Add mac1 to the ignore MAC list and see that the packet is
         * dropped
         */
        ldm.addMACToIgnoreList(HexString.toLong(mac1), 0);
        ret = ldm.receive(mockSwitch, pi, cntx);
        assertEquals(Command.STOP, ret);
        /* Verify that if we send a packet with another MAC it still works */
        pi = createPacketIn(mac2, mac3, srcIp, dstIp, vlan);
        cntx = new FloodlightContext();
        eth = new Ethernet();
        eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length);
        IFloodlightProviderService.bcStore.put(cntx,
                IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                eth);
        ret = ldm.receive(mockSwitch, pi, cntx);
        assertEquals(Command.CONTINUE, ret);

        /* TEST3: Add a MAC range and see if that is ignored */
        ldm.addMACToIgnoreList(HexString.toLong(mac2), 8);
        ret = ldm.receive(mockSwitch, pi, cntx);
        assertEquals(Command.STOP, ret);
        /* Send a packet with source MAC as mac3 and see that that is ignored
         * as well.
         */
        pi = createPacketIn(mac3, mac1, srcIp, dstIp, vlan);
        cntx = new FloodlightContext();
        eth = new Ethernet();
        eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length);
        IFloodlightProviderService.bcStore.put(cntx,
                IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                eth);
        ret = ldm.receive(mockSwitch, pi, cntx);
        assertEquals(Command.STOP, ret);
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

     replay(topology);



     // Build arp packets
     arpRequest1 = new Ethernet()
     .setSourceMACAddress("00:00:00:00:00:01")
     .setDestinationMACAddress("ff:ff:ff:ff:ff:ff")
     .setEtherType(Ethernet.TYPE_ARP)
     .setVlanID((short) 0)
     .setPriorityCode((byte) 0)
     .setPayload(
         new ARP()
         .setHardwareType(ARP.HW_TYPE_ETHERNET)
         .setProtocolType(ARP.PROTO_TYPE_IP)
         .setHardwareAddressLength((byte) 6)
         .setProtocolAddressLength((byte) 4)
         .setOpCode(ARP.OP_REQUEST)
         .setSenderHardwareAddress(HexString.fromHexString("00:00:00:00:00:01"))
         .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.1"))
         .setTargetHardwareAddress(HexString.fromHexString("00:00:00:00:00:00"))
         .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.100")));

     arpRequest1Serialized = arpRequest1.serialize();

     arpRequestPacketIn1 =
             ((OFPacketIn) getMockFloodlightProvider().getOFMessageFactory().
                     getMessage(OFType.PACKET_IN))
                     .setBufferId(-1)
                     .setInPort((short) 1)
                     .setPacketData(arpRequest1Serialized)
                     .setReason(OFPacketInReason.NO_MATCH)
                     .setTotalLength((short) arpRequest1Serialized.length);

     IFloodlightProviderService.bcStore.put(cntx,
                                            IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                                            (Ethernet) arpRequest1);

     // Mock proxy arp packet-out
     arpReply1 = new Ethernet()
     .setSourceMACAddress(LBVip.LB_PROXY_MAC)
     .setDestinationMACAddress(HexString.fromHexString("00:00:00:00:00:01"))
     .setEtherType(Ethernet.TYPE_ARP)
     .setVlanID((short) 0)
     .setPriorityCode((byte) 0)
     .setPayload(
         new ARP()
         .setHardwareType(ARP.HW_TYPE_ETHERNET)
         .setProtocolType(ARP.PROTO_TYPE_IP)
         .setHardwareAddressLength((byte) 6)
         .setProtocolAddressLength((byte) 4)
         .setOpCode(ARP.OP_REPLY)
         .setSenderHardwareAddress(HexString.fromHexString(LBVip.LB_PROXY_MAC))
         .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.100"))
         .setTargetHardwareAddress(HexString.fromHexString("00:00:00:00:00:01"))
         .setTargetProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.1")));

     arpReply1Serialized = arpReply1.serialize();

     arpReplyPacketOut1 =
             (OFPacketOut) getMockFloodlightProvider().getOFMessageFactory().
                 getMessage(OFType.PACKET_OUT);
     arpReplyPacketOut1.setBufferId(OFPacketOut.BUFFER_ID_NONE)
         .setInPort(OFPort.OFPP_NONE.getValue());
     List<OFAction> poactions = new ArrayList<OFAction>();
     poactions.add(new OFActionOutput(arpRequestPacketIn1.getInPort(), (short) 0xffff));
     arpReplyPacketOut1.setActions(poactions)
         .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
         .setPacketData(arpReply1Serialized)
         .setLengthU(OFPacketOut.MINIMUM_LENGTH+
                     arpReplyPacketOut1.getActionsLength()+
                     arpReply1Serialized.length);

     lb.receive(sw1, arpRequestPacketIn1, cntx);
     verify(sw1, topology);

     assertTrue(wc1.hasCaptured())// wc1 should get packetout

     List<OFMessage> msglist1 = wc1.getValues();

     for (OFMessage m: msglist1) {
         if (m instanceof OFPacketOut)
             assertEquals(arpReplyPacketOut1, m);
         else
             assertTrue(false); // unexpected message
     }

     //
     // Skip arpRequest2 test - in reality this will happen, but for unit test the same logic
     // is already validated with arpRequest1 test above
     //

     // Build icmp packets
     icmpPacket1 = new Ethernet()
     .setSourceMACAddress("00:00:00:00:00:01")
     .setDestinationMACAddress(LBVip.LB_PROXY_MAC)
     .setEtherType(Ethernet.TYPE_IPv4)
     .setVlanID((short) 0)
     .setPriorityCode((byte) 0)
     .setPayload(
         new IPv4()
         .setSourceAddress("10.0.0.1")
         .setDestinationAddress("10.0.0.100")
         .setProtocol(IPv4.PROTOCOL_ICMP)
         .setPayload(new ICMP()
         .setIcmpCode((byte) 0)
         .setIcmpType((byte) 0)));

     icmpPacket1Serialized = icmpPacket1.serialize();

     icmpPacketIn1 =
             ((OFPacketIn) getMockFloodlightProvider().getOFMessageFactory().
                     getMessage(OFType.PACKET_IN))
                     .setBufferId(-1)
                     .setInPort((short) 1)
                     .setPacketData(icmpPacket1Serialized)
                     .setReason(OFPacketInReason.NO_MATCH)
                     .setTotalLength((short) icmpPacket1Serialized.length);

     icmpPacket2 = new Ethernet()
     .setSourceMACAddress("00:00:00:00:00:02")
     .setDestinationMACAddress(LBVip.LB_PROXY_MAC)
     .setEtherType(Ethernet.TYPE_IPv4)
     .setVlanID((short) 0)
     .setPriorityCode((byte) 0)
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

        storeClient =
                syncService.getStoreClient(Controller.SWITCH_SYNC_STORE_NAME,
                                           Long.class,
                                           SwitchSyncRepresentation.class);

        testPacket = new Ethernet()
        .setSourceMACAddress("00:44:33:22:11:00")
        .setDestinationMACAddress("00:11:22:33:44:55")
        .setEtherType(Ethernet.TYPE_ARP)
        .setPayload(
                new ARP()
View Full Code Here

Examples of net.floodlightcontroller.packet.Ethernet

        controller.addOFMessageListener(OFType.PACKET_IN, test1);
        controller.addOFMessageListener(OFType.ERROR, test2);
        controller.handleMessage(sw, pi, cntx);
        verify(test1, test2, sw);

        Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
                IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
        assertArrayEquals(testPacket.serialize(), eth.serialize());
    }
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.