tcpreplay的安装使用

2023-05-16

转自:https://www.cnblogs.com/zlslch/p/7325599.html?utm_source=itdadao&utm_medium=referral

tcpreplay是什么?

  简单的说, tcpreplay是一种pcap包的重放工具, 它可以将用ethreal, wireshark工具抓下来的包原样或经过任意修改后重放回去. 它允许你对报文做任意的修改(主要是指对2层, 3层, 4层报文头), 指定重放报文的速度等, 这样tcpreplay就可以用来复现抓包的情景以定位bug, 以极快的速度重放从而实现压力测试。
  tcpreplay本身包含了几个辅助工具(tcpprep、tcprewrite、tcpreplay和tcpbridge), 用于准备发包的cache, 重写报文等。这也是 Tcpreplay 的第一个字母大写T的原因 。

      * tcpprep - 简单的说就是划分哪些包是client的, 哪些是server的, 一会发包的时候client的包从一个网卡发, server的包可能从另一个网卡发。

        即区分pcap数据包的流向,即区分出客户端和服务器。
      * tcprewrite - 简单的说就是修改2层, 3层, 4层报文头部。

        即改写pcap数据包的2-4层的头部信息,即MAC地址、IP地址和PORT等。
      * tcpreplay - 真正发包, 可以选择主、从网卡, 发包速度等。

        即回放pcap文件中的数据包。

   * tcpreplay-edit-更写pcap数据并回放,将tcprewrite和tcpreplat一条命令实现。
      * tcpbridge - bridge two network segments with the power of tcprewrite。

    

 

   以下是官网的原文。

The Tcpreplay suite includes the following tools:

  • tcpprep - multi-pass pcap file pre-processor which determines packets as client or server and creates cache files used by tcpreplay and tcprewrite
  • tcprewrite - pcap file editor which rewrites TCP/IP and Layer 2 packet headers
  • tcpreplay - replays pcap files at arbitrary speeds onto the network
  • tcpliveplay - Replays network traffic stored in a pcap file on live networks using new TCP connections
  • tcpreplay-edit - replays & edits pcap files at arbitrary speeds onto the network
  • tcpbridge - bridge two network segments with the power of tcprewrite
  • tcpcapinfo - raw pcap file decoder and debugger

 

 

  官网


http://tcpreplay.synfin.net/  

 

 

 

 

 

 

 

 

  在CentOS里安装tcpreplay,总的来说,有如下两种安装方法。

 

  第一种安装方法:(推荐)

  直接yum -y install tcpreplay即可。


[root@datatest ~]# yum -y install tcpreplay  

 

 

 

复制代码


[root@datatest ~]# tcpreplay -V
tcpreplay version: 4.2.5 (build git:v4.2.5)
Copyright 2013-2017 by Fred Klassen <tcpreplay at appneta dot com> - AppNeta
Copyright 2000-2012 by Aaron Turner <aturner at synfin dot net>
The entire Tcpreplay Suite is licensed under the GPLv3
Cache file supported: 04
Not compiled with libdnet.
Compiled against libpcap: 1.4.0
64 bit packet counters: enabled
Verbose printing via tcpdump: enabled
Packet editing: disabled
Fragroute engine: disabled
Injection method: PF_PACKET send()
Not compiled with netmap
[root@datatest ~]#   

复制代码

 

 

 

 

 

  第二种安装方法:

在Centos中安装TCPReplay

 

 

 

 

Tcpreplay的初步使用

  1、查看Tcpreplay里的tcpreplay的帮助文档命令

复制代码


[root@datatest ~]# tcpreplay -h
tcpreplay (tcpreplay) - Replay network traffic stored in pcap files
Usage:  tcpreplay [ -<flag> [<val>] | --<name>[{=| }<val>] ]... <pcap_file(s)>

   -q, --quiet                Quiet mode
安静模式

  -a
精确的时间(使用高速 cpu 发包)
  
  -d
输出调试信息(0-5,默认 0)


   -T, --timer=str            Select packet timing mode: select, ioport, gtod, nano
       --maxsleep=num         Sleep for no more then X milliseconds between packets
   -v, --verbose              Print decoded packets via tcpdump to STDOUT
可选参数,每发送一个报文都以 tcpdump 风格打印对应信息



   -A, --decode=str           Arguments passed to tcpdump decoder
可选参数,在使用 tcpdump 风格打印输出信息时,同时再调用 tcpdump 中的参数


   -K, --preload-pcap         Preloads packets into RAM before sending

  -c
双网卡回放报文必选参数,后跟文件名


   -C, --cachefile=str        Split traffic via a tcpprep cache file
把报文存在内部缓存中

  -N 
获得网络接口和出口


   -2, --dualfile             Replay two files at a time from a network tap
   -i, --intf1=str            Client to server/RX/primary traffic output interface  

双网卡回放报文必选参数,指定从接口
  

  -I, --intf2=str Server to client/TX/secondary traffic output interface
      --listnics List available network interfaces and exit
  

双网卡回放报文必选参数,指定主接口

  

  -l, --loop=num Loop through the capture file X times
      --loopdelay-ms=num Delay between loops in milliseconds 
     --pktlen Override the snaplen and use the actual packet len
可选参数,指定循环次数

  -S
制定包长度




   -L, --limit=num            Limit the number of packets to send
       --duration=num         Limit the number of seconds to send
限制发包数量


  


   -x, --multiplier=str       Modify replay speed to a given multiple
   -p, --pps=str              Replay packets at a given packets/sec
可选参数,指定每秒发送报文的个数。制定该参数,其他速率相关的参数被忽略,
打印信息不会有速率和每秒发送报文的统计


   -M, --mbps=str             Replay packets at a given Mbps
以 Mbps(兆字节每秒)发送报文

  -m
可选参数,指定一个倍数值,比默认发送速度快多少倍发送报文


   -t, --topspeed             Replay packets as fast as possible
以最快的速度回放报文



   -o, --oneatatime           Replay one packet at a time for each user input
       --pps-multi=num        Number of packets to send for each time interval
       --unique-ip            Modify IP addresses each loop iteration to generate unique flows
       --unique-ip-loops=str  Number of times to loop before assigning new unique ip
       --no-flow-stats        Suppress printing and tracking flow count, rates and expirations
       --flow-expiry=num      Number of inactive seconds before a flow is considered expired
