Page 89 - 《软件学报》2020年第9期
P. 89
2710 Journal of Software 软件学报 Vol.31, No.9, September 2020
Abstract: SDN (software-defined network) is designed to solve the problems of traditional networks with complex and scattered
architecture, making the network more flexible.The characteristic of the P4 programming language is that users can directly define P4
programs according to their needs for processing data packets,and then compile and configure user requirements to network equipment
through the adaptation file.The SDN data plane conformance test for the P4 programming language is to send the consistency test cases to
the P4 network equipment to evaluate the consistency of the actual output and the expected output.Conformance test cases are the carriers
for performing conformance tests,and the traditional manual construction of test cases is a tedious and time-consuming work.This article
focuses on the design principles and generation method of SDN data plane software conformance test cases for P4 programming language,
gives the conformance test case coverage standards,designs the command information entity structure and the test case entity structure,
and uses the simple_switch virtual switch loaded with the P4 program as the test object to illustrate the conformance test case generation
process.This paper also implements an automatic test case generation tool for P4 network device conformance testing, and verifies the
effectiveness of the tool to automatically generate test cases, and realizes the simplicity of the conformance test case construction process
Key words: conformance test; test case generation; test coverage; SDN (software-defined networks); P4 (programming protocol-
independent packet processors) intermediate node programming language
在网络需求不断增加、网络灵活性要求不断提高的背景下,SDN(software-defined network)解决了架构复杂
且分散的传统网络出现的问题,使网络具有更强的灵活性.SDN 使网络控制平面和转发平面分离,使网络具有可
编程性.斯坦福大学的 Nick 教授及其团队研究出 P4 高级编程语言,P4 是一种协议独立的针对数据转发平面编
程的语言,旨在允许我们定义交换机将识别(或“解析”)的表头、如何匹配每个表头以及我们希望交换机在每个
表头上执行的操作.P4 语言的特征在于,用户可以直接根据自己对处理数据包的需求定义 P4 程序.
OpenFlow 协议是比较流行的 SDN 南向协议,目前,针对 OpenFlow 协议的一致性测试工作展开了很多,但是
面向 P4 编程语言的一致性测试研究甚少,缺乏成熟的一致性测试方案.P4 编程语言具有巨大的灵活性且传统的
人工构造测试用例是一项繁琐耗时费力的工作,面向 P4 编程语言研究 SDN 数据平面软件一致性测试用例生成
方法具有重要意义.
面向 P4 编程语言的一致性测试,本质上是将测试用例发送给 P4 网络设备,通过比较实际输出和预期输出
的一致程度,保证了 P4 网络设备在错综复杂的网络环境中的表现与预期表现一致性.面向 P4 编程语言的 SDN
数据平面软件一致性测试,目的在于保障控制器与网络设备之间的互操作性.
装载了 P4 程序的网络设备基本的工作机制为:接收数据包;解析器以有限状态机的形式解析数据包包头,
从初始状态开始,每一种状态解析一种协议,从低层协议解析匹配首部定义的协议进而转移到高层协议字段,最
终转移至目标状态;执行 Match-Action 动作,数据包头的目的地址与表的匹配字段进行匹配,当数据包中的字段
和匹配字段根据给定的匹配类型匹配成功时,就会执行对应的动作,如果匹配不成功,则会执行默认动作
(default_action).
本文重点描述面向 P4 编程语言的 SDN 数据平面软件一致性测试用例生成方法进行综述.具体来说,通过
研究 SDN 架构、P4 程序的工作原理,我们发现表和动作是实现转发功能的核心部分:动作可以处理数据,定义
转发等动作;而表是匹配动作表(match-action tables)的简称,表会定义匹配字段(key)、匹配方式以及匹配成功后
执行的对应动作.本文生成测试用例的核心思想是:通过划分测试用例类型,获取 P4 目标网络设备控制命令集,
依据 P4 程序表和动作具体信息构造测试用例.本文设计并实现了自动生成批量测试用例的工具,并以装载 P4
程序的 simple_switch 虚拟交换机为测试对象说明测试用例的生成过程.
1 相关工作
本节介绍 SDN 体系架构、SDN 领域的 P4 编程语言介绍及相关研究和面向 OpenFlow 协议以及面向 P4
编程语言的一致性测试的相关研究.
1.1 SDN体系架构
[1]
SDN 是由美国斯坦福大学 Clean State 课题研究组提出的,是网络虚拟化的一种实现方式 . 2007 年,Casado