Coder Social home page Coder Social logo

network-patricia's Introduction

network-patricia

An implementation of a Patricia Trie geared specifically for storing IP addresses with a CIDR-style prefix.

The Patricia Trie and its close relative, the Radix Trie are space- optimized data structures well-suited for storing network addresses.

Nodes with only one child are merged with their child. Though this yields higher average access costs, it's a very convenient property when dealing with overlapping ranges and potentially duplicate addresses.

libpatricia

Functions for inserting nodes, removing nodes, and searching in a Patricia trie designed for IP addresses and netmasks. A head node must be created with (key,mask) = (0,0).

ptest

This executable serves as an example of how to use the Patricia Trie library for doing longest-prefix matching.

We begin by adding a default node as the head of the Patricia trie. This will become an initialization function (pat_init). We then read in a set of IPv4 addresses and network masks from a data file (given in argv[1]) and insert them into the trie.

Implementation Notes

The fact that we keep multiple masks per node makes this more complicated and computationally expensive then a standard trie. We do this because we need to do longest prefix matching, which is useful for computer networks, but not as useful in other applications.

Performance

Traversing is an O(k) operation (where "k" is the length of the key).

Authors

License

Licensed under the GNU LGPL 2.1.

Copyright (c) 2000 The Regents of the University of Michigan

Copyright (c) 2014 J. Brandt Buckley

network-patricia's People

Contributors

brandt avatar

Stargazers

Bjørnar Ness avatar  avatar  avatar Ray Yan avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.