Skip to main content

Count the number of hits (HTTP, packets, etc) per autonomous system number (ASN) and related network blocks

Project description

ASN counter

Count the number of hits (HTTP, packets, etc) per autonomous system number (ASN) and related network blocks.

This is useful when you get a lot of traffic on a server to figure out which network is responsible for the traffic, to direct abuse complaints or block whole networks, or on core routers to figure out who your peers are and who you might want to seek particular peering agreements with.

Features

  • reads packets from a text file (or stdin) one per line
  • counts number of hits, packets, sizes, latency, etc per ASN and netblock
  • can parse some tcpdump output or read packets directly from interfaces with scapy
  • fast ASN lookups pyasn
  • automatic download of relevant databases from routeviews.org
  • Prometheus exporter
  • written in Python
  • optional Python REPL interpreter shell to drill into reports

See the manual page for full documentation and examples. See also the test suite and performance metrics.

See CONTRIBUTING.md for how to contribute, file issues, or get help.

Installation

Simply:

pip install asncounter

Can also run from the source directory directly.

Note that the pip install does not build or deploy the manual page, as that depends on pandoc or some markdown-to-man converter, which feels too complicated to setup in the Python tool chain.

The Debian package properly builds and ships the manual page, however, see debian/rules for an example of how to package this on your own distribution.

Dependencies

Optional dependencies

  • manhole: to get a debugging socket
  • scapy: to scrape packets directly without tcpdump (slower)
  • prometheus_client: to export Prometheus metrics
  • netaddr: to aggregate network blocks in the REPL or manhole

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asncounter-0.5.1-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file asncounter-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: asncounter-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for asncounter-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 383297ba0f9a0cb2d35597dcd631018c10875cdb8bc3c0a56a859157d70d2808
MD5 c6a0aa8d0f9f8607053067b9d1c66006
BLAKE2b-256 10ae849ac9e3bc0d3d482889f4577a4f98897fd342796a029117544e9a5e3200

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page