{ "info": { "author": "Pier Carlo Chiodi", "author_email": "pierky@pierky.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "Intended Audience :: Telecommunications Industry", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: System :: Networking" ], "description": "Unique Smallest Routable Entries Monitor (USREsMonitor)\n=======================================================\n\n|Build Status| |PYPI Version|\n\nThis library is inspired by an issue opened by Thomas Mangin on the repository of [InvalidRoutesReporter](https://github.com/pierky/invalidroutesreporter): https://github.com/pierky/invalidroutesreporter/issues/1\n\nGiven a set (or stream) of IP prefixes, this library calculates the unique smallest routable entries (SREs) covered by them.\n\nDe-duplication of overlapping prefixes is performed. SREs are calculated on the basis of a target prefix length that can be set on input.\n\nPrefixes can be added and removed as they come (for example from a BGP session) and the resultant set of unique SREs is computed accordingly.\n\nExample:\n\n```\n>>> from pierky.usres_monitor import UniqueSmallestRoutableEntriesMonitor\n>>> monitor = UniqueSmallestRoutableEntriesMonitor(target_prefix_len4=24)\n>>> monitor.add_net(\"192.168.0.0/16\")\n>>> [\"first: {first_ip}, last: {last_ip}, cnt: {cnt}\".format(**prefix) for prefix in monitor.get_prefixes(4)]\n['first: 192.168.0.0, last: 192.168.255.0, cnt: 256']\n>>> monitor.get_count(4)\n256\n```\n\nSo, 192.168.0.0/16 contains 256 /24 subnets.\n\nNow, add a prefix that is already covered by the previous one:\n\n```\n>>> monitor.add_net(\"192.168.0.0/21\")\n>>> [\"first: {first_ip}, last: {last_ip}, cnt: {cnt}\".format(**prefix) for prefix in monitor.get_prefixes(4)]\n['first: 192.168.0.0, last: 192.168.255.0, cnt: 256']\n```\n\nNothing changed. Add a prefix that covers the 2 already added before:\n\n```\n>>> monitor.add_net(\"192.0.0.0/8\")\n>>> [\"first: {first_ip}, last: {last_ip}, cnt: {cnt}\".format(**prefix) for prefix in monitor.get_prefixes(4)]\n['first: 192.0.0.0, last: 192.255.255.0, cnt: 65536']\n```\n\nHere it is, 192.0.0.0/8 covers both 192.168.0.0/16 and 192.168.0.0/21 and contains 65536 /24 subnets.\n\nNow remove the two larger prefixes:\n\n```\n>>> monitor.del_net(\"192.0.0.0/8\")\n>>> monitor.del_net(\"192.168.0.0/16\")\n>>> [\"first: {first_ip}, last: {last_ip}, cnt: {cnt}\".format(**prefix) for prefix in monitor.get_prefixes(4)]\n['first: 192.168.0.0, last: 192.168.7.0, cnt: 8']\n```\n\nOnly 192.168.0.0/21 remains, with its 8 /24 subnets.\n\nAdd now a second prefix:\n\n```\n>>> monitor.add_net(\"192.168.8.0/21\")\n>>> [\"first: {first_ip}, last: {last_ip}, cnt: {cnt}\".format(**prefix) for prefix in monitor.get_prefixes(4)]\n['first: 192.168.0.0, last: 192.168.7.0, cnt: 8', 'first: 192.168.8.0, last: 192.168.15.0, cnt: 8']\n>>> monitor.get_count(4)\n16\n```\n\nTwo prefixes are printed, each one covering 8 SREs, for a total of 16 SREs.\n\nBoth IPv4 and IPv6 can be used, also simultaneously with the same monitor object:\n\n```\n>>> from pierky.usres_monitor import UniqueSmallestRoutableEntriesMonitor\n>>> monitor = UniqueSmallestRoutableEntriesMonitor(target_prefix_len4=24, target_prefix_len6=56)\n>>> monitor.add_net(\"192.168.0.0/16\")\n>>> monitor.add_net(\"10.0.0.0/8\")\n>>> monitor.add_net(\"2001:db8:aaaa::/48\")\n>>> [\"first: {first_ip}, last: {last_ip}, cnt: {cnt}\".format(**prefix) for prefix in monitor.get_prefixes(4)]\n['first: 192.168.0.0, last: 192.168.255.0, cnt: 256', 'first: 10.0.0.0, last: 10.255.255.0, cnt: 65536']\n>>> [\"first: {first_ip}, last: {last_ip}, cnt: {cnt}\".format(**prefix) for prefix in monitor.get_prefixes(6)]\n['first: 2001:db8:aaaa::, last: 2001:db8:aaaa:ff00::, cnt: 256']\n>>> monitor.get_count(4)\n65792\n>>> monitor.get_count(6)\n256\n```\n\nInstallation\n------------\n\n```\npip install usresmonitor\n```\n\nOptionally, the [apsw](https://github.com/rogerbinns/apsw) SQLite library can be installed; in that case, it will be preferred during the setup of the backend database used by USREsMonitor.\n\nFuture work\n-----------\n\nAdd some examples of how this library can be used (ExaBGP integration).\n\nStatus\n------\n\n**First-release**, looking for testers and reviewers.\n\nBug? Issues?\n------------\n\nBut also suggestions? New ideas?\n\nPlease create an `issue on GitHub `_ or `drop me a message `_.\n\nAuthor\n------\n\nPier Carlo Chiodi - https://pierky.com\n\nBlog: https://blog.pierky.com Twitter: `@pierky `_\n\n.. |Build Status| image:: https://travis-ci.org/pierky/usres_monitor.svg?branch=master\n :target: https://travis-ci.org/pierky/usres_monitor\n.. |PYPI Version| image:: https://img.shields.io/pypi/v/usres_monitor.svg\n :target: https://pypi.python.org/pypi/usres_monitor/\n\n\nChange log\n----------\n\nv0.1.1\n++++++\n\nFix: better exception handling of duplicate prefixes\n\nv0.1.0\n++++++\n\nFirst release.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/pierky/usres_monitor", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pierky/usres_monitor", "keywords": "BGP,IP Routing", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "usresmonitor", "package_url": "https://pypi.org/project/usresmonitor/", "platform": "", "project_url": "https://pypi.org/project/usresmonitor/", "project_urls": { "Download": "https://github.com/pierky/usres_monitor", "Homepage": "https://github.com/pierky/usres_monitor" }, "release_url": "https://pypi.org/project/usresmonitor/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "A library to get unique smallest routable entries from a set of IP prefixes.", "version": "0.1.1" }, "last_serial": 3006802, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "5a08b82dc7b17e3f92981e58457f627e", "sha256": "c6159380c687b9cd69fc31b9552ea36f0c0207370f07601ebafd25adcb75461f" }, "downloads": -1, "filename": "usresmonitor-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5a08b82dc7b17e3f92981e58457f627e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21005, "upload_time": "2017-07-07T17:25:12", "url": "https://files.pythonhosted.org/packages/c3/1d/cefd3bf3b974aecb7de076a754db8e5241c2d48b7bbb21a536a2865034d1/usresmonitor-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5a08b82dc7b17e3f92981e58457f627e", "sha256": "c6159380c687b9cd69fc31b9552ea36f0c0207370f07601ebafd25adcb75461f" }, "downloads": -1, "filename": "usresmonitor-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5a08b82dc7b17e3f92981e58457f627e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21005, "upload_time": "2017-07-07T17:25:12", "url": "https://files.pythonhosted.org/packages/c3/1d/cefd3bf3b974aecb7de076a754db8e5241c2d48b7bbb21a536a2865034d1/usresmonitor-0.1.1.tar.gz" } ] }