2

I am using RYU controller with flowvisor. As flowvisor do not support any other version other than openflow v1. I am using openflow v1 in my project.

I have topology of 3 ovs switches and controller sits in one of server conataining ovs bridge. Other two ovs bridge in other servers connects to controller through public interface. But when run my ryu application, it connects to switches but not able to add rules with nw_src match . I am getting this error here:

hub: uncaught exception: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/hub.py", line 52, in _launch
    func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py", line 276, in _event_loop
    handler(ev)
  File "/home/vishlesh/ryu-scripts/sample.py", line 79, in switch_features_handler
    self.add_flow(datapath, 10, match, action)
  File "/home/vishlesh/ryu-scripts/sample.py", line 137, in add_flow
    datapath.send_msg(mod)
  File "/usr/local/lib/python2.7/dist-packages/ryu/controller/controller.py", line 235, in send_msg
    msg.serialize()
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_parser.py", line 212, in serialize
    self._serialize_body()
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_0_parser.py", line 2135, in _serialize_body
    self.match.serialize(self.buf, offset)
  File "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_0_parser.py", line 213, in serialize
    self.nw_src, self.nw_dst, self.tp_src, self.tp_dst)
  File "/usr/local/lib/python2.7/dist-packages/ryu/lib/pack_utils.py", line 25, in msg_pack_into
    buf += struct.pack(fmt, *args)
error: cannot convert argument to integer

My code is here:

class SimpleSwitch(app_manager.RyuApp):
    OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
    """
        Constructor:
        You can define some globally used variables inside the class
    """
    def __init__(self, *args, **kwargs):
        super(SimpleSwitch, self).__init__(*args, **kwargs)
        # arp table: for searching
        self.arp_table ={"10.0.0.3":"53:54:00:69:ae:2b",
                         "10.1.0.3":"52:54:00:cb:51:8b"}
        self.TCP_proto = 6
        self.UDP_proto = 17
        self.ICMP_proto = 1

 @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
    def switch_features_handler(self, ev):
        datapath = ev.msg.datapath
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser

        # Insert Static rule
        match1 = parser.OFPMatch()
        action1 = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER)]
        self.add_flow(datapath, 0, match1, action1)


        match2 = parser.OFPMatch(dl_type = ether.ETH_TYPE_ARP)
        action2 = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER)]
        self.add_flow(datapath, 40, match2, action2)
        print "added rule#1"

        # Installing static rules to process TCP/UDP and ICMP and ACL
        dpid = datapath.id  # classifying the switch ID
        print("switch ",dpid," detected")
        if dpid == 2: # switch ovs of host 1
            match = parser.OFPMatch(dl_type=ether.ETH_TYPE_IP,
                 nw_proto=self.TCP_proto,
                 nw_src = '10.0.0.3' , nw_dst = '10.1.0.3' )
            action = [parser.OFPActionOutput(2)]
            self.add_flow(datapath, 10, match, action)

Please help.

explorer
  • 737
  • 1
  • 8
  • 23

0 Answers0