1
votes

While capturing packets on Windows 7 x64, timestamps don't seem to have float precision. the code is given below.

from scapy.all import sniff
pkts = sniff(count=10)
pkts[0].time
-> for higher precision output
print('%.6f'%pkts[0].time)

output

1506009934
1506009934.000000

any ideas how to get precise values for timestamps?

1
If you print(type(pkts[0].time)) what do you get?Mark Ransom
you are right on point it is giving me <type 'int'> in response. But how to correct that?Kashif Ahmad
I don't know scapy and I can't find the time attribute in the documentation, so I don't know what units it's using. Sorry I can't help.Mark Ransom
@KashifAhmad Are you sure it didn't work. I tried your code (I use scapy 2.3.2) and printing just the timestamp I got 1506018140.84 and using print('%.6f'%pkts[0].time) I got 1506018140.836040 for the same timestamp.coder
Yes I am hundred percent sure about this. As I have some pcap files where I have assigned timestamps to packets. If you want to read those timestamps then it would give you float values. But when scapy tries to sniff or even with 'sr' function it wouldn't show any float valuesKashif Ahmad

1 Answers

1
votes

This has been fixed in Scapy's development version. Get it from the official repository and your code should give the results you expect.