I'm trying to use Pyshark to capture traffic about a tcp connection, to determine metrics such as RTT, throughput, and packet loss. However, it seems these attributes are not always available.
I'm successfully capturing packets, with a TCP layer. However, when accessing the packet.tcp.analysis_ack_rtt value, sometimes a value is returned, while other times an AttributeError is thrown.
capture = pyshark.LiveCapture(interface="eno1", bpf_filter="tcp and port 5201")
for packet in capture.sniff_continuously():
print("RTT", packet.tcp.analysis_ack_rtt)
I was sort of expecting all packets to have this field, and don't see a reason why some packets do while others don't.
On a separate note, does anyone know how to access tcp.analysis.lost_segment? It seems it is also not an attribute of the packets.