一、网络抓包
tcpdump
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ] [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ] [ -i interface ] [ -j tstamptype ] [ -M secret ] [ --number ] [ -Q in|out|inout ] [ -r file ] [ -s snaplen ] [ --time-stamp-precision precision ] [ --immediate-mode ] [ -T type ] [ --version ] [ -V file ] [ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z postrotate-command ] [ -Z user ] [ expression ]
简单选项
-A 以ASCII码方式显示每一个数据包(不会显示数据包中链路层头部信息). 在抓取包含网页数据的数据包时, 可方便查看数据(nt: 即Handy for capturing web pages). -c count tcpdump将在接受到count个数据包后退出. -C file-size (nt: 此选项用于配合-w file 选项使用) 该选项使得tcpdump 在把原始数据包直接保存到文件中之前, 检查此文件大小是否超过file-size. 如果超过了, 将关闭此文件,另创一个文件继续用于原始数据包的记录. 新创建的文件名与-w 选项指定的文件名一致, 但文件名后多了一个数字.该数字会从1开始随着新创建文件的增多而增加. file-size的单位是百万字节(nt: 这里指1,000,000个字节,并非1,048,576个字节, 后者是以1024字节为1k, 1024k字节为1M计算所得, 即1M=1024 * 1024 = 1,048,576) -d 以容易阅读的形式,在标准输出上打印出编排过的包匹配码, 随后tcpdump停止.(nt | rt: human readable, 容易阅读的,通常是指以ascii码来打印一些信息. compiled, 编排过的. packet-matching code, 包匹配码,含义未知, 需补充) -dd 以C语言的形式打印出包匹配码. -ddd 以十进制数的形式打印出包匹配码(会在包匹配码之前有一个附加的'count'前缀). -D 打印系统中所有tcpdump可以在其上进行抓包的网络接口. 每一个接口会打印出数字编号, 相应的接口名字, 以及可能的一个网络接口描述. 其中网络接口名字和数字编号可以用在tcpdump 的-i flag 选项(nt: 把名字或数字代替flag), 来指定要在其上抓包的网络接口. 此选项在不支持接口列表命令的系统上很有用(nt: 比如, Windows 系统, 或缺乏 ifconfig -a 的UNIX系统); 接口的数字编号在windows 2000 或其后的系统中很有用, 因为这些系统上的接口名字比较复杂, 而不易使用. 如果tcpdump编译时所依赖的libpcap库太老,-D 选项不会被支持, 因为其中缺乏 pcap_findalldevs()函数. -e 每行的打印输出中将包括数据包的数据链路层头部信息 -E spi@ipaddr algo:secret,... 可通过spi@ipaddr algo:secret 来解密IPsec ESP包(nt | rt:IPsec Encapsulating Security Payload,IPsec 封装安全负载, IPsec可理解为, 一整套对ip数据包的加密协议, ESP 为整个IP 数据包或其中上层协议部分被加密后的数据,前者的工作模式称为隧道模式; 后者的工作模式称为传输模式 . 工作原理, 另需补充). 需要注意的是, 在终端启动tcpdump 时, 可以为IPv4 ESP packets 设置密钥(secret). 可用于加密的算法包括des-cbc, 3des-cbc, blowfish-cbc, rc3-cbc, cast128-cbc, 或者没有(none).默认的是des-cbc(nt: des, Data Encryption Standard, 数据加密标准, 加密算法未知, 另需补充).secret 为用于ESP 的密钥, 使用ASCII 字符串方式表达. 如果以 0x 开头, 该密钥将以16进制方式读入. 该选项中ESP 的定义遵循RFC2406, 而不是 RFC1827. 并且, 此选项只是用来调试的, 不推荐以真实密钥(secret)来使用该选项, 因为这样不安全: 在命令行中输入的secret 可以被其他人通过ps 等命令查看到. 除了以上的语法格式(nt: 指spi@ipaddr algo:secret), 还可以在后面添加一个语法输入文件名字供tcpdump 使用(nt:即把spi@ipaddr algo:secret,... 中...换成一个语法文件名). 此文件在接受到第一个ESP 包时会打开此文件, 所以最好此时把赋予tcpdump 的一些特权取消(nt: 可理解为, 这样防范之后, 当该文件为恶意编写时,不至于造成过大损害). -f 显示外部的IPv4 地址时(nt: foreign IPv4 addresses, 可理解为, 非本机ip地址), 采用数字方式而不是名字.(此选项是用来对付Sun公司的NIS服务器的缺陷(nt: NIS, 网络信息服务, tcpdump 显示外部地址的名字时会用到她提供的名称服务): 此NIS服务器在查询非本地地址名字时,常常会陷入无尽的查询循环). 由于对外部(foreign)IPv4地址的测试需要用到本地网络接口(nt: tcpdump 抓包时用到的接口)及其IPv4 地址和网络掩码. 如果此地址或网络掩码不可用, 或者此接口根本就没有设置相应网络地址和网络掩码(nt: linux 下的 'any' 网络接口就不需要设置地址和掩码, 不过此'any'接口可以收到系统中所有接口的数据包), 该选项不能正常工作. -F file 使用file 文件作为过滤条件表达式的输入, 此时命令行上的输入将被忽略. -i interface 指定tcpdump 需要监听的接口. 如果没有指定, tcpdump 会从系统接口列表中搜寻编号最小的已配置好的接口(不包括 loopback 接口).一但找到第一个符合条件的接口, 搜寻马上结束. 在采用2.2版本或之后版本内核的Linux 操作系统上, 'any' 这个虚拟网络接口可被用来接收所有网络接口上的数据包(nt: 这会包括目的是该网络接口的, 也包括目的不是该网络接口的). 需要注意的是如果真实网络接口不能工作在'混杂'模式(promiscuous)下,则无法在'any'这个虚拟的网络接口上抓取其数据包. 如果 -D 标志被指定, tcpdump会打印系统中的接口编号,而该编号就可用于此处的interface 参数. -l 对标准输出进行行缓冲(nt: 使标准输出设备遇到一个换行符就马上把这行的内容打印出来).在需要同时观察抓包打印以及保存抓包记录的时候很有用. 比如, 可通过以下命令组合来达到此目的: ``tcpdump -l | tee dat'' 或者 ``tcpdump -l > dat & tail -f dat''.(nt: 前者使用tee来把tcpdump 的输出同时放到文件dat和标准输出中, 而后者通过重定向操作'>', 把tcpdump的输出放到dat 文件中, 同时通过tail把dat文件中的内容放到标准输出中) -L 列出指定网络接口所支持的数据链路层的类型后退出.(nt: 指定接口通过-i 来指定) -m module 通过module 指定的file 装载SMI MIB 模块(nt: SMI,Structure of Management Information, 管理信息结构MIB, Management Information Base, 管理信息库. 可理解为, 这两者用于SNMP(Simple Network Management Protoco)协议数据包的抓取. 具体SNMP 的工作原理未知, 另需补充). 此选项可多次使用, 从而为tcpdump 装载不同的MIB 模块. -M secret 如果TCP 数据包(TCP segments)有TCP-MD5选项(在RFC 2385有相关描述), 则为其摘要的验证指定一个公共的密钥secret. -n 不对地址(比如, 主机地址, 端口号)进行数字表示到名字表示的转换. -N 不打印出host 的域名部分. 比如, 如果设置了此选现, tcpdump 将会打印'nic' 而不是 'nic.ddn.mil'. -O 不启用进行包匹配时所用的优化代码. 当怀疑某些bug是由优化代码引起的, 此选项将很有用. -p 一般情况下, 把网络接口设置为非'混杂'模式. 但必须注意 , 在特殊情况下此网络接口还是会以'混杂'模式来工作; 从而, '-p' 的设与不设, 不能当做以下选现的代名词:'ether host {local-hw-add}' 或 'ether broadcast'(nt: 前者表示只匹配以太网地址为host 的包, 后者表示匹配以太网地址为广播地址的数据包). -q 快速(也许用'安静'更好?)打印输出. 即打印很少的协议相关信息, 从而输出行都比较简短. -R 设定tcpdump 对 ESP/AH 数据包的解析按照 RFC1825而不是RFC1829(nt: AH, 认证头, ESP, 安全负载封装, 这两者会用在IP包的安全传输机制中). 如果此选项被设置, tcpdump 将不会打印出'禁止中继'域(nt: relay prevention field). 另外,由于ESP/AH规范中没有规定ESP/AH数据包必须拥有协议版本号域,所以tcpdump不能从收到的ESP/AH数据包中推导出协议版本号. -r file 从文件file 中读取包数据. 如果file 字段为 '-' 符号, 则tcpdump 会从标准输入中读取包数据. -S 打印TCP 数据包的顺序号时, 使用绝对的顺序号, 而不是相对的顺序号.(nt: 相对顺序号可理解为, 相对第一个TCP 包顺序号的差距,比如, 接受方收到第一个数据包的绝对顺序号为232323, 对于后来接收到的第2个,第3个数据包, tcpdump会打印其序列号为1, 2分别表示与第一个数据包的差距为1 和 2. 而如果此时-S 选项被设置, 对于后来接收到的第2个, 第3个数据包会打印出其绝对顺序号:232324, 232325). -s snaplen 设置tcpdump的数据包抓取长度为snaplen, 如果不设置默认将会是68字节(而支持网络接口分接头(nt: NIT, 上文已有描述,可搜索'网络接口分接头'关键字找到那里)的SunOS系列操作系统中默认的也是最小值是96).68字节对于IP, ICMP(nt: Internet Control Message Protocol,因特网控制报文协议), TCP 以及 UDP 协议的报文已足够, 但对于名称服务(nt: 可理解为dns, nis等服务), NFS服务相关的数据包会产生包截短. 如果产生包截短这种情况, tcpdump的相应打印输出行中会出现''[|proto]''的标志(proto 实际会显示为被截短的数据包的相关协议层次). 需要注意的是, 采用长的抓取长度(nt: snaplen比较大), 会增加包的处理时间, 并且会减少tcpdump 可缓存的数据包的数量, 从而会导致数据包的丢失. 所以, 在能抓取我们想要的包的前提下, 抓取长度越小越好.把snaplen 设置为0 意味着让tcpdump自动选择合适的长度来抓取数据包. -T type 强制tcpdump按type指定的协议所描述的包结构来分析收到的数据包. 目前已知的type 可取的协议为: aodv (Ad-hoc On-demand Distance Vector protocol, 按需距离向量路由协议, 在Ad hoc(点对点模式)网络中使用), cnfp (Cisco NetFlow protocol), rpc(Remote Procedure Call), rtp (Real-Time Applications protocol), rtcp (Real-Time Applications con-trol protocol), snmp (Simple Network Management Protocol), tftp (Trivial File Transfer Protocol, 碎文件协议), vat (Visual Audio Tool, 可用于在internet 上进行电 视电话会议的应用层协议), 以及wb (distributed White Board, 可用于网络会议的应用层协议). -t 在每行输出中不打印时间戳 -tt 不对每行输出的时间进行格式处理(nt: 这种格式一眼可能看不出其含义, 如时间戳打印成1261798315) -ttt tcpdump 输出时, 每两行打印之间会延迟一个段时间(以毫秒为单位) -tttt 在每行打印的时间戳之前添加日期的打印 -u 打印出未加密的NFS 句柄(nt: handle可理解为NFS 中使用的文件句柄, 这将包括文件夹和文件夹中的文件) -U 使得当tcpdump在使用-w 选项时, 其文件写入与包的保存同步.(nt: 即, 当每个数据包被保存时, 它将及时被写入文件中,而不是等文件的输出缓冲已满时才真正写入此文件) -U 标志在老版本的libcap库(nt: tcpdump 所依赖的报文捕获库)上不起作用, 因为其中缺乏pcap_cump_flush()函数. -v 当分析和打印的时候, 产生详细的输出. 比如, 包的生存时间, 标识, 总长度以及IP包的一些选项. 这也会打开一些附加的包完整性检测, 比如对IP或ICMP包头部的校验和. -vv 产生比-v更详细的输出. 比如, NFS回应包中的附加域将会被打印, SMB数据包也会被完全解码. -vvv 产生比-vv更详细的输出. 比如, telent 时所使用的SB, SE 选项将会被打印, 如果telnet同时使用的是图形界面, 其相应的图形选项将会以16进制的方式打印出来(nt: telnet 的SB,SE选项含义未知, 另需补充). -w 把包数据直接写入文件而不进行分析和打印输出. 这些包数据可在随后通过-r 选项来重新读入并进行分析和打印. -W filecount 此选项与-C 选项配合使用, 这将限制可打开的文件数目, 并且当文件数据超过这里设置的限制时, 依次循环替代之前的文件, 这相当于一个拥有filecount 个文件的文件缓冲池. 同时, 该选项会使得每个文件名的开头会出现足够多并用来占位的0, 这可以方便这些文件被正确的排序. -x 当分析和打印时, tcpdump 会打印每个包的头部数据, 同时会以16进制打印出每个包的数据(但不包括连接层的头部).总共打印的数据大小不会超过整个数据包的大小与snaplen 中的最小值. 必须要注意的是, 如果高层协议数据没有snaplen 这么长,并且数据链路层(比如, Ethernet层)有填充数据, 则这些填充数据也会被打印.(nt: so for link layers that pad, 未能衔接理解和翻译, 需补充 ) -xx tcpdump 会打印每个包的头部数据, 同时会以16进制打印出每个包的数据, 其中包括数据链路层的头部. -X 当分析和打印时, tcpdump 会打印每个包的头部数据, 同时会以16进制和ASCII码形式打印出每个包的数据(但不包括连接层的头部).这对于分析一些新协议的数据包很方便. -XX 当分析和打印时, tcpdump 会打印每个包的头部数据, 同时会以16进制和ASCII码形式打印出每个包的数据, 其中包括数据链路层的头部.这对于分析一些新协议的数据包很方便. -y datalinktype 设置tcpdump 只捕获数据链路层协议类型是datalinktype的数据包 -Z user 使tcpdump 放弃自己的超级权限(如果以root用户启动tcpdump, tcpdump将会有超级用户权限), 并把当前tcpdump的用户ID设置为user, 组ID设置为user首要所属组的ID(nt: tcpdump 此处可理解为tcpdump 运行之后对应的进程) 此选项也可在编译的时候被设置为默认打开.(nt: 此时user 的取值未知, 需补充)
二、cap文件查看
wireshark
tshark
tcpdump
三、pcap修改
分割、合并
Usage: editcap [options] ... <infile> <outfile> [ <packet#>[-<packet#>] ... ] <infile> and <outfile> must both be present. A single packet or a range of packets can be selected. Packet selection: -r keep the selected packets; default is to delete them. -A <start time> only output packets whose timestamp is after (or equal to) the given time (format as YYYY-MM-DD hh:mm:ss). -B <stop time> only output packets whose timestamp is before the given time (format as YYYY-MM-DD hh:mm:ss). Duplicate packet removal: --novlan remove vlan info from packets before checking for duplicates. -d remove packet if duplicate (window == 5). -D <dup window> remove packet if duplicate; configurable <dup window>. Valid <dup window> values are 0 to 1000000. NOTE: A <dup window> of 0 with -v (verbose option) is useful to print MD5 hashes. -w <dup time window> remove packet if duplicate packet is found EQUAL TO OR LESS THAN <dup time window> prior to current packet. A <dup time window> is specified in relative seconds (e.g. 0.000001). NOTE: The use of the 'Duplicate packet removal' options with other editcap options except -v may not always work as expected. Specifically the -r, -t or -S options will very likely NOT have the desired effect if combined with the -d, -D or -w. --skip-radiotap-header skip radiotap header when checking for packet duplicates. Useful when processing packets captured by multiple radios on the same channel in the vicinity of each other. Packet manipulation: -s <snaplen> truncate each packet to max. <snaplen> bytes of data. -C [offset:]<choplen> chop each packet by <choplen> bytes. Positive values chop at the packet beginning, negative values at the packet end. If an optional offset precedes the length, then the bytes chopped will be offset from that value. Positive offsets are from the packet beginning, negative offsets are from the packet end. You can use this option more than once, allowing up to 2 chopping regions within a packet provided that at least 1 choplen is positive and at least 1 is negative. -L adjust the frame (i.e. reported) length when chopping and/or snapping. -t <time adjustment> adjust the timestamp of each packet. <time adjustment> is in relative seconds (e.g. -0.5). -S <strict adjustment> adjust timestamp of packets if necessary to ensure strict chronological increasing order. The <strict adjustment> is specified in relative seconds with values of 0 or 0.000001 being the most reasonable. A negative adjustment value will modify timestamps so that each packet's delta time is the absolute value of the adjustment specified. A value of -0 will set all packets to the timestamp of the first packet. -E <error probability> set the probability (between 0.0 and 1.0 incl.) that a particular packet byte will be randomly changed. -o <change offset> When used in conjunction with -E, skip some bytes from the beginning of the packet. This allows one to preserve some bytes, in order to have some headers untouched. --seed <seed> When used in conjunction with -E, set the seed to use for the pseudo-random number generator. This allows one to repeat a particular sequence of errors. -I <bytes to ignore> ignore the specified number of bytes at the beginning of the frame during MD5 hash calculation, unless the frame is too short, then the full frame is used. Useful to remove duplicated packets taken on several routers (different mac addresses for example). e.g. -I 26 in case of Ether/IP will ignore ether(14) and IP header(20 - 4(src ip) - 4(dst ip)). -a <framenum>:<comment> Add or replace comment for given frame number Output File(s): -c <packets per file> split the packet output to different files based on uniform packet counts with a maximum of <packets per file> each. -i <seconds per file> split the packet output to different files based on uniform time intervals with a maximum of <seconds per file> each. -F <capture type> set the output file type; default is pcapng. An empty "-F" option will list the file types. -T <encap type> set the output file encapsulation type; default is the same as the input file. An empty "-T" option will list the encapsulation types. --inject-secrets <type>,<file> Insert decryption secrets from <file>. List supported secret types with "--inject-secrets help". --discard-all-secrets Discard all decryption secrets from the input file when writing the output file. Does not discard secrets added by "--inject-secrets" in the same command line. Miscellaneous: -h display this help and exit. -v verbose output. If -v is used with any of the 'Duplicate Packet Removal' options (-d, -D or -w) then Packet lengths and MD5 hashes are printed to standard-error.
合并
Usage: mergecap [options] -w <outfile>|- <infile> [<infile> ...] Output: -a concatenate rather than merge files. default is to merge based on frame timestamps. -s <snaplen> truncate packets to <snaplen> bytes of data. -w <outfile>|- set the output filename to <outfile> or '-' for stdout. -F <capture type> set the output file type; default is pcapng. an empty "-F" option will list the file types. -I <IDB merge mode> set the merge mode for Interface Description Blocks; default is 'all'. an empty "-I" option will list the merge modes. Miscellaneous: -h display this help and exit. -v verbose output.
tcpprep
tcpprep (tcpprep) - Create a tcpreplay cache cache file from a pcap file. Usage: tcpprep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... -a, --auto=str Auto-split mode - prohibits these options: cidr port regex mac -c, --cidr=str CIDR-split mode - prohibits these options: auto port regex mac -r, --regex=str Regex-split mode - prohibits these options: auto port cidr mac -p, --port Port-split mode - prohibits these options: auto regex cidr mac -e, --mac=str Source MAC split mode - prohibits these options: auto regex cidr port --reverse Matches to be client instead of server -C, --comment=str Embedded cache file comment --no-arg-comment Do not embed any cache file comment -x, --include=str Include only packets matching rule - prohibits the option 'exclude' -X, --exclude=str Exclude any packet matching this rule - prohibits the option 'include' -o, --cachefile=str Output cache file -i, --pcap=str Input pcap file to process -P, --print-comment=str Print embedded comment in the specified cache file -I, --print-info=str Print basic info from the specified cache file -S, --print-stats=str Print statistical information about the specified cache file -s, --services=str Load services file for server ports - requires the option 'port' -N, --nonip Send non-IP traffic out server interface -R, --ratio=str Ratio of client to server packets - requires the option 'auto' -m, --minmask=num Minimum network mask length in auto mode - requires the option 'auto' - it must be in the range: 0 to 32 -M, --maxmask=num Maximum network mask length in auto mode - requires the option 'auto' - it must be in the range: 0 to 32 -v, --verbose Print decoded packets via tcpdump to STDOUT -A, --decode=str Arguments passed to tcpdump decoder - requires the option 'verbose' -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. 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. The following option preset mechanisms are supported: - reading file /usr/bin/.tcppreprc The basic operation of tcpreplay is to resend all packets from the input file(s) out a single file. Tcpprep processes a pcap file and applies a set of user-specified rules to create a cache file which tells tcpreplay whether or not to send each packet and which interface the packet should be sent out of. For more details, please see the Tcpreplay Manual at: http://tcpreplay.appneta.com Please send bug reports to: <tcpreplay-users@lists.sourceforge.net>
tcprewrite
tcprewrite error: The infile option is required tcprewrite (tcprewrite) - Rewrite the packets in a pcap file. Usage: tcprewrite [ -<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 -e, --endpoints=str Rewrite IP addresses to be between two endpoints --tcp-sequence=num Change TCP Sequence (and ACK) numbers /w given seed -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, --infile=str Input pcap file to be processed -o, --outfile=str Output pcap file -c, --cachefile=str Split traffic via tcpprep cache file -v, --verbose Print decoded packets via tcpdump to STDOUT -A, --decode=str Arguments passed to tcpdump decoder --fragroute=str Parse fragroute configuration file --fragdir=str Which flows to apply fragroute to: c2s, s2c, both --skip-soft-errors Skip writing packets with soft errors -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
四、pcap重放
tcpreplay
Warning: May need to run as root to get access to all network interfaces. tcpreplay (tcpreplay) - Replay network traffic stored in pcap files Usage: tcpreplay [ -<flag> [<val>] | --<name>[{=| }<val>] ]... <pcap_file(s)> -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 - requires the option 'verbose' -K, --preload-pcap Preloads packets into RAM before sending -c, --cachefile=str Split traffic via a tcpprep cache file - requires the option 'intf2' -- and prohibits the option 'dualfile' -2, --dualfile Replay two files at a time from a network tap - requires the option 'intf2' -- and prohibits the option 'cachefile' -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 - it must be in the range: greater than or equal to 0 --loopdelay-ms=num Delay between loops in milliseconds - requires the option 'loop' - it must be in the range: greater than or equal to 0 --pktlen Override the snaplen and use the actual packet len -L, --limit=num Limit the number of packets to send - it must be in the range: greater than or equal to 1 --duration=num Limit the number of seconds to send - it must be in the range: greater than or equal to 1 -x, --multiplier=str Modify replay speed to a given multiple - prohibits these options: pps mbps oneatatime topspeed -p, --pps=str Replay packets at a given packets/sec - prohibits these options: multiplier mbps oneatatime topspeed -M, --mbps=str Replay packets at a given Mbps - prohibits these options: multiplier pps oneatatime topspeed -t, --topspeed Replay packets as fast as possible - prohibits these options: mbps multiplier pps oneatatime -o, --oneatatime Replay one packet at a time for each user input - prohibits these options: mbps pps multiplier topspeed --pps-multi=num Number of packets to send for each time interval - requires the option 'pps' - it must be in the range: greater than or equal to 1 --unique-ip Modify IP addresses each loop iteration to generate unique flows - requires the option 'loop' --unique-ip-loops=str Number of times to loop before assigning new unique ip - requires the option '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 - prohibits the option 'no-flow-stats' - it must be in the range: greater than or equal to 0 -P, --pid Print the PID of tcpreplay at startup --stats=num Print statistics every X seconds, or every loop if '0' - it must be in the range: greater than or equal to 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 - 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. tcpreplay is a tool for replaying network traffic from files saved with tcpdump or other tools which write pcap(3) files. The following option preset mechanisms are supported: - reading file /usr/bin/.tcpreplayrc The basic operation of tcpreplay is to resend all packets from the input file(s) at the speed at which they were recorded, or a specified data rate, up to as fast as the hardware is capable. Optionally, the traffic can be split between two interfaces, written to files, filtered and edited in various ways, providing the means to test firewalls, NIDS and other network devices. For more details, please see the Tcpreplay Manual at: http://tcpreplay.appneta.com Please send bug reports to: <tcpreplay-users@lists.sourceforge.net>
参考资料:
2.http://otsuka752.github.io/wiki/tcprewrite.html
3.https://github.com/appneta/tcpreplay
4.http://tcpreplay.appneta.com/wiki/tcpprep