我试图在SDN上显示DOS攻击。我正在使用带有POX
控制器的Mininet
。我已使用python
修改控制器,以不在交换机中注册PING
流量的流规则。然而,即使我ping了一个不属于网络的未知主机,尽管ARP泛滥,控制器似乎仍然运行良好。我想这是因为ARP回复超时。如何增加ARP回复超时,以便控制器在声明找不到主机之前至少等待30秒。这是迄今为止我的控制器的代码
"""
A super simple OpenFlow learning switch that installs rules for
each pair of L2 addresses.
"""
# These next two imports are common POX convention
from pox.core import core
import pox.openflow.libopenflow_01 as of
# Even a simple usage of the logger is much nicer than print!
log = core.getLogger()
# This table maps (switch,MAC-addr) pairs to the port on 'switch' at
# which we last saw a packet *from* 'MAC-addr'.
# (In this case, we use a Connection object for the switch.)
table = {}
# To send out all ports, we can use either of the special ports
# OFPP_FLOOD or OFPP_ALL. We'd like to just use OFPP_FLOOD,
# but it's not clear if all switches support this, so we make
# it selectable.
all_ports = of.OFPP_FLOOD
# Handle messages the switch has sent us because it has no
# matching rule.
def _handle_PacketIn (event):
packet = event.parsed
# Learn the source
table[(event.connection,packet.src)] = event.port
dst_port = table.get((event.connection,packet.dst))
if dst_port is None:
# We don't know where the destination is yet. So, we'll just
# send the packet out all ports (except the one it came in on!)
# and hope the destination is out there somewhere. :)
msg = of.ofp_packet_out(data = event.ofp)
msg.actions.append(of.ofp_action_output(port = all_ports))
event.connection.send(msg)
log.debug("Flooding packets to all ports")
else:
# Since we know the switch ports for both the source and dest
# MACs, we can install rules for both directions.
icmp_found = packet.find('icmp')
msg = of.ofp_packet_out()
msg.data = event.ofp
msg.actions.append(of.ofp_action_output(port = dst_port))
event.connection.send(msg)
log.debug("Installing %s <-> %s" % (packet.src, packet.dst))
del table[(event.connection, packet.src)]
del table[(event.connection, packet.dst)]
# log.debug(table)
def launch (disable_flood = False):
global all_ports
if disable_flood:
all_ports = of.OFPP_ALL
core.openflow.addListenerByName("PacketIn", _handle_PacketIn)
log.info("Pair-Learning switch running.")
目前没有回答
相关问题 更多 >
编程相关推荐