有没有一种有效的方法来获得pyshark中的字段偏移

Is there an efficienct way to get field offset in pyshark

有没有一种有效的方法来获取使用pyshark捕获的数据包中某些字段的偏移量? 例如,我需要获取源 IP 在整个数据包内或数据包中某个层 header 内的偏移量。可能吗?

我能够解决我的问题。这是一个示例代码:

import pyshark

packets = pyshark.FileCapture(input_file=pcap_file_dir)
print(int(packets[0].ip.src.pos)) # Prints the offset of source IP