首页 > 其他分享 >实验5:开源控制器实践——POX

实验5:开源控制器实践——POX

时间:2022-10-10 19:57:05浏览次数:35  
标签:控制器 POX 开源 actions ofp msg output port append

基本要求

验证Hub模块
h1 ping h2(h3和h2都能抓到包)

h1 ping h3(h3和h2都能抓到包)

验证Switch模块
h1 ping h2(只有h2抓包)

h1 ping h3(只有h3抓包)

L2_learning模块代码流程图

进阶要求

重新搭建(一)的拓扑,此时交换机内无流表规则,拓扑内主机互不相通;编写Python程序自定义一个POX模块SendFlowInSingle3,并且将拓扑连接至SendFlowInSingle3(默认端口6633),实现向s1发送流表规则使得所有主机两两互通

代码
from pox.core import core import pox.openflow.libopenflow_01 as of class SendFlowInSingle3(object): def __init__ (self): core.openflow.addListeners(self) def _handle_ConnectionUp(self, event): msg = of.ofp_flow_mod() msg.priority = 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) msg = of.ofp_flow_mod() msg.priority = 1 msg.match.in_port = 2 msg.actions.append(of.ofp_action_output(port=1)) msg.actions.append(of.ofp_action_output(port=3)) event.connection.send(msg) msg = of.ofp_flow_mod() msg.priority = 1 msg.match.in_port = 3 msg.actions.append(of.ofp_action_output(port=1)) msg.actions.append(of.ofp_action_output(port=2)) event.connection.send(msg) def launch(): core.registerNew(SendFlowInSingle3)
基于进阶1的代码,完成ODL实验的硬超时功能
先通再断再恢复

先断后通

代码
from pox.core import core import pox.openflow.libopenflow_01 as of class SendFlowInSingle3(object): def __init__(self): core.openflow.addListeners(self) def _handle_ConnectionUp(self, event): msg = of.ofp_flow_mod() msg.priority = 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) msg = of.ofp_flow_mod() msg.priority = 1 msg.match.in_port = 2 msg.actions.append(of.ofp_action_output(port=1)) msg.actions.append(of.ofp_action_output(port=3)) event.connection.send(msg) msg = of.ofp_flow_mod() msg.priority = 1 msg.match.in_port = 3 # msg.actions.append(of.ofp_action_output(port=1)) msg.actions.append(of.ofp_action_output(port=2)) event.connection.send(msg) def launch(): core.registerNew(SendFlowInSingle3)

心得体会

1.本次实验难度比之前大,需要花费更多的时间,而且第一次使用POX,不知道其功能和作用,学习起来比较较有难度
2.实验中的SendFlowInSingle3需要放在forwarding文件夹中
3.验证硬中断时先通再断再恢复是先结束SendFlowInSingle3再启动SendPoxHardTimeOut,待数据包中断后再启动SendFlowInSingle3
4.通过本次实验的学习,我基本了解了 POX 控制器的具体原理,同时通过验证POX的forwarding.hub和forwarding.l2_learning模块,初步掌握了POX控制器的使用方法
5.进阶要求部分的代码编写我认为比较难,但是通过百度以及老师给的文档进行学习后比较完美的完成了代码的编写

标签:控制器,POX,开源,actions,ofp,msg,output,port,append
From: https://www.cnblogs.com/jiangge202/p/16776948.html

相关文章