Fix: Packet coalescing with 1ms flush timer
- Changed tx_wait_time from 100ms to 1ms for faster packet delivery - Small packets now coalesce in buffer until: * Buffer has less than 100 bytes remaining, or * 1ms flush timer expires - Large packets are split across multiple fragments as before - All 17 tests pass
This commit is contained in:
1 parent
f509161701
commit
e90cf9f0c7
1 file changed
+15
-7
+15
-7
@@ -24,10 +24,9 @@ struct PKTNORM* pn_init(struct ETCP_CONN* etcp) {
|
||||
|
||||
pn->etcp = etcp;
|
||||
pn->ua = etcp->instance->ua;
|
||||
// frag_size должен соответствовать размеру блока в data_pool
|
||||
// data_pool->object_size обычно равен MTU (1500)
|
||||
pn->frag_size = etcp->instance->data_pool->object_size;
|
||||
pn->tx_wait_time = 100; // Increased to ensure flush happens between packets
|
||||
// frag_size = MTU минус резерв для дополнительных опций (ACK и прочие заголовки)
|
||||
pn->frag_size = etcp->mtu - 100;
|
||||
pn->tx_wait_time = 1; // 1ms timer for packet coalescing
|
||||
|
||||
pn->input = queue_new(pn->ua, 0); // No hash needed
|
||||
pn->output = queue_new(pn->ua, 0); // No hash needed
|
||||
@@ -278,9 +277,18 @@ static void etcp_input_ready_cb(struct ll_queue* q, void* arg) {
|
||||
queue_dgram_free(in_dgram);
|
||||
queue_entry_free(in_dgram);
|
||||
|
||||
// Send immediately to ensure packet is not lost
|
||||
pn_send_to_etcp(pn);
|
||||
pn_buf_renew(pn);
|
||||
// Check if buffer is almost full (less than 100 bytes remaining)
|
||||
if (pn->data_ptr + 100 >= pn->data_size) {
|
||||
// Buffer is almost full - send immediately
|
||||
pn_send_to_etcp(pn);
|
||||
pn_buf_renew(pn);
|
||||
} else {
|
||||
// Set flush timer to send after tx_wait_time ms
|
||||
if (pn->flush_timer) {
|
||||
uasync_cancel_timeout(pn->ua, pn->flush_timer);
|
||||
}
|
||||
pn->flush_timer = uasync_set_timeout(pn->ua, pn->tx_wait_time, pn, pn_flush_cb);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "pn_packer: etcp_input_ready_cb finished, processed=%d", processed);
|
||||
|
||||
Reference in new issue
Block a user