一次回放一个报文


   -P, --pid                  Print the PID of tcpreplay at startup
       --stats=num            Print statistics every X seconds, or every loop if '0'
可选参数,表示在输出信息中打印 PID 信息,用于单用户和单账户模式下暂停和重
启程序


   -V, --version              Print version information
现实版本号


   -h, --less-help            Display less usage information and exit
   -H, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager
       --save-opts[=arg]      save the option state to a config file
       --load-opts=str        load options from a config file

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
tcpreplay is a tool for replaying network traffic from files saved with
tcpdump or other tools which write pcap(3) files.

Please send bug reports to:  <tcpreplay-users@lists.sourceforge.net>
[root@datatest ~]#   

复制代码

 

  Tcpreplay 根据 cach 文件来回放 pcap 文件中的数据。

 

 

   tcpreplay小例子


[root@datatest ~]#  tcpreplay --intf1=eth1 --intf2=eth0 –t --cachfile=cach_test.cach http_rewrite_pcap  

  

  --intf1=eth1 是指主接口是 eth1, 服务器-> 客户端的数据包通过这个接口发送。

      服务器和客户端的区分是从 tcpprep 的处理结果 cach_test.cach 中得到的。
  --intf2=eth0 是指从接口是 eth0,客户端->服务器的数据包通过这个接口发送。
  --cachfile=cach_test_cach 是指 tcpreplay 用 下面的tcpprep 的处理结果--cach_test.cach 来区分方向。
  http_rewrite.pcap 是指 tcpreplay 发送的是来自 http_rewrite.pcap 这个文件中的数据包 。

 


[root@datatest ~]#  tcpreplay –i eth1 –I eth0 –c ceshiftp.cach ceshiftp.pcap  

   -i, --intf1这是数据重放的时候,的从接口。     -I, --intf2这是数据重放的时候,的主接口。  –c是双网卡回放报文必选参数,后跟文件名

 

 

 

  在linux下, 用ifconfig命令可以获得接口的名字。

  但在cygwin下必须用下面的命令获得接口的名字。
  在cygwin下获得接口的名字:


$ tcpreplay --listnics  

 

  假设在windows下的cygwin里安装的tcpreplay

复制代码


