Skip to content

Commit 9bf6e07

Browse files
authored
Merge pull request #16 from travelping/snaplength-feature
Added snaplength-feature (-s tshark parameter), specified base image as alpine:3.9.
2 parents 13e7804 + f74061d commit 9bf6e07

File tree

4 files changed

+35
-15
lines changed

4 files changed

+35
-15
lines changed

Diff for: CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
## v1.2.0- Feature:
2+
3+
- Added snaplength feature
4+
- Specified base image as alpine:3.9
5+
16
## v1.1.0- Feature:
27

3-
- Added formatting option
8+
- Reworked (experimental) formatting option
9+
10+
## v1.0.2- (Experimental) Feature:
11+
12+
- Added (experimental) formatting option
413

514
## v1.0.1
615

Diff for: Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine
1+
FROM alpine:3.9
22

33
RUN apk add --no-cache tshark coreutils
44

@@ -10,6 +10,7 @@ ENV MAXFILESIZE="1000"
1010
ENV MAXFILENUM="10"
1111
ENV FILENAME="dump"
1212
ENV FORMAT="pcapng"
13+
ENV SNAPLENGTH=""
1314

1415
USER root:root
1516

Diff for: README.md

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# TSHARK in a container
22

3-
This container starts a tshark and safes the captured packages in files. It
4-
uses a ring buffer with a default file size of 1 Gigabyte and a maximum number
3+
This container starts a tshark and safes the captured packages in files. It
4+
uses a ring buffer with a default file size of 1 Gigabyte and a maximum number
55
of files of 10. All files are stored in the `/data` directory.
66

77
## Usage
@@ -23,6 +23,7 @@ These options are configurable:
2323
| `DURATION` | `""` |
2424
| `FILENAME` | `dump` |
2525
| `FORMAT` | `pcapng` |
26+
| `SNAPLENGTH` | <deactivated> |
2627

2728
`IFACE` space-separated list of interfaces tshark should listen on.
2829

@@ -34,22 +35,26 @@ be opened. The unit for this is Megabytes (1 Megabyte = 1,000,000 bytes).
3435
`MAXFILENUM` is the maximum number of files that are opened before tshark
3536
starts overwriting old files one by one beginning with the first one.
3637

37-
`DURATION` is the maximum number of seconds tshark waits until it begins to
38+
`DURATION` is the maximum number of seconds tshark waits until it begins to
3839
write into the next file.
3940

40-
The `FILENAME` variable sets the filename that is used. The default value is
41-
`dump`. A number will be attached to each file (see tshark manpage for more
42-
information). To dump on multiple interfaces simply add more interfaces to this
41+
The `FILENAME` variable sets the filename that is used. The default value is
42+
`dump`. A number will be attached to each file (see tshark manpage for more
43+
information). To dump on multiple interfaces simply add more interfaces to this
4344
variable seperated by a whitespace (e.g. "eth0 eth1").
4445

4546
`FORMAT` sets the file-format of the written trace. Note that when you're setting
4647
the `FORMAT` to `pcap` for example, the `FILENAME` has to be changed to `dump.pcap`.
4748
Other formats are described in the [official tshark documentation](https://www.wireshark.org/docs/man-pages/tshark.html).
4849

50+
`SNAPLENGTH` is the amount of data for each frame that is actually captured by the
51+
network capturing tool and stored into the CaptureFile. This is sometimes called PacketSlicing.
52+
By default this is turned off so large packets are not truncated by accident.
53+
4954
Example:
5055

5156
```
52-
-> % ls -1 dump
57+
-> % ls -1 dump
5358
dump_00164_20180622110637
5459
dump_00165_20180622110638
5560
dump_00166_20180622110639
@@ -73,13 +78,13 @@ option to read captured raw packages from a file.
7378

7479
### Display Filters
7580

76-
Since `tshark` does not allow for wireshark like filters to be applied to a
77-
capture stream. And the functionality of piping to a `tshark` and than applying
78-
a read filter is also broken (see
79-
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2234), applying wireshark
81+
Since `tshark` does not allow for wireshark like filters to be applied to a
82+
capture stream. And the functionality of piping to a `tshark` and than applying
83+
a read filter is also broken (see
84+
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2234), applying wireshark
8085
like filters needs to be done in a second filter pass.
8186

82-
This can be done with a local installed instance of `tshark` or using the
87+
This can be done with a local installed instance of `tshark` or using the
8388
`tshark` provided by the docker-pcap container:
8489

8590
```

Diff for: run.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ then
3535
BUFFEROPTS="$BUFFEROPTS -b duration:$DURATION"
3636
fi
3737

38-
/usr/bin/tshark $BUFFEROPTS -w "/data/$FILENAME" -f "$FILTER" $INTERFACES -F $FORMAT
38+
if [ -n "$SNAPLENGTH" ];
39+
then
40+
SNAPLENGTH="-s $SNAPLENGTH"
41+
fi
42+
43+
/usr/bin/tshark $BUFFEROPTS -w "/data/$FILENAME" -f "$FILTER" $INTERFACES -F $FORMAT $SNAPLENGTH

0 commit comments

Comments
 (0)