问题
My question might be a little vague as I clearly misunderstand a lot, but I'll give it a try anyway: Suppose I have 7 switches in a Fat Tree topology, and the bottom four are each connected to two hosts. When I start the controller I instructs the switches to send LLDP packets and this is how I learn the topology. Also I calculate a Spanning Tree to use when I flood packets like ARP requests.
My problem: how do I learn which switch a certain host is connected to? If h1
sends a layer 3 packet to h3
, I know how to route the packets because I have a spanning tree, but this might not be the shortests route. I use Dijkstra to compute shortest routes from each switch to all others, but if I want to send a message to h3
, I don't know what switch is directly connected to it.
Any ideas?
回答1:
The component responsible for do it is the Host_tracker. You need listen the Host_tracker event in your code, just like this:
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 YourController(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(YourController)
来源:https://stackoverflow.com/questions/26066259/pox-mininet-learning-location-of-hosts