Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-077
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-077
2021-077
Commits
efbcea67
Commit
efbcea67
authored
May 07, 2021
by
Bhanu Senevirathne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
a8017e16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
WeightedroundRobin
WeightedroundRobin
+52
-0
No files found.
WeightedroundRobin
0 → 100644
View file @
efbcea67
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)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment