Merge pull request #1444 from GUVWAF/master

Optimize retransmission timer
pull/1445/head
Sacha Weatherstone 2022-05-09 09:33:16 +10:00 zatwierdzone przez GitHub
commit 4940822ae8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 12 dodań i 4 usunięć

Wyświetl plik

@ -160,9 +160,15 @@ uint32_t RadioInterface::getPacketTime(MeshPacket *p)
uint32_t RadioInterface::getRetransmissionMsec(const MeshPacket *p)
{
assert(shortPacketMsec); // Better be non zero
// was 20 and 22 secs respectively, but now with shortPacketMsec as 2269, this should give the same range
return random(9 * shortPacketMsec, 10 * shortPacketMsec);
static uint8_t bytes[MAX_RHPACKETLEN];
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded);
uint32_t packetAirtime = getPacketTime(numbytes + sizeof(PacketHeader));
uint32_t tCADmsec = 2 * (1 << sf) / bw; // duration of CAD is roughly 2 symbols according to SX127x datasheet
/* Make sure enough time has elapsed for this packet to be sent and an ACK is received.
* Right now we have to wait until another node floods the same packet, as that is our implicit ACK.
* TODO: Revise when want_ack will be used (right now it is always set to 0 afterwards).
*/
return 2*packetAirtime + 2*MIN_TX_WAIT_MSEC + shortPacketMsec + shortPacketMsec*2 + PROCESSING_TIME_MSEC + 2*tCADmsec;
}
/** The delay to use when we want to send something but the ether is busy */

Wyświetl plik

@ -63,6 +63,8 @@ class RadioInterface
uint8_t cr = 7;
uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving
const uint32_t MIN_TX_WAIT_MSEC = 100; // minimum time to wait before transmitting after sensing the channel in ms
const uint32_t PROCESSING_TIME_MSEC = 4500; // time to construct, process and construct a packet again (empirically determined)
MeshPacket *sendingPacket = NULL; // The packet we are currently sending
uint32_t lastTxStart = 0L;

Wyświetl plik

@ -150,7 +150,7 @@ bool ReliableRouter::stopRetransmission(GlobalPacketId key)
if (old) {
auto numErased = pending.erase(key);
assert(numErased == 1);
packetPool.release(old->packet);
cancelSending(getFrom(old->packet), old->packet->id);
return true;
} else
return false;