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. :-) HTH Will _______________________________________________ p2p-hackers mailing list p2p-hackers@lists.zooko.com http://lists.zooko.com/mailman/listinfo/p2p-hackers