R/Kademlia: No removal of non-responding bucket entries
As of 2359b9c8, the R/Kademlia implementation never removes nodes from its routing table again unless they're evicted by entries with a better proximity.
So far that is an acceptable drawback, as the network is stable and without churn. Thus nodes never leave the system and become unreachable; the threat of an MITM attacker dropping messages can be seen as rather equivalent to the attacker replying with spoofed messages instead. But once churn becomes relevant, a mechanism for removing unresponding nodes from buckets needs to be implemented. Otherwise there is the danger of very proximity-close nodes accumulating in the routing table, dropping out of the network over time, but still blocking fresh nodes from entering the bucket again as most other nodes have a worse proximity.
implementation idea
For quicker lookup performance whether an entry needs to be removed at each timeout event, I propose to introduce an additional std::map<RoutingAddressPtr,KademliaAddressPtr>
. By looking up the routing address of the failing node, we can get its kademlia address and from this determine the bucket it needs to be removed from.
It has to be noted that by default, a map compares only the pointers of its keys. Thus a custom comparator class that compares the addresses behind the pointers is to be implemented and used for the map.