2014-09-26 26 views
1

我的問題可能有點模糊,因爲我明顯誤解了很多,但我仍會嘗試: 假設我在Fat Tree topology中有7個開關,最下面四個每個都連接到兩臺主機。當我啓動控制器時,我指示交換機發送LLDP數據包,這就是我學習拓撲的方式。另外,我計算一個生成樹,以在像ARP請求那樣泛洪數據包時使用。Pox/Mininet:學習主機的位置

我的問題:如何瞭解某個主機連接到哪個開關?如果h1h3發送第3層數據包,我知道如何路由數據包,因爲我有一棵生成樹,但這可能不是最短的路由。我使用Dijkstra來計算從每個交換機到所有其他交換機的最短路由,但是如果我想向h3發送消息,我不知道直接連接到交換機的是什麼交換機。

任何想法?

回答

1

負責執行此操作的組件是Host_tracker。你需要聽你的代碼中的Host_tracker事件,就像這樣:

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) 
+0

謝謝先生,這段代碼幫助我檢測主機down – 2017-03-31 11:51:53