Package net.floodlightcontroller.packet

Examples of net.floodlightcontroller.packet.IPacket


            processPacketIn(IOFSwitch sw, OFPacketIn pi,
                            FloodlightContext cntx) {
       
        Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
                                                              IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
        IPacket pkt = eth.getPayload();
        if (eth.isBroadcast() || eth.isMulticast()) {
            // handle ARP for VIP
            if (pkt instanceof ARP) {
                // retrieve arp to determine target IP address                                                      
View Full Code Here


       
        // have to do proxy arp reply since at this point we cannot determine the requesting application type
        byte[] vipProxyMacBytes = vips.get(vipId).proxyMac.toBytes();
       
        // generate proxy ARP reply
        IPacket arpReply = new Ethernet()
            .setSourceMACAddress(vipProxyMacBytes)
            .setDestinationMACAddress(eth.getSourceMACAddress())
            .setEtherType(Ethernet.TYPE_ARP)
            .setVlanID(eth.getVlanID())
            .setPriorityCode(eth.getPriorityCode())
View Full Code Here

     *            method to derive wildcards for the decision to be taken
     * @return true if the rule matches the given packet-in, false otherwise
     */
    public boolean matchesFlow(long switchDpid, short inPort, Ethernet packet,
            WildcardsPair wildcards) {
        IPacket pkt = packet.getPayload();

        // dl_type type
        IPv4 pkt_ip = null;

        // nw_proto types
View Full Code Here

     * Checks to see if an Ethernet frame is a DHCP packet.
     * @param frame The Ethernet frame.
     * @return True if it is a DHCP frame, false otherwise.
     */
    protected boolean isDhcpPacket(Ethernet frame) {
        IPacket payload = frame.getPayload(); // IP
        if (payload == null) return false;
        IPacket p2 = payload.getPayload(); // TCP or UDP
        if (p2 == null) return false;
        IPacket p3 = p2.getPayload(); // Application
        if ((p3 != null) && (p3 instanceof DHCP)) return true;
        return false;
    }
View Full Code Here

        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(
                new IPv4()
                .setTtl((byte) 128)
                .setSourceAddress(srcIp)
                .setDestinationAddress(dstIp)
                .setPayload(new UDP()
                .setSourcePort((short) 5000)
                .setDestinationPort((short) 5001)
                .setPayload(new Data(new byte[] {0x01}))));
        byte[] testPacketSerialized = testPacket.serialize();
        OFPacketIn pi;
        // build out input packet
        pi = ((OFPacketIn) BasicFactory.getInstance().getMessage(OFType.PACKET_IN))
                .setBufferId(-1)
                .setInPort((short) 1)
View Full Code Here

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

     /* Test plan:
      * - two clients and two servers on sw1 port 1, 2, 3, 4
      * - mock arp request received towards vip1 from (1L, 1)
      * - proxy arp got pushed out to (1L, 1)- check sw1 getting the packetout
      * - mock icmp request received towards vip1 from (1L, 1)
      * - device manager list of devices queried to identify source and dest devices
      * - routing engine queried to get inbound and outbound routes
      * - check getRoute calls and responses
      * - sfp called to install flows
      * - check sfp calls
      */

     // Build topology
     reset(topology);
     expect(topology.isIncomingBroadcastAllowed(anyLong(), anyShort())).andReturn(true).anyTimes();
     expect(topology.getL2DomainId(1L)).andReturn(1L).anyTimes();
     expect(topology.isAttachmentPointPort(1L, (short)1)).andReturn(true).anyTimes();
     expect(topology.isAttachmentPointPort(1L, (short)2)).andReturn(true).anyTimes();
     expect(topology.isAttachmentPointPort(1L, (short)3)).andReturn(true).anyTimes();
     expect(topology.isAttachmentPointPort(1L, (short)4)).andReturn(true).anyTimes();
     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)
View Full Code Here

        // Creating mock switch to which we will send packet out and
        IOFSwitch sw = createMock(IOFSwitch.class);
        expect(sw.getId()).andReturn(new Long(0));

        // Mock Packet-in
        IPacket testPacket = new Ethernet()
        .setSourceMACAddress("00:44:33:22:11:00")
        .setDestinationMACAddress("00:11:22:33:44:55")
        .setEtherType(Ethernet.TYPE_ARP)
        .setPayload(
                new ARP()
                .setHardwareType(ARP.HW_TYPE_ETHERNET)
                .setProtocolType(ARP.PROTO_TYPE_IP)
                .setHardwareAddressLength((byte) 6)
                .setProtocolAddressLength((byte) 4)
                .setOpCode(ARP.OP_REPLY)
                .setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:00"))
                .setSenderProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.1"))
                .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)
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.packet.IPacket

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.