Match ICMP packet Floodlight

0

I am building an SDN using Floodlight and mininet. There will be 4 switches and 2 hosts in this setup.

The topology can be visualized as follows: enter image description here

When using ping from h1 to h4, the ping packet will first use the path h1 -> s1 -> s2 -> s4 -> h4. The second time using ping it will go through s3 instead of s2.

I have already setup some code to add the flow in the flow table. And it was successfully create the rules in the flow table of mininet

void addMyFlow(IOFSwitch sw, Ethernet eth, int port){
        if((port!=1)&&(port!=2)) return;

        OFFlowMod.Builder fmb;

        OFFactory myFactory=sw.getOFFactory();

        fmb=myFactory.buildFlowAdd();

        MacAddress srcMac = eth.getSourceMACAddress();
        MacAddress dstMac = eth.getDestinationMACAddress();

        Match myMatch = myFactory.buildMatch()
                .setExact(MatchField.IN_PORT, OFPort.of(port))
                .setExact(MatchField.IP_PROTO, IpProtocol.ICMP)
                .setExact(MatchField.ICMPV4_TYPE, ICMPv4Type.ECHO)
                .build();


        ArrayList<OFAction> actionList = new ArrayList<OFAction>();
        OFActions actions = myFactory.actions();


        OFActionOutput output = actions.buildOutput()
            .setMaxLen(0xFFffFFff)
            .setPort(OFPort.of(3-port))
            .build();
        actionList.add(output);

        fmb
        .setIdleTimeout(5)
        //.setHardTimeout(5)
        .setBufferId(OFBufferId.NO_BUFFER)
        .setCookie(cookie)
        .setPriority(2)
        .setMatch(myMatch);

        FlowModUtils.setActions(fmb, actionList, sw);



        try {
            messageDamper.write(sw, fmb.build());
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }

However, the problem is that, I only want to set up this rules for ping request (ICMP message). Hence, in the code above, in the match, I add the two conditions of IP_Proto == ICMPV4 and ICMPV4_Type == Echo. Unfortunately, it seems like it doesn't work. I know this because the Floodlight auto generate some manager packet (ARP,...) and it also add the rules to the flow table.

My question is how can I apply the matching rule to only the ICMP message?

java
mininet
google-floodlight

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0