实验5:开源控制器实践——POX
基本要求
基础要求只需要提交h1 ping h2、h2和h3的tcpdump抓包结果截图,外加L2_learning模块代码流程图
使用 tcpdump 验证Hub模块
使用 tcpdump 验证Switch模块
进阶要求
请提交相关代码和运行结果,以及ovs-ofctl交换机流表项截图
编写Python程序自定义一个POX模块SendFlowInSingle3,并且将拓扑连接至SendFlowInSingle3(默认端口6633),实现向s1发送流表规则使得所有主机两两互通
from pox.core import core
import pox.openflow.libopenflow_01 as of
from pox.lib.addresses import IPAddr
class SendFlowInSingle3(object)://注册组件
def __init__ (self):
core.openflow.addListeners(self)
def _handle_ConnectionUp(self,event):
msg = of.ofp_flow_mod()// 使用ofp_flow_mod()的方法向交换机来下发流表
msg.priority = 1
msg.match.in_port = 1
msg.actions.append(of.ofp_action_output(port = of.OFPP_ALL))//向所有端口转发
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 = of.OFPP_ALL))
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 = of.OFPP_ALL))
event.connection.send(msg)
def launch ():
core.registerNew(SendFlowInSingle3)
个人总结:
本次实验基本操作比较简单,能够理解pox控制器的工作原理,根据老师提供的资料验证了pox的forwarding.hub和forwarding.l2_learning模块,初步掌握了pox控制器的使用方法