简体   繁体   中英

Python dpkt packet analysis

I'm wanting to find the timestamping from pcap file using python dpkt package; similar to tcpdump -tttt option which would provide me the details of time with date of the packet that was generated .

It would be great if you could provide some code snippet in your question. A rough guess is that you can try something like this:

myPcap = open('test.pcap')
pcap = dpkt.pcap.Reader(myPcap)
for ts in pcap:
   print ts

It can be done by importing the datetime package.

import dpkt

import datetime

for ts, buf in pcap:
  eth=dpkt.ethernet.Ethernet()

//this is the method that is used to convert the epoch time to date

date1=**datetime.datetime.fromtimestamp(float(ts)).strftime('%d-%m-%Y')**

//rest of the code can go after this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM