Walk Through Example - Converting a pcap File to CSV

In this example, we convert the pcap in the ‘test’ directory of the pcap2csv installation into a CSV file.

Steps

1. Follow the steps in Installing pcap2csv to download pcap2csv source file and install.

  1. After installing, change directory to the test folder within pcap2csv root:

    cd test
    

3. In the test directory you will find a sample pcap file (test1.pcap) which we will be converting to a csv file in the test1_out folder. Run the command below to convert the pcap file to csv:

pcap2csv -v -p ./test1.pcap -o ./test1_out

This will create a csv version of test1.pcap, in addition to a metadata file and a log file, saving all in the test1_out directory. Please take a look at the files in test1_out directory to examine the output. Full descriptions for the output csv file can be found in Usage Details.


Alternatively, the example above can be executed with the command:

./test1

Or with

python3 test1.py

Or within a python3 shell environment

from pcap2csv.pcap2csv import Pcap2csv
pcapmaker = Pcap2csv('test1.pcap', 'test1_out')
pcapmaker.makecsvs()