mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-16 17:34:37 +02:00
force timeout NAK to fit MTU
This commit is contained in:
parent
d9254aa2e9
commit
42b5b37b96
3 changed files with 16 additions and 4 deletions
|
@ -248,11 +248,15 @@ void Connection::sendNAK(SequenceNumber sequenceNumberRecieved) {
|
|||
|
||||
void Connection::sendTimeoutNAK() {
|
||||
if (_lossList.getLength() > 0) {
|
||||
|
||||
int timeoutPayloadSize = std::min((int) (_lossList.getLength() * 2 * sizeof(SequenceNumber)),
|
||||
ControlPacket::maxPayloadSize());
|
||||
|
||||
// construct a NAK packet that will hold all of the lost sequence numbers
|
||||
auto lossListPacket = ControlPacket::create(ControlPacket::TimeoutNAK, 2 * _lossList.getLength() * sizeof(SequenceNumber));
|
||||
auto lossListPacket = ControlPacket::create(ControlPacket::TimeoutNAK, timeoutPayloadSize);
|
||||
|
||||
// Pack in the lost sequence numbers
|
||||
_lossList.write(*lossListPacket);
|
||||
_lossList.write(*lossListPacket, timeoutPayloadSize / 2);
|
||||
|
||||
// have our parent socket send off this control packet
|
||||
_parentSocket->writeBasePacket(*lossListPacket, _destination);
|
||||
|
|
|
@ -167,9 +167,17 @@ SequenceNumber LossList::popFirstSequenceNumber() {
|
|||
return front;
|
||||
}
|
||||
|
||||
void LossList::write(ControlPacket& packet) {
|
||||
void LossList::write(ControlPacket& packet, int maxPairs) {
|
||||
int writtenPairs = 0;
|
||||
for(const auto& pair : _lossList) {
|
||||
packet.writePrimitive(pair.first);
|
||||
packet.writePrimitive(pair.second);
|
||||
|
||||
++writtenPairs;
|
||||
|
||||
// check if we've written the maximum number we were told to write
|
||||
if (maxPairs != -1 && writtenPairs >= maxPairs) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
SequenceNumber getFirstSequenceNumber() const;
|
||||
SequenceNumber popFirstSequenceNumber();
|
||||
|
||||
void write(ControlPacket& packet);
|
||||
void write(ControlPacket& packet, int maxPairs = -1);
|
||||
|
||||
private:
|
||||
std::list<std::pair<SequenceNumber, SequenceNumber>> _lossList;
|
||||
|
|
Loading…
Reference in a new issue