mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
fix send/process for ACK packets
This commit is contained in:
parent
b5ec02bd01
commit
acd7a7a732
2 changed files with 14 additions and 11 deletions
|
@ -134,7 +134,7 @@ void Connection::sendACK(bool wasCausedBySyncTimeout) {
|
|||
|
||||
// setup the ACK packet, make it static so we can re-use it
|
||||
static const int ACK_PACKET_PAYLOAD_BYTES = sizeof(_lastSentACK) + sizeof(_currentACKSubSequenceNumber)
|
||||
+ sizeof(_rtt) + sizeof(int32_t) + sizeof(int32_t);
|
||||
+ sizeof(_rtt) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t);
|
||||
static auto ackPacket = ControlPacket::create(ControlPacket::ACK, ACK_PACKET_PAYLOAD_BYTES);
|
||||
ackPacket->reset(); // We need to reset it every time.
|
||||
|
||||
|
@ -412,7 +412,10 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
|
|||
}
|
||||
|
||||
// this is a valid ACKed sequence number - update the flow window size and the last received ACK
|
||||
controlPacket->readPrimitive(&_flowWindowSize);
|
||||
int32_t packedFlowWindow;
|
||||
controlPacket->readPrimitive(&packedFlowWindow);
|
||||
|
||||
_flowWindowSize = packedFlowWindow;
|
||||
|
||||
if (ack == _lastReceivedACK) {
|
||||
// processing an already received ACK, bail
|
||||
|
@ -433,8 +436,12 @@ void Connection::processACK(std::unique_ptr<ControlPacket> controlPacket) {
|
|||
// set the RTT for congestion control
|
||||
_congestionControl->setRTT(_rtt);
|
||||
|
||||
if (controlPacket->getPayloadSize() > (qint64) (sizeof(SequenceNumber) + sizeof(SequenceNumber) + sizeof(rtt))) {
|
||||
if (controlPacket->bytesLeftToRead() > 0) {
|
||||
int32_t receiveRate, bandwidth;
|
||||
|
||||
Q_ASSERT_X(controlPacket->bytesLeftToRead() == sizeof(receiveRate) + sizeof(bandwidth),
|
||||
"Connection::processACK", "sync interval ACK packet does not contain expected data");
|
||||
|
||||
controlPacket->readPrimitive(&receiveRate);
|
||||
controlPacket->readPrimitive(&bandwidth);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "PacketTimeWindow.h"
|
||||
|
||||
#include <numeric>
|
||||
#include <cmath>
|
||||
|
||||
#include <NumericalConstants.h>
|
||||
|
@ -48,16 +49,11 @@ int median(Iterator begin, Iterator end) {
|
|||
|
||||
int32_t meanOfMedianFilteredValues(std::vector<int> intervals, int numValues, int valuesRequired = 0) {
|
||||
// grab the median value of the intervals vector
|
||||
int median = 0;
|
||||
if (numValues % 2 == 0) {
|
||||
median = intervals[numValues / 2];
|
||||
} else {
|
||||
median = (intervals[(numValues / 2) - 1] + intervals[numValues / 2]) / 2;
|
||||
}
|
||||
int intervalsMedian = median(intervals.begin(), intervals.end());
|
||||
|
||||
static const int MEDIAN_FILTERING_BOUND_MULTIPLIER = 8;
|
||||
int upperBound = median * MEDIAN_FILTERING_BOUND_MULTIPLIER;
|
||||
int lowerBound = median / MEDIAN_FILTERING_BOUND_MULTIPLIER;
|
||||
int upperBound = intervalsMedian * MEDIAN_FILTERING_BOUND_MULTIPLIER;
|
||||
int lowerBound = intervalsMedian / MEDIAN_FILTERING_BOUND_MULTIPLIER;
|
||||
|
||||
int sum = 0;
|
||||
int count = 0;
|
||||
|
|
Loading…
Reference in a new issue