The FlowTable manages the collection of flows. You can choose between two backends depending on your performance and ordering requirements:
- Hash Backend (
FlowIndexBackend::Hash): Uses std::unordered_map. Provides average $O(1)$ complexity. Best for high-performance flow tracking. - Tree Backend (
FlowIndexBackend::Tree): Uses std::map (typically a Red-Black tree). Closest to the original softflowd implementation. Provides $O(\log n)$ complexity.
Compile-time selection
Use templates to select the backend with zero runtime overhead:
softflow::FlowTable<softflow::FlowIndexBackend::Tree> table(65536);
Runtime selection
Use FlowTableRuntime to switch backends at runtime (e.g., via command-line arguments):
softflow::FlowTableRuntime table(softflow::FlowIndexBackend::Tree, 65536);
In the softflowd_cpp executable, you can switch the backend using the --backend flag:
softflowd_cpp --backend=hash ...
softflowd_cpp --backend=tree ...