$ tcpreplay --listnics
|Available network interfaces:
|Alias   Name    Description
|%0      \Device\NPF_GenericDialupAdapter
|        Adapter for generic dialup and VPN capture
|%1      \Device\NPF_{6B508B29-B3E3-4D0B-892F-02914AC9A668}
|    Intel(R) 82566DM Gigabit Network Connection (Microsoft's Packet
|    Scheduler)
|%2      \Device\NPF_{CBCE38CA-1FAD-4AEB-89DF-FD2D8EF861FA}
|    D-Link DFE-530TX PCI Fast Ethernet Adapter (rev.C)
|    (Microsoft's Packet Scheduler)
|%3      \Device\NPF_{ABB813FE-3C51-49A3-8146-16CD2C4507C3}
|    D-Link DFE-530TX PCI Fast Ethernet Adapter (rev.C)
|    (Microsoft's Packet Scheduler)  

复制代码

 

 

   从中可以看出这台机器有两块网卡, 一块叫做%1, 另一块叫做%2. 下面就可以指定网卡重发包了:
  用tcpreplay发包:


[root@datatest ~]#  tcpreplay -c mgcp.cach -i %1 -I %2 out.pcap  

   这条命令是把out.pcap包, 按照mgcp.cach里划分的主机包和客户端包的方式, 将主机包从网卡%1发出去, 将客户端包从网卡%2发出去.
 

  注:修改目的IP的MAC地址的时候,MAC地址不是目的机网卡物理地址,而是源机器所连接的交换机MAC地址。

 

 

 

 

 

 

 

2、查看Tcpreplay里的tcprewrite的帮助文档命令

 

复制代码


[root@datatest ~]# tcprewrite -h
tcprewrite (tcprewrite) - Rewrite the packets in a pcap file.
Usage:  tcprewrite [ -<flag> [<val>] | --<name>[{=| }<val>] ]...

   -r, --portmap=str          Rewrite TCP/UDP ports
重写 tcp/udp 端口


   -s, --seed=num             Randomize src/dst IPv4/v6 addresses w/ given seed
随机改写 IP 地址


   -N, --pnat=str             Rewrite IPv4/v6 addresses using pseudo-NAT
通过伪 NAT 重写 ip 地址


   -S, --srcipmap=str         Rewrite source IPv4/v6 addresses using pseudo-NAT



   -D, --dstipmap=str         Rewrite destination IPv4/v6 addresses using pseudo-NAT
   -e, --endpoints=str        Rewrite IP addresses to be between two endpoints
  

在最后 2 个点之间重写 ip 地址  

   -b, --skipbroadcast        Skip rewriting broadcast/multicast IPv4/v6 addresses
不重写广播/多播 IP 地址


   -C, --fixcsum              Force recalculation of IPv4/TCP/UDP header checksums
强制重新计算 TP/RCP/UDP 校验和



   -m, --mtu=num              Override default MTU length (1500 bytes)
       --mtu-trunc            Truncate packets larger then specified MTU
指定 MTU



   -E, --efcs                 Remove Ethernet checksums (FCS) from end of frames
       --ttl=str              Modify the IPv4/v6 TTL/Hop Limit
       --tos=num              Set the IPv4 TOS/DiffServ/ECN byte
       --tclass=num           Set the IPv6 Traffic Class byte
       --flowlabel=num        Set the IPv6 Flow Label
删除以太网最后一帧的校验和(删除最后 2 个字节)




   -F, --fixlen=str           Pad or truncate packet data to match header length
       --fuzz-seed=num        Fuzz 1 in X packets.  Edit bytes, length, or emulate packet drop
       --fuzz-factor=num      Set the Fuzz 1 in X packet ratio (default 1 in 8 packets)
       --skipl2broadcast      Skip rewriting broadcast/multicast Layer 2 addresses
       --dlt=str              Override output DLT encapsulation
       --enet-dmac=str        Override destination ethernet MAC addresses
       --enet-smac=str        Override source ethernet MAC addresses
       --enet-subsmac=str     Substitute MAC addresses
       --enet-mac-seed=num    Randomize MAC addresses
       --enet-mac-seed-keep-bytes=num Randomize MAC addresses
       --enet-vlan=str        Specify ethernet 802.1q VLAN tag mode
       --enet-vlan-tag=num    Specify the new ethernet 802.1q VLAN tag value
       --enet-vlan-cfi=num    Specify the ethernet 802.1q VLAN CFI value
       --enet-vlan-pri=num    Specify the ethernet 802.1q VLAN priority
       --hdlc-control=num     Specify HDLC control value
       --hdlc-address=num     Specify HDLC address
       --user-dlt=num         Set output file DLT type
       --user-dlink=str       Rewrite Data-Link layer with user specified data

填充或截取包的数据以匹配包头长度



   -i, --infile=str           Input pcap file to be processed
处理输出 pcap 文件



   -o, --outfile=str          Output pcap file
输出 pcap 文件



   -c, --cachefile=str        Split traffic via tcpprep cache file
使用 tcpprep cach 文件分离流量





   -v, --verbose              Print decoded packets via tcpdump to STDOUT
tcpdump 风格打印对应信息




   -A, --decode=str           Arguments passed to tcpdump decoder
       --skip-soft-errors     Skip writing packets with soft errors
可选参数,在使用 tcpdump 风格输出信息时,同时再调用 tcpdump 中的参数





   -V, --version              Print version information
显示版本号





   -h, --less-help            Display less usage information and exit
   -H, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager
       --save-opts[=arg]      save the option state to a config file
       --load-opts=str        load options from a config file

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.

Please send bug reports to:  <tcpreplay-users@lists.sourceforge.net>
[root@datatest ~]#   

复制代码

 

   简单地说, tcprewrite 就是改写 pcap 包里的报文头部, 包括 2 层, 3 层, 4 层,即 MAC 地址、IP 地址和PORT 等。tcpreplay 只保证能把包送出去, 至于包真正能到达的地址, 我认为还是根据原来的包的 IP 和 mac,

如果是在同一网段,可能需要把 mac 地址改成测试设备的 mac,如果需要经过网关, 就得将 IP 地址改为测试设备的 IP 以及端口号 。

 

 

  tcpreplay只保证能把包送出去, 至于包真正能到达的地址, 我认为还是根据原来的包的IP和mac. 如果是在同一网段, 可能需要把mac地址改成测试设备的mac, 如果需要经过网关, 就得将IP地址改为测试设备的IP以及端口号。
  tcprewrite的基本格式是(请注意命令中是没有换行符的, 只为了阅读的方便添加了换行符): 详请可以用tcprewrite ?命令查询详情。


[root@datatest ~]#   tcprewrite --enet-smac=host_src_mac,client_src_mac   \
              --enet-dmac=host_dst_mac, client_dst_mac \
              --endpoints=host_dst_ip:client_dst_ip    \
              --portmap=old_port1:new_port1,old_port2, new_port2 \
|             -i input.pcap -c input.cach -o out.pcap  

  解释一下:

  该命令的输入参数是input.pcap和input.cach文件, 结果将另存为out.pcap文件。

  该命令将所有input.pcap包里的主机包(由input.cach文件指定哪些包是主机包, 哪些包是客户端包)的源mac地址, 目的mac地址。

   目的IP地址分别改为 :host_src_mac,host_dst_mac和host_dst_ip。

  客户端包源mac地址, 目的mac地址。

  目的IP地址分别改为 :client_src_mac, client_dst_mac和client_dst_ip。

  将端口号由old_port1改为 new_port1, 将端口号由old_port2改为new_port2。
 

 

 


 

 

 

 

 




  举个小例子


[root@datatest ~]# tcprewrite --enet-smac=11:22:22:22:22:22,22:22:22:22:22:22  \
--enet-dmac=FF:FF:FF:FF:FF:FF   \
--endpoints=192.168.0.1:192.168.0.11    \
--portmap=5070:5061,9060:5060    \
-i success.pcap -o out.pcap -c success.cach  

  该命令将修改后的包的

  主机端的二层, 三层, 四层头分别为: 11:22:22:22:22:22,192.168.0.1,5061,

  客户端包的二层, 三层, 四层头分别为: 22:22:22:22:22:22,192.168.0.11, 5060。
 

 

 

 


[root@datatest ~]#  tcprewrite --seed=6 -i success.pcap -o out.pcap -c success.cach  

  该命令将根据数字 6 按特征算法生成一个新的 server_ip 和 client_ip。

 

 

 

 


[root@datatest ~]#  tcprewrite --pmap=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24    \
-i success.pcap -o out.pcap -c success.cach  

  该命令将把主机端和客户端 192.168.0.0/16、172.16.0.0/12 网段的 ip 地址分别改为 10.77.0.0/16、10.1.0.0/24。
 

 

 


[root@datatest ~]#   tcprewrite --srcipmap=192.168.0.0/16:10.77.0.0/16   \
-i success.pcap -o out.pcap -c success.cach  

  该命令将把主机端和客户端的源 ip 为 192.168.0.0/16 网段改为 10.77.0.0/16 网段

 

 

 


[root@datatest ~]#   tcprewrite --dstipmap=172.16.0.0/12:10.1.0.0/24
-i success.pcap -o out.pcap -c success.cach  

  该命令将把主机端和客户端的目的 ip 为 192.168.0.0/16 网段改为 10.77.0.0/16 网段。

 

 

 

   修改2层头

    1) 修改MAC地址
    如果不指定cache文件, 将把所有包的源mac地址和目的mac地址都改写成00:44:66:FC:29:AF和00:55:22:AF:C6:37:


[root@datatest ~]#  tcprewrite --enet-dmac=00:55:22:AF:C6:37 --enet-smac=00:44:66:FC:29:AF --infile=input.pcap --outfile=output.pcap  

 

  指定cache文件后, 将server包的目的/源mac地址改写成00:44:66:FC:29:AF/00:66:AA:D1:32:C2,

          将client的目的/源mac地址改成:00:55:22:AF:C6:37/00:22:55:AC:DE:AC, 注意是server地址在前.


[root@datatest ~]#  tcprewrite --enet-dmac=00:44:66:FC:29:AF,00:55:22:AF:C6:37 --enet-smac=00:66:AA:D1:32:C2,00:22:55:AC:DE:AC --cachefile=input.cache --infile=input.pcap --outfile=output.pcap  

 


 

  2) 修改802.1q VLAN
  经常客户的抓包带有VLAN头域, 这些包如果不去掉VLAN头是没有办法在自己的交换机上replay的, tcprewrite提了去掉或添加VLAN的方法:
    去掉vlan很简单:


