mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 18:23:22 +02:00
fixed packet sequence number rollover
This commit is contained in:
parent
7a191961cf
commit
f3b8d04c06
2 changed files with 7 additions and 4 deletions
|
@ -28,6 +28,7 @@
|
|||
|
||||
typedef unsigned char OCTREE_PACKET_FLAGS;
|
||||
typedef uint16_t OCTREE_PACKET_SEQUENCE;
|
||||
const uint16_t MAX_OCTREE_PACKET_SEQUENCE = 65535;
|
||||
typedef quint64 OCTREE_PACKET_SENT_TIME;
|
||||
typedef uint16_t OCTREE_PACKET_INTERNAL_SECTION_SIZE;
|
||||
const int MAX_OCTREE_PACKET_SIZE = MAX_PACKET_SIZE;
|
||||
|
|
|
@ -875,10 +875,13 @@ void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
|
|||
return; // ignore any packets that are unreasonable
|
||||
}
|
||||
|
||||
// determine our expected sequence number... handle rollover appropriately
|
||||
OCTREE_PACKET_SEQUENCE expected = _incomingPacket > 0 ? _incomingLastSequence + 1 : sequence;
|
||||
|
||||
// Guard against possible corrupted packets... with bad sequence numbers
|
||||
const int MAX_RESONABLE_SEQUENCE_OFFSET = 2000;
|
||||
const int MIN_RESONABLE_SEQUENCE_OFFSET = -2000;
|
||||
int sequenceOffset = (sequence - _incomingLastSequence);
|
||||
int sequenceOffset = (sequence - expected);
|
||||
if (sequenceOffset > MAX_RESONABLE_SEQUENCE_OFFSET || sequenceOffset < MIN_RESONABLE_SEQUENCE_OFFSET) {
|
||||
qDebug() << "ignoring unreasonable packet... sequence:" << sequence << "_incomingLastSequence:" << _incomingLastSequence;
|
||||
return; // ignore any packets that are unreasonable
|
||||
|
@ -901,7 +904,6 @@ void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
|
|||
qDebug() << "last packet duplicate got:" << sequence << "_incomingLastSequence:" << _incomingLastSequence;
|
||||
}
|
||||
} else {
|
||||
OCTREE_PACKET_SEQUENCE expected = _incomingLastSequence+1;
|
||||
if (sequence != expected) {
|
||||
if (wantExtraDebugging) {
|
||||
qDebug() << "out of order... got:" << sequence << "expected:" << expected;
|
||||
|
@ -958,9 +960,9 @@ void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
|
|||
}
|
||||
}
|
||||
|
||||
// only bump the last sequence if it was greater than our previous last sequence, this will keep us from
|
||||
// only bump the last sequence if it was greater than our expected sequence, this will keep us from
|
||||
// accidentally going backwards when an out of order (recovered) packet comes in
|
||||
if (sequence > _incomingLastSequence) {
|
||||
if (sequence >= expected) {
|
||||
_incomingLastSequence = sequence;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue