mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Increase max file transfer speed.
Fix bug that limited it to 1K packets per second.
This commit is contained in:
parent
25843bf141
commit
73b2144edc
|
@ -2283,10 +2283,10 @@ static void send_crypto_packets(Net_Crypto *c)
|
||||||
} else {
|
} else {
|
||||||
if (((uint64_t)((1000.0 / conn->packet_send_rate) + 0.5) + conn->last_packets_left_set) <= temp_time) {
|
if (((uint64_t)((1000.0 / conn->packet_send_rate) + 0.5) + conn->last_packets_left_set) <= temp_time) {
|
||||||
double n_packets = conn->packet_send_rate * (((double)(temp_time - conn->last_packets_left_set)) / 1000.0);
|
double n_packets = conn->packet_send_rate * (((double)(temp_time - conn->last_packets_left_set)) / 1000.0);
|
||||||
|
n_packets += conn->last_packets_left_rem;
|
||||||
|
|
||||||
uint32_t num_packets = n_packets;
|
uint32_t num_packets = n_packets;
|
||||||
double rem = n_packets - (double)num_packets;
|
double rem = n_packets - (double)num_packets;
|
||||||
uint64_t adj = (uint64_t)((rem * (1000.0 / conn->packet_send_rate)) + 0.5);
|
|
||||||
|
|
||||||
if (conn->packets_left > num_packets * 4 + CRYPTO_MIN_QUEUE_LENGTH) {
|
if (conn->packets_left > num_packets * 4 + CRYPTO_MIN_QUEUE_LENGTH) {
|
||||||
conn->packets_left = num_packets * 4 + CRYPTO_MIN_QUEUE_LENGTH;
|
conn->packets_left = num_packets * 4 + CRYPTO_MIN_QUEUE_LENGTH;
|
||||||
|
@ -2294,20 +2294,22 @@ static void send_crypto_packets(Net_Crypto *c)
|
||||||
conn->packets_left += num_packets;
|
conn->packets_left += num_packets;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->last_packets_left_set = temp_time - adj;
|
conn->last_packets_left_set = temp_time;
|
||||||
|
conn->last_packets_left_rem = rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((uint64_t)((1000.0 / conn->packet_send_rate_requested) + 0.5) + conn->last_packets_left_requested_set) <=
|
if (((uint64_t)((1000.0 / conn->packet_send_rate_requested) + 0.5) + conn->last_packets_left_requested_set) <=
|
||||||
temp_time) {
|
temp_time) {
|
||||||
double n_packets = conn->packet_send_rate_requested * (((double)(temp_time - conn->last_packets_left_requested_set)) /
|
double n_packets = conn->packet_send_rate_requested * (((double)(temp_time - conn->last_packets_left_requested_set)) /
|
||||||
1000.0);
|
1000.0);
|
||||||
|
n_packets += conn->last_packets_left_requested_rem;
|
||||||
|
|
||||||
uint32_t num_packets = n_packets;
|
uint32_t num_packets = n_packets;
|
||||||
double rem = n_packets - (double)num_packets;
|
double rem = n_packets - (double)num_packets;
|
||||||
uint64_t adj = (uint64_t)((rem * (1000.0 / conn->packet_send_rate_requested)) + 0.5);
|
|
||||||
conn->packets_left_requested = num_packets;
|
conn->packets_left_requested = num_packets;
|
||||||
|
|
||||||
conn->last_packets_left_requested_set = temp_time - adj;
|
conn->last_packets_left_requested_set = temp_time;
|
||||||
|
conn->last_packets_left_requested_rem = rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->packets_left > conn->packets_left_requested)
|
if (conn->packets_left > conn->packets_left_requested)
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define CRYPTO_CONN_ESTABLISHED 4
|
#define CRYPTO_CONN_ESTABLISHED 4
|
||||||
|
|
||||||
/* Maximum size of receiving and sending packet buffers. */
|
/* Maximum size of receiving and sending packet buffers. */
|
||||||
#define CRYPTO_PACKET_BUFFER_SIZE 16384 /* Must be a power of 2 */
|
#define CRYPTO_PACKET_BUFFER_SIZE 32768 /* Must be a power of 2 */
|
||||||
|
|
||||||
/* Minimum packet rate per second. */
|
/* Minimum packet rate per second. */
|
||||||
#define CRYPTO_PACKET_MIN_RATE 4.0
|
#define CRYPTO_PACKET_MIN_RATE 4.0
|
||||||
|
@ -151,10 +151,12 @@ typedef struct {
|
||||||
double packet_send_rate;
|
double packet_send_rate;
|
||||||
uint32_t packets_left;
|
uint32_t packets_left;
|
||||||
uint64_t last_packets_left_set;
|
uint64_t last_packets_left_set;
|
||||||
|
double last_packets_left_rem;
|
||||||
|
|
||||||
double packet_send_rate_requested;
|
double packet_send_rate_requested;
|
||||||
uint32_t packets_left_requested;
|
uint32_t packets_left_requested;
|
||||||
uint64_t last_packets_left_requested_set;
|
uint64_t last_packets_left_requested_set;
|
||||||
|
double last_packets_left_requested_rem;
|
||||||
|
|
||||||
uint32_t last_sendqueue_size[CONGESTION_QUEUE_ARRAY_SIZE], last_sendqueue_counter;
|
uint32_t last_sendqueue_size[CONGESTION_QUEUE_ARRAY_SIZE], last_sendqueue_counter;
|
||||||
long signed int last_num_packets_sent[CONGESTION_LAST_SENT_ARRAY_SIZE],
|
long signed int last_num_packets_sent[CONGESTION_LAST_SENT_ARRAY_SIZE],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user