[root@datatest ~]#  tcprewrite --enet-vlan=del --infile=input.pcap --outfile=output.pcap  

  

  添加vlan也很简单, 下面的命令将VLAN tag设成40, CFI设成1, VLAN priority设成4.


[root@datatest ~]#  tcprewrite --enet-vlan=add --enet-vlan-tag=40 --enet-vlan-cfi=1 --enet-vlan-pri=4 --infile=input.pcap --outfile=output.pcap  

 

 

  3) 修改二层协议名:
  好像是将Ethernet协议头转成Cisco HDLC或其它二层协议? 这部分没有真正用过, 需要的
人自行参考tcpreplay官方网站: http://tcpreplay.synfin.net/wiki/manual

 

 

 

   修改3层头
  从版本3.4.2开始, tcprewrite开始支持ipv6协议, tcpreplay升级蛮快。 tcprewrite修改IP地址后会自动帮你计算校验和, 这点还是蛮周到的。

  命令行传入IPv6地址的时候要使用方括号, 例如: [2001::dead:beef]或[2001::/16]


  1) 修改目的IP
  根据cache文件里的标识, 将server的IP改为10.10.1.1, client的IP改为10.10.1.2:


[root@datatest ~]#  tcprewrite --endpoints=10.10.1.1:10.10.1.2 --cachefile=input.cache --infile=input.pcap --outfile=output.pcap --skipbroadcast  

 


  2)修改IP地址的网络部分
    注: 2)和3)没有验证过。

    众所周知, IP地址同网络部分和主机部分组成, 下面的命令可以将子网地址为10.0.0.0/8或192.168.0.0/16的IP改成子网为172.16.0.0/12:


[root@datatest ~]#  tcprewrite --pnat=10.0.0.0/8:172.16.0.0/12,192.168.0.0/16:172.16.0.0/12 --infile=input.pcap --outfile=output.pcap --skipbroadcast  

 

  下面的命令是基于client包或server包修改子网地址:


[root@datatest ~]#   tcprewrite --pnat=10.0.0.0/8:192.168.0.0/24 --pnat=10.0.0.0/8:192.168.1.0/24 --cachefile=input.cache --infile=input.pcap --outfile=output.pcap --skipbroadcast  

 

 

  3) 修改IP头的其它部分:
  

  修改IPv4头的TOS为50


[root@datatest ~]#  tcprewrite --tos=50 --infile=input.pcap --outfile=output.pcap  

 

  将IPv6头Traffic Class值改为33


[root@datatest ~]#  tcprewrite --tclass=33 --infile=input.pcap --outfile=output.pcap  

 

 

  修改Flow Label field:


[root@datatest ~]#  tcprewrite --flowlabel=67234 --infile=input.pcap --outfile=output.pcap  

 

 

 

 修改4层头
  和修改IP头一样, 修改4层头的时候tcpwrite会自动计算校验和, 这个就不需要担心了.

 

  1) 修改端口号
    将80端口号改为8080, 22改为8022:


[root@datatest ~]#  tcprewrite --portmap=80:8080,22:8022 --infile=input.pcap --outfile=output.pcap  

 

  2) 强制计算传输层校验和:
  有些应用可能不计算传输层的校验和, 可以让tcpwrite强制计算一下:


[root@datatest ~]#  tcprewrite --fixcsum --infile=input.pcap --outfile=output.pcap  

 

 

  修改5-7层数据
  tcpwrite对5-7层的修改非常有限, 顶多也就是抓包没有抓全, 中间的应用层数据丢了。tcpwrite将没有抓到的数据补成全0, 或者修改tcp/udp的长度字节, 或者将该包丢弃. 有需要的直接参考官方资料吧。

 

 

 

 

 

 

 

 

3、查看Tcpreplay里的tcpprep的帮助文档命令

 

复制代码


[root@datatest ~]# tcpprep -h
tcpprep (tcpprep) - Create a tcpreplay cache cache file from a pcap file.
Usage:  tcpprep [ -<flag> [<val>] | --<name>[{=| }<val>] ]...

   -a, --auto=str             Auto-split mode
一般情况下都需要的参数,表示按模式自动分离通信流量生成 cach 文件 

   -c, --cidr=str             CIDR-split mode
可选参数, 表示分离流量时采用 CIDR(无类别域间路由选择,是一个在 internet
上创建附加地址的方法,这些地址提供给服务提供商,再由服务提供商分配给客户。
CIDR 将路由集中起来,使一个 IP 地址代表主要骨干提供商提供的几千个 IP 地址,
从而减轻 internet 路由器的负担) 

   -r, --regex=str            Regex-split mode
可选参数,表示使用 regex 模式分离通信流量,有点类似于 CIDR 模式,但是它匹
配的是服务器源 IP 

   -p, --port                 Port-split mode
可选参数,基于目的端口来分离通信流量,它区分的依据是任何 0-1023 端口都是
服务器的端发出的报文,其他的端口都是客户端发出的报文 

   -e, --mac=str              Source MAC split mode
表示基于服务器源 MAC 地址分离通信流量 

       --reverse              Matches to be client instead of server

   -C, --comment=str          Embedded cache file comment
可选参数,表示在 cach 文件中嵌入注释内容,用于注释说明 cach 文件的内容。使用位置不要放在最后,生成 cach 后可以使用-P 查看写入的内容。


       --no-arg-comment       Do not embed any cache file comment
   -x, --include=str          Include only packets matching rule
重要可选参数,表示按照参数定义的需求来定义发送报文

   -X, --exclude=str          Exclude any packet matching this rule
可选参数,是-x 的取反

   -o, --cachefile=str        Output cache file
  

   生成 cach 文件必带参数,后跟 cach 后缀的文件名,表示这个输出的 cach 文
件以这个文件名命名


-i, --pcap=str             Input pcap file to process  

  生成 cach 文件必带参数,后跟 pcap 文件名,表示这个 pcap 文件需要处理


