是的,这似乎不如MariusMatutiae的回答所说。
tcpdump ...{other options}... -w httpdebug.pcap -W 48 -G 1800 -C 100
$ ls -l
-rw-r--r--. 1 tcpdump tcpdump 100007441 Mar 17 17:57 httpdebug.pcap00
-rw-r--r--. 1 tcpdump tcpdump 46895104 Mar 17 18:02 httpdebug.pcap01
-rw-r--r--. 1 tcpdump tcpdump 93091143 Mar 17 17:47 httpdebug.pcap02
-rw-r--r--. 1 tcpdump tcpdump 5372072 Mar 17 16:17 httpdebug.pcap03
在我看来,它可能-C 100
在30分钟内捕获尽可能多的MB文件,因为它httpdebug.pcap03
具有最早的时间戳,并且比100MB小得多,因此看起来好像是在30分钟处被剪切了。一旦达到30分钟,它就会跳回httpdebug.pcap00
并增加数字,达到100MB。这意味着,如果您在30分钟内有很多请求,则会获得很高的httpdebug.pcapXX数字。如果您再也无法在一段时间内收到这么多请求,那么那些高httpdebug.pcapXX数字将永远不会被覆盖。
所以我在考虑每个时间片的周期性文件意味着时间片是-G 1800
,并且它将每个循环一次-G 1800
并递增-C 100
。
我不确定是否-W 48
会影响它,但是也许您可以达到httpdebug.pcap47
(计数从0开始,它将停止捕获数据包。
最近,GitHub出现了一个有关措辞混乱的问题。他们没有更改实现,但是他们试图使文档更加清晰。
该提议的变更对合并2019年1月28日。
截至2019年3月17日,这是当前文档:
-C
:
.BI \-C " file_size"
Before writing a raw packet to a savefile, check whether the file is
currently larger than \fIfile_size\fP and, if so, close the current
savefile and open a new one. Savefiles after the first savefile will
have the name specified with the
.B \-w
flag, with a number after it, starting at 1 and continuing upward.
The units of \fIfile_size\fP are millions of bytes (1,000,000 bytes,
not 1,048,576 bytes).
-G
:
.BI \-G " rotate_seconds"
If specified, rotates the dump file specified with the
.B \-w
option every \fIrotate_seconds\fP seconds.
Savefiles will have the name specified by
.B \-w
which should include a time format as defined by
.BR strftime (3).
If no time format is specified, each new file will overwrite the previous.
Whenever a generated filename is not unique, tcpdump will overwrite the
preexisting data; providing a time specification that is coarser than the
capture period is therefore not advised.
.IP
If used in conjunction with the
.B \-C
option, filenames will take the form of `\fIfile\fP<count>'.
-W
:
.B \-W
Used in conjunction with the
.B \-C
option, this will limit the number
of files created to the specified number, and begin overwriting files
from the beginning, thus creating a 'rotating' buffer.
In addition, it will name
the files with enough leading 0s to support the maximum number of
files, allowing them to sort correctly.
.IP
Used in conjunction with the
.B \-G
option, this will limit the number of rotated dump files that get
created, exiting with status 0 when reaching the limit.
.IP
If used in conjunction with both
.B \-C
and
.B \-G,
the
.B \-W
option will currently be ignored, and will only affect the file name.
我仍然认为这有点令人困惑,但是我想与我上面的结论有所不同,它表示-W
与一起使用时-C -G
除了文件名外不影响其他任何内容。
通常,-W
用于限制文件数。因此,如果要无限期捕获,请不要使用它。