DPDK Sample Applications User Guides(11)IP Fragmentation样例应用程序

官方文档查看地址:
http://doc.dpdk.org/guides/sample_app_ug/ip_frag.html
PDF下载地址:
https://www.intel.com/content/www/us/en/embedded/technology/packet-processing/dpdk/dpdk-sample-applications-user-guide.html

本篇难度系数:
翻译:☆☆☆☆☆
理解:★★☆☆☆

11. IP分片样例应用程序
IPv4分片应用程序是使用数据平面开发工具包(DPDK)处理数据包的一个简单示例。应用程序使用IPv4和IPv6包分片进行L3转发。

11.1概述
该应用程序演示了使用零拷贝缓冲区来处理包碎片。初始化和运行时路径非常类似于L2转发样例应用程序的路径(在实际和虚拟环境中)。本指南强调了这两个应用程序之间的差异。

与L2转发示例应用程序有三个关键区别:

  • 第一个区别是IP碎片样例应用程序使用了间接缓冲区。
  • 第二个区别是转发决策是基于从输入包的IP头读取的信息做出的。
  • 第三个区别是应用程序通过卸载标志区分IP和非IP流量。

最长前缀匹配表(LPM用于IPv4, LPM6用于IPv6)用于存储/查找与该IP地址相关联的输出端口号。任何不匹配的包都被转发到原始端口。

默认情况下,支持高达9.5 KB的输入帧大小。在转发之前,输入的IP包被分割,以适应“标准”以太网* v2 MTU(1500字节)。

11.2编译应用程序
要编译示例应用程序,请参见编译示例应用程序 http://doc.dpdk.org/guides/sample_app_ug/compiling.html。

应用程序位于ip_fragment子目录中。

11.3运行应用程序
创建LPM对象,并加载从全局l3fwd_ipv4_route_arrayl3fwd_ipv6_route_array表中读取的预配置条目。对于每个输入包,都将包转发决策(即包的输出接口标识)作为LPM查找的结果。如果IP包的大小大于默认输出MTU,则输入包将被分割,并通过输出接口发送多个片段。

执行:

./build/ip_fragmentation [EAL options] -- -p PORTMASK [-q NQ]

地点:

  • -p PORTMASK端口掩码是要配置的端口的十六进制位掩码
  • -q NQ是每个lcore的队列数量(=端口)(默认为1)

要在linux环境中运行这个例子,每个lcore有2个lcore(2,4)和2个端口(0,2),每个lcore有一个RX队列:

./build/ip_fragmentation -l 2,4 -n 3 -- -p 5
EAL: coremask set to 14
EAL: Detected lcore 0 on socket 0
EAL: Detected lcore 1 on socket 1
EAL: Detected lcore 2 on socket 0
EAL: Detected lcore 3 on socket 1
EAL: Detected lcore 4 on socket 0
...

Initializing port 0 on lcore 2... Address:00:1B:21:76:FA:2C, rxq=0 txq=2,0 txq=4,1
done: Link Up - speed 10000 Mbps - full-duplex
Skipping disabled port 1
Initializing port 2 on lcore 4... Address:00:1B:21:5C:FF:54, rxq=0 txq=2,0 txq=4,1
done: Link Up - speed 10000 Mbps - full-duplex
Skipping disabled port 3IP_FRAG: Socket 0: adding route 100.10.0.0/16 (port 0)
IP_FRAG: Socket 0: adding route 100.20.0.0/16 (port 1)
...
IP_FRAG: Socket 0: adding route 0101:0101:0101:0101:0101:0101:0101:0101/48 (port 0)
IP_FRAG: Socket 0: adding route 0201:0101:0101:0101:0101:0101:0101:0101/48 (port 1)
...
IP_FRAG: entering main loop on lcore 4
IP_FRAG: -- lcoreid=4 portid=2
IP_FRAG: entering main loop on lcore 2
IP_FRAG: -- lcoreid=2 portid=0

要在linux环境中运行这个例子,每个lcore有1个lcore(4)和2个端口(0,2),每个lcore有2个RX队列:

./build/ip_fragmentation -l 4 -n 3 -- -p 5 -q 2

要测试应用程序,应该在流生成器中设置与l3fwd_ipv4_route_array和/或l3fwd_ipv6_route_array表中的值匹配的流。

  • 默认的l3fwd_ipv4_route_array表为:
struct l3fwd_ipv4_route l3fwd_ipv4_route_array[] = {
    {IPv4(100, 10, 0, 0), 16, 0},
    {IPv4(100, 20, 0, 0), 16, 1},
    {IPv4(100, 30, 0, 0), 16, 2},
    {IPv4(100, 40, 0, 0), 16, 3},
    {IPv4(100, 50, 0, 0), 16, 4},
    {IPv4(100, 60, 0, 0), 16, 5},
    {IPv4(100, 70, 0, 0), 16, 6},
    {IPv4(100, 80, 0, 0), 16, 7},
};
  • 默认的l3fwd_ipv6_route_array表为:
struct l3fwd_ipv6_route l3fwd_ipv6_route_array[] = {
    {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 0},
    {{2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 1},
    {{3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 2},
    {{4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 3},
    {{5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 4},
    {{6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 5},
    {{7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 6},
    {{8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 7},
};

例如,对于目标地址为100.10.1.1、包长度为9198字节的输入IPv4包,将有7个IPv4包从端口#0发送到目标地址100.10.1.1:其中6个包的长度为1500字节,一个包的长度为318字节。IP碎片样例应用程序提供了基本的NUMA支持,因为所有内存结构都分配在所有具有活动lcore的套接字上。

有关运行应用程序和环境抽象层(EAL)选项的一般信息,请参阅DPDK入门指南。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章