mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Send more request packets if packet receive rate is high.
This commit is contained in:
parent
d699a9627f
commit
9fc96fae6f
|
@ -2129,7 +2129,7 @@ static void send_crypto_packets(Net_Crypto *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((conn->status == CRYPTO_CONN_NOT_CONFIRMED || conn->status == CRYPTO_CONN_ESTABLISHED)
|
if ((conn->status == CRYPTO_CONN_NOT_CONFIRMED || conn->status == CRYPTO_CONN_ESTABLISHED)
|
||||||
&& ((CRYPTO_SEND_PACKET_INTERVAL / 4) + conn->last_request_packet_sent) < temp_time) {
|
&& ((CRYPTO_SEND_PACKET_INTERVAL) + conn->last_request_packet_sent) < temp_time) {
|
||||||
if (send_request_packet(c, i) == 0) {
|
if (send_request_packet(c, i) == 0) {
|
||||||
conn->last_request_packet_sent = temp_time;
|
conn->last_request_packet_sent = temp_time;
|
||||||
}
|
}
|
||||||
|
@ -2141,9 +2141,18 @@ static void send_crypto_packets(Net_Crypto *c)
|
||||||
double request_packet_interval = (REQUEST_PACKETS_COMPARE_CONSTANT / (((double)num_packets_array(
|
double request_packet_interval = (REQUEST_PACKETS_COMPARE_CONSTANT / (((double)num_packets_array(
|
||||||
&conn->recv_array) + 1.0) / (conn->packet_recv_rate + 1.0)));
|
&conn->recv_array) + 1.0) / (conn->packet_recv_rate + 1.0)));
|
||||||
|
|
||||||
|
double request_packet_interval2 = ((CRYPTO_PACKET_MIN_RATE / conn->packet_recv_rate) *
|
||||||
|
(double)CRYPTO_SEND_PACKET_INTERVAL) + (double)PACKET_COUNTER_AVERAGE_INTERVAL;
|
||||||
|
|
||||||
|
if (request_packet_interval2 < request_packet_interval)
|
||||||
|
request_packet_interval = request_packet_interval2;
|
||||||
|
|
||||||
if (request_packet_interval < PACKET_COUNTER_AVERAGE_INTERVAL)
|
if (request_packet_interval < PACKET_COUNTER_AVERAGE_INTERVAL)
|
||||||
request_packet_interval = PACKET_COUNTER_AVERAGE_INTERVAL;
|
request_packet_interval = PACKET_COUNTER_AVERAGE_INTERVAL;
|
||||||
|
|
||||||
|
if (request_packet_interval > CRYPTO_SEND_PACKET_INTERVAL)
|
||||||
|
request_packet_interval = CRYPTO_SEND_PACKET_INTERVAL;
|
||||||
|
|
||||||
if (temp_time - conn->last_request_packet_sent > (uint64_t)request_packet_interval) {
|
if (temp_time - conn->last_request_packet_sent > (uint64_t)request_packet_interval) {
|
||||||
if (send_request_packet(c, i) == 0) {
|
if (send_request_packet(c, i) == 0) {
|
||||||
conn->last_request_packet_sent = temp_time;
|
conn->last_request_packet_sent = temp_time;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user