I was looking for a method to sniff packets being received and sent by a specific program, as I have seen some packet analyzers such as CommView have the ability to do "Packet-to-application mapping".
I want to achieve this in Python, and I don't mind any extra modules that I have to install and am already familiar with the Scapy and socket modules.
I would prefer this to be on Windows, but if that's not possible I could use Ubuntu.
: this is my first post.
Pyshark works with Wireshark and its component TShark on both Windows and Linux. It's a bit immature, but might suit your purposes.
You should install it from the GitHub repository; the PyPI version seems to be missing a fix that causes an error.