Table of Contents

Scapy

Sample

import pandas as pd
from scapy.all import rdpcap
from scapy.all import IP

packets = rdpcap("input.pcap")

records = []
for i, pkt in enumerate(packets):
    if IP in pkt:
        records.append({"idx": i, "time": pkt[IP].time, "src": pkt[IP].src, "dst": pkt[IP].dst, "id": pkt[IP].id, "len": pkt[IP].len})
    else:
        records.append({"idx": i, "time": pkt[IP].time, "src": None, "dst": None, "id": None, "len": None})

df = pd.DataFrame(records)

References