SDN第五次上机作业
实验5:开源控制器实践——POX
(一)基本要求
一、搭建SDN拓扑,协议使用Open Flow 1.0,控制器使用部署于本地的POX(默认监听6633端口)
- 快速建立所需拓扑
sudo mn --topo=single,3 --mac --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow10
二、阅读Hub模块代码,使用 tcpdump 验证Hub模块
hub:
1.开启(pox目录下)POX:./pox.py log.level --DEBUG forwarding.hub
2.打开窗口:在mininet里:xterm h2/h3
3.在打开窗口输入 tcpdump
4.h1 ping h2

5.h1 ping h3

l2_learning:
1.开启(pox目录下)POX:./pox.py log.level --DEBUG forwarding.l2_learning
2.打开窗口:在mininet里:xterm h2/h3
3.在打开窗口输入 tcpdump
4.h1 ping h2

5.h1 ping h3

结论:hub情况下两台host都会有收到数据包,而l2_learning情况下只有ping的那台才有
L2_learning流程图:

(二)进阶要求
from pox.core import core
import pox.openflow.libopenflow_01 as of
from pox.lib.addresses import IPAddr
from pox.lib.addresses import EthAddr
log = core.getLogger()
class SendFlowInSingle3 (object):
def __init__ (self,ignore = None):
core.openflow.addListeners(self)
self.ignore = set(ignore) if ignore else ()
def _handle_ConnectionUp (self, event):
msg=of.ofp_flow_mod()
msg.idle_timeout=0
msg.hard_timeout=0
msg.priority=1
msg.match.in_port = 1
msg.actions.append(of.ofp_action_output(port=0xfffb))
event.connection.send(msg)
msg.match.in_port = 2
msg.actions.append(of.ofp_action_output(port=0xfffb))
event.connection.send(msg)
msg.match.in_port = 3
msg.actions.append(of.ofp_action_output(port=0xfffb))
event.connection.send(msg)
if event.dpid in self.ignore:
log.debug("Ignoring connection %s" % (event.connection,))
return
log.debug("Connection %s" % (event.connection,))
def launch (ignore = None):
if ignore:
ignore = ignore.replace(',', ' ').split()
ignore = set(str_to_dpid(dpid) for dpid in ignore)
core.registerNew(SendFlowInSingle3)

实验总结:
这次实验主要学习使用Pox,最开始做各种问题,求助了几个同学才知道要怎么进行实验,其实不难,就是第一次用非常生疏,熟悉了一下pox命令之后就好做一点了
流程图部分研究了一下L2_learning模块代码,稍微理解了一点是怎么回事,应该是这么个流程(吧)
进阶部分,一言难尽
请教了一个同学,他的意思是l2_learning.py代码的class里面的内容进行修改,去掉一些不需要的变量
但是我改了半天最后还是没法用...最后还是找他要的代码
这个,有耐心的同学可以去试试,没耐心还是建议放了,非常的折磨人......
浙公网安备 33010602011771号