首页 > 解决方案 > How to handle invalid TTL packets with flow mods? RYU OpenFlow 1.3

问题描述

I want to forward packets with invalid TTL to the controller. Is there any way to set a flow mod for that?

标签: routesttlopenflowtracerouteryu

解决方案


答案是肯定的,你可以做到。根据这个 Ryu 控制器文档页面,您可以在您的 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 消息请阅读OpenFlow 规范 1.3


推荐阅读