我只想从存储在数据库中的数据包获取时间戳,如原始字节。
>>> type(packet)
<class 'scapy.layers.inet.IP'>
>>> packet.time
1447958279.494598
>>> packet_string = str(packet)
>>> packet_string
'E\x00\x00<\xd6#@\x00@\x06f\x96\x7f\x00\x00\x01\x7f\x00\x00\x01
\xc8\xb509\xe0\xc7!!\x00\x00\x00\x00\xa0\x02\xaa\xaa\xb3T\x00
\x00\x02\x04\xff\xd7\x04\x02\x08\n\x00\x00\xf7\x02\x00\x00\x00
\x00\x01\x03\x03\x07'
>>>
>>>
>>> packet_from_string = IP(packet_string)
>>> packet_from_string
<IP version=4L ihl=5L tos=0x0 len=60 id=54819 flags=DF frag=0L
ttl=64 proto=tcp chksum=0x6696 src=127.0.0.1 dst=127.0.0.1
options=[] |<TCP sport=51381 dport=12345 seq=3771146529 ack=0
dataofs=10L reserved=0L flags=S window=43690 chksum=0xb354 urgptr=0
options=[('MSS', 65495), ('SAckOK', ''), ('Timestamp', (63234, 0)),
('NOP', None), ('WScale', 7)] |>>
>>> packet.time
1447958279.494598
>>> datetime.fromtimestamp(packet.time).strftime('%Y-%m-%d %H:%M:%S')
'2015-11-20 00:37:59'
>>> packet_from_string.time
1447960493.24821
>>> datetime.fromtimestamp(packet_from_string.time).strftime('%Y-%m-%d %H:%M:%S')
'2015-11-20 01:14:53'
如何从原始字节构建的数据包中获取实时时间戳?