Skip to content

ipv{4,6}-flow-classifier: store flow info in unordered maps for quicker flow lookup

Following the discussion in https://groups.google.com/g/ns-3-users/c/epkB_TIQl4M:

This MR exchanges the std::maps used in ipv{4,6}-flow-classifier to store flow information with std::unordered_maps. This speeds up FindFlow(FlowId flowId) a lot. For m_flowMap I've also included custom hashes for the respective FiveTuple definitions.

So far, to the best of my knowledge, the insertion order has only been leveraged in SerializeToXmlStream(). Since serialization is requested by the user and maybe done not too frequently, I am now creating a sorted std::map in SerializeToXmlStream() to sort the entries by FiveTuple on-demand.

I guess this is a good compromise between speed and memory usage, however we need to keep m_flowMap and m_inverseFlowMap synchronized, which may be suboptimal.

I'm open to suggestions for improvement.

Merge request reports

Loading