Mininet で実行しているカスタム トポロジがあり、2 つのスイッチ s1 と s2 があります。コントローラーとして pox を使用しています。スイッチを識別するための Python コードを作成しましたが、これは正しい方法ですか? 私が使用できる他のより良い方法はありますか?他の代替案を提案できる機関はありますか?
コード:
from pox.core import core
import pox.openflow.libopenflow_01 as of
from pox.lib.util import dpidToStr
log = core.getLogger()
s1_dpid=0
s2_dpid=0
def _handle_ConnectionUp (event):
global s1_dpid, s2_dpid
print "ConnectionUp: ",
dpidToStr(event.connection.dpid)
#remember the connection dpid for switch
for m in event.connection.features.ports:
if m.name == "s1-eth1":
s1_dpid = event.connection.dpid
print "s1_dpid=", s1_dpid
elif m.name == "s2-eth1":
s2_dpid = event.connection.dpid
print "s2_dpid=", s2_dpid