sdnopenflowryu

OpenFlow 13, RYU SDN controller, what exactly is a buffer_id?


I've been struggling with the RYU SDN controller working on OpenFlow13 for quite a while now. And I don't understand what we need a buffer_id for.

I am trying to write a proxy application, so when I receive 192.168.2.2 as a ipv4.dst I modify it to 172.10.2.2.

I do this using the command

actions = [parser.OFPActionSetField(eth_dst=pkt_ethernet.dst),parser.OFPActionSetField(ipv4_dst=pkt_ipv4.dst),parser.OFPActionOutput(2)]

out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
                              in_port=in_port, actions=actions, data=data)
    datapath.send_msg(out)

pkt_ipv4.dst has the new IP.

I get a bad request, OFPBRC_BUFFER_EMPTY(7)

I am trying to send the packet out without adding flows to the controller for now. But I plan to add flows later.


Solution

  • "In most cases, switches and routers are configured for "best-effort" packet forwarding."

    https://fasterdata.es.net/network-tuning/router-switch-buffer-size-issues/

    If the switch can't forward on the packet immediately then it needs to be queued and stored in a buffer to prevent it being dropped.

    The buffer_id is simply to uniquely identify and track the packet if it is in a buffer. If it isn't in a buffer then buffer ID is not specified, and is set to OFP_NO_BUFFER

    You are trying to send an OFPacketOut that contains a buffer_id referencing an empty buffer. You need to only specify the buffer once for any incoming OFPacketIn, and otherwise set the buffer_id to OFPacketOut.BUFFER_ID_NONE.