块流/丢包ryu控制器

时间:2017-07-10 07:12:49

标签: python ddos sdn openflow ryu

我试图实现一种阻止特定流量并因此丢弃数据包的方法。我将数据路径,源IP和目标IP传递给它。应用程序检测到流,但流继续工作,源发送数据,dest主机接收数据。我做错了什么?

def drop_flow(self, datapath, ip_src, ip_dst):
    ofproto = datapath.ofproto
    parser = datapath.ofproto_parser

    match = parser.OFPMatch(ipv4_src=ip_src, 
                            ipv4_dst=ip_dst) 

    inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, [])]
    mod = parser.OFPFlowMod(datapath=datapath,
                            command=ofproto.OFPFC_DELETE,
                            out_port=ofproto.OFPP_ANY,
                            out_group=ofproto.OFPG_ANY,
                            match=match, instructions=inst)  

    print "deleting flow entries in the table "
    datapath.send_msg(mod)

谢谢!

1 个答案:

答案 0 :(得分:0)

也许你应该这样做:

mod = parser.OFPFlowMod(datapath=datapath,
                        out_port=ofproto.OFPP_ANY,
                        out_group=ofproto.OFPG_ANY,
                        match=match, instructions=inst)  

您提供的命令是删除流程,并且您想将其添加到交换机,不是吗?

希望它有所帮助!