Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started