1

my environment is mininet. what im trying to achieve is, that each time, a switch connects or disconnects to the pox controller, the controller should print all connected switches (their DPIDs).

def _handle_ConnectionUp (self, event):

print "Switch %s has come up." % event.dpid

is that something i can work with? and what do i need to implement before that i can use _handle_ConnectionUp ?

thanks in advance.

4

1 に答える 1

1

最良の方法は、コントローラー クラスでセットを定義し、そこにすべてのスイッチの DPID を追加することです。したがって、_handle_ConnectionUp でイベントが発生するたびに、スイッチの DPID を取得し、それに応じて追加できます。

メインコントローラークラスのinit関数で

self.switches = set()

および _handle_ConnectionUp 関数

def _handle_ConnectionUp(self, event):
        """
        Fired up openflow connection with the switch
        save the switch dpid
        Args:
            event: openflow ConnectionUp event
        Returns: Nada
        """
        self.switches.add(pox.lib.util.dpid_to_str(event.dpid))

したがって、必要に応じて、接続ダウンのイベントをキャッチしてスイッチを削除する必要があります。Dart バージョンの POX コントローラーで現在利用可能なすべての openflow イベント ミックスインのリストを取得するには、https://github.com/noxrepo/pox/blob/dart/pox/openflow/ init .py line 336 at event mixinsに移動します。

 _eventMixin_events = set([
    ConnectionUp,
    ConnectionDown,
    FeaturesReceived,
    PortStatus,
    FlowRemoved,
    PacketIn,
    BarrierIn,
    ErrorIn,
    RawStatsReply,
    SwitchDescReceived,
    FlowStatsReceived,
    AggregateFlowStatsReceived,
    TableStatsReceived,
    PortStatsReceived,
    QueueStatsReceived,
    FlowRemoved,
  ])

さらに支援が必要な場合は、Dart POX を使用した完全に機能する SDN コントローラーのコードを確認してください。ギリシャのテッサロニキで開催された Python Meetup のために私が書いたもので、 https://github.com/tsartsaris/pythess-SDNで見つけることができます。

于 2016-03-11T18:56:31.383 に答える