在纪元时间过滤tshark错误
问题描述:
我有一个pcap文件,我想过滤出一些数据包基于他们与tshark时代的时间戳。在纪元时间过滤tshark错误
我有一个时间戳t1。我需要这些数据包,其时间戳比t1晚。 时间戳t1从另一个pcap文件中提取。到现在为止还挺好。
在以下几行中,我将时间戳t1(1499351908.01)转换为日期时间格式p(2017-07-06 10:38:28)。我这样做是因为tshark需要这样的符号进行过滤。否则会发生错误。
t1_c = DT.datetime.fromtimestamp(t1)
p = t1_c.strftime('%Y-%m-%d %H:%M:%S')
在以下行中我specifiy输入和输出文件和tshark的过滤器:
os.system('tshark -r test_in.pcap -w test_out.pcap -Y "frame.time >= p"')
所以,如果我跑我的代码,会出现此tshark的错误:
tshark: "p" is not a valid absolute time. Example: "Nov 12, 1999 08:55:44.123" or "2011-07-04 12:34:56"
什么是错的?过滤符号是否错误?
在此先感谢!
答
只需在字符串中重写p就不会替代它。这里是你的线应该看起来像:
os.system('tshark -r test_in.pcap -w test_out.pcap -Y "frame.time >= {}"'.format(p))
谢谢!现在它工作:) – crappidy