Pktgen 命令行参数

来源:互联网 发布:linux epoll wait 编辑:程序博客网 时间:2024/06/06 13:16
Pktgen 命令行参数

The Pktgen commandline usage is:
./app/app/``$(target}``/pktgen [EAL options] -- \
                             [-h] [-P] [-G] [-T] [-f cmd_file] \
                             [-l log_file] [-s P:PCAP_file] [-m <string>]



Usage: ./app/app/x86_64-dnet-linuxapp-gcc/pktgen [EAL options] –- [-h] [-P] [-G] [-T] [-f cmd_file] [-l log_file] [-s P:PCAP_file] [-m <string>]

-h: Display the usage/help information shown above
-s P:file: The PCAP packet file to stream. P is the port number.
-f filename: The script command file (.pkt) to execute or a Lua script (.lua) file. See Running Script Files.
-l filename: The filename to write a log to.
-P: Enable PROMISCUOUS mode on all ports.
-G: Enable socket support using default server values of localhost:0x5606. See Socket Support for Pktgen.
-g address: Same as -G but with an optional IP address and port number. See Socket Support for Pktgen.
-T: Enable color terminal output in VT100
-N: Enable NUMA support.
-m <string>: Matrix for mapping ports to logical cores.
--crc-strip    Strip CRC on all ports


________________________________________________________________________________________________________________
关键参数介绍
-s  : 如果你想用pktgen发送pcap文件
[-s P:PCAP_file]  -s 0 : 1.pcap     0表示在第0个网卡,1.pcap及文件名

-f  : 在运行pktgen时可以运行指定的脚步文件,进行初始化配置

-P  : 启动所有网卡,并进入混杂模式,想指定特定网卡 用 -p mask

-G  : 让pktgen成为服务器,之后后可以进行远程控制 默认是 localhost:0x5606

-g  : 让pktgen成为服务器,之后后可以进行远程控制 可以进行IP和端口的设置

-m  : 指定lcore和port的映射关系

________________________________________________________________________________________________________________

-m 选项介绍

defined with a BNF-like grammar as follows:
BNF: (or kind of BNF)
<matrix-string>   := """ <lcore-port> { "," <lcore-port>} """
<lcore-port>      := <lcore-list> "." <port-list>
<lcore-list>      := "[" <rx-list> ":" <tx-list> "]"
<port-list>       := "[" <rx-list> ":" <tx-list>"]"
<rx-list>         := <num> { "/" (<num> | <list>) }
<tx-list>         := <num> { "/" (<num> | <list>) }
<list>            := <num> { "/" (<range> | <list>) }
<range>           := <num> "-" <num> { "/" <range> }
<num>             := <digit>+
<digit>           := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

MD,毛都看懂,还是来看看例子吧:
1.0, 2.1, 3.2                 - core 1 handles port 0 rx/tx,
                                core 2 handles port 1 rx/tx
                                core 3 handles port 2 rx/tx
1.[0-2], 2.3, ...             - core 1 handle ports 0,1,2 rx/tx,
                                core 2 handle port 3 rx/tx
[0-1].0, [2/4-5].1, ...       - cores 0-1 handle port 0 rx/tx,
                                cores 2,4,5 handle port 1 rx/tx
[1:2].0, [4:6].1, ...         - core 1 handles port 0 rx,
                                core 2 handles port 0 tx,
[1:2].[0-1], [4:6].[2/3], ... - core 1 handles port 0 & 1 rx,
                                core 2 handles port  0 & 1 tx
[1:2-3].0, [4:5-6].1, ...     - core 1 handles port 0 rx, cores 2,3 handle port 0 tx
                                core 4 handles port 1 rx & core 5,6 handles port 1 tx
[1-2:3].0, [4-5:6].1, ...     - core 1,2 handles port 0 rx, core 3 handles port 0 tx
                                core 4,5 handles port 1 rx & core 6 handles port 1 tx
[1-2:3-5].0, [4-5:6/8].1, ... - core 1,2 handles port 0 rx, core 3,4,5 handles port 0 tx
                                core 4,5 handles port 1 rx & core 6,8 handles port 1 tx
[1:2].[0:0-7], [3:4].[1:0-7], - core 1 handles port 0 rx, core 2 handles ports 0-7 tx
                                core 3 handles port 1 rx & core 4 handles port 0-7 tx
BTW: you can use "{}" instead of "[]" as it does not matter to the syntax.

总结:
在 -m 选项时
. 表示lcore和port的分割
- 表示范围
/ 表示关系 或
: 前面表示读,后面表示写

随笔挑一个来解释
[1:2].[0-1], [4:6].[2/3]
lcore=1 进行 0-1 的 Rx
lcore=2 进行 0-1 的 Tx
lcore=4 进行 2和3 的 Rx
lcore=6 进行 2和3 的 Tx

此处有点问题,[lcore].[port]
lcore 可以指定为 不存在的 -l 0-4  你可以把lcore搞成 10
port  就不能了
________________________________________________________________________________________________________________

到此,Pktgen能够运行,而且能够根据需要指定其运行参数 EAL option 和 Pktgen Option
MD, 老子是研发啊,怎么搞得像翻译了,我都有去开翻译公司的冲动了,专注于翻译软件文档
之后把之前看过的文档全搞起来。不过就我这二调子,水得一比,还不如驴得水,自己看看还行

_______________________________________________________________________________________________________________