-P, --print-comment=str    Print embedded comment in the specified cache file
可选参数,表示查看 cach 文件的内容

   -I, --print-info=str       Print basic info from the specified cache file
表示打印 cach 文件的基本信息


   -S, --print-stats=str      Print statistical information about the specified cache file
表示打印 cach 文件的统计信

   -s, --services=str         Load services file for server ports  

  表示从服务器端口下载服务文件


-N, --nonip                Send non-IP traffic out server interface
表示从服务器端口发送无 IP 流量


   -R, --ratio=str            Ratio of client to server packets
  

  可选参数,一个比例值。服务器端发起的连接数和客户端发起的连接数的比例,值
大于 2 就视为服务器端


-m, --minmask=num          Minimum network mask length in auto mode
可选参数,在选用 router 模式时使用,表示最小掩码,掩码默认是 30


   -M, --maxmask=num          Maximum network mask length in auto mode
可选参数,在选用 router 模式时使用,表示最大掩码,默认是 8


   -v, --verbose              Print decoded packets via tcpdump to STDOUT
可选参数,显示 tcpprep 生成 cach 文件的处理过程。信息的随时大于


   -A, --decode=str           Arguments passed to tcpdump decoder
可选参数,在实验 tcpdump 风格打印输出信息时,同时再调用 tcpdump 中的参数


   -V, --version              Print version information
   -h, --less-help            Display less usage information and exit
   -H, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager
       --save-opts[=arg]      save the option state to a config file
       --load-opts=str        load options from a config file
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
tcpprep is a 'pcap(3)' file pre-processor which creates a cache file which
provides "rules" for 'tcprewrite(1)' and 'tcpreplay(1)' on how to process
and send packets.

Please send bug reports to:  <tcpreplay-users@lists.sourceforge.net>
[root@datatest ~]#   

复制代码

 

 

   tcpprep 是一个在 tcprewrite 和 tcpreplay 之前使用的 pcap 文件的处理程序。使用 tcpprep 的目的就是建立一个 cach 文件,用于分离通信流量中的两方(通常叫做 主要的/次要的 或者 客户端/服务器),为 tcprewrite 和 tcpreplay 处理与发送报文做准备。

  如果你正打算在两块网卡上使用 tcpreplay 的话,那么 tcpprep 就是用来决定每一个报文(packet)从哪一个接口发出。通过使用这样一个分离的程序来建立一个 cach 文件,tcpreplay 就可以根据这个 cach 文件通过自身的计算来分离流量,高速率的发送报文。cach 文件的作用主要是加速报文的发送,cach 文件中存放着 pcap 文件中每个帧的编号和时间戳等信息,以达到 tcpreplay 回放时可以更加快速的发送报文的目的。 

  举个例子, 如果你用 wireshark 或者ethereal抓了一个 pcap 文件,里面可能既有 A 地址发给 B 地址的包,也有 B地址发给 A 址的包,用 tcpprep 工具可以指定从 A 到 B 的包从主网卡发出, 从 B 到 A 的包从次网卡发出。 
 


  
  tcpprep 用法举例 
1、根据报文源 IP 确定 client/server 报文


[root@datatest ~]#  tcpprep -c 172.22.64.2/24 -i mgcp.pcap -o mgcp.cach   

  上面的命令指定所有源 IP 为 172.22.64.2/24 的包, 都将从主网卡发出, 其它的从次网卡发出 。输入文件是mgcp.pcap, 输出文件为mgcp.cach。

 

2、使用自动模式确定 client/server 报文 


 [root@datatest ~]#  tcpprep -a client -i mgcp.pcap -o mgcp.cach  

  上面的命令采用自动/client 模式指定分包模式。

  自动模式这里按我的理解解释一下:
  tcpprep 在自动模式下认为有下面行为的 IP 为 client 端:

    1、发 TCP SYN 包的一方

    2、发 DNS 包的一方

    3、 收入到 ICMP-Port Unreachable 的一方;

      认为有下面行为的一方为 server 端:

    1、发 TCPSyn/Ack 的一方

    2、发 DNS 应答的一方

    3、发 ICMP-Port Unreachable 的一方

  而被认定为 server 的那一方发的那些包, 将从主网卡发出, 被认定为 client 的包则从次网卡发出. 而自动/client 模式将所有没有认出的包都归为 client, 同理自动/server 模式将没有认出的包都归为 server.这种模式貌似不如按 IP 地址分类的方式好用 。

 

 



 

 

 


  

 

 

 

 

 

 

 

 

 

 

 

 

4、查看Tcpreplay里的tcpreplay-edit的帮助文档命令

 

复制代码


