Scapy PcapReader and packets time

auino picture auino · Nov 7, 2012 · Viewed 13.9k times · Source

I'm reading a PCAP file using Scapy using a script such as the (semplified) following one:

#! /usr/bin/env python
from scapy.all import *
# ...
myreader = PcapReader(myinputfile)
for p in myreader:
    pkt = p.payload
    print pkt.time

In this case the packets time is not relative to PCAP capture time, but starts from the instant I've launched my script. I'd like to start from 0.0 or to be relative to the PCAP capture.

How can I fix it (possibly without "manually" retrieving the first packet time and repeatedly using math to fix the problem)?

Answer

auino picture auino · Nov 7, 2012

I saw that using pkt.time is wrong, in this case.
I should print p.time instead.