Skip to content

Reduce the use of DHT pings when GetNodes packets are sent #1111

@jackzhp

Description

@jackzhp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions