小言_互联网的博客

tcpreplay的使用

425人阅读  评论(0)

tcpreplay 可以很方便地重放pcap数据包,用于进行一些网络测试。但是 值得注意的是!tcpreplay是通过网卡的io函数,直接构造L2的网络数据包,因此tcpreplay重放过程中不会对会话的状态进行跟踪,例如重放过程中tcp的三次握手 其实并没有三次握手、而是tcpreplay故意sleep抓取的数据包那么的时间间隔。

Tcpreplay is designed to work with network hardware and normally does not penetrate deeper than Layer 2. Yazan Siam with sponsorship from Cisco developed tcpliveplay to replay TCP pcap files directly to servers. Use this utility if you want to test the entire network stack and into the application.

使用方法

安装

下载源码:

git clone https://github.com/appneta/tcpreplay

安装依赖包

sudo apt-get install build-essential libpcap-dev autoconf autogen libtool

安装tcpreplay:

cd tcprelpay
./autogen.sh
./configure
make
sudo make install

如果报libopt版本错误问题,在生成makefile文件的时候带上参数:

./configure --disable-local-libopt

使用

首先,在其他地方采集需要重放的pcap文件,假设得到的pcap为sample.pcap

执行:

sudo tcpreplay -t -v --intf1=ens33 sample.pcap 

其中-t 表示以最快的速度重放数据包,-v表示打印数据包细节,–intf1指定使用那一个网卡发送数据包,最后跟所需重放的pcap.


转载:https://blog.csdn.net/jmh1996/article/details/101053123
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场