-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> - We should send one packet to each node every <fixed interval>, so as
> not to give away information about them.
> - So we should send one ping every 5 seconds to each node.
> - Will this cause it to take a long time for a node to recognize that it
> is no longer overloaded?
Do pings necessarily have to be sent at fixed intervals, as long as
there's a maximum interval between successive pings? Rather than sending
dedicated pings, how about adding a ping header to an outgoing data
packet where possible? For example if the max interval between pings is
5 seconds, start looking for a suitable data packet after 4 seconds, and
if a ping still hasn't been sent after 5 seconds then send a dedicated
ping. Either way the neighbour responds immediately with a pong.
In fact pings, coalescing and keepalives can be handled with a single
mechanism:
to queue a non-urgent message:
add message to tail of queue
data in queue += size of message
while (data in queue >= sensible packet size) send a packet
set coalescing timer for message at head of queue
to queue an urgent message: /* eg a pong */
add message to tail of queue
data in queue += size of message
while (data in queue > 0) send a packet
set keepalive timer
to send a packet:
cancel coalescing timer
cancel keepalive timer
size of packet = 0
if (ping flag is raised)
add ping header to packet
lower ping flag
cancel ping end timer
set ping start timer /* eg 4 seconds */
while (size of packet + size of message at head of queue <= max)
remove message from head of queue
data in queue -= size of message
add message to packet
data in packet += size of message
transmit packet /* may be empty */
when coalescing timer expires:
send a packet
when keepalive timer expires:
send a packet
when ping start timer expires: /* eg 4 seconds */
raise ping flag
set ping end timer /* eg another second */
when ping end timer expires:
send a packet
I think it's possible to handle all the timers for all neighbours with a
single thread (PacketSender). If the keepalive interval is higher than
the maximum ping interval then there's no need for a keepalive timer.
Cheers,
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFENtMryua14OQlJ3sRAmYIAKDBOjL2CJsbjqXrC3eFPuPTssN9cACfUNKt
DoOi07JsMvvgj7P59sRxBuI=
=48DF
-----END PGP SIGNATURE-----