OpenFlow 介绍

发布时间: 更新时间: 总字数:1714 阅读时间:4m 作者: 分享 复制网址
专栏文章
  1. OpenFlow 介绍(当前)

OpenFlow 是一种网络通信协议,属于 数据链路层,能够控制网络交换器或路由器的转发平面,借此改变网络数据包所走的网络路径。OpenFlow 被认为是第一个软件定义网络标准之一。本文主要参考 OpenFlow v1.5.1 协议进行解析。

简介

OpenFlow 在 SDN 中的角色:SDN 控制平面与数据平面之间提供通信接口标准,目的是实现SDN网络的转发与控制分离架构

工作原理

传统网络

通过 路由表MAC 地址转发数据包

基于 OpenFlow 的 SDN 网络

  • SDN 控制器 通过使用 OpenFlow 协议来管理交换机,如下发流表、获取交换机上的端口、流量的统计信息等
  • OpenFlow 交换机 查询 流表 转发数据包
    • 支持 OpenFlow 的交换机中包含多个 Flow table,通过 Flow table 过滤数据包并执行与 flow 相匹配的表项中的 Instructions

基本概念

  • Flow(流) 是具有相同特征的数据包集合,流具有方向性,一般源MAC、目的MAC分别相同的数据包集合称为一条流
  • Flow Table(流表) 是 OpenFlow 交换机收到流后进行抓发的规则表,相当于二层的 Mac 地址表和三层的路由表,OpenFlow 1.1 之后支持多张流表
    • 流表由 流表项(Flow Entry) 组成
    • Flow table 中的条目有优先级,过滤数据包时按照优先级(priority)从高到底依次匹配
  • Group Table(组表) 是由若干条组表项(Group Entry)组成,具有将多个端口定义为一个组的能力,从而实现广播、多播,负载均衡、链路聚合、故障转移等
    • 有多个 group entry 组成
  • Meter Table(计量表) 对流进行测量,从而为流提供QoS功能,如限速、DiffServ
    • 每台 OpenFlow 交换机只有一张计量表(Meter Table),由若干计量表项(Meter Entry)组成,每个计量表项可以定义一至多个计量带(Meter Band),计量带定义了带宽阈值和数据包处理方式(丢弃、DSCP标记)

流表项(Flow Entry)

MatchFields Priority Counters Instructions Timeouts Cookie Flags
  • Match Fields(匹配域):用于匹配数据包,是流表匹配的依据,如根据 源IP地址 + 目的IP地址 匹配一条流
Simplified flowchart detailing packet flow through an OpenFlow switch
  • Priority(优先级):表示该流表项的优先程度,越大优先级越高
  • Counters(计数器):当流表匹配时更新,用于统计流信息
  • Instructions(指令):修改 action setpipeline processing
    • Action 包括:
      • Apply-Actions(Optional)
      • Clear-Actions(Required)
      • Write-Actions(Required)
      • Write-Metadata(Optional)
      • Stat-Trigger(Optional)
      • Goto-Table(Required)
    • Actios 包括,OpenFlow 交换机需要实现下述的 Required Action:
      • Required Action: Output port no. The Output action forwards a packet to a specified OpenFlow port (see 4.1) where it starts egress processing.
      • Required Action: Group group id. Process the packet through the specified group (see 5.10). The exact interpretation depends on group type.
      • Required Action: Drop. There is no explicit action to represent drops.
      • Optional Action: Set-Queue queue id. The set-queue action sets the queue id for a packet.
      • Optional Action: Meter meter id. Direct packet to the specified meter.
      • Optional Action: Push-Tag/Pop-Tag ethertype. Switches may support the ability to push/pop tags as shown in Table 2
      • Optional Action: Set-Field field type value. The various Set-Field actions are identified by their field type and modify the values of respective header fields in the packet
      • Optional Action: Copy-Field src field type dst field type. The Copy-Field action may copy data between any header or pipeline fields.
      • Optional Action: Change-TTL ttl. The various Change-TTL actions modify the values of the IPv4 TTL, IPv6 Hop Limit or MPLS TTL in the packet.
Matching and Instruction execution in a flow table
  • Timeouts(超时时间):流被交换机标记为失效的最长时间,或最大阻塞时间
  • Cookie:由控制器设置的数值,用来统计流过滤、修改和删除的请求,processing packets 中未被使用
  • Flags(标志):用于流表项管理,例如 OFPFF_SEND_FLOW_REM 标志会触发流删除该流条目的消息

其中,流表项(Flow Entry)由 MatchFieldsPriority 形成联合主键。

Group entry

Group Identifier Group Type Counters Action Buckets
  • group identifier: a 32 bit unsigned integer uniquely identifying the group on the OpenFlow switch.
  • group type: to determine group semantics (see Section 5.10.1).
    • Required: indirect: Execute the one defined bucket in this group.
    • Required: all: Execute all buckets in the group.
    • Optional: select: Execute one bucket in the group.
    • Optional: fast failover: Execute the first live bucket.
  • counters: updated when packets are processed by a group.
  • action buckets: an ordered list of action buckets, where each action bucket contains a set of actions to execute and associated parameters. The actions in a bucket are always applied as an action set (see 5.6).

Pipeline Processing

流水线上,多个flow table按照其数字编号从小到大排列着(table0, table1, … table N),进入交换机的数据包都是从pipeline的第一个flow table(即 table0)开始处理,对table0中的条目一条一条开始匹配

  • 如果匹配成功则执行相应的action(这些动作可能导致从flow table跳到group table中)
  • 若果所有条目都没有成功匹配,则根据table自身的不同配置执行相应的处理 Table Miss Flow Entry
    • drop
    • Goto-Table
    • 转发给控制器
Packet flow through the processing pipeline

Meter Table

Meter Identifier Meter Bands Counters
  • meter identifier: a 32 bit unsigned integer uniquely identifying the meter
  • meter bands: an unordered list of meter bands, where each meter band specifies the rate of the band and the way to process the packet
  • counters: updated when packets are processed by a meter

OpenFlow 流表下发方式

  • Proactive:在 OpenFlow 交换机预置路由表,数据包没有到达 OpenFlow 交换机前,SDN 控制器就行 OpenFlow 交换机主动下发流表
  • Reactive:按需下发流表,若数据包经过 OpenFlow 交换机没有查到所需的流表,会产生 Packet-In 消息询问 SDN 控制器,SDN 控制器计算路由后下发流表到 OpenFlow 交换机

示例

参考

  1. https://opennetworking.org/
  2. OpenFlow 协议入门
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数