On Thu, Mar 26, 2009 at 10:09:20AM +0000, Will Morton wrote: > On 26/03/2009, Richard Price <r.m.pr...@cs.bham.ac.uk> wrote: > > > > But my question is, say I'm in a P2P network and I'm connected to > > multiple peers. Is one keepalive message from a single peer, say every 2 > > minutes, enough to stop my router timing out all my connections? Or do > > all peers each have to ensure that their individual connection does not > > timeout by regularly sending keepalive messages? If so how regularly? > > > > If you are going through a NAT device, you need to send or receive a > packet to/from each host every N seconds or else the NAT mapping for > that host will be dropped. These devices don't have very much memory > so they don't wait very long before dumping idle connections. I > believe most of them use a Least-Recently Used algorithm to keep track > of which details to dump when memory gets tight, so in a sense the > different connections are competing with each other. Anecdotal > evidence suggests a safe value is about 30 seconds, but I have no hard > data to back that up. > > If you're not going through NAT, you don't need to send a keep-alive > to keep the connection up, but you'd want one anyway to detect dead > hosts, although you could safely use one a lot longer than 30s. How > much longer would depend on how much memory you're happy to have > sitting around keeping track of dead hosts. Trade-offs, always. :-) >
Even without NAT, you may still need this for some stateful firewalls that tend to throw away their state too soon. Whether or not you need this at all heavily depends upon the exact NAT(s) and firewall implementations you're going through as well as their configuration parameters, and they both vary widely in the wild. Some follow the BEHAVE guidelines, but that number is still far from 100%, so for at least several more years, you still have to code for the worst behaving cases. _______________________________________________ p2p-hackers mailing list p2p-hackers@lists.zooko.com http://lists.zooko.com/mailman/listinfo/p2p-hackers