Search code examples
pythonsdnryu

Add a flow entry to flow table using Ryu


I am generating a proto=150 traffic using scapy tool.I want to add a flow table entry so that a switch will always send this pkt to the controller.

I am generating IP traffic using scapy with proto 150:

S=IP(proto=150,dst='10.0.0.2',len=100)

I am editing simple_switch.py app in ryu controller.

I am trying to add entry at the start of this app with Table Miss flow entry but when I check flow table , I can only see Table miss flow entry but no other entry which I am trying to add here.

What I am doing:

// This is proto 150 which i want always to be sent to controller

match = parser.OFPMatch(ip_proto=150)
actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER)]
self.add_flow(datapath, 2, match, actions)

//This is Table miss flow entry

match = parser.OFPMatch()
actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,                                                 ofproto.OFPCML_NO_BUFFER)]
    self.add_flow(datapath, 0, match, actions)

I am getting no error, I feel something is wrong with the Match(ip_proto=150). Please help me how can I send proto 150 always to controller.

Thanks a lot.

I hope I am clear if not clear please let me know.


Solution

  • You need to add eth_type match in your flow . Matching Eth_type is a prerequisite to matching ip_proto in Openflow Spec . (Refer page 51 of Spec https://www.opennetworking.org/images/stories/downloads/sdn-resources/onf-specifications/openflow/openflow-spec-v1.3.1.pdf)