fix(mesh/tx): requeue failed transmits with backoff instead of dropping
A TX that fails to start (startTransmit error) or never completes (send-complete IRQ lost) was released permanently — with an nRF52 SoftDevice servicing BLE connection events this silently ate ~40 % of DIRECT-route forwards (measured A/B on mast-three: direct_rx +5 / direct_tx +3 with an idle BLE connection, 5/5 with BLE off). Flood redundancy masked the same loss for flood traffic. Retry up to MESH_TX_RETRIES (3) with a short growing backoff; a duplicate on air is harmless (hasSeen dedup). New tallies tx_start_fail/tx_timeout in stats-packets + ERR_EVENT_TX_* flags make this failure class visible at last. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5fb0fb4ce
commit
6e076a6e8d
5 files changed
+54
-11
No files matched your search
@@ -1459,8 +1459,9 @@ void MyMesh::formatRadioStatsReply(char *reply) {
|
||||
}
|
||||
|
||||
void MyMesh::formatPacketStatsReply(char *reply) {
|
||||
StatsFormatHelper::formatPacketStats(reply, radio_driver, getNumSentFlood(), getNumSentDirect(),
|
||||
getNumRecvFlood(), getNumRecvDirect());
|
||||
StatsFormatHelper::formatPacketStats(reply, radio_driver, getNumSentFlood(), getNumSentDirect(),
|
||||
getNumRecvFlood(), getNumRecvDirect(),
|
||||
getNumTxStartFail(), getNumTxTimeout());
|
||||
}
|
||||
|
||||
void MyMesh::saveIdentity(const mesh::LocalIdentity &new_id) {
|
||||
|
||||
+28
-5
@@ -19,6 +19,7 @@ namespace mesh {
|
||||
void Dispatcher::begin() {
|
||||
n_sent_flood = n_sent_direct = 0;
|
||||
n_recv_flood = n_recv_direct = 0;
|
||||
n_tx_start_fail = n_tx_timeout = 0;
|
||||
_err_flags = 0;
|
||||
radio_nonrx_start = _ms->getMillis();
|
||||
|
||||
@@ -117,9 +118,20 @@ void Dispatcher::loop() {
|
||||
MESH_DEBUG_PRINTLN("%s Dispatcher::loop(): WARNING: outbound packed send timed out!", getLogDateTime());
|
||||
|
||||
_radio->onSendFinished();
|
||||
logTxFail(outbound, 2 + outbound->getPathByteLen() + outbound->payload_len);
|
||||
|
||||
releasePacket(outbound); // return to pool
|
||||
// CUSTOM (TeTeHacko): the send-complete IRQ never arrived (SoftDevice/BLE
|
||||
// preemption can wedge the LoRa driver mid-TX). Requeue with a short
|
||||
// backoff instead of dropping -- a duplicate on air is harmless (hasSeen
|
||||
// dedup), a dropped direct forward is a black hole.
|
||||
n_tx_timeout++;
|
||||
_err_flags |= ERR_EVENT_TX_TIMEOUT;
|
||||
if (outbound->_tx_attempts < MESH_TX_RETRIES) {
|
||||
outbound->_tx_attempts++;
|
||||
_mgr->queueOutbound(outbound, 0, futureMillis(40 + 80 * outbound->_tx_attempts));
|
||||
} else {
|
||||
logTxFail(outbound, 2 + outbound->getPathByteLen() + outbound->payload_len);
|
||||
releasePacket(outbound); // return to pool
|
||||
}
|
||||
outbound = NULL;
|
||||
} else {
|
||||
return; // can't do any more radio activity until send is complete or timed out
|
||||
@@ -204,6 +216,7 @@ void Dispatcher::checkRecv() {
|
||||
if (tryParsePacket(pkt, raw, len)) {
|
||||
pkt->_snr = _radio->getLastSNR() * 4.0f;
|
||||
pkt->_rssi = (int8_t)_radio->getLastRSSI();
|
||||
pkt->_tx_attempts = 0;
|
||||
score = _radio->packetScore(_radio->getLastSNR(), len);
|
||||
air_time = _radio->getEstAirtimeFor(len);
|
||||
rx_air_time += air_time;
|
||||
@@ -330,9 +343,18 @@ void Dispatcher::checkSend() {
|
||||
if (!success) {
|
||||
MESH_DEBUG_PRINTLN("%s Dispatcher::loop(): ERROR: send start failed!", getLogDateTime());
|
||||
|
||||
logTxFail(outbound, outbound->getRawLength());
|
||||
|
||||
releasePacket(outbound); // return to pool
|
||||
// CUSTOM (TeTeHacko): startTransmit() failing is usually transient
|
||||
// (SPI/BUSY hiccup while the SoftDevice services a BLE connection
|
||||
// event). Requeue with a short backoff instead of dropping.
|
||||
n_tx_start_fail++;
|
||||
_err_flags |= ERR_EVENT_TX_START_FAIL;
|
||||
if (outbound->_tx_attempts < MESH_TX_RETRIES) {
|
||||
outbound->_tx_attempts++;
|
||||
_mgr->queueOutbound(outbound, 0, futureMillis(40 + 80 * outbound->_tx_attempts));
|
||||
} else {
|
||||
logTxFail(outbound, outbound->getRawLength());
|
||||
releasePacket(outbound); // return to pool
|
||||
}
|
||||
outbound = NULL;
|
||||
return;
|
||||
}
|
||||
@@ -360,6 +382,7 @@ Packet* Dispatcher::obtainNewPacket() {
|
||||
} else {
|
||||
pkt->payload_len = pkt->path_len = 0;
|
||||
pkt->_snr = 0;
|
||||
pkt->_tx_attempts = 0;
|
||||
}
|
||||
return pkt;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,17 @@ typedef uint32_t DispatcherAction;
|
||||
#define ERR_EVENT_FULL (1 << 0)
|
||||
#define ERR_EVENT_CAD_TIMEOUT (1 << 1)
|
||||
#define ERR_EVENT_STARTRX_TIMEOUT (1 << 2)
|
||||
#define ERR_EVENT_TX_START_FAIL (1 << 3) // CUSTOM (TeTeHacko): startSendRaw() returned error (radio busy/SPI hiccup)
|
||||
#define ERR_EVENT_TX_TIMEOUT (1 << 4) // CUSTOM (TeTeHacko): send-complete IRQ never came before outbound_expiry
|
||||
|
||||
// CUSTOM (TeTeHacko): how many times a failed TX (start fail or send timeout) is
|
||||
// requeued before the packet is finally dropped. Transient failures are common
|
||||
// when the nRF52 SoftDevice (BLE connection events) preempts the LoRa driver —
|
||||
// measured ~40 % direct-forward loss with an idle BLE connection. A short retry
|
||||
// converts those losses into ~100-300 ms of extra latency.
|
||||
#ifndef MESH_TX_RETRIES
|
||||
#define MESH_TX_RETRIES 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The low-level task that manages detecting incoming Packets, and the queueing
|
||||
@@ -123,6 +134,7 @@ class Dispatcher {
|
||||
bool prev_isrecv_mode;
|
||||
uint32_t n_sent_flood, n_sent_direct;
|
||||
uint32_t n_recv_flood, n_recv_direct;
|
||||
uint32_t n_tx_start_fail, n_tx_timeout; // CUSTOM (TeTeHacko): TX failure tallies (see MESH_TX_RETRIES)
|
||||
unsigned long tx_budget_ms;
|
||||
unsigned long last_budget_update;
|
||||
unsigned long duty_cycle_window_ms;
|
||||
@@ -184,6 +196,8 @@ public:
|
||||
uint32_t getNumSentDirect() const { return n_sent_direct; }
|
||||
uint32_t getNumRecvFlood() const { return n_recv_flood; }
|
||||
uint32_t getNumRecvDirect() const { return n_recv_direct; }
|
||||
uint32_t getNumTxStartFail() const { return n_tx_start_fail; } // CUSTOM (TeTeHacko)
|
||||
uint32_t getNumTxTimeout() const { return n_tx_timeout; } // CUSTOM (TeTeHacko)
|
||||
void resetStats() {
|
||||
n_sent_flood = n_sent_direct = n_recv_flood = n_recv_direct = 0;
|
||||
_err_flags = 0;
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
uint8_t payload[MAX_PACKET_PAYLOAD];
|
||||
int8_t _snr;
|
||||
int8_t _rssi; // CUSTOM (TeTeHacko): last-hop RSSI (dBm) captured at RX, for the passive mesh analyzer
|
||||
uint8_t _tx_attempts; // CUSTOM (TeTeHacko): failed TX tries so far (RAM only; Dispatcher requeues instead of dropping)
|
||||
|
||||
/**
|
||||
* \brief calculate the hash of payload + type
|
||||
|
||||
@@ -40,16 +40,20 @@ public:
|
||||
uint32_t n_sent_flood,
|
||||
uint32_t n_sent_direct,
|
||||
uint32_t n_recv_flood,
|
||||
uint32_t n_recv_direct) {
|
||||
sprintf(reply,
|
||||
"{\"recv\":%u,\"sent\":%u,\"flood_tx\":%u,\"direct_tx\":%u,\"flood_rx\":%u,\"direct_rx\":%u,\"recv_errors\":%u}",
|
||||
uint32_t n_recv_direct,
|
||||
uint32_t n_tx_start_fail = 0, // CUSTOM (TeTeHacko): TX failure tallies
|
||||
uint32_t n_tx_timeout = 0) { // (defaults keep other callers unchanged)
|
||||
sprintf(reply,
|
||||
"{\"recv\":%u,\"sent\":%u,\"flood_tx\":%u,\"direct_tx\":%u,\"flood_rx\":%u,\"direct_rx\":%u,\"recv_errors\":%u,\"tx_start_fail\":%u,\"tx_timeout\":%u}",
|
||||
driver.getPacketsRecv(),
|
||||
driver.getPacketsSent(),
|
||||
n_sent_flood,
|
||||
n_sent_direct,
|
||||
n_recv_flood,
|
||||
n_recv_direct,
|
||||
driver.getPacketsRecvErrors()
|
||||
driver.getPacketsRecvErrors(),
|
||||
n_tx_start_fail,
|
||||
n_tx_timeout
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user