python live data tracing similar to wireshark

based upon tshark pyshark provides the functionalities.


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:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store