mySDN Lab6
mySDN Lab6
Controlled by flowvisor_lab1_lower
#!/usr/bin/python # Add switch links
self.addLink('s1', 's2', **http_link_config)
from mininet.topo import Topo self.addLink('s2', 's4', **http_link_config)
self.addLink('s1', 's3', **video_link_config)
class FVTopo(Topo): self.addLink('s3', 's4', **video_link_config)
log = core.getLogger()
s1_dpid=0
s2_dpid=0
s3_dpid=0
s4_dpid=0
def _timer_func():
for connection in core.openflow._connections.values():
connection.send(of.ofp_stats_request(body=of.ofp_port_stats_request()))
print "Sent %i port stats request(s)" % (len(core.openflow._connections))
def _handle_portstats_received(event):
#stats=flow_stats_to_list(event.stats)
#print "PortStatsReceived from %s: %s" % (dpidToStr(event.connection.dpid), stats)
for f in event.stats:
if int(f.port_no)<65534:
print "PortNo:", f.port_no, " dpid:", event.connection.dpid
def _handle_ConnectionUp (event): def _handle_PacketIn (event):
global s1_dpid, s2_dpid, s3_dpid, s4_dpid global s1_dpid, s2_dpid, s3_dpid, s4_dpid
print "ConnectionUp: ", print "PacketIn: ", dpidToStr(event.connection.dpid)
dpidToStr(event.connection.dpid)
if event.connection.dpid==s1_dpid:
#remember the connection dpid for switch msg = of.ofp_flow_mod()
for m in event.connection.features.ports: msg.priority =1
if m.name == "s1-eth1": msg.idle_timeout = 0
s1_dpid = event.connection.dpid msg.hard_timeout = 0
print "s1_dpid=", s1_dpid msg.match.in_port =3
elif m.name == "s2-eth1": msg.actions.append(of.ofp_action_output(port = 1))
s2_dpid = event.connection.dpid event.connection.send(msg)
print "s2_dpid=", s2_dpid
elif m.name == "s3-eth1": msg = of.ofp_flow_mod()
s3_dpid = event.connection.dpid msg.priority =1
print "s3_dpid=", s3_dpid msg.idle_timeout = 0
elif m.name == "s4-eth1": msg.hard_timeout = 0
s4_dpid = event.connection.dpid msg.match.in_port =1
print "s4_dpid=", s4_dpid msg.actions.append(of.ofp_action_output(port = 3))
event.connection.send(msg)
elif event.connection.dpid==s2_dpid: elif event.connection.dpid==s4_dpid:
msg = of.ofp_flow_mod() msg = of.ofp_flow_mod()
msg.priority =1 msg.priority =1
msg.idle_timeout = 0 msg.idle_timeout = 0
msg.hard_timeout = 0 msg.hard_timeout = 0
msg.match.in_port =1 msg.match.in_port =1
msg.actions.append(of.ofp_action_output(port = 2)) msg.actions.append(of.ofp_action_output(port = 3))
event.connection.send(msg) event.connection.send(msg)
log = core.getLogger()
s1_dpid=0
s2_dpid=0
s3_dpid=0
s4_dpid=0
def _timer_func():
for connection in core.openflow._connections.values():
connection.send(of.ofp_stats_request(body=of.ofp_port_stats_request()))
print "Sent %i port stats request(s)" % (len(core.openflow._connections))
def _handle_portstats_received(event):
#stats=flow_stats_to_list(event.stats)
#print "PortStatsReceived from %s: %s" % (dpidToStr(event.connection.dpid), stats)
for f in event.stats:
if int(f.port_no)<65534:
print "PortNo:", f.port_no, " dpid:", event.connection.dpid
def _handle_ConnectionUp (event): def _handle_PacketIn (event):
global s1_dpid, s2_dpid, s3_dpid, s4_dpid global s1_dpid, s2_dpid, s3_dpid, s4_dpid
print "ConnectionUp: ", print "PacketIn: ", dpidToStr(event.connection.dpid)
dpidToStr(event.connection.dpid)
if event.connection.dpid==s1_dpid:
#remember the connection dpid for switch msg = of.ofp_flow_mod()
for m in event.connection.features.ports: msg.priority =1
if m.name == "s1-eth2": msg.idle_timeout = 0
s1_dpid = event.connection.dpid msg.hard_timeout = 0
print "s1_dpid=", s1_dpid msg.match.in_port =4
elif m.name == "s2-eth1": msg.actions.append(of.ofp_action_output(port = 2))
s2_dpid = event.connection.dpid event.connection.send(msg)
print "s2_dpid=", s2_dpid
elif m.name == "s3-eth1": msg = of.ofp_flow_mod()
s3_dpid = event.connection.dpid msg.priority =1
print "s3_dpid=", s3_dpid msg.idle_timeout = 0
elif m.name == "s4-eth2": msg.hard_timeout = 0
s4_dpid = event.connection.dpid msg.match.in_port =2
print "s4_dpid=", s4_dpid msg.actions.append(of.ofp_action_output(port = 4))
event.connection.send(msg)
elif event.connection.dpid==s3_dpid: elif event.connection.dpid==s4_dpid:
msg = of.ofp_flow_mod() msg = of.ofp_flow_mod()
msg.priority =1 msg.priority =1
msg.idle_timeout = 0 msg.idle_timeout = 0
msg.hard_timeout = 0 msg.hard_timeout = 0
msg.match.in_port =1 msg.match.in_port =2
msg.actions.append(of.ofp_action_output(port = 2)) msg.actions.append(of.ofp_action_output(port = 4))
event.connection.send(msg) event.connection.send(msg)
Start FlowVisor
Create Slices
H2 can ping h4
References
• Installation from Binary,
https://github.com/OPENNETWORKINGLAB/flowvisor/
wiki/Installation-from-Binary
• Flowvisor Exercise,
https://github.com/onstutorial/onstutorial/wiki/Flowvi
sor-Exercise
• POX Wiki,
https://openflow.stanford.edu/display/ONL/POX+Wiki