|
|
|
@ -586,7 +586,7 @@ static void ack_timeout_check(struct ETCP_CONN* etcp) { |
|
|
|
|
|
|
|
|
|
|
|
int64_t elapsed = now - pkt->last_timestamp; |
|
|
|
int64_t elapsed = now - pkt->last_timestamp; |
|
|
|
if (elapsed > timeout) { |
|
|
|
if (elapsed > timeout) { |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[%s] timeout for seq=%u, elapsed=%lld, now=%llu, timeout=%llu, send_count=%u. Moving: wait_ack -> send_q", |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] timeout for seq=%u, elapsed=%lld, now=%llu, timeout=%llu, send_count=%u. Moving: wait_ack -> send_q", |
|
|
|
etcp->log_name, pkt->seq, (unsigned long long)elapsed, (unsigned long long)now, (unsigned long long)timeout, pkt->send_count); |
|
|
|
etcp->log_name, pkt->seq, (unsigned long long)elapsed, (unsigned long long)now, (unsigned long long)timeout, pkt->send_count); |
|
|
|
|
|
|
|
|
|
|
|
// Remove from wait_ack
|
|
|
|
// Remove from wait_ack
|
|
|
|
@ -731,7 +731,7 @@ struct ETCP_DGRAM* etcp_request_pkt(struct ETCP_CONN* etcp) { |
|
|
|
struct INFLIGHT_PACKET* inf_pkt = (struct INFLIGHT_PACKET*)queue_data_get(etcp->input_send_q); |
|
|
|
struct INFLIGHT_PACKET* inf_pkt = (struct INFLIGHT_PACKET*)queue_data_get(etcp->input_send_q); |
|
|
|
if (inf_pkt) { |
|
|
|
if (inf_pkt) { |
|
|
|
uint64_t now=get_time_tb(); |
|
|
|
uint64_t now=get_time_tb(); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] send_q->wait_ack seq=%d TS=%llu", etcp->log_name, inf_pkt->seq, now); |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] send_q->wait_ack seq=%d TS=%llu", etcp->log_name, inf_pkt->seq, now); |
|
|
|
|
|
|
|
|
|
|
|
// === NEW: per-link inflight + send_hist logic ===
|
|
|
|
// === NEW: per-link inflight + send_hist logic ===
|
|
|
|
// Compute 1-based link number in the linked list (as requested)
|
|
|
|
// Compute 1-based link number in the linked list (as requested)
|
|
|
|
@ -772,7 +772,7 @@ struct ETCP_DGRAM* etcp_request_pkt(struct ETCP_CONN* etcp) { |
|
|
|
size_t ack_q_size = queue_entry_count(etcp->ack_q); |
|
|
|
size_t ack_q_size = queue_entry_count(etcp->ack_q); |
|
|
|
|
|
|
|
|
|
|
|
if (!inf_pkt && ack_q_size == 0) { |
|
|
|
if (!inf_pkt && ack_q_size == 0) { |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] no data/ack to send", etcp->log_name); |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] no data/ack to send", etcp->log_name); |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -820,7 +820,7 @@ struct ETCP_DGRAM* etcp_request_pkt(struct ETCP_CONN* etcp) { |
|
|
|
uint16_t dly=get_current_timestamp()-ack_pkt->recv_timestamp; |
|
|
|
uint16_t dly=get_current_timestamp()-ack_pkt->recv_timestamp; |
|
|
|
dgram->data[ptr++]=dly; |
|
|
|
dgram->data[ptr++]=dly; |
|
|
|
dgram->data[ptr++]=dly>>8; |
|
|
|
dgram->data[ptr++]=dly>>8; |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] add ACK N%d dTS=%d", etcp->log_name, ack_pkt->seq, dly); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] Send ACK seq=%d need=%d", etcp->log_name, ack_pkt->seq, etcp->last_delivered_id+1); |
|
|
|
queue_entry_free((struct ll_entry*)ack_pkt); |
|
|
|
queue_entry_free((struct ll_entry*)ack_pkt); |
|
|
|
|
|
|
|
|
|
|
|
if (inf_pkt && inf_pkt->ll.len+ptr>=etcp->mtu-10) break;// pkt len (надо просчитать точнее включая все заголовки)
|
|
|
|
if (inf_pkt && inf_pkt->ll.len+ptr>=etcp->mtu-10) break;// pkt len (надо просчитать точнее включая все заголовки)
|
|
|
|
@ -852,7 +852,7 @@ struct ETCP_DGRAM* etcp_request_pkt(struct ETCP_CONN* etcp) { |
|
|
|
|
|
|
|
|
|
|
|
if (inf_pkt) { |
|
|
|
if (inf_pkt) { |
|
|
|
// фрейм data (0) обязательно в конец
|
|
|
|
// фрейм data (0) обязательно в конец
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] add DATA (seq=%u, len=%u), ack_size=%d", etcp->log_name, inf_pkt->seq, inf_pkt->ll.len, dgram->data[1]); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] Send DATA (seq=%u, len=%u), ack_size=%d send_count=%d", etcp->log_name, inf_pkt->seq, inf_pkt->ll.len, dgram->data[1], inf_pkt->send_count); |
|
|
|
dgram->data[ptr++]=0;// payload
|
|
|
|
dgram->data[ptr++]=0;// payload
|
|
|
|
dgram->data[ptr++]=inf_pkt->seq; |
|
|
|
dgram->data[ptr++]=inf_pkt->seq; |
|
|
|
dgram->data[ptr++]=inf_pkt->seq>>8; |
|
|
|
dgram->data[ptr++]=inf_pkt->seq>>8; |
|
|
|
@ -863,7 +863,7 @@ struct ETCP_DGRAM* etcp_request_pkt(struct ETCP_CONN* etcp) { |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
int chk=queue_check_consistency(etcp->ack_q); |
|
|
|
int chk=queue_check_consistency(etcp->ack_q); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] only ACK (size=%d) packet with %d bytes total (chk=%d) rem=%d", etcp->log_name, ack_q_size, ptr, chk, remain_len); |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] only ACK (size=%d) packet with %d bytes total (chk=%d) rem=%d", etcp->log_name, ack_q_size, ptr, chk, remain_len); |
|
|
|
} |
|
|
|
} |
|
|
|
if (ptr>=PACKET_DATA_SIZE-50) DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[%s] SIZE ERROR!!! %d", ptr); |
|
|
|
if (ptr>=PACKET_DATA_SIZE-50) DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[%s] SIZE ERROR!!! %d", ptr); |
|
|
|
|
|
|
|
|
|
|
|
@ -1135,7 +1135,7 @@ void etcp_conn_input(struct ETCP_DGRAM* pkt) { |
|
|
|
} |
|
|
|
} |
|
|
|
if ((int32_t)(etcp->last_delivered_id-seq)<0) if (queue_find_data_by_index(etcp->recv_q, &seq, 4)==NULL) {// проверяем есть ли пакет с этим seq
|
|
|
|
if ((int32_t)(etcp->last_delivered_id-seq)<0) if (queue_find_data_by_index(etcp->recv_q, &seq, 4)==NULL) {// проверяем есть ли пакет с этим seq
|
|
|
|
uint32_t pkt_len=len-5; |
|
|
|
uint32_t pkt_len=len-5; |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] adding packet seq=%u to recv_q (last_delivered_id=%u)", etcp->log_name, seq, etcp->last_delivered_id); |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] adding packet seq=%u to recv_q (last_delivered_id=%u)", etcp->log_name, seq, etcp->last_delivered_id); |
|
|
|
// отправляем пакет в очередь на сборку
|
|
|
|
// отправляем пакет в очередь на сборку
|
|
|
|
uint8_t* payload_data = memory_pool_alloc(etcp->instance->data_pool); |
|
|
|
uint8_t* payload_data = memory_pool_alloc(etcp->instance->data_pool); |
|
|
|
if (!payload_data) { |
|
|
|
if (!payload_data) { |
|
|
|
@ -1159,7 +1159,7 @@ void etcp_conn_input(struct ETCP_DGRAM* pkt) { |
|
|
|
// Copy the actual payload data
|
|
|
|
// Copy the actual payload data
|
|
|
|
memcpy(payload_data, data + 5, pkt_len); |
|
|
|
memcpy(payload_data, data + 5, pkt_len); |
|
|
|
queue_data_put_with_index(etcp->recv_q, (struct ll_entry*)rx_pkt, 0, 4); |
|
|
|
queue_data_put_with_index(etcp->recv_q, (struct ll_entry*)rx_pkt, 0, 4); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] packet seq=%u added to recv_q, calling assembly (last_delivered_id=%u)", etcp->log_name, seq, etcp->last_delivered_id); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] RX seq=%u need=%u)", etcp->log_name, seq, etcp->last_delivered_id+1); |
|
|
|
if ((int32_t)(seq - etcp->last_delivered_id) == 1) etcp_output_try_assembly(etcp);// пробуем собрать выходную очередь из фрагментов
|
|
|
|
if ((int32_t)(seq - etcp->last_delivered_id) == 1) etcp_output_try_assembly(etcp);// пробуем собрать выходную очередь из фрагментов
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|