Verify compact attempt isolation, wire boundaries and exhaustion recovery

This commit is contained in:
evgeny committed 2026-10-23 19:23:30 +02:00
1 parent 0987d9dd04
commit b73d6e91e2
2 files changed
+97 -17

No files matched your search

+16 -16
View File
@@ -53,7 +53,7 @@ static void attempt_retire(struct ETCP_LINK* link, struct ETCP_TX_ATTEMPT* attem
struct INFLIGHT_PACKET* packet = logical_find(conn, attempt->seq);
if (!conn->active_attempts || link->inflight_bytes < attempt->ll.len || !link->inflight_packets ||
(packet && !packet->active_attempts)) {
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[%s] attempt accounting mismatch link=%u id=%llu seq=%u flight=%u/%u len=%u logical=%u",
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[%s] attempt accounting mismatch link=%u key=%llu seq=%u flight=%u/%u len=%u logical=%u",
conn->log_name, link->local_link_id, (unsigned long long)attempt->attempt_id, attempt->seq,
link->inflight_bytes, link->inflight_packets, attempt->ll.len, packet ? packet->active_attempts : 0);
abort();
@@ -65,8 +65,8 @@ static void attempt_retire(struct ETCP_LINK* link, struct ETCP_TX_ATTEMPT* attem
link->bbr_loss_since_ack = lost > INT_MAX ? INT_MAX : (uint32_t)lost;
bbr_note_loss(link->bbr);
}
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] retire link=%u attempt=%llu seq=%u reason=%s flight=%u/%u logical_active=%u",
conn->log_name, link->local_link_id, (unsigned long long)attempt->attempt_id, attempt->seq,
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] retire link=%u attempt=%u seq=%u reason=%s flight=%u/%u logical_active=%u",
conn->log_name, link->local_link_id, (unsigned)(uint16_t)attempt->attempt_id, attempt->seq,
loss ? "RTO" : retry ? "link_close" : "ACK/rollback", link->inflight_bytes, link->inflight_packets,
packet ? packet->active_attempts : 0);
queue_remove_data(link->attempts, &attempt->ll); queue_entry_free(&attempt->ll);
@@ -91,8 +91,8 @@ static void retransmit_cb(void* arg) {
while (link->attempts->head) {
struct ETCP_TX_ATTEMPT* attempt = (struct ETCP_TX_ATTEMPT*)link->attempts->head;
if (!attempt->sent_at_us || now - attempt->sent_at_us < rto) break;
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] RTO link=%u attempt=%llu seq=%u age_us=%llu RTO_us=%u RTT_us=%u jitter_us=%u",
link->etcp->log_name, link->local_link_id, (unsigned long long)attempt->attempt_id, attempt->seq,
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] RTO link=%u attempt=%u seq=%u age_us=%llu RTO_us=%u RTT_us=%u jitter_us=%u",
link->etcp->log_name, link->local_link_id, (unsigned)(uint16_t)attempt->attempt_id, attempt->seq,
(unsigned long long)(now - attempt->sent_at_us), rto, link->data_rtt_us, link->data_jitter_us);
attempt_retire(link, attempt, 1, 1);
}
@@ -203,8 +203,8 @@ void etcp_tx_complete(struct ETCP_DGRAM* dgram, int success) {
attempt->is_app_limited = !conn->input_queue->count && conn->input_send_q->count == 1 &&
(!pn || (!pn->input->count && !pn->pending && !pn->data_ptr));
if (link->bbr && link->bbr->mode == BBR_PROBE_RTT) attempt->is_app_limited = 1;
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] sent seq=%u attempt=%llu path=%u previous=%u bytes=%u flight=%u/%u",
conn->log_name, packet->seq, (unsigned long long)attempt->attempt_id, link->local_link_id,
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] sent seq=%u attempt=%u path=%u previous=%u bytes=%u flight=%u/%u",
conn->log_name, packet->seq, (unsigned)(uint16_t)attempt->attempt_id, link->local_link_id,
packet->last_link ? packet->last_link->local_link_id : 0, packet->ll.len, link->inflight_bytes, link->inflight_packets);
if (packet->last_attempt_id && packet->last_link) packet->last_link->total_retransmissions++;
packet->send_hist[packet->send_count % 8] = link->local_link_id;
@@ -227,7 +227,7 @@ void etcp_tx_ack(struct ETCP_LINK* link, uint32_t seq, uint64_t attempt_id, uint
}
struct ETCP_TX_ATTEMPT* attempt = (struct ETCP_TX_ATTEMPT*)queue_find_data_by_index(link->attempts, &attempt_id);
if (attempt && (attempt->seq != seq || !attempt->sent_at_us)) {
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] invalid attempt ACK path=%u id=%llu seq=%u expected=%u committed=%d",
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] invalid attempt ACK path=%u key=%llu seq=%u expected=%u committed=%d",
conn->log_name, link->local_link_id, (unsigned long long)attempt_id, seq, attempt->seq, !!attempt->sent_at_us);
return;
}
@@ -238,8 +238,8 @@ void etcp_tx_ack(struct ETCP_LINK* link, uint32_t seq, uint64_t attempt_id, uint
((peer_rx_bytes > link->peer_rx_data_bytes && peer_rx_time_us < link->peer_rx_data_time_us) ||
(peer_rx_bytes < link->peer_rx_data_bytes && peer_rx_time_us > link->peer_rx_data_time_us) ||
(peer_rx_bytes == link->peer_rx_data_bytes && peer_rx_time_us != link->peer_rx_data_time_us)))) {
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] inconsistent RX point path=%u attempt=%llu point=%llu/%llu previous=%llu/%llu",
conn->log_name, link->local_link_id, (unsigned long long)attempt_id,
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] inconsistent RX point path=%u seq=%u attempt=%u point=%llu/%llu previous=%llu/%llu",
conn->log_name, link->local_link_id, seq, (unsigned)(uint16_t)attempt_id,
(unsigned long long)peer_rx_bytes, (unsigned long long)peer_rx_time_us,
(unsigned long long)link->peer_rx_data_bytes, (unsigned long long)link->peer_rx_data_time_us);
rx_valid = 0;
@@ -286,8 +286,8 @@ void etcp_tx_ack(struct ETCP_LINK* link, uint32_t seq, uint64_t attempt_id, uint
}
}
if (interval > UINT32_MAX || (interval && !rs.interval_us))
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] BW interval unrepresentable path=%u attempt=%llu local_us=%llu RX=%llu/%llu",
conn->log_name, link->local_link_id, (unsigned long long)attempt_id, (unsigned long long)interval,
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] BW interval unrepresentable path=%u seq=%u attempt=%u local_us=%llu RX=%llu/%llu",
conn->log_name, link->local_link_id, seq, (unsigned)(uint16_t)attempt_id, (unsigned long long)interval,
(unsigned long long)rx_bytes, (unsigned long long)rx_us);
link->last_ack_time_us = now;
if (sample.sent_at_us > link->first_tx_time_us) link->first_tx_time_us = sample.sent_at_us;
@@ -296,17 +296,17 @@ void etcp_tx_ack(struct ETCP_LINK* link, uint32_t seq, uint64_t attempt_id, uint
bbr_main(link->bbr, &rs, &cwnd, &pacing, conn->normalizer->frag_size, link->inflight_bytes, limited);
etcp_link_update_inflight_lim(link, cwnd); etcp_loadbalancer_set_pacing_rate(link, pacing);
}
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] ACK seq=%u attempt=%llu path=%u RTT_us=%u delay_us=%u sample=%u/%u "
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] ACK seq=%u attempt=%u path=%u RTT_us=%u delay_us=%u sample=%u/%u "
"local_interval_us=%llu RX=%llu/%llu flight=%u cwnd=%u pace=%u RTO_us=%u",
conn->log_name, seq, (unsigned long long)attempt_id, link->local_link_id,
conn->log_name, seq, (unsigned)(uint16_t)attempt_id, link->local_link_id,
rtt, receiver_delay_us, rs.delivered, rs.interval_us, (unsigned long long)interval,
(unsigned long long)rx_bytes, (unsigned long long)rx_us, link->inflight_bytes, link->inflight_lim_bytes,
link->bbr_pacing_rate, etcp_tx_rto_us(link));
link->acked_bytes += sample.ll.len; link->acked_packets++;
link->bbr_loss_since_ack = 0; link->cwnd_limited = 0;
retransmit_arm(link);
} else DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] old/foreign ACK seq=%u attempt=%llu path=%u: logical only",
conn->log_name, seq, (unsigned long long)attempt_id, link->local_link_id);
} else DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] old/foreign ACK seq=%u attempt=%u path=%u: logical only",
conn->log_name, seq, (unsigned)(uint16_t)attempt_id, link->local_link_id);
etcp_ack_recv(conn, seq);
etcp_conn_wake_sender(conn);
}