warjiang / dpkt

Automatically exported from code.google.com/p/dpkt
Other
0 stars 0 forks source link

Time stamp problem in dpkt #129

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I used dpkt for parsing a pcap file. but when I printed timestamp(ts) output 
was like this:1408173480.93
but I need ts should have 6 float digit. for example:1408173480.936543
what should I do?

Original issue reported on code.google.com by mh3nmshy...@gmail.com on 16 Aug 2014 at 9:55

GoogleCodeExporter commented 9 years ago

Original comment by kbandla@in2void.com on 25 Dec 2014 at 4:13

GoogleCodeExporter commented 9 years ago
I am assuming that you are doing something like this:
for ts, buf in pcap:
    print ts

And then you observe the timestamp to be "1408173480.93" instead of 
"1408173480.936543", as shown in wireshark. This is because the print function 
in python limits float to two decimal places. 

Example:
>>> x = 1258494066.119061
>>> x
1258494066.119061
>>> print x
1258494066.12

If you really need to print the full value, use format:
>>> "{0:.6f}".format(x)
'1258494066.119061'

Original comment by kbandla@in2void.com on 25 Dec 2014 at 5:53

GoogleCodeExporter commented 9 years ago
Issue 46 has been merged into this issue.

Original comment by kbandla@in2void.com on 25 Dec 2014 at 7:00