How to use Wireshark for long duration captures ka21A000000HcpyQAC | GE Customer Center

How to use Wireshark for long duration captures

Objective
How to use Wireshark (on Windows) to capture a driver or network issue that may only occur very infrequently, for example, to capture data on an issue which may occur only once a month.

Environment
Primary Product Line: All
Product Module: All

Procedure
To capture Wireshark data, you will need to use “dumpcap” which is a command line utility installed as part of Wireshark. It resides in the Wireshark root folder (e.g. C:\Program Files\Wireshark).
 
In order for the system to find dumpcap, you will need to include it as part of the Windows PATH environment variable, or explicitly specify the path.
 
To explicitly specify the PATH, you may need to include the path portion in double quotes (e.g. “C:\Program Files\Wireshark\dumpcap” -i 3  -q  -b filesize:200000  -b files:5000 -B 1024  -w d:\traces\mytrace.pca).

We use the
duration keyword in place of filesize to specify a length of time (in seconds) to spend filling each file (for example, one hour, or 3600 seconds). And to avoid eventually filling the entire hard disk with capture files, we can include the files parameter to set up a ring buffer: Once the maximum number of files have been saved, the oldest file is deleted and a new empty file is created in its place. The example below shows how we can instruct dumpcap to maintain a rotating record of the last 24 hours worth of traffic:

dumpcap -i 3 -q -b duration:3600 -b files:25 -w d:\traces\mytrace.pcap
 
We can also specify filters to limit the types of traffic captured by dumpcap. For example, the following command captures only DNS traffic destined to or coming from 169.16.22.120:


dumpcap -i 3 -q -b duration:3600 -b files:25 -f "host 169.16.22.120" -w d:\traces\mytrace.pcap


Where:
                -i = interface number (determined by entering dumpcap -D in a command prompt)
                -q = quiet mode, eliminates displaying packet count
                -b filesize:n, is the file size to create in KB
                -b duration:n, is the amount of time to run
                -b files:n, is the number of files of the above size to create
                -B n, is the size of the kernel buffer to use.
                -w <path>.pcap is the location to write the output files. The path specified must exist.
 
A full description of dumpcap options can be found in the Wireshark root folder, specifically, in the file dumpdcap.html (C:/Program Files/Wireshark/dumpcap.html)

In addition, a full description of the filter syntax is available in the Pcap-CaptureFilters hyperlink.
 
Additional Notes:
1. It is NOT recommended that you save logs to the system drive, you should use a non-system, such as drive D for this capture. If a non-system drive does not exist you can also use a USB drive.
 
2. The filesize on a 64bit system is optimal at 200MB (200000). For a 32bit system, the optimal value is 50MB (50000) or 100MB (100000).

3. The files saved will be in ISO format. For example, assuming the files were saved using  the following command line:

dumpcap -i 3 -q -b duration:3600 -b files:25 -w d:\traces\mytrace.pcap

the contents of the d:\traces folder would contain files with a sequence number and timestamp as follows:


mytrace_00001_20170626164602.pcap
.
.
.
mytrace_00024_20170627154602.pcap

Where:
00001 = file sequence number
2017 = year
0626 = month/day
164202 = hour/min/sec in 24h format

The above time also indicated when the file capture was "started".