diff options
author | irungentoo <irungentoo@gmail.com> | 2015-11-17 19:12:16 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-11-17 19:12:16 -0500 |
commit | 9fc96fae6f970fe4c80ff0ceafb20ffe155419a3 (patch) | |
tree | fbf78f1fff29536922bd87a9fc49bb25bc5229da /toxcore | |
parent | d699a9627f615f0ad9c1c0c51279461c1edda08b (diff) |
Send more request packets if packet receive rate is high.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/net_crypto.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 5cd4cba3..b4640c61 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -2129,7 +2129,7 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2129 | } | 2129 | } |
2130 | 2130 | ||
2131 | if ((conn->status == CRYPTO_CONN_NOT_CONFIRMED || conn->status == CRYPTO_CONN_ESTABLISHED) | 2131 | if ((conn->status == CRYPTO_CONN_NOT_CONFIRMED || conn->status == CRYPTO_CONN_ESTABLISHED) |
2132 | && ((CRYPTO_SEND_PACKET_INTERVAL / 4) + conn->last_request_packet_sent) < temp_time) { | 2132 | && ((CRYPTO_SEND_PACKET_INTERVAL) + conn->last_request_packet_sent) < temp_time) { |
2133 | if (send_request_packet(c, i) == 0) { | 2133 | if (send_request_packet(c, i) == 0) { |
2134 | conn->last_request_packet_sent = temp_time; | 2134 | conn->last_request_packet_sent = temp_time; |
2135 | } | 2135 | } |
@@ -2141,9 +2141,18 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2141 | double request_packet_interval = (REQUEST_PACKETS_COMPARE_CONSTANT / (((double)num_packets_array( | 2141 | double request_packet_interval = (REQUEST_PACKETS_COMPARE_CONSTANT / (((double)num_packets_array( |
2142 | &conn->recv_array) + 1.0) / (conn->packet_recv_rate + 1.0))); | 2142 | &conn->recv_array) + 1.0) / (conn->packet_recv_rate + 1.0))); |
2143 | 2143 | ||
2144 | double request_packet_interval2 = ((CRYPTO_PACKET_MIN_RATE / conn->packet_recv_rate) * | ||
2145 | (double)CRYPTO_SEND_PACKET_INTERVAL) + (double)PACKET_COUNTER_AVERAGE_INTERVAL; | ||
2146 | |||
2147 | if (request_packet_interval2 < request_packet_interval) | ||
2148 | request_packet_interval = request_packet_interval2; | ||
2149 | |||
2144 | if (request_packet_interval < PACKET_COUNTER_AVERAGE_INTERVAL) | 2150 | if (request_packet_interval < PACKET_COUNTER_AVERAGE_INTERVAL) |
2145 | request_packet_interval = PACKET_COUNTER_AVERAGE_INTERVAL; | 2151 | request_packet_interval = PACKET_COUNTER_AVERAGE_INTERVAL; |
2146 | 2152 | ||
2153 | if (request_packet_interval > CRYPTO_SEND_PACKET_INTERVAL) | ||
2154 | request_packet_interval = CRYPTO_SEND_PACKET_INTERVAL; | ||
2155 | |||
2147 | if (temp_time - conn->last_request_packet_sent > (uint64_t)request_packet_interval) { | 2156 | if (temp_time - conn->last_request_packet_sent > (uint64_t)request_packet_interval) { |
2148 | if (send_request_packet(c, i) == 0) { | 2157 | if (send_request_packet(c, i) == 0) { |
2149 | conn->last_request_packet_sent = temp_time; | 2158 | conn->last_request_packet_sent = temp_time; |