The following program demonstrates the basics of capturing a packet. The device name is passed as a string. If you don't know the device name, use the previous example to get a list of the devices available on your machine. If you don't see the exact devices listed, you may need to elevate your privileges and run the program with sudo.
The promiscuous mode is an option you can enable to listen for packets that are not destined for your device. The promiscuous mode is particularly relevant with wireless devices because wireless network devices actually have the capability to pick up packets in the air that were intended for other recipients.
Wireless traffic is particularly vulnerable to sniffing because all the packets are broadcast through the air instead of through Ethernet, where physical access is required for the wire to intercept traffic. Providing...