mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Some protocol efficiency improvements.
Reduced the amount of waste from dropped packets.
This commit is contained in:
parent
e3ee9702fb
commit
8760aba257
|
@ -799,7 +799,7 @@ static int reset_max_speed_reached(Net_Crypto *c, int crypt_connection_id)
|
|||
dt->length) != 0) {
|
||||
send_failed = 1;
|
||||
} else {
|
||||
dt->sent_time = 1;
|
||||
dt->sent_time = current_time_monotonic();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, cons
|
|||
Packet_Data *dt1 = NULL;
|
||||
|
||||
if (get_data_pointer(&conn->send_array, &dt1, packet_num) == 1)
|
||||
dt1->sent_time = 1;
|
||||
dt1->sent_time = current_time_monotonic();
|
||||
} else {
|
||||
conn->maximum_speed_reached = 1;
|
||||
LOGGER_ERROR("send_data_packet failed\n");
|
||||
|
@ -2000,7 +2000,14 @@ static int udp_handle_packet(void *object, IP_Port source, const uint8_t *packet
|
|||
/* Ratio of recv queue size / recv packet rate (in seconds) times
|
||||
* the number of ms between request packets to send at that ratio
|
||||
*/
|
||||
#define REQUEST_PACKETS_COMPARE_CONSTANT (0.5 * 100.0)
|
||||
#define REQUEST_PACKETS_COMPARE_CONSTANT (0.125 * 100.0)
|
||||
|
||||
/* Multiplier for maximum allowed resends. */
|
||||
#define PACKET_RESEND_MULTIPLIER 2
|
||||
|
||||
/* Timeout for increasing speed after congestion event (in ms). */
|
||||
#define CONGESTION_EVENT_TIMEOUT 4000
|
||||
|
||||
static void send_crypto_packets(Net_Crypto *c)
|
||||
{
|
||||
uint32_t i;
|
||||
|
@ -2078,7 +2085,11 @@ static void send_crypto_packets(Net_Crypto *c)
|
|||
double min_speed = 1000.0 * (((double)(total_sent)) / ((double)(CONGESTION_QUEUE_ARRAY_SIZE) *
|
||||
PACKET_COUNTER_AVERAGE_INTERVAL));
|
||||
|
||||
conn->packet_send_rate = min_speed * 1.2;
|
||||
if (conn->last_congestion_event + CONGESTION_EVENT_TIMEOUT < temp_time) {
|
||||
conn->packet_send_rate = min_speed * 1.2;
|
||||
} else {
|
||||
conn->packet_send_rate = min_speed;
|
||||
}
|
||||
|
||||
if (conn->packet_send_rate < CRYPTO_PACKET_MIN_RATE) {
|
||||
conn->packet_send_rate = CRYPTO_PACKET_MIN_RATE;
|
||||
|
@ -2101,12 +2112,13 @@ static void send_crypto_packets(Net_Crypto *c)
|
|||
conn->last_packets_left_set = temp_time;
|
||||
}
|
||||
|
||||
int ret = send_requested_packets(c, i, ~0);
|
||||
int ret = send_requested_packets(c, i, conn->packets_left * PACKET_RESEND_MULTIPLIER);
|
||||
|
||||
if (ret != -1) {
|
||||
if (ret < conn->packets_left) {
|
||||
conn->packets_left -= ret;
|
||||
} else {
|
||||
conn->last_congestion_event = temp_time;
|
||||
conn->packets_left = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
#define CONGESTION_QUEUE_ARRAY_SIZE 24
|
||||
|
||||
/* Connection ping in ms. TODO: calculate it per connection. */
|
||||
#define DEFAULT_PING_CONNECTION 100
|
||||
#define DEFAULT_PING_CONNECTION 50
|
||||
|
||||
typedef struct {
|
||||
uint64_t sent_time;
|
||||
|
@ -149,6 +149,7 @@ typedef struct {
|
|||
uint32_t last_sendqueue_size[CONGESTION_QUEUE_ARRAY_SIZE], last_sendqueue_counter;
|
||||
long signed int last_num_packets_sent[CONGESTION_QUEUE_ARRAY_SIZE];
|
||||
uint32_t packets_sent;
|
||||
uint64_t last_congestion_event;
|
||||
|
||||
/* TCP_connection connection_number */
|
||||
unsigned int connection_number_tcp;
|
||||
|
|
Loading…
Reference in New Issue
Block a user