Monday, October 3, 2016

Replaying network packets captured in a PCAP file

Some devices broadcast GPS positions over the network and saved into a PCAP file. Incidentally, PCAP stands for Packet CAPture. I got hold of some PCAP files and tried to use the Linux tcpreplay command to playback the captured network packets over the network.

The tcpreplay command input arguments require to specify the network interface and it conveniently advertises an option --listnics to list all the network interfaces on your machine. An example usage is displayed in  the screenshot below.

$ sudo tcpreplay --listnics


However, using any of the listed interfaces will result in an error when attempting to playback a pcap file, as shown below.

$ sudo tcpreplay --intf1 bluetooth0 *.pcap



After some research, I found the ip command with the link option that lists the network interfaces correctly.

$ ip link



Now plugging in the correct interface name into the tcpreplay command, my network packets are successfully replayed and broadcasted.

$ sudo tcpreplay --intf1 enp0s25 *.pcap

 

No comments: