I'm trying to add a flow entry to a switch using POX controller, my code is:
fm = of.ofp_flow_mod()
fm.match.in_port = 1
fm.priority = 33001
fm.match.dl_type = 0x800
fm.match.nw_src = IPAddr("10.0.0.1")
fm.match.nw_dst = IPAddr("10.0.0.5")
fm.actions.append(of.ofp_action_output( port = 2 ) )
event.connection.send( fm )
However, when I ping from 10.0.0.1 to 10.0.0.5 there's no reply. What can be the problem ? (I've also added symmetric flow for the ICMP reply)
Thank you
(Note: I changed
10.0.0.5
to10.0.0.3
in the following examples, as I tested with a 1 switch, 3 hosts topology in mininet.)Your problem is that ARP requests are not getting through. You'll need to add two additional rules to let messages of dl_type=0x0806 through. So:
If you don't have any loops in your network, you can also just add a single rule that floods the packets on every port except the one it came from.
Some more information: When you send an ICMP echo request destined towards an IP address, the following happens:
If the initial query yields no response, the ICMP packet is not sent as the host does not know where to send it next. You can see this in the
tcpdump
example at the end of this answer.This is the output from mininet:
So what if we already "know" what the next hop is? In this case we can tell
ping
to send the ICMP IPv4 packet out a specific interface. It will not use ARP then. However, the receiver of the ping request will still try to use ARP to figure out how to send the response. The request will arrive, but the response will not.You can force the initial ping to be sent to a specific interface, without using an ARP request by running:
Then the initial ICMP packet will also go through even if you do not have ARP rules setup (as the
nw_src
andnw_dst
match). If you runtcpdump
on h3 (Runxterm h3
and in the new terminaltcpdump
), you can see that the ICMP message arrives in this case, but the return message does not.The long sequence of ARP requests at the end is the receiving host trying to figure out over which interface it should send the response back.