【Openflow Tutorial】Create a learning switch

Openflow Tutorial: Create a learning switch

Github: https://github.com/mininet/openflow-tutorial/wiki

选择POX作为远程控制器,编写python程序实现交换机(Switch)功能,比较交换机(Switch)与集线器(Hub)的区别。

1.Switch VS Hub

Hub是将信号直接传输给所有其它端口,即传输线路是共享的;而Switch能够选择目标端口,在很大程度上减少冲突的发生,为通信双方提供了一条独占的线路。例如,对于mininet中的虚拟主机h1,h2,h3,若h1想要ping h2,则hub会将packet发送给h2与h3,而switch只会发送给h2。

2. Realize the function of Switch

要实现Switch功能,GitHub上下载的of_tutorial.py已经给出了较详细的注释说明,翻译成中文,其大致流程如下:
① 如果 目标端口未知:从packet中学习
② 如果 目标端口已知:发送packet;打印log信息;Match, Action, connection.send
③ 其他:向所有其他端口发送

# Copyright 2012 James McCauley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
This component is for use with the OpenFlow tutorial.

It acts as a simple hub, but can be modified to act like an L2
learning switch.

It's roughly similar to the one Brandon Heller did for NOX.
"""

from pox.core import core
import pox.openflow.libopenflow_01 as of

log = core.getLogger()



class Tutorial (object):
  """
  A Tutorial object is created for each switch that connects.
  A Connection object for that switch is passed to the __init__ function.
  """
  def __init__ (self, connection):
    # Keep track of the connection to the switch so that we can
    # send it messages!
    self.connection = connection

    # This binds our PacketIn event listener
    connection.addListeners
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值