diff options
author | irungentoo <irungentoo@gmail.com> | 2015-11-12 15:48:14 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-11-12 15:48:14 -0500 |
commit | e1089c1779fb1c58f17937108a6ba8c3d39573ae (patch) | |
tree | bf1202f197cc9537c715b129a6cd97f9fc3978ac /toxcore | |
parent | c84b9c4b4c18a35df8e2bc134d3cdddd255f44a0 (diff) |
Less magic numbers.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/net_crypto.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index a35cc4da..17748697 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -2105,6 +2105,12 @@ static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet | |||
2105 | /* Timeout for increasing speed after congestion event (in ms). */ | 2105 | /* Timeout for increasing speed after congestion event (in ms). */ |
2106 | #define CONGESTION_EVENT_TIMEOUT 1000 | 2106 | #define CONGESTION_EVENT_TIMEOUT 1000 |
2107 | 2107 | ||
2108 | /* If the send queue is SEND_QUEUE_RATIO times larger than the | ||
2109 | * calculated link speed the packet send speed will be reduced | ||
2110 | * by a value depending on this number. | ||
2111 | */ | ||
2112 | #define SEND_QUEUE_RATIO 2.0 | ||
2113 | |||
2108 | static void send_crypto_packets(Net_Crypto *c) | 2114 | static void send_crypto_packets(Net_Crypto *c) |
2109 | { | 2115 | { |
2110 | uint32_t i; | 2116 | uint32_t i; |
@@ -2196,8 +2202,8 @@ static void send_crypto_packets(Net_Crypto *c) | |||
2196 | double send_array_ratio = (((double)npackets) / min_speed); | 2202 | double send_array_ratio = (((double)npackets) / min_speed); |
2197 | 2203 | ||
2198 | //TODO: Improve formula? | 2204 | //TODO: Improve formula? |
2199 | if (send_array_ratio > 2.0 && CRYPTO_MIN_QUEUE_LENGTH < npackets) { | 2205 | if (send_array_ratio > SEND_QUEUE_RATIO && CRYPTO_MIN_QUEUE_LENGTH < npackets) { |
2200 | conn->packet_send_rate = min_speed * (1.0 / (send_array_ratio / 2.0)); | 2206 | conn->packet_send_rate = min_speed * (1.0 / (send_array_ratio / SEND_QUEUE_RATIO)); |
2201 | } else if (conn->last_congestion_event + CONGESTION_EVENT_TIMEOUT < temp_time) { | 2207 | } else if (conn->last_congestion_event + CONGESTION_EVENT_TIMEOUT < temp_time) { |
2202 | conn->packet_send_rate = min_speed * 1.2; | 2208 | conn->packet_send_rate = min_speed * 1.2; |
2203 | } else { | 2209 | } else { |