diff options
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 1fac8edd..dcc32486 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -2159,7 +2159,7 @@ static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet | |||
2159 | 2159 | ||
2160 | /* The dT for the average packet recieving rate calculations. | 2160 | /* The dT for the average packet recieving rate calculations. |
2161 | Also used as the */ | 2161 | Also used as the */ |
2162 | #define PACKET_COUNTER_AVERAGE_INTERVAL 200 | 2162 | #define PACKET_COUNTER_AVERAGE_INTERVAL 100 |
2163 | 2163 | ||
2164 | /* Ratio of recv queue size / recv packet rate (in seconds) times | 2164 | /* Ratio of recv queue size / recv packet rate (in seconds) times |
2165 | * the number of ms between request packets to send at that ratio | 2165 | * the number of ms between request packets to send at that ratio |
@@ -2225,13 +2225,13 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | //new "dropped" value: weighted average of previous value and packet drop rate measured by the number of packets which were resends of previous packets | 2227 | //new "dropped" value: weighted average of previous value and packet drop rate measured by the number of packets which were resends of previous packets |
2228 | double dropped = (conn->dropped) * 0.5 + (conn->packets_resent / dt) * 0.5; | 2228 | double dropped = (conn->dropped) * 0.30 + ((double)conn->packets_resent / dt) * 0.70; |
2229 | 2229 | ||
2230 | //since the "dropped" packets measure is delayed in time from the actual # of dropped packets, | 2230 | //since the "dropped" packets measure is delayed in time from the actual # of dropped packets, |
2231 | // ignore dropped packet measure for a second after it becomes high and the send rate is lowered as a result | 2231 | // ignore dropped packet measure for 2 seconds after it becomes high and the send rate is lowered as a result |
2232 | double drop_ignore_new; | 2232 | double drop_ignore_new; |
2233 | 2233 | ||
2234 | if (conn->drop_ignore_start + 1000 < temp_time) { | 2234 | if (conn->drop_ignore_start + 2000 < temp_time) { |
2235 | drop_ignore_new = 0.0; | 2235 | drop_ignore_new = 0.0; |
2236 | 2236 | ||
2237 | if ((dropped * 1000.0) / conn->packet_send_rate >= 0.10) { | 2237 | if ((dropped * 1000.0) / conn->packet_send_rate >= 0.10) { |
@@ -2249,7 +2249,6 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2249 | realrate = r; | 2249 | realrate = r; |
2250 | } | 2250 | } |
2251 | 2251 | ||
2252 | |||
2253 | //calculate exponential increase in rate, triggered when drop rate is below 5% for 5 seconds | 2252 | //calculate exponential increase in rate, triggered when drop rate is below 5% for 5 seconds |
2254 | if ((dropped * 1000.0) / conn->packet_send_rate >= 0.05) { | 2253 | if ((dropped * 1000.0) / conn->packet_send_rate >= 0.05) { |
2255 | conn->rate_increase_stop_start = temp_time; | 2254 | conn->rate_increase_stop_start = temp_time; |