1

I would like to capture RTCP packets and parse its. As I see in the pyshark documentation for live capture I have to define timeout, our packet_count. As my understanding after this option the live capture is stopped, and I able to parse the data. I need to do a calculation so I always need data from packet "n" and "n+1". If the pyshark is parsing data after the timeout, or after x packet, how can I garantee to have always the "n" and "n+1" packet.

Here is an example:

capture = pyshark.LiveCapture(interface='eth0')
for packet in capture.sniff_continuously(packet_count=5):
    print 'Just arrived:', packet

If I capture 5 packets, how to do the calculation for the 5th packet? I cannot capture infinite number of packets.

Is it a doable idea if I capture only 1 packet assign it to a packet_0 then capture one more with a while cycle continuously assign it to packet_1, do the calculation, and then shit the packet_1 to packet_0, and return to the beginning of while cycle (capture 1 packet to packet_1)

jtarjanyi
  • 17
  • 1
  • 7

1 Answers1

1

I write in my code:

pcap_reader = pyshark.LiveCapture('en0')
for packet in pcap_reader.sniff_continuously():
    print(packet)

refer: https://github.com/KimiNewt/pyshark/blob/6311e3e5598d42220ef02b896375544c1825113b/src/pyshark/capture/live_capture.py#L105

JerryDi
  • 11
  • 2