Commit efbcea67 authored by Bhanu Senevirathne's avatar Bhanu Senevirathne

Add new file

parent a8017e16
import pox.openflow.libopenflow_01 as of
import pox.lib.packet as pkt
from pox.lib.packet import *
import random
log = core.getLogger()
s1_dpid = 0
value = random.randint(1, 10000)
def launch ():
def _handle_ConnectionUp(event):
def _handle_PacketIn(self, event):
def portAssign(val):
server = 0
if val <= 5000:
server = 1
elif val <= 8000:
server = 2
elif val <= 10000:
server = 3
return server
def _handle_ConnectionUp(event):
global s1_dpid, s2_dpid, s3_dpid
print "ConnectionUp: ", dpidToStr(event.connection.dpid)
def _handle_PacketIn (self, event):
global s1_dpid
print
"PacketIn: ", dpidToStr(event.connection.dpid)
if event.connection.dpid == s1_dpid:
packet = event.parsed
msg = of.ofp_flow_mod()
msg.actions.append(of.ofp_action_output(port=portAssign(value)))
event.connection.send(msg)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment