Prerequisites
Before running these examples, you need to have libpcap
installed. In addition, we have to use a third-party Go package. Fortunately, this package is provided by Google, a trusted source. Go's get
ability will download and install the remote package. Git will also be needed for go get
to work properly.
Installing libpcap and Git
The libpcap
package dependency does not come pre-installed on most systems, and the installation procedure is different for each operating system. Here we will cover the installation steps for libpcap
and git
for Ubuntu, Windows, and macOS. I highly recommend that you use Ubuntu or other Linux distributions for best results. Without libpcap
, gopacket
will not function, and git
is required to fetch the gopacket
dependency.
Installing libpcap on Ubuntu
In Ubuntu, libpcap-0.8
is already installed by default. To install the gopacket
library, though, you also need the header files in the development package. You can install the header files through the libpcap...