Design POX controller step by step

In this article, I’ll describe how to understand the POX controller’s behavior, and illustrate how to design the behavior step by step.

1. Hub behavior
I will use the network below in this exercise. In this case, C0 is POX controller located in one PC, and S1, h1, h2, h3 is simulated by mininet.

In POX, the hub behavior is defined in pox\forwarding\hub.py. Let’s read the code at first.


def _handle_ConnectionUp (event):msg = of.ofp_flow_mod()msg.actions.append(of.ofp_action_output(port = of.OFPP_FLOOD))event.connection.send(msg)log.info("Hubifying %s", dpidToStr(event.dpid))def launch ():core.openflow.addListenerByName("ConnectionUp", _handle_ConnectionUp)log.info("Hub running.")

The hub module contains a launch function, which is called to initialize this module. Basically, each module should have launch function. In launch function, addListenerByName is called. The addListererByName is used to register a call back function for specific events issued by either the OpenFlow module or other module. When a connection to a switch ups, a “ConnectionUp” event is issued, then _handle_ConnectionUp function will be called to handle the event.

_handle_ConnectionUp function has two important tasks. The 1st one is form the open flow rule, and the 2nd is to send the rule to open switch. Function ofp_flow_mod and ofp_action_output will initialized/modified the open flow rule. Once the rules is decided, connection.send function sends an OpenFlow message to a switch, i.e, deploy the rule to open switch.

Testing case:
a. Capture packet in PC. Open Flow packets will be captured.
b. Ping from h1 to h3, capture packets via tcpdump in h1, h2, h3. All packets will be flooded in all three hosts.

2. Switch behavior
In POX, basic switch behavior is defined in pox\forwarding\l2_learning. The topology is same as above.
As usual, let’s read code firstly.

The l2_learning module uses core.registerNew function to register with class name l2_learning. After registration, l2_learning is a module of POX, and it also need add event listener via function addListeners in its init function.

While working as l2 switch mode, the open flow rule is not deployed during controller startup process. It’s down to open switch when first packet in.

Testing case:
a. Ping from h1 to h3, capture packets via tcpdump in h1, h2, h3. BC packet should be found in all hosts, and ping is only found in h1 and h3.

3. Self-defined firewall behavior
Based on the knowledge above, let’s start to design a firewall to filter ping reply. The easy way is to use the l2 learning component, and then add more code in PacketIn event handler. Here’s a sample for blocking ping reply:

"""
Block ICMP reply"""from pox.core import coreTYPE_ECHO_REPLY   = 0def block_handler (event):# Handles packet events and kills the ones once the packet is PING replyicmpp = event.parsed.find('icmp')if not icmpp: return # Not ICMP#if it is ping reply, block it:if (icmpp.type == TYPE_ECHO_REPLY):# Halt the event, stopping l2_learningcore.getLogger("blocker").debug("Blocked TCP %s <-> %s",tcpp.srcport, tcpp.dstport)event.halt = Truedef launch ():# Listen to packet eventscore.openflow.addListenerByName("PacketIn", block_handler)

Design POX controller step by step相关推荐

  1. Cisco Wireless Controller 5508 Configuration Step by Step – Part 1 (CLI and GUI Access, Upgrade)

    As the industry's most deployed controller, the Cisco 5500 Series Wireless Controller provides the h ...

  2. RDL(C) Report Design Step by Step 3: Mail Label

    RDL(C) Report Design Step by Step 3: Mail Label Crystal Report在报表向导中提供了三种向导类型给用户进行选择--Standard.Cross ...

  3. RDL(C) Report Design Step by Step 2: SubReport

    RDL(C) Report Design Step by Step 2: SubReport 前两天,有网友在Blog上评论要求将子报表的配置贴出来,由于这两天有些别的事情,所以耽搁了:另外,自己也比 ...

  4. RDL(C) Report Design Step by Step 1: DrillThrough Report

    RDL(C) Report Design Step by Step 1: DrillThrough Report 前一段时间,发了几篇关于RDLC报表的随笔,由于这些随笔中没有关于报表设计方面的内容, ...

  5. RDL(C) Report Design Step by Step

    RDL(C) Report Design Step by Step 1: DrillThrough Report 前一段时间,发了几篇关于RDLC报表的随笔,由于这些随笔中没有关于报表设计方面的内容, ...

  6. 【Step By Step】将Dotnet Core部署到Docker下

    一.使用.Net Core构建WebAPI并访问Docker中的Mysql数据库 这个的过程大概与我之前的文章<尝试.Net Core-使用.Net Core + Entity FrameWor ...

  7. 数据库设计Step by Step (10)——范式化

    引言:前文(数据库设计Step by Step (9)--ER-to-SQL转化)讨论了如何把ER图转化为关系表结构.本文将介绍数据库范式并讨论如何范式化候选表.我们先来看一下此刻处在数据库生命周期中 ...

  8. Asp.Net Core 5 REST API 使用 JWT 身份验证 - Step by Step(二)

    翻译自 Mohamad Lawand 2021年1月22日的文章 <Asp Net Core 5 Rest API Authentication with JWT Step by Step> ...

  9. Asp.Net Core 5 REST API - Step by Step(一)

    翻译自 Mohamad Lawand 2021年1月19日的文章 <Asp.Net Core 5 Rest API Step by Step> [1] 在本文中,我们将创建一个简单的 As ...

最新文章

  1. itext转html为pdf 锚点,ITEXT输出pdf..docx
  2. 松下SW-9585-C全功能DVD刻录机 狂降100+享受专业刻录!
  3. linux CentOS 系统下如何将php和mysql命令加入到环境变量中
  4. 【Vue】class style:Vue中的两种样式处理方法
  5. FreeBSD内核简介
  6. 如何解决linux下编译出现的multiple definition of错误
  7. POJ2262 ZOJ1951 UVa543 Goldbach's Conjecture
  8. C#Excel上传批量导入sqlserver
  9. HTML5 - WebSQL
  10. Android开发案例 点击按钮出现 简易的消息提示框
  11. 《Linux/UNIX系统编程手册》推荐
  12. 应用matlab软件编写 t检验,应用matlab软件进行方差分析 应用方差分析的前提条件...
  13. 什么是类?什么是对象?类与对象之间是什么关系?类的特性有哪些?
  14. android没有adm_求助 Android studio的ADM打不开是什么原因
  15. vue-cli4引入Element Plus 插件
  16. 关于电机编码器的知识汇总,都在这里了!
  17. miui系统分身测试软件,【MIUI 8评测】手机分身初上手,黑科技值爆表!
  18. oracle连接失败日志文件,Oracle中的联机日志文件发生不同程度损坏的恢
  19. 杭州计算机中级职称评级流程,杭州本地中级工程师****流程
  20. 享元模式(Flyweight模式)

热门文章

  1. YottaChain创始人王东临:存储公链进军商用市场的必杀技!
  2. 二叉树——重建二叉树
  3. ann神经网络模型评价指标,神经网络模型参数辨识
  4. vue axios 怎么也获取不了后台传过来的session 求大神指教
  5. 最全控件,开发工具,国外软件
  6. Jconsole简介
  7. 《使用Java理解程序逻辑》学习笔记
  8. 究竟什么是三网合一?
  9. autocad2014 菜单栏 闪退_AutoCAD2014_Windows 10 闪退
  10. 【风光摄影后期笔记】PS——亮度蒙版(1)笔刷