Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pcap-ct

Python wrapper for the pcap library.

Overview

Python pcap-ct package is a simplified object-oriented Python wrapper for libpcap C library - the current tcpdump.org version, and the WinPcap port for Windows..

pcap-ct is a pure Python package, based on the low-level libcap package.
It is fully compliant implementation of the original PyPCAP 1.2.3 API (with some minor improvements and bug fixes) by implementing whole its functionality in a clean Python instead of Cython and C.

PyPI record.

Documentation.

About original PyPCAP:

Borrowed from the original website:

PyPCAP

This is a simplified object-oriented Python wrapper for libpcap - the current tcpdump.org version, and the WinPcap port for Windows.

Example use #1:

>>> import pcap
>>> sniffer = pcap.pcap(name=None, promisc=True, immediate=True, timeout_ms=50)
>>> addr = lambda pkt, offset: '.'.join(str(ord(pkt[i])) for i in range(offset, offset + 4))
>>> for ts, pkt in sniffer:
...     print('%d\tSRC %-16s\tDST %-16s' % (ts, addr(pkt, sniffer.dloff + 12), addr(pkt, sniffer.dloff + 16)))
...

Example use #2:

Listing Interfaces

>>> import pcap
>>> print ("Interfaces:\n" + '\n'.join(pcap.findalldevs()))

Windows notes

WinPcap has compatibility issues with Windows 10, therefore it’s recommended to use Npcap (Nmap’s packet sniffing library for Windows, based on the WinPcap/Libpcap libraries, but with improved speed, portability, security, and efficiency). Please enable WinPcap API-compatible mode during the library installation.

Installation

Prerequisites:

To install run:

python -m pip install --upgrade pcap-ct

Development

Prerequisites:

  • Development is strictly based on tox. To install it run:

    python -m pip install --upgrade tox

Visit Development page.

Installation from sources:

clone the sources:

git clone https://github.com/karpierz/pcap-ct.git pcap-ct

and run:

python -m pip install ./pcap-ct

or on development mode:

python -m pip install --editable ./pcap-ct

License

Copyright (c) 2016-2025 Adam Karpierz
Licensed under the BSD license
Please refer to the accompanying LICENSE file.

Authors

Changelog

1.3.0b3 (2025-02-14)

  • Drop support for Python 3.8

  • 100% code linting.

  • Copyright year update.

  • Setup (dependencies) update.

1.3.0b2 (2024-08-13)

  • Add support for Python 3.12 and 3.13

  • Drop support for Python 3.7

  • Add support for PyPy 3.9 and 3.10

  • Drop support for PyPy 3.7 and 3.8

  • Setup (dependencies) update.

1.3.0b1 (2022-09-10)

  • Support for libpcap.set_buffer_size() via ‘buffer_size’
    (optional) pcap constructor’s parameter.
  • Added ‘datalink’ optional parameter to pcap constructor
    (thank you very much easy-easy@Github for the patch!).
  • Tox configuration has been moved to pyproject.toml

1.2.3b14 (2022-08-30)

  • Update for libpcap>=1.11.0b6

  • Add support for Python 3.10 and 3.11

  • Add preliminary support for PyPy 3.7, 3.8 and 3.9

  • Setup update (currently based mainly on pyproject.toml).

1.2.3b12 (2022-01-19)

  • Fixed a bug in pcap.sendpacket()
    (thank you very much EvanSonnemans@Github
    for report and bugfix!).

1.2.3b11 (2022-01-10)

  • Update for libpcap>=1.11.0b3

  • Drop support for Python 3.6.

  • Copyright year update.

  • Setup update.

1.2.3b9 (2021-11-10)

  • Update for libpcap>=1.11.0b2

  • Copyright year update.

  • Fixes for Linux.

  • Setup update.

1.2.3b5 (2020-10-18)

  • Add support for Python 3.9.

  • Drop support for Python 3.5.

  • Fixed a critical setup of ‘libpcap’ package
    (thank you very much msrst@Github!).
  • General update and cleanup.

  • Fixed docs setup.

1.2.3b1 (2019-11-14)

  • Update for PyPCAP 1.2.3.

  • Add support for Python 3.8.

  • Drop support for Python 2.

  • Drop support for Python 3.4.

  • Update required setuptools version.

  • Setup improvements and cleanup.

1.2.0b5 (2018-11-08)

  • Update required setuptools version.

  • Minor setup and tests improvements.

1.2.0b4 (2018-02-26)

  • Improve and simplify setup and packaging.

1.2.0b3 (2018-02-01)

  • Update for PyPCAP 1.2.0.

1.2.0b2 (2017-10-10)

  • Minor changes.

1.2.0b1 (2017-10-05)

  • Next beta release.

  • Update for PyPCAP 1.2.0rc.

1.1.6b4 (2017-10-04)

  • Fourth beta release.

1.1.6b3 (2017-08-28)

  • Third beta release.

1.1.6b2 (2017-08-28)

  • Second beta release.

1.1.6b1 (2017-08-27)

  • First beta release.

1.1.6a15 (2017-08-25)

  • Next alpha release.

1.1.6a0 (2017-06-10)

  • First alpha release.

0.0.1 (2016-09-23)

  • Initial release.

Metadata

Release files for pcap-ct 1.3.0b3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pcap-ct 1.3.0b3
File Size Uploaded
pcap_ct-1.3.0b3.tar.gz 27.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pcap-ct 1.3.0b3
File Interpreter ABI Platform
pcap_ct-1.3.0b3-py3-none-any.whl Python 3 none any Details

Total release size: 40.0 kB

Release files / pcap_ct-1.3.0b3.tar.gz

Download URL pcap_ct-1.3.0b3.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8021444a188f894417b38e088ce15e3c26376121dd995ff6f550f49b500f296c
BLAKE2b-256 checksum
How to use checksums
e8a9dbbe5e225c943be8dee4c3da06e5da68c21a2b298d81c756d66f1a2aa295
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / pcap_ct-1.3.0b3-py3-none-any.whl

Download URL pcap_ct-1.3.0b3-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37b610e940bdfba306411a1ee2ba2fc8e7f1a5469ae7e680880b8f02e1fb4366
BLAKE2b-256 checksum
How to use checksums
c28a005d6c94d88879f277728073d021758905a906fee708aafb725af7032aab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page