]> The Tcpdump Group git mirrors - tcpslice/blob - tcpslice.1
Use TS_RAW_US_MAX_DIGITS in parse_time().
[tcpslice] / tcpslice.1
1 .\" Copyright (c) 1991, 1996, 2000
2 .\" The Regents of the University of California. All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that: (1) source code distributions
6 .\" retain the above copyright notice and this paragraph in its entirety, (2)
7 .\" distributions including binary code include the above copyright notice and
8 .\" this paragraph in its entirety in the documentation or other materials
9 .\" provided with the distribution, and (3) all advertising materials mentioning
10 .\" features or use of this software display the following acknowledgement:
11 .\" ``This product includes software developed by the University of California,
12 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13 .\" the University nor the names of its contributors may be used to endorse
14 .\" or promote products derived from this software without specific prior
15 .\" written permission.
16 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 .\"
20 .TH TCPSLICE 1 "22 March 2024"
21 .SH NAME
22 tcpslice \- extract pieces of and/or merge together pcap files
23 .SH SYNOPSIS
24 .na
25 .B tcpslice
26 [
27 .B \-DdlhRrtv
28 ] [
29 .B \-w
30 .I output-file
31 ]
32 .ti +9
33 [
34 .B \-s
35 .I types
36 [
37 .B \-e
38 .I seconds
39 ] [
40 .B \-f
41 .I format
42 ] ]
43 .ti +9
44 [
45 .I start-time
46 [
47 .I end-time
48 ] ]
49 .I file ...
50 .br
51 .ad
52 .SH DESCRIPTION
53 .LP
54 .I Tcpslice
55 is a program for extracting portions of
56 .B .pcap
57 (but not
58 .BR .pcapng )
59 files produced using
60 .BR tcpdump (1)'s
61 .B \-w
62 flag or many other programs.
63 It can also be used to merge together several such files, as discussed
64 below.
65 .LP
66 The basic operation of
67 .I tcpslice
68 is to copy to
69 .I stdout
70 all packets from its input file(s) whose timestamps fall
71 within a given range. The starting and ending times of the range
72 may be specified on the command line. All ranges are inclusive.
73 The starting time defaults
74 to the earliest time of the first packet in
75 any of the input files; we call
76 this the
77 .I first time.
78 The ending time defaults to ten years after the starting time.
79 Thus, the command
80 .I tcpslice trace-file
81 simply copies
82 .I trace-file
83 to \fIstdout\fP (assuming the file does not include more than
84 ten years' worth of data).
85 .SH TIME FORMATS
86 .LP
87 There are a number of ways to specify times. The first is using
88 Unix timestamps of the form
89 .I sssssssss.uuuuuu
90 (this is the format specified by \fItcpdump\fP's
91 .B \-tt
92 flag).
93 For example,
94 .B 654321098.7654
95 specifies 38 seconds and 765,400 microseconds
96 after 8:51PM PDT, Sept. 25, 1990.
97 .LP
98 All examples in this manual are given
99 for PDT times, but when displaying times and interpreting times symbolically
100 as discussed below,
101 .I tcpslice
102 uses the local timezone, regardless of the timezone in which the pcap
103 file was generated. The daylight-savings setting used is that which is
104 appropriate for the local timezone at the date in question. For example,
105 times associated with summer months will usually include daylight-savings
106 effects, and those with winter months will not.
107 .LP
108 Times may also be specified relative
109 to either the
110 .I first time
111 (when specifying a starting time)
112 or the starting time (when specifying an ending time)
113 by preceding a numeric value in seconds with a `+'.
114 For example, a starting time of
115 .B +200
116 indicates 200 seconds after the
117 .I first time,
118 and the two arguments
119 .B +200 +300
120 indicate from 200 seconds after the
121 .I first time
122 through 500 seconds after the
123 .I first time.
124 .LP
125 Times may also be specified in terms of years (y), months (m), days (d),
126 hours (h), minutes (m), seconds (s), and microseconds(u). For example,
127 the Unix timestamp
128 .B 654321098.7654
129 discussed above could also be expressed
130 as
131 .BR 1990y9m25d20h51m38s765400u .
132 2 or 4 digit years may be used; 2 digits can specify years from 1970 to
133 2069.
134 .LP
135 When specifying times using this style, fields that are omitted default
136 as follows. If the omitted field is a unit
137 .I greater
138 than that of the first specified field, then its value defaults to
139 the corresponding value taken from either
140 .I first time
141 (if the starting time is being specified) or the starting time
142 (if the ending time is being specified).
143 If the omitted field is a unit
144 .I less
145 than that of the first specified field, then it defaults to zero (1 for days).
146 For example, suppose that the input file has a
147 .I first time
148 of the Unix timestamp mentioned above, i.e., 38 seconds and 765,400 microseconds
149 after 8:51PM PDT, Sept. 25, 1990. To specify 9:36PM PDT (exactly) on the
150 same date we could use
151 .BR 21h36m .
152 To specify a range from 9:36PM PDT through 1:54AM PDT the next day we
153 could use
154 .BR "21h36m 26d1h54m" .
155 .LP
156 Relative times can also be specified when using the
157 .I ymdhmsu
158 format. Omitted fields then default to 0 if the unit of the field is
159 .I greater
160 than that of the first specified field, and to the corresponding value
161 taken from either the
162 .I first time
163 or the starting time if the omitted field's unit is
164 .I less
165 than that of the first specified field. Given a
166 .I first time
167 of the Unix timestamp mentioned above,
168 .B 22h +1h10m
169 specifies a range from 10:00PM PDT on that date through 11:10PM PDT, and
170 .B +1h +1h10m
171 specifies a range from 38.7654 seconds after 9:51PM PDT through 38.7654
172 seconds after 11:01PM PDT. The first hour of the file could be extracted
173 using
174 .BR "+0 +1h" .
175 .LP
176 Note that with the
177 .I ymdhmsu
178 format there is an ambiguity between using
179 .I m
180 for `month' or for `minute'. The ambiguity is resolved as follows: if an
181 .I m
182 field is followed by a
183 .I d
184 field then it is interpreted as specifying months; otherwise it
185 specifies minutes.
186 .SH MULTIPLE INPUT FILES
187 .LP
188 If more than one input file is specified then
189 .I tcpslice
190 merges the packets from the various input files into the single
191 output file. Normally, this merge is done based on the
192 value of the time stamps in the packets in the individual files.
193 (Tcpslice assumes that
194 .I within
195 each input file, packets are in time stamp order.)
196 If the
197 .B \-l
198 option is used, the value used for ordering is the time stamp of
199 a given packet minus the time stamp of the first packet in the
200 input file in which the given packet occurs.
201 .LP
202 When merging files, by default
203 .I tcpslice
204 will discard any
205 .I duplicate
206 packet it finds in more than one file. A duplicate is a packet
207 that has an identical timestamp (either relative or absolute) and
208 identical packet contents (for as much as was captured) as another
209 packet previously seen in a different file. Note that it is possible
210 for the network to generate true replicates of packets, and for
211 systems that can return the same timestamp for multiple packets,
212 these can be mistaken for duplicates and discarded. Accordingly,
213 .I tcpslice
214 will not discard duplicates in the same trace file. In addition,
215 you can use the
216 .B \-D
217 option to suppress any discarding of duplicates.
218 .LP
219 .I tcpslice
220 will refuse to merge multiple files if they don't have the same
221 link-layer header type.
222 .SH OPTIONS
223 .LP
224 If any of
225 .BR \-R ,
226 .B \-r
227 or
228 .B \-t
229 are specified then
230 .I tcpslice
231 reports the timestamps of the first and last packets in each input file
232 and exits. Only one of these three options may be specified.
233 .TP
234 .B \-D
235 Do not discard duplicate packets seen when merging multiple trace files.
236 .TP
237 .B \-d
238 Dump the start and end times specified by the given range and
239 exit. This option is useful for checking that the given range actually
240 specifies the times you think it does. If one of
241 .BR \-R ,
242 .B \-r
243 or
244 .B \-t
245 has been specified then the times are dumped in the corresponding
246 format; otherwise,
247 .B -R
248 (raw format) is used.
249 .TP
250 .BI \-e " seconds"
251 Specify a number of
252 .I seconds
253 to wait after the last packet was seen before considering a session
254 to be expired (default: 0 = do not expire inactive sessions). This
255 is only effective when the
256 .B \-s
257 option is used to track sessions.
258 .TP
259 .BI \-f " format"
260 Specify the name
261 .I format
262 of PCAP files to which each session will be extracted (default: NULL = do
263 not extract sessions to separate files). This is only effective when the
264 .B \-s
265 option is used to track sessions.
266 .TP
267 .B \-h
268 Print the tcpslice and libpcap version strings, print a usage message, and exit.
269 .TP
270 .B \-l
271 When merging more than one file, merge on the basis of
272 relative time, rather than absolute time.
273 Normally, when merging
274 files is done, packets are merged based on absolute time stamps. With
275 .B \-l
276 packets are merged based on the relative time between
277 the start of the file in which the packet is found and the time stamp
278 of the packet itself.
279 The time stamp of packets in the output file is calculated
280 as the relative time for the packet within its file plus
281 .I first time.
282 .TP
283 .B \-R
284 Dump the timestamps of the first and last packets in each input file
285 as raw timestamps (i.e., in the form \fI sssssssss.uuuuuu\fP).
286 .TP
287 .B \-r
288 Same as
289 .B \-R
290 except the timestamps are dumped in human-readable format, similar
291 to that used by
292 .BR date (1).
293 .TP
294 .BI \-s " types"
295 Enable session tracking for the specified
296 .I types
297 which is a comma-separated list of the following:
298 .RS
299 .TP
300 .B tcp
301 track all TCP connections
302 .TP
303 .B sip
304 track SIP-based VoIP calls, which may enable tracking of TCP
305 connections but only the ones that are related to SIP calls.
306 This feature is only available if tcpslice was linked against
307 Aymeric Moizard's GNU oSIP library; if not, install the latest
308 version of
309 .I libosip2
310 from https://www.gnu.org/software/osip/ and recompile tcpslice.
311 .TP
312 .B h323
313 track H.323-based VoIP calls, which may enable tracking of TCP
314 connections but only the ones that are related to H.323 calls.
315 This feature is only available if tcpslice was linked against
316 Objective Systems' Open H.323 library for C; if not, install the
317 latest version of
318 .I libooh323c
319 from https://sourceforge.net/projects/ooh323c/ and recompile tcpslice.
320 .PP
321 Session tracking altogether is only available if tcpslice was linked
322 against a recent version (>1.20) of Rafal Wojtczuk's Network Intrusion
323 Detection System library; if not, install the latest version of
324 .I libnids
325 from http://libnids.sourceforge.net/ and recompile tcpslice.
326 .RE
327 .TP
328 .B \-t
329 Same as
330 .B \-R
331 except the timestamps are dumped in
332 .I tcpslice
333 format, i.e., in the
334 .I ymdhmsu
335 format discussed above.
336 .TP
337 .B \-v
338 Turn on verbose mode. Currently this only affects session tracking (\fB\-s\fP)
339 messages: if specified at least once, sessions openings and closings
340 are displayed regardless of the time (by default the closings are only
341 displayed past
342 .IR end-time );
343 if specified at least twice, subsessions (sessions initiated by other
344 sessions) openings and closings are also displayed.
345 .TP
346 .BI \-w " output-file"
347 Direct the output to \fIoutput-file\fR rather than \fIstdout\fP.
348 .SH "SEE ALSO"
349 .BR tcpdump (1)
350 .SH AUTHORS
351 The original author was:
352 .LP
353 Vern Paxson, of
354 Lawrence Berkeley Laboratory, University of California, Berkeley, CA.
355 .LP
356 It is currently maintained by The Tcpdump Group.
357 .LP
358 The current version is available at:
359 .LP
360 .RS
361 .I https://github.com/the-tcpdump-group/tcpslice
362 .RE
363 .LP
364 .LP
365 The original distribution is available via anonymous ftp:
366 .LP
367 .RS
368 .I ftp://ftp.ee.lbl.gov/tcpslice-1.2a3.tar.gz
369 .RE
370 .SH BUGS
371 Please send problems, bugs, questions, desirable enhancements, etc. to:
372 .LP
373 .RS
374 tcpdump-workers@lists.tcpdump.org
375 .RE
376 .LP
377 Please send source code contributions as git pull requests through the
378 project page above.
379 .LP
380 An input filename that exactly matches the
381 .I sssssssss.uuuuuu
382 or the
383 .I ymdhmsu
384 format discussed above can be confused with a start/end time (regardless if
385 the date and the time are valid in the latter case). Such filenames can be
386 specified with a leading `./'; for example, specify the file
387 .B 1976y07m04d
388 as
389 .B ./1976y07m04d
390 and
391 .B 00000123
392 as
393 .BR ./00000123 .
394 Alternatively, renaming the files to
395 .B 1976y07m04d.pcap
396 and
397 .B 00000123.pcap
398 respectively would resolve this ambiguity.
399 .LP
400 .I tcpslice
401 cannot read its input from \fIstdin\fP, since it uses random-access
402 to rummage through its input files.
403 .LP
404 .I tcpslice
405 cannot process an otherwise valid input file that contains fewer than two
406 packets.
407 .LP
408 .I tcpslice
409 refuses to write to its output if it is a terminal
410 (as indicated by
411 .BR isatty (3)).
412 This is not a bug but a feature,
413 to prevent it from spraying binary data to the user's terminal.
414 Note that this means you must either redirect \fIstdout\fP or specify an
415 output file via \fB\-w\fP.
416 .LP
417 .I tcpslice
418 will not work properly on pcap files spanning more than one year;
419 with files containing portions of packets whose original length was
420 more than 65,535 bytes; nor with files containing fewer than two packets.
421 Such files result in
422 the error message: `couldn't find final packet in file'. These problems
423 are due to the interpolation scheme used by
424 .I tcpslice
425 to greatly speed up its processing when dealing with large trace files.
426 Note that
427 .I tcpslice
428 can efficiently extract slices from the middle of trace files of any
429 size, and can also work with truncated trace files (i.e., the final packet
430 in the file is only partially present, typically due to \fItcpdump\fP
431 being ungracefully killed).
432 .LP
433 Adding
434 .B \-l
435 has broken some compatibility with older versions, since
436 .I tcpslice
437 now merges its input files, rather than (approximately) concatenating
438 them together as it did previously.
439 .LP
440 It would sometimes be convenient if you could specify a clock offset
441 to use with the
442 .B \-l
443 option.
444 .LP
445 It would be nice if
446 .I tcpslice
447 supported more general editing of trace files.