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

Uploaded Python 3

File details

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

File metadata

  • Download URL: asncounter-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 23.7 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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60b7f6c98e73d68fd58167570500211b959052ce8540622a9e1879ace7f2e2c0
MD5 1cbae139cdacbbeca63cfd764c980b2e
BLAKE2b-256 e1a1fb5f3c2921041893550ed9d0c039b595a880f72f6ac67c91931e94f0f846

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