Answered step by step
Verified Expert Solution
Link Copied!

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_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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions