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.6.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asncounter-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d4ee7048516d2237ed737c03817912699e0d4d600778ac7b81c4515de858ccd
MD5 89deeed5d6e5a53a4ceace122bf3a9c6
BLAKE2b-256 b26782aea22997fc9057ea905fba7b00515c2196031a849a8b0fb40f9cf1f274

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