我正在使用RYU控制器和flowvisor。由于flowvisor不支持openflow v1以外的任何其他版本。我在我的项目中使用openflow v1。
我有3个ovs开关的拓扑结构,控制器位于服务器中,其中一个是ovs桥。其他服务器中的其他两个ov桥通过公共接口连接到控制器。但是当运行我的ryu应用程序时,它连接到交换机但不能用nw_src匹配添加规则。我在这里得到这个错误:
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
我的代码在这里:
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)
请帮忙。