# isginf/pcap-diff architecture

> Architecture diagram of the GitHub repository isginf/pcap-diff, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/isginf/pcap-diff
- Repository: https://github.com/isginf/pcap-diff

## Overview

pcap-diff is a single-file command-line tool that compares packet contents across two or more PCAP captures and writes differing packets to a new capture. Its workflow parses options, reads captures into packet maps keyed by normalized serialization, compares those maps according to left/right selection rules, and writes the result. The README documents field-ignore and layer-boundary options. The excerpt omits some implementation details, so the graph keeps the major stages within the one supported source file and shows only evidenced relationships.

Main entry points: [`pcap_diff.py`](https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py) (Capture reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_comparison["PCAP comparison"]
  node_options["Option parsing<br/>[pcap_diff.py]"]
  node_capture["Capture reader<br/>[pcap_diff.py]"]
  node_normalize["Packet normalization<br/>[pcap_diff.py]"]
  node_compare["Difference selection<br/>[pcap_diff.py]"]
  node_output["Diff capture output<br/>[pcap_diff.py]"]
end

node_user(("CLI user"))
node_scapy["Scapy"]
node_pcapfiles["PCAP files"]

node_user -->|"sets options"| node_options
node_options -->|"selects inputs"| node_capture
node_capture -->|"reads packets"| node_scapy
node_pcapfiles -->|"provides captures"| node_capture
node_capture -->|"serializes packets"| node_normalize
node_normalize -->|"keys packets"| node_compare
node_options -->|"configures ignores"| node_normalize
node_compare -->|"selects differences"| node_output
node_output -.->|"writes capture"| node_scapy
node_output -.->|"produces diff"| node_pcapfiles

click node_options "https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py"
click node_capture "https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py"
click node_normalize "https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py"
click node_compare "https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py"
click node_output "https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_options,node_capture,node_normalize,node_compare,node_output,node_user toneBlue
class node_scapy,node_pcapfiles toneIndigo
```

## Components

### PCAP comparison

- [Option parsing](https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py): `pcap_diff.py`
- [Capture reader](https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py): `pcap_diff.py`
- [Packet normalization](https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py): `pcap_diff.py`
- [Difference selection](https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py): `pcap_diff.py`
- [Diff capture output](https://github.com/isginf/pcap-diff/blob/master/pcap_diff.py): `pcap_diff.py`

### Other components

- **CLI user**
- **Scapy**
- **PCAP files**

## Connections

- CLI user → Option parsing: sets options (evidence: `pcap_diff.py`)
- Option parsing → Capture reader: selects inputs (evidence: `pcap_diff.py`)
- Capture reader → Scapy: reads packets (evidence: `pcap_diff.py`)
- PCAP files → Capture reader: provides captures (evidence: `pcap_diff.py`)
- Capture reader → Packet normalization: serializes packets (evidence: `pcap_diff.py`)
- Packet normalization → Difference selection: keys packets (evidence: `pcap_diff.py`)
- Option parsing → Packet normalization: configures ignores (evidence: `pcap_diff.py`)
- Difference selection → Diff capture output: selects differences (evidence: `pcap_diff.py`)
- Diff capture output → Scapy: writes capture
- Diff capture output → PCAP files: produces diff
