# sach/system-verilog-packet-library architecture

> Architecture diagram of the GitHub repository sach/system-verilog-packet-library, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sach/system-verilog-packet-library
- Repository: https://github.com/sach/system-verilog-packet-library

## Overview

Pktlib is a SystemVerilog packet-construction and inspection library. The principal workflow configures and randomizes protocol headers, packs them into packet bytes, then displays or compares packets; it also supports smart unpacking and PCAP input/output. Header classes model the protocol stages, while array and checksum classes provide internal byte and integrity operations. README documents these capabilities and class responsibilities; sampled source confirms PCAP DPI operations, but does not expose the full SystemVerilog call wiring, so uncertain links are omitted.

Main entry points: [`pktlib_class.sv`](https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_class.sv) (Packet library), [`hdr_db`](https://github.com/sach/system-verilog-packet-library/tree/master/hdr_db) (Protocol headers), [`hdr_db/include/pcap/pcap_dump.c`](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/pcap/pcap_dump.c) (PCAP file API), [`pktlib_main_class.sv`](https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_main_class.sv) (Library base)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Packet orchestration"]
  node_packet_lib["Packet library<br/>[pktlib_class.sv]"]
  node_main["Library base"]
  node_object["Base object"]
end

subgraph group_protocols["Protocol headers"]
  node_hdr_base["Header base<br/>[hdr_class.sv]"]
  node_header_db["Protocol headers"]
  node_l2_headers["Ethernet headers<br/>[eth_hdr_class.sv]"]
  node_network_headers["IP headers<br/>[ipv4_hdr_class.sv]"]
  node_transport_headers["Transport headers<br/>[tcp_hdr_class.sv]"]
  node_payload["Packet payload<br/>[data_class.sv]"]
end

subgraph group_utilities["Packet utilities"]
  node_arrays["Byte operations"]
  node_integrity["CRC and checksum"]
  node_display["Display and compare"]
end

subgraph group_capture["PCAP integration"]
  node_pcap_sv["PCAP DPI wrapper<br/>[pcap_dpi.sv]"]
  node_pcap_dpi["PCAP bridge<br/>[pcap_dpi.c]"]
  node_pcap_api["PCAP file API<br/>[pcap_dump.c]"]
end

subgraph group_security["Security support"]
  node_gcm_sv["GCM DPI interface<br/>[gcm_dpi.sv]"]
  node_gcm_bridge["GCM DPI bridge<br/>[gcm_dpi.cpp]"]
  node_gcm_engine["GCM engine<br/>[gcm.cpp]"]
  node_aes["AES implementation<br/>[aescrypt.c]"]
end

node_user(("Test author"))
node_libpcap["libpcap"]
node_packet_bytes["Packet bytes"]
node_pcap_file["PCAP capture"]

node_user -->|"configures and invokes"| node_packet_lib
node_packet_lib -->|"uses base"| node_main
node_main -->|"extends"| node_object
node_packet_lib -->|"configures and randomizes"| node_header_db
node_header_db -->|"models headers"| node_hdr_base
node_header_db -->|"includes"| node_l2_headers
node_header_db -->|"includes"| node_network_headers
node_header_db -->|"includes"| node_transport_headers
node_header_db -->|"includes"| node_payload
node_packet_lib -->|"packs and unpacks"| node_arrays
node_packet_lib -->|"computes and corrupts"| node_integrity
node_packet_lib -->|"displays and compares"| node_display
node_packet_lib -->|"packs to"| node_packet_bytes
node_packet_bytes -->|"unpacks from"| node_packet_lib
node_pcap_sv -->|"calls DPI"| node_pcap_dpi
node_pcap_dpi -->|"reads and writes"| node_pcap_api
node_pcap_api -->|"uses"| node_libpcap
node_pcap_api -->|"reads or writes"| node_pcap_file
node_gcm_sv -.->|"calls DPI"| node_gcm_bridge
node_gcm_bridge -.->|"invokes"| node_gcm_engine
node_gcm_engine -.->|"encrypts with"| node_aes

click node_packet_lib "https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_class.sv"
click node_main "https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_main_class.sv"
click node_object "https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_object_class.sv"
click node_hdr_base "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/hdr_class.sv"
click node_header_db "https://github.com/sach/system-verilog-packet-library/tree/master/hdr_db"
click node_l2_headers "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/eth_hdr_class.sv"
click node_network_headers "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/ipv4_hdr_class.sv"
click node_transport_headers "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/tcp_hdr_class.sv"
click node_payload "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/data_class.sv"
click node_arrays "https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_array_class.sv"
click node_integrity "https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_crc_chksm_class.sv"
click node_display "https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_display_class.sv"
click node_pcap_sv "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/pcap/pcap_dpi.sv"
click node_pcap_dpi "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/pcap/pcap_dpi.c"
click node_pcap_api "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/pcap/pcap_dump.c"
click node_gcm_sv "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/gcm-aes/sv-file/gcm_dpi.sv"
click node_gcm_bridge "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/gcm-aes/c-file/gcm_dpi.cpp"
click node_gcm_engine "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/gcm-aes/c-file/gcm.cpp"
click node_aes "https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/gcm-aes/c-file/aescrypt.c"

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_packet_lib,node_main,node_object toneBlue
class node_hdr_base,node_header_db,node_l2_headers,node_network_headers,node_transport_headers,node_payload toneAmber
class node_arrays,node_integrity,node_display toneMint
class node_pcap_sv,node_pcap_dpi,node_pcap_api toneRose
class node_gcm_sv,node_gcm_bridge,node_gcm_engine,node_aes,node_user,node_libpcap,node_packet_bytes,node_pcap_file toneIndigo
```

## Components

### Packet orchestration

- [Packet library](https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_class.sv): `pktlib_class.sv`
- [Library base](https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_main_class.sv): `pktlib_main_class.sv`
- [Base object](https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_object_class.sv): `pktlib_object_class.sv`

### Protocol headers

- [Header base](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/hdr_class.sv): `hdr_db/hdr_class.sv`
- [Protocol headers](https://github.com/sach/system-verilog-packet-library/tree/master/hdr_db): `hdr_db`
- [Ethernet headers](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/eth_hdr_class.sv): `hdr_db/eth_hdr_class.sv`
- [IP headers](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/ipv4_hdr_class.sv): `hdr_db/ipv4_hdr_class.sv`
- [Transport headers](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/tcp_hdr_class.sv): `hdr_db/tcp_hdr_class.sv`
- [Packet payload](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/data_class.sv): `hdr_db/data_class.sv`

### Packet utilities

- [Byte operations](https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_array_class.sv): `pktlib_array_class.sv`
- [CRC and checksum](https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_crc_chksm_class.sv): `pktlib_crc_chksm_class.sv`
- [Display and compare](https://github.com/sach/system-verilog-packet-library/blob/master/pktlib_display_class.sv): `pktlib_display_class.sv`

### PCAP integration

- [PCAP DPI wrapper](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/pcap/pcap_dpi.sv): `hdr_db/include/pcap/pcap_dpi.sv`
- [PCAP bridge](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/pcap/pcap_dpi.c): `hdr_db/include/pcap/pcap_dpi.c`
- [PCAP file API](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/pcap/pcap_dump.c): `hdr_db/include/pcap/pcap_dump.c`

### Security support

- [GCM DPI interface](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/gcm-aes/sv-file/gcm_dpi.sv): `hdr_db/include/gcm-aes/sv-file/gcm_dpi.sv`
- [GCM DPI bridge](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/gcm-aes/c-file/gcm_dpi.cpp): `hdr_db/include/gcm-aes/c-file/gcm_dpi.cpp`
- [GCM engine](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/gcm-aes/c-file/gcm.cpp): `hdr_db/include/gcm-aes/c-file/gcm.cpp`
- [AES implementation](https://github.com/sach/system-verilog-packet-library/blob/master/hdr_db/include/gcm-aes/c-file/aescrypt.c): `hdr_db/include/gcm-aes/c-file/aescrypt.c`

### Other components

- **Test author**
- **libpcap**
- **Packet bytes**
- **PCAP capture**

## Connections

- Test author → Packet library: configures and invokes
- Packet library → Library base: uses base
- Library base → Base object: extends
- Packet library → Protocol headers: configures and randomizes
- Protocol headers → Header base: models headers
- Protocol headers → Ethernet headers: includes
- Protocol headers → IP headers: includes
- Protocol headers → Transport headers: includes
- Protocol headers → Packet payload: includes
- Packet library → Byte operations: packs and unpacks
- Packet library → CRC and checksum: computes and corrupts
- Packet library → Display and compare: displays and compares
- Packet library → Packet bytes: packs to
- Packet bytes → Packet library: unpacks from
- PCAP DPI wrapper → PCAP bridge: calls DPI
- PCAP bridge → PCAP file API: reads and writes
- PCAP file API → libpcap: uses
- PCAP file API → PCAP capture: reads or writes
- GCM DPI interface → GCM DPI bridge: calls DPI
- GCM DPI bridge → GCM engine: invokes
- GCM engine → AES implementation: encrypts with
