|
|
|
@ -817,7 +817,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] Send ACK seq=%d need=%d", etcp->log_name, ack_pkt->seq, etcp->last_delivered_id+1); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] RX 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 (надо просчитать точнее включая все заголовки)
|
|
|
|
@ -849,7 +849,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] Send DATA: seq=%u len=%u retry=%d; Qlen: in=%d snd=%d wait=%d", etcp->log_name, inf_pkt->seq, inf_pkt->ll.len, inf_pkt->send_count, etcp->input_queue->count, etcp->input_send_q->count, etcp->input_wait_ack->count); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] TX DATA: seq=%u len=%u retry=%d; Qlen: in=%d snd=%d wait=%d", etcp->log_name, inf_pkt->seq, inf_pkt->ll.len, inf_pkt->send_count, etcp->input_queue->count, etcp->input_send_q->count, etcp->input_wait_ack->count); |
|
|
|
|
|
|
|
|
|
|
|
dgram->data[ptr++]=0;// payload
|
|
|
|
dgram->data[ptr++]=0;// payload
|
|
|
|
dgram->data[ptr++]=inf_pkt->seq; |
|
|
|
dgram->data[ptr++]=inf_pkt->seq; |
|
|
|
@ -890,7 +890,7 @@ void etcp_output_try_assembly(struct ETCP_CONN* etcp) { |
|
|
|
struct ETCP_FRAGMENT* rx_pkt = (struct ETCP_FRAGMENT*)queue_find_data_by_index(etcp->recv_q, &next_expected_id, 4); |
|
|
|
struct ETCP_FRAGMENT* rx_pkt = (struct ETCP_FRAGMENT*)queue_find_data_by_index(etcp->recv_q, &next_expected_id, 4); |
|
|
|
if (!rx_pkt) { |
|
|
|
if (!rx_pkt) { |
|
|
|
// No more contiguous packets found
|
|
|
|
// No more contiguous packets found
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] no packet found for id=%u, stopping", etcp->log_name, next_expected_id); |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] no packet found for id=%u, stopping", etcp->log_name, next_expected_id); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -922,8 +922,8 @@ void etcp_output_try_assembly(struct ETCP_CONN* etcp) { |
|
|
|
next_expected_id++; |
|
|
|
next_expected_id++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] delivered %u contiguous packets (%u bytes), last_delivered_id=%u, output_queue_count=%d", |
|
|
|
if (delivered_count>0) DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] delivered %u contiguous packets (%u bytes), last_delivered_id=%u, asm_queue=%d, output_queue=%d", |
|
|
|
etcp->log_name, delivered_count, delivered_bytes, etcp->last_delivered_id, queue_entry_count(etcp->output_queue)); |
|
|
|
etcp->log_name, delivered_count, delivered_bytes, etcp->last_delivered_id, queue_entry_count(etcp->recv_q), queue_entry_count(etcp->output_queue)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Process ACK receipt - remove acknowledged packet from inflight queues
|
|
|
|
// Process ACK receipt - remove acknowledged packet from inflight queues
|
|
|
|
@ -1129,7 +1129,7 @@ void etcp_conn_input(struct ETCP_DGRAM* pkt) { |
|
|
|
queue_data_put_with_index(etcp->ack_q, (struct ll_entry*)p, 0, 4); |
|
|
|
queue_data_put_with_index(etcp->ack_q, (struct ll_entry*)p, 0, 4); |
|
|
|
if (etcp->ack_resp_timer == NULL) { |
|
|
|
if (etcp->ack_resp_timer == NULL) { |
|
|
|
etcp->ack_resp_timer = uasync_set_timeout(etcp->instance->ua, ACK_DELAY_TB, etcp, ack_response_timer_cb); |
|
|
|
etcp->ack_resp_timer = uasync_set_timeout(etcp->instance->ua, ACK_DELAY_TB, etcp, ack_response_timer_cb); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] set ack_timer for delayed ACK send", etcp->log_name); |
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "[%s] set ack_timer for delayed ACK send", etcp->log_name); |
|
|
|
} |
|
|
|
} |
|
|
|
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; |
|
|
|
@ -1157,7 +1157,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] RX seq=%u need=%u)", etcp->log_name, seq, etcp->last_delivered_id+1); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] RX seq=%u need=%u asm_len=%d", etcp->log_name, seq, etcp->last_delivered_id+1, etcp->recv_q->count); |
|
|
|
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);// пробуем собрать выходную очередь из фрагментов
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|