Debugging retransmission (again!)

merge-requests/9/merge
Phil Taylor 2022-05-05 00:06:50 +01:00
rodzic 85ba0fb569
commit cac93198a6
2 zmienionych plików z 13 dodań i 15 usunięć

Wyświetl plik

@ -1205,17 +1205,20 @@ void udpBase::dataReceived(QByteArray r)
packetsLost++; packetsLost++;
congestion = static_cast<double>(packetsSent) / packetsLost * 100; congestion = static_cast<double>(packetsSent) / packetsLost * 100;
txBufferMutex.lock(); txBufferMutex.lock();
QMap<quint16,SEQBUFENTRY>::iterator match = txSeqBuf.find(in->seq); auto match = txSeqBuf.find(in->seq);
if (match != txSeqBuf.end()) { if (match != txSeqBuf.end()) {
// Found matching entry? // Found matching entry?
// Send "untracked" as it has already been sent once. // Send "untracked" as it has already been sent once.
// Don't constantly retransmit the same packet, give-up eventually // Don't constantly retransmit the same packet, give-up eventually
qDebug(logUdp()) << this->metaObject()->className() << ": Sending (single packet) retransmit of " << QString("0x%1").arg(match->seqNum,0,16); qDebug(logUdp()) << this->metaObject()->className() << ": Sending (single packet) retransmit of " << QString("0x%1").arg(match->seqNum, 0, 16);
match->retransmitCount++; match->retransmitCount++;
udpMutex.lock(); udpMutex.lock();
udp->writeDatagram(match->data, radioIP, port); udp->writeDatagram(match->data, radioIP, port);
udpMutex.unlock(); udpMutex.unlock();
} }
else {
qDebug(logUdp()) << this->metaObject()->className() << ": Remote requested packet " << QString("0x%1").arg(in->seq, 0, 16) << " not found, have " << txSeqBuf.begin()->seqNum << "to" << txSeqBuf.end()->seqNum;;
}
txBufferMutex.unlock(); txBufferMutex.unlock();
} }
if (in->type == 0x04) { if (in->type == 0x04) {
@ -1293,9 +1296,9 @@ void udpBase::dataReceived(QByteArray r)
for (quint16 i = 0x10; i < r.length(); i = i + 2) for (quint16 i = 0x10; i < r.length(); i = i + 2)
{ {
quint16 seq = (quint8)r[i] | (quint8)r[i + 1] << 8; quint16 seq = (quint8)r[i] | (quint8)r[i + 1] << 8;
QMap<quint16, SEQBUFENTRY>::iterator match = txSeqBuf.find(seq); auto match = txSeqBuf.find(seq);
if (match == txSeqBuf.end()) { if (match == txSeqBuf.end()) {
qDebug(logUdp()) << this->metaObject()->className() << ": Remote requested packet " << QString("0x%1").arg(seq,0,16) << " not found"; qDebug(logUdp()) << this->metaObject()->className() << ": Remote requested packet " << QString("0x%1").arg(seq, 0, 16) << " not found, have " << txSeqBuf.begin()->seqNum << "to" << txSeqBuf.end()->seqNum;;
// Just send idle packet. // Just send idle packet.
sendControl(false, 0, seq); sendControl(false, 0, seq);
} }
@ -1307,7 +1310,6 @@ void udpBase::dataReceived(QByteArray r)
udpMutex.lock(); udpMutex.lock();
udp->writeDatagram(match->data, radioIP, port); udp->writeDatagram(match->data, radioIP, port);
udpMutex.unlock(); udpMutex.unlock();
match++;
packetsLost++; packetsLost++;
congestion = static_cast<double>(packetsSent) / packetsLost * 100; congestion = static_cast<double>(packetsSent) / packetsLost * 100;
} }
@ -1374,7 +1376,7 @@ void udpBase::dataReceived(QByteArray r)
else { else {
// This is probably one of our missing packets! // This is probably one of our missing packets!
missingMutex.lock(); missingMutex.lock();
QMap<quint16,int>::iterator s = rxMissing.find(in->seq); auto s = rxMissing.find(in->seq);
if (s != rxMissing.end()) if (s != rxMissing.end())
{ {
qInfo(logUdp()) << this->metaObject()->className() << ": Missing SEQ has been received! " << QString("0x%1").arg(in->seq,0,16); qInfo(logUdp()) << this->metaObject()->className() << ": Missing SEQ has been received! " << QString("0x%1").arg(in->seq,0,16);

Wyświetl plik

@ -799,7 +799,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l, CLIENT* current, QByteArray r)
} // This is a single packet retransmit request } // This is a single packet retransmit request
else if (in->type == 0x01 && in->len == 0x10) else if (in->type == 0x01 && in->len == 0x10)
{ {
QMap<quint16, SEQBUFENTRY>::iterator match = current->txSeqBuf.find(in->seq); auto match = current->txSeqBuf.find(in->seq);
if (match != current->txSeqBuf.end() && match->retransmitCount < 5) { if (match != current->txSeqBuf.end() && match->retransmitCount < 5) {
// Found matching entry? // Found matching entry?
@ -818,7 +818,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l, CLIENT* current, QByteArray r)
} }
else { else {
// Just send an idle! // Just send an idle!
qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Requested (single) packet " << QString("0x%1").arg(in->seq, 0, 16) << "not found"; qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Requested (single) packet " << QString("0x%1").arg(in->seq, 0, 16) << "not found, have " << current->txSeqBuf.begin()->seqNum << "to" << current->txSeqBuf.end()->seqNum;
sendControl(current, 0x00, in->seq); sendControl(current, 0x00, in->seq);
} }
} }
@ -838,11 +838,9 @@ void udpServer::commonReceived(QList<CLIENT*>* l, CLIENT* current, QByteArray r)
for (quint16 i = 0x10; i < r.length(); i = i + 2) for (quint16 i = 0x10; i < r.length(); i = i + 2)
{ {
quint16 seq = (quint8)r[i] | (quint8)r[i + 1] << 8; quint16 seq = (quint8)r[i] | (quint8)r[i + 1] << 8;
auto match = std::find_if(current->txSeqBuf.begin(), current->txSeqBuf.end(), [&cs = seq](SEQBUFENTRY& s) { auto match = current->txSeqBuf.find(seq);
return s.seqNum == cs;
});
if (match == current->txSeqBuf.end()) { if (match == current->txSeqBuf.end()) {
qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Requested (multiple) packet " << QString("0x%1").arg(seq,0,16) << " not found"; qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Requested (multiple) packet " << QString("0x%1").arg(seq,0,16) << " not found , have " << current->txSeqBuf.begin()->seqNum << "to" << current->txSeqBuf.end()->seqNum;;
// Just send idle packet. // Just send idle packet.
sendControl(current, 0, in->seq); sendControl(current, 0, in->seq);
} }
@ -860,8 +858,6 @@ void udpServer::commonReceived(QList<CLIENT*>* l, CLIENT* current, QByteArray r)
else { else {
qInfo(logUdpServer()) << "Unable to lock udpMutex()"; qInfo(logUdpServer()) << "Unable to lock udpMutex()";
} }
match++;
} }
} }
} }
@ -962,7 +958,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l, CLIENT* current, QByteArray r)
// Check whether this is one of our missing ones! // Check whether this is one of our missing ones!
if (current->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD))) if (current->missMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
{ {
QMap<quint16, int>::iterator s = current->rxMissing.find(in->seq); auto s = current->rxMissing.find(in->seq);
if (s != current->rxMissing.end()) if (s != current->rxMissing.end())
{ {
qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Missing SEQ has been received! " << QString("0x%1").arg(in->seq,0,16); qInfo(logUdpServer()) << current->ipAddress.toString() << "(" << current->type << "): Missing SEQ has been received! " << QString("0x%1").arg(in->seq,0,16);