[root@datatest ~]# tcpreplay-edit -h
tcpreplay (tcpreplay) - Replay network traffic stored in pcap files
Usage:  tcpreplay-edit [ -<flag> [<val>] | --<name>[{=| }<val>] ]... <pcap_file(s)>

   -r, --portmap=str          Rewrite TCP/UDP ports
   -s, --seed=num             Randomize src/dst IPv4/v6 addresses w/ given seed
   -N, --pnat=str             Rewrite IPv4/v6 addresses using pseudo-NAT
   -S, --srcipmap=str         Rewrite source IPv4/v6 addresses using pseudo-NAT
   -D, --dstipmap=str         Rewrite destination IPv4/v6 addresses using pseudo-NAT
   -e, --endpoints=str        Rewrite IP addresses to be between two endpoints
   -b, --skipbroadcast        Skip rewriting broadcast/multicast IPv4/v6 addresses
   -C, --fixcsum              Force recalculation of IPv4/TCP/UDP header checksums
   -m, --mtu=num              Override default MTU length (1500 bytes)
       --mtu-trunc            Truncate packets larger then specified MTU
   -E, --efcs                 Remove Ethernet checksums (FCS) from end of frames
       --ttl=str              Modify the IPv4/v6 TTL/Hop Limit
       --tos=num              Set the IPv4 TOS/DiffServ/ECN byte
       --tclass=num           Set the IPv6 Traffic Class byte
       --flowlabel=num        Set the IPv6 Flow Label
   -F, --fixlen=str           Pad or truncate packet data to match header length
       --fuzz-seed=num        Fuzz 1 in X packets.  Edit bytes, length, or emulate packet drop
       --fuzz-factor=num      Set the Fuzz 1 in X packet ratio (default 1 in 8 packets)
       --skipl2broadcast      Skip rewriting broadcast/multicast Layer 2 addresses
       --dlt=str              Override output DLT encapsulation
       --enet-dmac=str        Override destination ethernet MAC addresses
       --enet-smac=str        Override source ethernet MAC addresses
       --enet-subsmac=str     Substitute MAC addresses
       --enet-mac-seed=num    Randomize MAC addresses
       --enet-mac-seed-keep-bytes=num Randomize MAC addresses
       --enet-vlan=str        Specify ethernet 802.1q VLAN tag mode
       --enet-vlan-tag=num    Specify the new ethernet 802.1q VLAN tag value
       --enet-vlan-cfi=num    Specify the ethernet 802.1q VLAN CFI value
       --enet-vlan-pri=num    Specify the ethernet 802.1q VLAN priority
       --hdlc-control=num     Specify HDLC control value
       --hdlc-address=num     Specify HDLC address
       --user-dlt=num         Set output file DLT type
       --user-dlink=str       Rewrite Data-Link layer with user specified data
   -q, --quiet                Quiet mode
   -T, --timer=str            Select packet timing mode: select, ioport, gtod, nano
       --maxsleep=num         Sleep for no more then X milliseconds between packets
   -v, --verbose              Print decoded packets via tcpdump to STDOUT
   -A, --decode=str           Arguments passed to tcpdump decoder
   -K, --preload-pcap         Preloads packets into RAM before sending
   -c, --cachefile=str        Split traffic via a tcpprep cache file
   -2, --dualfile             Replay two files at a time from a network tap
   -i, --intf1=str            Client to server/RX/primary traffic output interface
   -I, --intf2=str            Server to client/TX/secondary traffic output interface
       --listnics             List available network interfaces and exit
   -l, --loop=num             Loop through the capture file X times
       --loopdelay-ms=num     Delay between loops in milliseconds
       --pktlen               Override the snaplen and use the actual packet len
   -L, --limit=num            Limit the number of packets to send
       --duration=num         Limit the number of seconds to send
   -x, --multiplier=str       Modify replay speed to a given multiple
   -p, --pps=str              Replay packets at a given packets/sec
   -M, --mbps=str             Replay packets at a given Mbps
   -t, --topspeed             Replay packets as fast as possible
   -o, --oneatatime           Replay one packet at a time for each user input
       --pps-multi=num        Number of packets to send for each time interval
       --unique-ip            Modify IP addresses each loop iteration to generate unique flows
       --unique-ip-loops=str  Number of times to loop before assigning new unique ip
   -!, --no-flow-stats        Suppress printing and tracking flow count, rates and expirations
   -", --flow-expiry=num      Number of inactive seconds before a flow is considered expired
   -P, --pid                  Print the PID of tcpreplay at startup
   -#, --stats=num            Print statistics every X seconds, or every loop if '0'
   -V, --version              Print version information
   -h, --less-help            Display less usage information and exit
   -H, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager
   -$, --save-opts[=arg]      save the option state to a config file
   -%, --load-opts=str        load options from a config file

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
tcpreplay is a tool for replaying network traffic from files saved with
tcpdump or other tools which write pcap(3) files.

Please send bug reports to:  <tcpreplay-users@lists.sourceforge.net>
[root@datatest ~]#   

复制代码

 

   tcpreplay-edit 实时修改包数据并回放,它是将 tcprewrite 和 tcpreplay 用一条命令实现。其好处是修改包数据不会新生成 pcap 文件。如果是需要不断的改写一个包文件并回放建议使用 tcpreplay-edit,如果是需要一次改写一个包文件并多次回放建议使用 tcprewrite 和 tcpreplay 的结合,这样具有更好的回放速率。 


  tcpreplay-edit小例子

  编写脚本,不断改写包文件的 IP 地址并回放: 

  比如,你自己写个test.sh脚本,然后赋予chmod 777 test.sh。执行就是


for i in {1..255}
do
tcpreplay-edit --endpoints=1.1.2.$i:1.1.1.2 -t -i eth2 -I eth1 -c edit.cach edit.pcap
done  

 

 

 

 

 

 

 

 

 

5、查看Tcpreplay里的tcpliveplay的帮助文档命令

复制代码


