https://github.com/byteb8/ip-routing
implements trie based longest prefix matching and binary search + hash table based BSPL approach to route the ip packet to a best match destination router for next hop.
https://github.com/byteb8/ip-routing
binary-search hashtable trie-tree
Last synced: 10 months ago
JSON representation
implements trie based longest prefix matching and binary search + hash table based BSPL approach to route the ip packet to a best match destination router for next hop.
- Host: GitHub
- URL: https://github.com/byteb8/ip-routing
- Owner: byteB8
- Created: 2025-04-15T03:44:58.000Z (about 1 year ago)
- Default Branch: development
- Last Pushed: 2025-04-15T11:15:09.000Z (about 1 year ago)
- Last Synced: 2025-07-19T16:57:11.454Z (11 months ago)
- Topics: binary-search, hashtable, trie-tree
- Language: C++
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### IP Routing Algorithms Implementation
Implements two different approaches for IP routing table lookups:
#### 1. Longest Prefix Match (LPM) using Trie
- Uses a binary trie data structure where each node represents a bit
- Each path from root to node represents an IP prefix
- Time Complexity: O(W) where W is the length of IP address in bits (32 for IPv4)
- Space Complexity: O(N*W) where N is number of routes
#### 2. Binary Search on Prefix Length (BSPL)
- Performs binary search on possible prefix lengths
- Maintains separate tables for each prefix length
- Time Complexity: O(log W) where W is the length of IP address
- Space Complexity: O(N) where N is number of routes
### Usage
```bash
# For LPM Trie implementation
cd lpm
g++ lpm.cpp -o lpm
./lpm
# For BSPL implementation
cd bspl
g++ bspl.cpp -o bspl
./bspl
```
### Input Format
The routing table should be in CSV format:
```
ip_prefix,router_name
192.168.20.16/28,Router1
192.168.0.0/16,Router2
192.168.1.0/24,Router3
10.10.0.0/16,Router4
```