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_01 as of
class Switch:
def __init__(self, connection, switch_id):
self.connection = connection
self.macToPort ={}
self.switch_id = switch_id
connection.addListeners(self)
def _handle_PacketIn(self, event):
in_port = event.port
packet = event.parsed
eth = packet.find("ethernet")
self.macToPort[eth.src]= in_port
if eth.dst in self.macToPort:
out_port = self.macToPort[eth.dst]
else:
out_port = of.OFPP_FLOOD
if out_port != of.OFPP_FLOOD:
msg = of.ofp_flow_mod()
msg.match = of.ofp_match()
msg.match.dl_dst = eth.dst
msg.match.in_port = event.port
msg.idle_timeout =10
msg.hard_timeout =30
msg.actions.append(of.ofp_action_output(port=out_port))
self.connection.send(msg)
else:
msg = of.ofp_packet_out()
msg.actions.append(of.ofp_action_output(port=out_port))
msg.data = event.ofp
self.connection.send(msg)
def _handle_ConnectionUp(event):
switch_id = event.connection).dpid # Extracting switch ID
Switch(event.connection, switch_id)
def launch():
core.openflow.addListenerByName("ConnectionUp",_handle_ConnectionUp) How to update this application of SDN controller as a switch in a mininet emulator for a tree topology with 2 levels and each swich connected to 4 hosts i.e. mn --topo,2,4 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!