This post demonstrates an interesting use-case of radix tries usage for Longest Prefix Match.
The post was born from a question asked by an IT forum member. The summary of the question looked as follows:
- There is a set of text files containing routing tables collected from various network devices.
- Each file represents one device.
- Device platforms and routing table formats may vary.
- It is required to analyze a routing path from any device to an arbitrary subnet or host on-demand.
- Resulting output should contain a list of routing table entries that are used for the routing to the given destination on each hop.
The one who asked a question worked as a TAC engineer. It is often that they collect or receive from the customers some text ‘snapshots’ of the network state for further offline analysis while troubleshooting the issues. Some automation could really save a lot of time.
I found this task interesting and also applicable to my own needs, so I decided to write a Proof-of-Concept implementation in Python 3 for Cisco IOS, IOS-XE, and ASA routing table format.
In this article, I’ll try to reconstruct the resulting script development process and my considerations behind each step.