title: Monitor network traffic while running a python script
body: <p>I am trying to monitor network traffic coming in and out of my VM**. My VM is connected to a socket via TCP (IP, PORT) with the python socket library. Once connected, I am sending a stream of bytes to the socket and then close the connection. The VM runs <strong>Ubuntu 18.04 LTS</strong>. The connection is made in a VPN tunnel.</p>
  <p>How do I capture the traffic for the source and destination while my python script runs? I have tried to work with scapy and Wireshark/pyshark, but the documentation I found did not help me a lot.</p>
  <p>Does anyone have an idea how I could do this? <strong>I am using python 3</strong></p>