[root@datatest ~]# tcpliveplay -H
tcpliveplay (tcpliveplay) - Replays network traffic stored in a pcap file on live networks using new TCP connections
Usage:  tcpliveplay [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \
        <eth0/eth1> <file.pcap> <Destinatin IP [1.2.3.4]> <Destination mac [0a:1b:2c:3d:4e:5f]> <'random' dst port OR specify dport #>

   -V, --version              Print version information
   -h, --less-help            Display less usage information and exit
   -H, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager
       --save-opts[=arg]      save the option state to a config file
       --load-opts=str        load options from a config file
                - disabled as '--no-load-opts'
                - may appear multiple times

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
This program, 'tcpliveplay' replays a captured set of packets using new TCP
connections with the captured TCP payloads against a remote host in order
to do comprehensive vulnerability testings.

The following option preset mechanisms are supported:
 - reading file /usr/bin/.tcpliveplayrc
The basic operation of tcpliveplay is it rewrites the given pcap file in a
scheduled event format and responds with the apporiate packet if the remote
host meets tcp protocal's SEQ/ACK expectation.  Once expectations are met,
then the local packets are sent with the same payload except with new tcp
SEQ & ACK numbers meeting the response from the remote hose.

The inputted pcap file are rewritten to start at the first encounter of the
SYN packet for correct operation making this packet be the first action in
the event schedule of local host doing the replay.

For more details, please see the Tcpreplay Manual at:
http://tcpreplay.appneta.com
[root@datatest ~]#   

复制代码

 

 

 

 

 

 

6、查看Tcpreplay里的tcpbridge的帮助文档命令

复制代码


[root@datatest ~]# tcpbridge -h
tcpbridge (tcpbridge) - Bridge network traffic across two interfaces
Usage:  tcpbridge [ -<flag> [<val>] | --<name>[{=| }<val>] ]...

   -r, --portmap=str          Rewrite TCP/UDP ports
   -s, --seed=num             Randomize src/dst IPv4/v6 addresses w/ given seed
   -N, --pnat=str             Rewrite IPv4/v6 addresses using pseudo-NAT
   -S, --srcipmap=str         Rewrite source IPv4/v6 addresses using pseudo-NAT
   -D, --dstipmap=str         Rewrite destination IPv4/v6 addresses using pseudo-NAT
   -b, --skipbroadcast        Skip rewriting broadcast/multicast IPv4/v6 addresses
   -C, --fixcsum              Force recalculation of IPv4/TCP/UDP header checksums
   -m, --mtu=num              Override default MTU length (1500 bytes)
       --mtu-trunc            Truncate packets larger then specified MTU
   -E, --efcs                 Remove Ethernet checksums (FCS) from end of frames
       --ttl=str              Modify the IPv4/v6 TTL/Hop Limit
       --tos=num              Set the IPv4 TOS/DiffServ/ECN byte
       --tclass=num           Set the IPv6 Traffic Class byte
       --flowlabel=num        Set the IPv6 Flow Label
   -F, --fixlen=str           Pad or truncate packet data to match header length
       --fuzz-seed=num        Fuzz 1 in X packets.  Edit bytes, length, or emulate packet drop
       --fuzz-factor=num      Set the Fuzz 1 in X packet ratio (default 1 in 8 packets)
       --skipl2broadcast      Skip rewriting broadcast/multicast Layer 2 addresses
       --dlt=str              Override output DLT encapsulation
       --enet-dmac=str        Override destination ethernet MAC addresses
       --enet-smac=str        Override source ethernet MAC addresses
       --enet-subsmac=str     Substitute MAC addresses
       --enet-mac-seed=num    Randomize MAC addresses
       --enet-mac-seed-keep-bytes=num Randomize MAC addresses
       --enet-vlan=str        Specify ethernet 802.1q VLAN tag mode
       --enet-vlan-tag=num    Specify the new ethernet 802.1q VLAN tag value
       --enet-vlan-cfi=num    Specify the ethernet 802.1q VLAN CFI value
       --enet-vlan-pri=num    Specify the ethernet 802.1q VLAN priority
       --hdlc-control=num     Specify HDLC control value
       --hdlc-address=num     Specify HDLC address
       --user-dlt=num         Set output file DLT type
       --user-dlink=str       Rewrite Data-Link layer with user specified data
   -i, --intf1=str            Primary interface (listen in uni-directional mode)
   -I, --intf2=str            Secondary interface (send in uni-directional mode)
   -u, --unidir               Send and receive in only one direction
       --listnics             List available network interfaces and exit
   -L, --limit=num            Limit the number of packets to send
   -M, --mac=str              MAC addresses of local NIC's
   -x, --include=str          Include only packets matching rule
   -X, --exclude=str          Exclude any packet matching this rule
   -P, --pid                  Print the PID of tcpbridge at startup
   -v, --verbose              Print decoded packets via tcpdump to STDOUT
   -A, --decode=str           Arguments passed to tcpdump decoder
   -V, --version              Print version information
   -h, --less-help            Display less usage information and exit
   -H, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager
       --save-opts[=arg]      save the option state to a config file
       --load-opts=str        load options from a config file

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
tcpbridge is a tool for selectively briding network traffic across two
interfaces and optionally modifying the packets in between

Please send bug reports to:  <tcpreplay-users@lists.sourceforge.net>
[root@datatest ~]#   

复制代码

 

 

 

 

 

7、查看Tcpreplay里的tcppcpinfo的帮助文档命令

复制代码


[root@datatest ~]# tcpcapinfo -h
/usr/bin/tcpcapinfo: illegal option -- h
tcpcapinfo (Tcpreplay Suite) - Pcap file dissector for debugging broken pcap files
Usage:  tcpcapinfo [ -<flag> [<val>] | --<name>[{=| }<val>] ]... <pcap_file(s)>

   -V, --version              Print version information
   -H, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
tcpcapinfo is a tool for decoding the structure of a pcap(3) file with a
focus on finding broken pcap files and determining how two related pcap
files might differ.

Please send bug reports to:  <tcpreplay-users@lists.sourceforge.net>
[root@datatest ~]#   

复制代码

 

 

 

 

 

 

 

 Tcpreplay总结 (以下只是一个小例子来完整跑一遍)

  通过 Tcpreplay 来修改、转发通信流量需要考虑的一共需要考虑以下 3 点:
    1、 确定哪有数据包是从客户端到服务器端的,哪有是从服务器端到客户端的
    2 、确定新的 MAC、IP、Port
    3、确定回放速率、循环次数、执行方式 

  第一步:
    用 tcpreplay 分离源/目的端口的流量。


tcpprep --port --cachfile=example.cach --pcap=example.pcap  

  这种情况下,认为所有目的端口小于1024 的,将被视为客户端->服务器的包。

        认为所有目的端口大于1024 的,否则视为服务器->客户端的包。

  该信息被存储在 tcpprp 的一个名叫 example.cach 的文件夹中。
  --port 根据端口号区分数据包的流向。
  --cachfile 指定输出的 cach 文件的名字,即在这里要输出为example.cach
  --pcap 指定要处理的数据包文件,即在这里要处理的是example.pcap。
  其实。tcpprep 支持许多的其他的模式,分离端口模式是其中的一种 。也就是说,第一步,大家自行选择。

 

 

  第二步:
  使用 tcprewrite 更改 ip 地址到本地网络:


$ tcprewrite --endpoints=172.16.0.1:172.16.5.35   --cachfile=example.cach --infile=example.pcap --outfile=new.pcap  

  这个例子里,我们想要所有的流量来自于 172.16.0.1 和 172.16.5.35。我们想要一个 IP 是“客户端”,一个 IP 是“服务器端 。
 

   tcprewrite 改写数据包:
    --endpoints 指定数据包的 client、server 端的 ip 地址
    --cachfie 上一步预处理的输出文件,即example.cach
    --infile 输入 pcap 文件,即example.pcap。
    --outfile 改写后的 pcap 文件 ,即new.pcap。

 

 

 

 

 

  第三步:用 tcpreplay,发送流量通过服务提供商


tcpreplay --intf1=eth0 --intf2=eth1 --cachfile=example.cach new.pcap  

  因为我们要分离 2 个接口(eth0 和 eth1)之间的通信,我们使用第一步中创建的 cach 文件,第二步中创建的 new.pacp。
  然后使用 tcpreplay 重发数据包。

 

 

 

 

 

  如果大家还是不明白,我就再详细的讲个案例。
  见

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

tcpreplay的安装使用 的相关文章

  • Checksum 校验和

    一 校验数据的一般算法比较 都是通过对数据进行校验产生一个校验值 xff0c 用来校验数据完整性 不同点 xff1a 算法不同 CRC采用多项式除法 xff0c MD5和SHA1使用的是替换 轮转等方法 xff1b 校验值的长度不同 CRC
  • GPIO小综合-按键实验

    之前用寄存器操作实现了跑马灯和蜂鸣器 这次接着输入寄存器IDR捕获按键 并且综合亮灯和发出声音 xff0c 作为寄存器GPIO小综合练习 首先查KEY的电路图 xff0c 分别用到了ACD几个时钟 KEY0对应PC8 xff0c KEY1对
  • 数据结构入门

    概念 数据 Data xff1a 是客观事物的符号表示 在计算机科学中指的是所有能输入到计算机中并被计算机程序处理的符号的总称 数据元素 Data Element xff1a 是数据的基本单位 xff0c 在程序中通常作为一个整体来进行考虑
  • Linux系统发布项目完整教程

    目录 1 后端代码打包 1 1后端代码中文件上传路径修改 1 2 后端代码打包 1 3 后端项目发布 2 前端静态资源打包 2 1 项目中关于路径修改的说明 2 2模拟域名访问的设置 修改HOSTS文件 2 3 前端请求路径修改 2 4 前
  • 畸变校正与极线校正(具体原理+Matlab代码)

    附 xff1a 相关需要的工具函数源代码 xff08 投影函数 校正矩阵计算等 xff09 见最下面 1 畸变校正 1 1 形成原因 图像畸变一般有两种 xff0c 第一种是透镜本身的形状有问题 xff0c 使得图像发生径向畸变 xff1b
  • c++的http请求

    include lt iostream gt include lt fstream gt include lt cstdlib gt include lt cstring gt include lt sys socket h gt incl
  • stl智能指针和boost智能指针对比

    先说说stl中的智能指针auto ptr xff0c 先说说auto ptr的特点 std auto ptr用来管理单个堆内存对象 xff0c 但是独享所有权 xff0c 且不允许赋值和拷贝 xff08 没有重载operator 61 xf
  • boost库noncopyable简介

    前言 看了一段时间的UNP对Linux下网络编程有了一定程度的理解 xff0c 经学长推荐 xff0c 开始学习陈硕老师的 Linux多线程服务端编程 看之前特地上了知乎 xff0c 阅读者需要具备一定的C 43 43 和网络编程基础 xf
  • 车道线检测和基于RGB交通标志检测系统

    好久好久好久没更新博客了 今天是冬至 首先跟大家说一声 冬至快乐 冬至吃过汤圆 又长了一岁 感觉真的时不待人 好像自己什么事情也没有完成 也没留下一些什么东西 所以今天就想来写写博客 我是分割线 运行环境 Win7系统64位 运行平台 Qt
  • c++中h文件和lib有什么区别

    转自 xff1a https zhidao baidu com question 510969923 html 1 lib 是若干个obj的集合 xff0c 本质与obj相同 xff01 lib有静态lib和动态lib之分 静态lib将导出
  • cmake在Windows上的使用

    cmake介绍 cmake是一个构建C 43 43 代码的跨平台工具 xff0c 他能够干什么呢 xff1f 他能够搜索你的平台环境 xff0c 然后生成平台上用于Build的文件 在Windows上安装了Visual Studio 他能够
  • ubuntu系统安装完nvidia显卡驱动后黑屏,不能进入系统

    昨天想看显卡 xff0c 更新了下驱动 xff0c 发现服务器重启进不去 步骤 1 开机按esc 进入 选项界面2 进去以后选择一个括号里面带recovery mode的选项3 然后它自动黑屏出现代码 xff0c 然后弹出一个选择框 xff
  • ubuntu18.04下cmake的安装

    一 使用安装命令 span class token function sudo span span class token function apt span span class token function install span c
  • Nginx/Lighttpd/Apache三大web服务器对比分析

    一 xff0e 软件介绍 apache lighttpd nginx 1 lighttpd Lighttpd是一个具有非常低的内存开销 xff0c cpu占用率低 xff0c 效能好 xff0c 以及丰富的模块等特点 lighttpd是众多
  • STM32学习笔记八——串口实现不定长数据传输

    生命不息 xff0c 奋斗不止 0 摘要 今天说一下STM32单片机的接收不定长度字节数据的方法 由于STM32单片机带IDLE中断 xff0c 所以利用这个中断 xff0c 可以接收不定长字节的数据 xff0c 由于STM32属于ARM单
  • linux shell 字符串长度

    本篇内容主要包括以下内容 xff1a 获取字符串长度的方法 各方法间性能比较 相关内容补充 说明 xff1a 本篇内容为学习shell 编程 老男孩教程 笔记 xff0c 部分内容为相关视频课程内容 xff0c 补充部分是我查资料所得 xf
  • measurement studio测控与单片机通信上位机

    using NationalInstruments Analysis using NationalInstruments Analysis Conversion using NationalInstruments Analysis Dsp
  • C语言实现Socket简单通信

    环境是linux xff0c 不过应该没什么影响 xff0c 因为只用到了socket的基本用法 xff0c 没有涉及pthread等 分为服务器端和客户端 xff0c 服务器端监听端口发来的请求 xff0c 收到后向客户端发送一个Hell
  • 接口工具POSTMAN怎么设置中文

    相信各位测试工程师或者测试小白们都会在进行接口测试的时候接触到POSTMAN这款强大的接口测试软件 Postman 从最初设计上就是为接口测试而生的 xff0c 所以在程序员中广泛使用 xff0c 在开发调试网络程序时跟踪一些网络请求 xf
  • 【第三方库】libcurl实现http及https方式下载和访问

    准备条件 xff1a 编译好的libcurl库 xff0c 如果要支持https xff0c 需要和openssl一起编译 xff0c 网上教程较多 示例代码 xff1a xff08 使用loadlibrary的方式只是为了测试方便 xff

随机推荐