问题描述
我想将 TTL 无效的数据包转发到控制器。有没有办法为此设置流模式?
解决方法
答案是肯定的,你可以做到。 根据{{3}},你可以在你的sdn应用的packet_in_handler函数中得到TTL无效的数据包:
@set_ev_cls(ofp_event.EventOFPPacketIn,MAIN_DISPATCHER)
def packet_in_handler(self,ev):
msg = ev.msg
dp = msg.datapath
ofp = dp.ofproto
if msg.reason == ofp.OFPR_NO_MATCH:
reason = 'NO MATCH'
elif msg.reason == ofp.OFPR_ACTION:
reason = 'ACTION'
elif msg.reason == ofp.OFPR_INVALID_TTL:
reason = 'INVALID TTL'
else:
reason = 'unknown'
self.logger.debug('OFPPacketIn received: '
'buffer_id=%x total_len=%d reason=%s '
'table_id=%d cookie=%d match=%s data=%s',msg.buffer_id,msg.total_len,reason,msg.table_id,msg.cookie,msg.match,utils.hex_array(msg.data))
有关 OpenFlow 的更多信息,请阅读 Packet_in 消息this Ryu controller doc page。