Skip to main content

Library for finding best route in the routing table

Project description

Library for finding best route in the routing table

Implementation of trie-tree best route finding algorithm.

It is actually a bindings wrapper for the Rust library.

Usage

See .pyi stub file (also included in the package) for detailed information.

The information from the stub file should be visible in your IDE hints as well as shown by "Go to Definition" IDE action.

Example

from ipaddress import IPv4Address

from best_route_finder import IPv4RoutingTableTree

table = IPv4RoutingTableTree()
table.insert(int(IPv4Address('192.168.1.0')), 24, 'ens192')
table.insert_by_string('10.0.0.0/8', 'ens10')

assert 'ens192' == table.search_by_string('192.168.1.123')
assert 'ens10' == table.search(int(IPv4Address('10.1.1.43')))

Creating form the list

The IPv4RoutingTableTree also provides an option to create a routing table by passing a list of entries.

class IPv4RoutingTableTree:
    (...)
    def from_mapping(entries: list[__RoutingTableEntry]) -> 'IPv4RoutingTableTree': ...

The entries have to implement interface compatible with:

@dataclass
class __RoutingTableEntry:
    """
    Interface for a class representing single routing table entry

    User shall provide own implementation of this interface
    """
    subnet: IPv4Network  #: a subnet part of an entry
    interface: str  #: next-hop interface name associated with the subnet

In low-level terms they have to be objects that will have proper attributes set, so the following code will not raise an error:

assert isinstance(entry.subnet.network_address._ip, int)
assert isinstance(entry.subnet.prefixlen, int)
assert isinstance(entry.interface, str)

Project details


Download files

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

Source Distribution

best_route_finder-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

best_route_finder-0.1.0-cp39-none-win_amd64.whl (128.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

File details

Details for the file best_route_finder-0.1.0.tar.gz.

File metadata

  • Download URL: best_route_finder-0.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.11.5

File hashes

Hashes for best_route_finder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d7da5ba44106069c8eece03ebb92c42dabdad77bdfbeb0f607278e800b821122
MD5 6a5682507d7fce95ed0ec2316e0b40a7
BLAKE2b-256 9cfe1413cdc0ac2414e7f4eff6d7c26a3e3242b8d6bc3d31476160d457418121

See more details on using hashes here.

File details

Details for the file best_route_finder-0.1.0-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for best_route_finder-0.1.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 3f7c64f1a69f64aaba137dd0f81466a36124ff73258c905e678195f4adda8569
MD5 8c3678a58c6ced7beb4eb361a0e42bf1
BLAKE2b-256 6245867f6b36295f3888c025688f7acf8b787ccb288da81ec00943181b66c7b4

See more details on using hashes here.

Supported by

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