Low-Level Packet
Manipulation Library

10 protocols. 66 CLI commands. 60+ Python bindings. PCAP support. Built for security research, penetration testing, and network tools.

Nim engine + Python bindings + REST API — use it however you want.

10
Protocols
66
CLI Commands
60+
Python Functions
42
API Endpoints
0
Dependencies
Python
CLI
API
Nim
import nimpacket as np

# Build a TCP SYN packet
pkt = np.build_tcp_syn_packet("192.168.1.100", "10.0.0.1", 54321, 80)

# Save to PCAP (opens in Wireshark)
np.write_pcap("crafted.pcap", [pkt])

# Parse any packet from hex
result = np.parse_packet(pkt)
print(result["tcp"]["dst_port"])  # 80

# Get PCAP stats
stats = np.pcap_stats("capture.pcap")
print(stats["protocols"])  # {"tcp": 120, "udp": 15, ...}
# Craft packets from the command line
$ nimpacket craft tcp-syn --src 192.168.1.100 --dst 10.0.0.1 --dport 80
$ nimpacket craft udp --src 10.0.0.1 --dst 8.8.8.8 --dport 53 --payload "hello"

# Parse raw packets
$ nimpacket parse auto --hex 4500002800010000...

# PCAP analysis
$ nimpacket pcap stats capture.pcap
$ nimpacket pcap filter capture.pcap --protocol tcp --output tcp.pcap
$ nimpacket pcap replay capture.pcap --speed 2.0

# Network scanning
$ nimpacket scan syn --target 192.168.1.1 --ports 1-1000
# Craft a packet over HTTP
$ curl -X POST https://apexnet.onrender.com/api/craft/tcp/syn \
    -H "Content-Type: application/json" \
    -d '{"src_ip":"192.168.1.100","dst_ip":"10.0.0.1","src_port":54321,"dst_port":80}'

# Response:
{
  "packet_hex": "4500002824aa0000...",
  "size": 40,
  "protocol": "tcp_syn"
}

# Parse, get PCAP stats, compute checksums — all via API
# Full Swagger docs at /docs
import nimpacket

# Create a TCP SYN packet
let ipv4 = IPv4Header(
  srcIP: parseIPv4("192.168.1.100"),
  dstIP: parseIPv4("10.0.0.1"),
  protocol: IPPROTO_TCP
)

let tcp = TCPHeader(
  srcPort: 12345,
  dstPort: 80,
  flags: TCP_SYN
)

# Stack layers and serialize
let packet = (ipv4 / tcp).toBytes()
echo "Packet ready: ", packet.len, " bytes"

// Core Features

[ 01 ]

10 Protocols

IPv4, IPv6, TCP, UDP, ICMP, ICMPv6, Ethernet, ARP, DNS, DHCP. Complete control over every header field.

[ 02 ]

Python Bindings

pip install nimpacket — 60+ functions. Craft, parse, send packets, and analyze PCAPs from Python.

[ 03 ]

66 CLI Commands

Craft, parse, send, scan, listen, fragment, PCAP tools, and utilities. All from the terminal.

[ 04 ]

PCAP Support

Read, write, filter, and replay .pcap files. Wireshark compatible. Deterministic replay engine with adjustable speed.

[ 05 ]

IP Fragmentation

5 evasion strategies: TinyFragments, OverlapPoison, OutOfOrder, TimeDelayed, PolymorphicRandom.

[ 06 ]

REST API

42 HTTP endpoints via ApexNet. Craft and parse packets from any language over HTTP.

[ 07 ]

Zero Dependencies

Pure Nim engine. No libpcap, no external C libraries. Easy to audit and deploy anywhere.

[ 08 ]

Native Performance

Compiles to machine code. Optimized checksums. Minimal memory allocations. Faster than Python-based alternatives.

[ 09 ]

Raw Sockets

Send and receive packets directly. Port scanning, network discovery, and custom tools. Requires admin privileges.

// Quick Start

[ Install via pip ]

$ pip install nimpacket

[ Install via Nimble ]

$ nimble install nimpacket

[ Craft & Send a Packet ]

import nimpacket as np

# Craft a TCP SYN
pkt = np.build_tcp_syn_packet("192.168.1.100", "10.0.0.1", 54321, 80)
print(f"Packet: {pkt.hex()}")

# Parse it back
parsed = np.parse_packet(pkt)
print(parsed["ipv4"]["src_ip"])  # 192.168.1.100

# Save to PCAP (opens in Wireshark)
np.write_pcap("output.pcap", [pkt])

// ApexNet API

All of NimPacket's power as a REST API. Craft packets, parse hex, analyze PCAPs — from any language, any platform, over HTTP.

Craft

Build TCP, UDP, ICMP, ARP, DNS, DHCP, IPv6, Ethernet packets from JSON parameters.

POST /api/craft/tcp/syn

Parse

Decode raw packet hex into structured JSON. Auto-detects protocol or parse specific layers.

POST /api/parse

PCAP

Upload .pcap files for stats, filtering, and deterministic replay scheduling.

POST /api/pcap/stats

Utility

Checksums, IP fragmentation with 5 evasion strategies, byte conversions.

POST /api/util/fragment
Open API Docs (Swagger) →

42 endpoints • Free to use • No API key required

// CLI Tool

66 commands. Everything from packet crafting to PCAP replay, right in your terminal.

Craft (18 commands)
tcp-syn, tcp-ack, tcp-rst, tcp-fin, tcp-psh, tcp-custom, udp, icmp-echo, icmp-unreachable, arp-request, arp-reply, arp-frame, dns-query, dns-response, dhcp-discover, dhcp-request, ipv6, icmpv6-echo
Parse (11 commands)
auto, ipv4, ipv6, tcp, udp, icmp, icmpv6, ethernet, arp, dns, dhcp
PCAP (5 commands)
read, stats, write, filter, replay
Network (10 commands)
send, scan (syn/udp/ping/arp), listen, fragment, send-fragmented
$ nimpacket craft tcp-syn --src 192.168.1.1 --dst 10.0.0.1 --dport 80
$ nimpacket pcap stats capture.pcap
$ nimpacket pcap replay capture.pcap --speed 2.0 --protocol tcp
$ nimpacket scan syn --target 192.168.1.0/24 --ports 80,443

// NimPacket vs Scapy

Feature NimPacket Scapy
Performance Native (Fast) Interpreted (Slow)
Dependencies Zero Many
Python Bindings 60+ functions Native Python
CLI Tool 66 commands Interactive only
REST API 42 endpoints None
PCAP Support Read/Write/Filter/Replay Full (via libpcap)
IP Fragmentation 5 evasion strategies Basic
Protocol Count 10 core protocols Hundreds
Type Safety Compile-time Runtime

// Use Cases

Port Scanning

Craft custom TCP SYN packets for port discovery. SYN, UDP, Ping, and ARP scan modes built in.

PCAP Analysis

Read capture files, get protocol stats, filter by protocol, and replay traffic with exact timing.

IDS/IPS Testing

Test detection systems with 5 IP fragmentation evasion strategies. Replay known-bad traffic at the firewall.

Protocol Testing

Send malformed or edge-case packets. Test DNS, DHCP, ARP implementations with crafted payloads.

Network Discovery

ARP requests to map topology. ICMP ping sweeps. Identify hosts and services on your network.

API Integration

Use ApexNet to add packet crafting to any app. Web dashboards, security tools, automation — over HTTP.

// Documentation

Full docs, API reference, CLI guide, and PCAP documentation on GitHub.