1.基本要求
使用 tcpdump 验证Hub模块
h1 ping h2(h3和h2都能抓到包)
h1 ping h3(h3和h2都能抓到包)
验证Switch模块
h1 ping h2(只有h2抓包)
h1 ping h3(只有h3抓包)
L2_learning模块代码流程图
2.进阶要求
重新搭建(一)的拓扑,此时交换机内无流表规则,拓扑内主机互不相通;编写Python程序自定义一个POX模块SendFlowInSingle3,并且将拓扑连接至SendFlowInSingle3(默认端口6633),实现向s1发送流表规则使得所有主机两两互通
code
from = pox.core import core
import pox.openflow.libopenflow_01 as of
from pox.openflow.of_json import *
def SendFlowInSingle3(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.openflow.addListenerByName("ConnectionUp", SendFlowInSingle3);
2.基于进阶1的代码,完成ODL实验的硬超时功能。
code
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.本次实验难度较之前要大,理解PDF的内容需要花费一定的时间,而且初次遇到POX,不知道其功能作用,学习起来较有难度。
2.在学习l2_learning模块时,参考了同学的流程图,并加以理解,在做进阶实验时遇到的困难比较多,因为文档为全英文,观看起来比较困难。在进行ODL实验时,在运行SendFlowInSingle3和SendPoxHardTimeOut的顺序上也尝试了较多次,需要先运行pox模板SendFlowInSingle3,接着将SendFlowInSingle3中断掉,再运行SendPoxHardTimeOut,等待中断后,将SendPoxHardTimeOut断掉,接着再次运行SendFlowInSingle3,实现任务要求。