如何在以下拓扑中使控制器检测链路断开或主机关闭

时间:2017-03-30 15:01:55

标签: networking sdn mininet pox

我正在尝试检测流向主机(服务器)的流量是否已关闭。以便将其重定向到正在运行的服务器。我计划在click(nfv)中实现重定向部分 我使用以下命令./pox.py openflow.discovery forwarding.l2_learning运行控制器。 如何让控制器检测主机关闭/链接。Topology i am implimenting

1 个答案:

答案 0 :(得分:0)

我可以使用以下代码检测主机

from pox.core import core
import pox
import pox.lib.packet as pkt
from pox.lib.revent import *
from pox.openflow.discovery import Discovery
from pox.host_tracker import host_tracker
import pox.openflow.libopenflow_01 as of

class kj_host(EventMixin):
  def __init__ (self):
    def startup ():
      core.openflow.addListeners(self, priority=0)
      core.openflow_discovery.addListeners(self)
      core.host_tracker.addListeners(self)
      """ Here is the place where is created the listener"""
    core.call_when_ready(startup, ('openflow','openflow_discovery', 'host_tracker'))


  def _handle_HostEvent (self, event):
    """ Here is the place where is used the listener"""
    print "Host, switchport and switch...", event.entry

  def _handle_PacketIn(self, event):
    """ Packet processing """
def launch():
  from host_tracker import launch
  launch()
  core.registerNew(kj_host)

我将此代码保存在kj_host.py中并放在/home/pox/pox/misc内,然后使用以下命令./pox.py openflow.discovery forwarding.l2_learning misc.kj_host运行控制器 参考: 1)answer from github 2)stackoverflow answer