Some updates
This commit is contained in:
parent
e0eb4c5a16
commit
ee7f26b7ed
@ -109,6 +109,8 @@ ssize_t AcknowledgeManager::execute_resend(const system_clock::time_point& now ,
|
||||
if(entry->next_resend <= now) {
|
||||
entry->next_resend = now + std::chrono::milliseconds{(int64_t) min(ceil(this->rto), 1500.f)};
|
||||
need_resend.push_back(entry);
|
||||
entry->resend_count++;
|
||||
entry->send_count++;
|
||||
}
|
||||
if(next_resend > entry->next_resend)
|
||||
next_resend = entry->next_resend;
|
||||
@ -128,8 +130,6 @@ ssize_t AcknowledgeManager::execute_resend(const system_clock::time_point& now ,
|
||||
}
|
||||
|
||||
resend_count++;
|
||||
packet->resend_count++;
|
||||
packet->send_count++;
|
||||
buffers.push_back(packet);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
#include <cstring>
|
||||
#include "PacketLossCalculator.h"
|
||||
|
||||
using namespace ts::protocol;
|
||||
@ -64,6 +65,19 @@ void UnorderedPacketLossCalculator::short_stats() {
|
||||
this->last_history_offset = this->packet_history_offset;
|
||||
}
|
||||
|
||||
void UnorderedPacketLossCalculator::reset() {
|
||||
this->received_packets_ = 0;
|
||||
this->received_packets_total_ = 0;
|
||||
this->lost_packets_ = 0;
|
||||
this->lost_packets_total_ = 0;
|
||||
this->reset_offsets();
|
||||
}
|
||||
void UnorderedPacketLossCalculator::reset_offsets() {
|
||||
this->packet_history_offset = 0;
|
||||
this->last_history_offset = 0;
|
||||
this->packet_history.clear();
|
||||
}
|
||||
|
||||
void CommandPacketLossCalculator::packet_send(uint32_t packet_id) {
|
||||
if(packet_id > this->packet_history_offset) {
|
||||
assert(packet_id - 1 == this->packet_history_offset); /* the method will only be called with an incrementing packet id */
|
||||
@ -71,8 +85,6 @@ void CommandPacketLossCalculator::packet_send(uint32_t packet_id) {
|
||||
auto lost = std::exchange(this->packet_ack_counts[packet_id % CommandPacketLossCalculator::packet_ack_counts_length], 1);
|
||||
this->lost_packets_ += lost;
|
||||
this->lost_packets_total_ += lost;
|
||||
if(lost > 0)
|
||||
__asm__("nop");
|
||||
this->packet_history_offset = packet_id;
|
||||
} else {
|
||||
/* We're not really interested if the packet id matches the resend packet. If not we may accidentally increase the loss count. */
|
||||
@ -85,8 +97,6 @@ void CommandPacketLossCalculator::ack_received(uint32_t packet_id) {
|
||||
auto& count = this->packet_ack_counts[packet_id % CommandPacketLossCalculator::packet_ack_counts_length];
|
||||
if(count > 0) /* could happen if receive an acknowledge for an packet which is older than out buffer size or the client send the ack twice... */
|
||||
count--;
|
||||
else
|
||||
__asm__("nop");
|
||||
|
||||
this->received_packets_++;
|
||||
this->received_packets_total_++;
|
||||
@ -102,4 +112,18 @@ void CommandPacketLossCalculator::short_stats() {
|
||||
const auto factor = target_interval / packets_passed;
|
||||
this->received_packets_ *= factor;
|
||||
this->lost_packets_ *= factor;
|
||||
}
|
||||
|
||||
void CommandPacketLossCalculator::reset() {
|
||||
this->received_packets_ = 0;
|
||||
this->received_packets_total_ = 0;
|
||||
this->lost_packets_ = 0;
|
||||
this->lost_packets_total_ = 0;
|
||||
this->reset_offsets();
|
||||
}
|
||||
|
||||
void CommandPacketLossCalculator::reset_offsets() {
|
||||
this->packet_history_offset = 0;
|
||||
this->packets_send_unshorten = 0;
|
||||
memset(packet_ack_counts, 0, packet_ack_counts_length);
|
||||
}
|
@ -48,6 +48,8 @@ namespace ts::protocol {
|
||||
|
||||
void packet_received(uint32_t /* packet id */);
|
||||
void short_stats();
|
||||
void reset();
|
||||
void reset_offsets();
|
||||
|
||||
[[nodiscard]] inline auto last_packet_id() const { return this->packet_history_offset; }
|
||||
[[nodiscard]] inline bool valid_data() const { return this->packet_history_offset >= 32; }
|
||||
@ -61,7 +63,6 @@ namespace ts::protocol {
|
||||
[[nodiscard]] inline uint32_t unconfirmed_received_packets() const { return this->packet_history.count(); };
|
||||
[[nodiscard]] inline uint32_t unconfirmed_lost_packets() const { return this->packet_history.max_bits() - this->packet_history.count(); };
|
||||
|
||||
inline void reset() { this->received_packets_ = 0; this->lost_packets_ = 0; }
|
||||
private:
|
||||
uint32_t received_packets_{0}, received_packets_total_{0}, lost_packets_{0}, lost_packets_total_{0};
|
||||
|
||||
@ -78,6 +79,8 @@ namespace ts::protocol {
|
||||
void ack_received(uint32_t /* packet id */); //Attention: This is a full ID!
|
||||
|
||||
void short_stats();
|
||||
void reset();
|
||||
void reset_offsets();
|
||||
|
||||
[[nodiscard]] inline bool valid_data() const { return true; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user