Skip to content

Commit 22dce23

Browse files
author
Chris
committed
Changes retransmit delay to not longer use buckets
1 parent cd92069 commit 22dce23

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

examples/simple_repeater/MyMesh.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,27 @@ int MyMesh::calcRxDelay(float score, uint32_t air_time) const {
396396
}
397397

398398
uint32_t MyMesh::getRetransmitDelay(const mesh::Packet *packet) {
399+
if(_prefs.tx_delay_factor == 0) {
400+
MESH_DEBUG_PRINTLN("getRetransmitDelay: Total tx delay: %d", _prefs.tx_delay_factor);
401+
return 5;
402+
}
403+
399404
uint32_t t = (_radio->getEstAirtimeFor(packet->path_len + packet->payload_len + 2) * _prefs.tx_delay_factor);
400-
return getRNG()->nextInt(0, 6) * t;
405+
uint32_t total_delay = getRNG()->nextInt(5, t);
406+
MESH_DEBUG_PRINTLN("getRetransmitDelay: Total tx delay: %d", total_delay);
407+
return total_delay;
401408
}
409+
402410
uint32_t MyMesh::getDirectRetransmitDelay(const mesh::Packet *packet) {
411+
if(_prefs.direct_tx_delay_factor == 0) {
412+
MESH_DEBUG_PRINTLN("getDirectRetransmitDelay: Total tx delay: %d", _prefs.direct_tx_delay_factor);
413+
return 5;
414+
}
415+
403416
uint32_t t = (_radio->getEstAirtimeFor(packet->path_len + packet->payload_len + 2) * _prefs.direct_tx_delay_factor);
404-
return getRNG()->nextInt(0, 6) * t;
417+
uint32_t total_delay = getRNG()->nextInt(5, t);
418+
MESH_DEBUG_PRINTLN("getDirectRetransmitDelay: Total tx delay: %d", total_delay);
419+
return total_delay;
405420
}
406421

407422
void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const mesh::Identity &sender,

src/Mesh.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ bool Mesh::allowPacketForward(const mesh::Packet* packet) {
1717
uint32_t Mesh::getRetransmitDelay(const mesh::Packet* packet) {
1818
uint32_t t = (_radio->getEstAirtimeFor(packet->getRawLength()) * 52 / 50) / 2;
1919

20-
return _rng->nextInt(0, 5)*t;
20+
uint32_t total_delay = getRNG()->nextInt(5, t);
21+
MESH_DEBUG_PRINTLN("getRetransmitDelay: Total tx delay: %d", total_delay);
22+
return total_delay;
2123
}
2224
uint32_t Mesh::getDirectRetransmitDelay(const Packet* packet) {
2325
return 0; // by default, no delay

0 commit comments

Comments
 (0)