1、概述
The OFSwitch13 module enhances the ns-3 Network Simulator with Software-Defined Networking (SDN) support. Despite the fact that the ns-3 already has a module for simulating OpenFlow switches, it provides a very outdated protocol implementation (OpenFlow 0.8.9, from 2008). Alternatively, OFSwitch13 supports OpenFlow protocol version 1.3, bringing both a switch device and a controller application interface to the ns-3 simulator, as depicted in The OFSwitch13 module overview, from [Chaves2016a]. With OFSwitch13, it is possible to interconnect ns-3 nodes to send and receive traffic using CsmaNetDevice or VirtualNetDevice. The controller application interface can be extended to implement any desired control logic to orchestrate the network. The communication between the controller and the switch is realized over standard ns-3 protocol stack, devices, and channels. The OFSwitch13 module relies on the external BOFUSS library for OFSwitch13. This library provides the switch datapath implementation, the support for converting OpenFlow messages to/from wire format, and the dpctl utility tool for configuring the switch from the command line.
OFSwitch13模块通过软件定义网络(SDN)支持增强了ns-3网络模拟器。尽管ns-3已经有一个用于模拟OpenFlow交换机的模块,但它提供的是非常过时的协议实现(来自2008年的OpenFlow 0.8.9版本)。相比之下,OFSwitch13支持OpenFlow协议版本1.3,为ns-3模拟器引入了交换机设备和控制器应用程序接口,如[Chaves2016a]中的OFSwitch13模块概述所示。使用OFSwitch13,可以通过CsmaNetDevice或VirtualNetDevice相互连接ns-3节点,以发送和接收流量。控制器应用程序接口可以扩展以实现任何所需的控制逻辑,以编排网络。控制器与交换机之间的通信是通过标准的ns-3协议栈、设备和通道实现的。OFSwitch13模块依赖于外部的BOFUSS库,用于支持OFSwitch13。该库提供了交换机数据路径实现,支持将OpenFlow消息转换为/自线格式,以及用于从命令行配置交换机的dpctl实用工具。
2、设计
2.1、OpenFlow 1.3 Switch Device
The OpenFlow 1.3 switch device, namely OFSwitch13Device, can be used to interconnect ns-3 nodes using the existing network devices and channels. The OFSwitch13Device internal structure figure shows the internal switch device structure. It takes a collection of OFSwitch13Port acting as input/output ports, each one associated with an ns-3 underlying NetDevice. In most cases, the CsmaNetDevice is used to build the ports, which will act as physical ports. However, it is possible to use the VirtualNetDevice to implement logical ports. The switch device acts as the intermediary between the ports, receiving a packet from one port and forwarding it to another. The BOFUSS library provides the OpenFlow switch datapath implementation (flow tables, group table, and meter table). Thus, packets entering the switch are sent to the library for OpenFlow pipeline processing before being forwarded to the correct output port(s). OpenFlow messages received from the controller are also sent to the library for datapath configuration.
OpenFlow 1.3交换机设备,即OFSwitch13Device,可用于通过现有的网络设备和通道相互连接ns-3节点。OFSwitch13Device内部结构图显示了内部交换机设备结构。它采用一组充当输入/输出端口的OFSwitch13Port,每个端口都与一个ns-3底层NetDevice关联。在大多数情况下,使用CsmaNetDevice来构建端口,这些端口将充当物理端口。然而,也可以使用VirtualNetDevice来实现逻辑端口。交换机设备充当端口之间的中介,从一个端口接收数据包并将其转发到另一个端口。BOFUSS库提供了OpenFlow交换机数据路径实现(流表、组表和计量表)。因此,进入交换机的数据包在转发到正确的输出端口之前,会发送到库中进行OpenFlow流水线处理。从控制器接收的OpenFlow消息也会发送到库中进行数据路径配置。
A packet enters the switch device through the OpenFlow receive callback in the underlying NetDevice, which is invoked for successfully received packets. This callback is a promiscuous one, but in contrast to a promiscuous protocol handler, the packet sent to this callback includes all the headers required for OpenFlow pipeline processing. Including this new callback in the NetDevice is the only required modification to the ns-3 source code for OFSwitch13 usage.
数据包通过底层NetDevice中的OpenFlow接收回调进入交换机设备,该回调在成功接收数据包时被调用。这个回调是一种混杂模式的回调,但与混杂模式协议处理程序不同的是,发送到此回调的数据包包括了进行OpenFlow流水线处理所需的所有标头。将这个新的回调包含在NetDevice中是使用OFSwitch13的唯一必需的ns-3源代码修改。
The incoming packet is checked for conformance to the CPU processing capacity (throughput) defined by the OFSwitch13Device::CpuCapacity attribute. Packets exceeding CPU processing capacity are dropped, while conformant packets are sent to the pipeline at the BOFUSS library. The module considers the concept of virtual TCAM (Ternary Content-Addressable Memory) to estimate the average flow table search time to model OpenFlow hardware operations. It considers that real OpenFlow implementations use sophisticated search algorithms for packet matching such as hierarchical hash tables or binary search trees. Because of that, the equation K * log_2 (n) is used to estimate the delay, where K is the OFSwitch13Device::TcamDelay attribute set to the time for a single TCAM operation, and n is the current number of entries on pipeline flow tables.
入站数据包将被检查,以符合由OFSwitch13Device::CpuCapacity属性定义的CPU处理能力(吞吐量)。超过CPU处理能力的数据包将被丢弃,而符合规定的数据包将被发送到BOFUSS库中的流水线进行处理。该模块考虑了虚拟TCAM(三态内容寻址内存)的概念,以估计平均流表搜索时间,以模拟OpenFlow硬件操作。它考虑到真实的OpenFlow实现使用复杂的搜索算法进行数据包匹配,比如分层哈希表或二叉搜索树。因此,使用方程式 K * log_2 (n) 来估计延迟,其中 K 是OFSwitch13Device::TcamDelay属性,表示单个TCAM操作的时间,而 n 则表示流水线流表上当前的条目数。
Packets coming back from the library for output action are sent to the OpenFlow queue provided by the module. An OpenFlow switch provides limited QoS support employing a simple queuing mechanism, where each port can have one or more queues attached to it. Packets sent to a specific queue are treated according to that queue’s configuration. Queue configuration takes place outside the OpenFlow protocol. The OFSwitch13Queue abstract base class implements the queue interface, extending the ns-3 Queue
class to allow compatibility with the CsmaNetDevice used within OFSwitch13Port objects (VirtualNetDevice does not use queues). In this way, it is possible to replace the standard CsmaNetDevice::TxQueue attribute by this modified OFSwitch13Queue object. Internally, it can hold a collection of N (possibly different) queues, each one identified by a unique ID ranging from 0 to N-1. Packets sent to the OpenFlow queue for transmission by the CsmaNetDevice are expected to carry the QueueTag, which is used by the OFSwitch13Queue::Enqueue method to identify the internal queue that will hold the packet. Specialized OFSwitch13Queue subclasses can perform different output scheduling algorithms by implementing the Peek,Dequeue, and Remove pure virtual methods from ns-3 Queue. The last two methods must call the NotifyDequeue and NotifyRemoved methods respectively, which are used by the OFSwitch13Queue to keep consistent statistics.
从库返回的用于输出操作的数据包将被发送到模块提供的OpenFlow队列。OpenFlow交换机通过简单的排队机制提供有限的QoS支持,其中每个端口可以附加一个或多个队列。发送到特定队列的数据包将根据该队列的配置进行处理。队列配置在OpenFlow协议之外进行。OFSwitch13Queue抽象基类实现了队列接口,扩展了ns-3的Queue
The OpenFlow port type queue can be configured by the OFSwitch13Port::QueueFactory attribute at construction time. Currently, the OFSwitch13PriorityQueue is the only specialized OpenFlow queue available for use. It implements the priority queuing discipline for a collection of N priority queues, identified by IDs ranging from 0 to N-1 with decreasing priority (queue ID 0 has the highest priority). The output scheduling algorithm ensures that higher-priority queues are always served first. The OFSwitch13PriorityQueue::QueueFactory and OFSwitch13PriorityQueue::NumQueues attributes can be used to configure the type and the number of internal priority queues, respectively. By default, it creates a single DropTailQueue operating in packet mode with the maximum number of packets set to 100.
OpenFlow端口类型的队列可以在构造时通过OFSwitch13Port::QueueFactory属性进行配置。目前,OFSwitch13PriorityQueue是唯一可用于使用的专门的OpenFlow队列。它为一组N个优先级队列实现了优先级排队策略,每个队列由从0到N-1的ID标识,优先级递减(队列ID 0具有最高优先级)。输出调度算法确保始终首先服务于更高优先级的队列。OFSwitch13PriorityQueue::QueueFactory和OFSwitch13PriorityQueue::NumQueues属性分别用于配置内部优先级队列的类型和数量。默认情况下,它创建一个在分组模式下运行的单个DropTailQueue,最大数据包数量设置为100。
2.2、OpenFlow 1.3 Controller Application Interface
The OpenFlow 1.3 controller application interface, namely OFSwitch13Controller, provides the necessary functionalities for controller implementation. It can handle a collection of OpenFlow switches, as illustrated in The OFSwitch13Controller internal structure figure. For constructing OpenFlow configuration messages and sending them to the switches, the controller interface relies on the dpctl utility provided by the BOFUSS library. With a simple command-line syntax, this utility can be used to add flows to the pipeline, query for switch features and status, and change other configurations.
OpenFlow 1.3控制器应用程序接口,即OFSwitch13Controller,提供了控制器实现所需的功能。它可以处理一组OpenFlow交换机,如OFSwitch13Controller内部结构图所示。为了构建OpenFlow配置消息并将其发送到交换机,控制器接口依赖于BOFUSS库提供的dpctl实用工具。通过简单的命令行语法,该实用工具可以用于向流水线添加流规则、查询交换机的特性和状态以及更改其他配置。
For OpenFlow messages coming from the switches, the controller interface provides a collection of internal handlers to deal with the different types of messages. Some handlers cannot be modified by derived class, as they must behave as already implemented. Other handlers can be overridden to implement the desired control logic.
The OFSwitch13 module brings the OFSwitch13LearningController class that implements the controller interface to work as a “learning bridge controller” (see 802.1D). This learning controller instructs the OpenFlow switches to forward incoming unicast frames from one port to the single correct output port whenever possible (similar to the ns3::BridgeNetDevice).
对于来自交换机的OpenFlow消息,控制器接口提供了一组内部处理程序来处理不同类型的消息。有些处理程序不能被派生类修改,因为它们必须按照已经实现的方式运行。其他处理程序可以被覆盖以实现所需的控制逻辑。
OFSwitch13模块引入了OFSwitch13LearningController类,该类实现了控制器接口,以工作为“学习桥控制器”(参见802.1D标准)。这个学习控制器指示OpenFlow交换机在可能的情况下将入站单播帧从一个端口转发到单个正确的输出端口(类似于ns3::BridgeNetDevice)。
2.3、OpenFlow channel
The OpenFlow channel is the interface that connects switches to OpenFlow controllers. Through this interface, the controller configures and manages the switch. In the OFSwitch13 module, the controller interface can manage the switch devices remotely over a separate dedicated network (out-of-band controller connection). It is possible to use standard ns-3 protocol stack, channels and devices to create the OpenFlow channel connections using a single shared channel or individual links between the controller interface and each switch device. This model provides realistic control plane connections, including communication delay and, optionally, error models. It also simplifies the OpenFlow protocol analysis, as the ns-3 tracing subsystem can be used for outputting PCAP files.
OpenFlow通道是连接交换机与OpenFlow控制器的接口。通过这个接口,控制器可以配置和管理交换机。在OFSwitch13模块中,控制器接口可以通过一个独立的专用网络远程管理交换机设备(带外控制器连接)。可以使用标准的ns-3协议栈、通道和设备来创建OpenFlow通道连接,可以使用单个共享通道或控制器接口与每个交换机设备之间的单独链接。这个模型提供了逼真的控制平面连接,包括通信延迟和可选的错误模型。它还简化了OpenFlow协议分析,因为ns-3跟踪子系统可以用于输出PCAP文件。
Considering that the OpenFlow messages traversing the OpenFlow channel follow the standard wire format, it is also possible to use the ns-3 TapBridge module to integrate an external OpenFlow controller, running on the local machine, to the simulated environment.
考虑到通过OpenFlow通道传输的OpenFlow消息遵循标准的线路格式,还可以使用ns-3的TapBridge模块将在本地计算机上运行的外部OpenFlow控制器集成到模拟环境中。