Question: from pox.core import core from pox.lib.addresses import EthAddr import pox.openflow.libopenflow _ 0 1 as of class Switch: def _ _ init _ _ ( self
from pox.core import core
from pox.lib.addresses import EthAddr
import pox.openflow.libopenflow as of
class Switch:
def initself connection, switchid:
self.connection connection
self.macToPort
self.switchid switchid
connection.addListenersself
def handlePacketInself event:
inport event.port
packet event.parsed
eth packet.findethernet
self.macToPortethsrc inport
if eth.dst in self.macToPort:
outport self.macToPortethdst
else:
outport ofOFPPFLOOD
if outport ofOFPPFLOOD:
msg ofofpflowmod
msgmatch ofofpmatch
msgmatch.dldst eth.dst
msgmatch.inport event.port
msgidletimeout
msghardtimeout
msgactions.appendofofpactionoutputportoutport
self.connection.sendmsg
else:
msg ofofppacketout
msgactions.appendofofpactionoutputportoutport
msgdata event.ofp
self.connection.sendmsg
def handleConnectionUpevent:
switchid event.connectiondpid # Extracting switch ID
Switcheventconnection, switchid
def launch:
core.openflow.addListenerByNameConnectionUphandleConnectionUp How to update this application of SDN controller as a switch in a mininet emulator for a tree topology with levels and each swich connected to hosts ie mn topo, so that i am able to transfer packets to hosts connected to different switches through controller
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
