I'm trying to learn from the forwarding.l3_learning example in POX controller.
In the expiration handler, if the time of a packet in buffer is expired it's
removed from the controller.
Later the controller instructs the switch to drop the packet in these lines:
po = of.ofp_packet_out(buffer_id = buffer_id, in_port = in_port)
core.openflow.sendToDPID(dpid, po)
I don't see such specific instruction in the created message to switch. I don't understand how the switch knows it should drop the packet.
This is a
PACKET_OUT
message with no actions. As there are no actions, the switch just drops the packet. If you want the switch to apply the matching again (like when the packet came in from the network), you'd need to explicitly set the action tooutput:OFPP_TABLE
.This is not really clearly stated in the OpenFlow specification, but all switch implementations work this way (e.g. see here).
The reason this sending of an
PACKET_OUT
with no actions is done at all is because switches keep packets stored in their buffer (at the slot specified by thebuffer_id
) until the controller tells the switch what to do with it. Over time, these buffers will fill up if the controller never does anything with the packets, so by explicitly sending them out with no actions the buffers are freed.If all buffers are full in a switch, the packets (instead of just the
buffer_id
) are sent inside thePACKET_IN
message to the controller, which decreases performance.