python live data tracing similar to wireshark

Adarsha Regmi
1 min readMay 27, 2022


based upon tshark pyshark provides the functionalities.


>> pip install pyshark

After installing the wheel we can access the function provided by the library. One of the example is

import pyshark
capture = pyshark.LiveCapture(interface='eth0')

> The above command imports pyshark and captures the data streaming over the selected ‘eth0’ interface. The timeout is set for the pyshark to trace the data.

f = ("layers.txt", "w")
if len(capture) > 0:
for packet in capture:
val = packet.__dict__['layers']

> this command checks the library for traced data and stores in layers.txt file.

The below is image for viewing the packet

eg. example for traced data

Github link for example:

for pyshark: