-
Notifications
You must be signed in to change notification settings - Fork 299
Description
At present, toxcore consume too much energy when udp is used.
The reason is that net_crypto send 0x10(ping/alive) and 0x01 message all the time.
The 0x10 is sent once every 8 seconds. And if it is not received in FRIEND_CONNECTION_TIMEOUT(32seconds), the connection will be disconnected.
In order to save energe, I suggest friend_con->ping_lastrecv should also be update upon any message received, at least be updated upon 0x01 message is received. 0x10(ping) should not be sent before channel idle for enough time. And whenever 0x10 is sent, 0x01 can be sent instead.
0x01 can serve as ping, so 0x10 is indeed not needed. For smooth transition, update friend_con->ping_lastrecv upon any message received. Then next phase, remove or reduce the sending of 0x10(ping). I mean for this change, the first phase is not to require 0x10(ping) to be received that often.
Be noted that if you have 100 friends, then every 8 seconds, 100 0x10 messages should be received.
By this way, many message sending will be removed, and energy consumption will be much lower.
Jack