Hi Pat,
I'm sorry for the late reply. Yes, the key is exactly what you described.
As you mention, there is currently no collision prevention, with the hope that the key is generated in a uniform distribution which should prevent collisions as much as possible.
The challenge with collision detection is that it should be done on every packet:
- run hash5Tuple() on the packet
-
If it matches an existing connection, compare the params of this packet to the flow params (IP src, IP dst, port src, port dst, protocol)
-
If those match - there is no collisio
- Otherwise there is a collision and there are different ways to handle it. One way is to keep a linked list of all the connections that have this flow key. Assuming that a collision is rare, that list should contain usually 1 element, sometimes 2
The step 2 that is mentioned above is tricky because this check that needs to be done for every packet which has a performance cost.
Another option is to increase the flow key size to 8-bytes but this will have a memory cost for all flows, although collisions only happen rarely (and will not solve the collision problem completely).
Thanks,
PcapPlusPlus maintainer