diff --git a/AGENTS.md b/AGENTS.md index 2f895c7..a2ed832 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -230,6 +230,11 @@ Crypto: Fixed CCM nonce size to 13 bytes, all crypto tests passing - просмотри где используется эта функция - убедись что изменение поведения не повлияет на остальные теста где функция используется +Работа с очередями. +- Буфера забивать нельзя! всегда контролируй заполненность буфера. Для этого есть инструмент queue_wait_threshold +- Для получения из очереди также есть callback. их нужно использовать в тестах. + + тех задания для реализации в каталоге /doc. /doc/etcp_protocol.txt - основной протокол (похож на TCP+QUIC, поддеиживает шифрования, load balancing multi-link, работу а неустойчивых каналах, утилизацию полосы и недопущение перегрузки каналов связи) - реализация в /src/etcp*.c/h diff --git a/src/pkt_normalizer.c b/src/pkt_normalizer.c index 0fce62b..81851c7 100644 --- a/src/pkt_normalizer.c +++ b/src/pkt_normalizer.c @@ -108,14 +108,14 @@ void pn_packer_send(struct PKTNORM* pn, uint8_t* data, uint16_t len) { entry->len = len; entry->dgram_pool = NULL; - int ret = queue_data_put(pn->input, entry, 0); - DEBUG_INFO(DEBUG_CATEGORY_NORMALIZER, "pn_packer_send: queue_data_put returned %d, input count=%d", ret, queue_entry_count(pn->input)); - // Cancel flush timer if active if (pn->flush_timer) { uasync_cancel_timeout(pn->ua, pn->flush_timer); pn->flush_timer = NULL; } + + int ret = queue_data_put(pn->input, entry, 0); + DEBUG_INFO(DEBUG_CATEGORY_NORMALIZER, "pn_packer_send: queue_data_put returned %d, input count=%d", ret, queue_entry_count(pn->input)); } // Internal: Packer callback @@ -223,19 +223,6 @@ static void pn_flush_cb(void* arg) { pn_send_to_etcp(pn); } -// Public: Force flush pending data -void pn_flush(struct PKTNORM* pn) { - if (!pn) return; - - // Cancel flush timer if active - if (pn->flush_timer) { - uasync_cancel_timeout(pn->ua, pn->flush_timer); - pn->flush_timer = NULL; - } - - // Send pending data - pn_send_to_etcp(pn); -} // Internal: Unpacker callback (assembles fragments into original packets) static void pn_unpacker_cb(struct ll_queue* q, void* arg) { diff --git a/src/pkt_normalizer.h b/src/pkt_normalizer.h index 292189d..7d3bf9f 100644 --- a/src/pkt_normalizer.h +++ b/src/pkt_normalizer.h @@ -48,7 +48,4 @@ void pn_unpacker_reset_state(struct PKTNORM* pn); // создаёт malloc data, копирует, помещает в input. void pn_packer_send(struct PKTNORM* pn, uint8_t* data, uint16_t len); -// Принудительно отправить накопленные данные (flush) -void pn_flush(struct PKTNORM* pn); - #endif // PKT_NORMALIZER_H \ No newline at end of file diff --git a/src/ффф b/src/ффф deleted file mode 100755 index 56143e8..0000000 --- a/src/ффф +++ /dev/null @@ -1,33 +0,0 @@ -Один тест не работает. - - -./test -[pass 1] -[pass 2] -[pass 3] -... -Error callback: null pointer! -[test fail] - -LLM: Я нашел проблему!!! -тест не проходит потому что тест вызываает callback в котором нужно освобдить память. Но указатель null. -В аргументе передаётся только null. Тогда как получить нужный укзатель? -Память выделена в первом блоке. Надо чтобы free освобождал первый блок. Точно. Надо доработать free -/edit stdlib.h +30 -1 -Компилируем и запускаем - - -... ./test -segmentation fault: core dumped - -Да, всё чисто! теперь сообщения об ошибке нет! -Теперь пересоберем остальные тесты и запустим - -Много ошибок! Только один тест проходит. Надо выяснить причину. -Вижу, мы поменяли free, теперь надо обновить все тесты. Приступаю. -..... -Тесты падают, много ошибок. Надо восстановить из бэкапа. -Восстановил. Тесты не собираются, нет makefile. лучше всё переписать заново. -там должно быть два файла. Удалю сразу все. - -rm -r / diff --git a/test_pkt_normalizer_etcp_debug.log b/test_pkt_normalizer_etcp_debug.log new file mode 100644 index 0000000..20c5206 --- /dev/null +++ b/test_pkt_normalizer_etcp_debug.log @@ -0,0 +1 @@ +/bin/bash: строка 1: ./test_pkt_normalizer_etcp: Нет такого файла или каталога diff --git a/tests/! b/tests/! new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_config_debug b/tests/test_config_debug new file mode 100755 index 0000000..e2a6b18 Binary files /dev/null and b/tests/test_config_debug differ diff --git a/tests/test_crypto b/tests/test_crypto new file mode 100755 index 0000000..0209165 Binary files /dev/null and b/tests/test_crypto differ diff --git a/tests/test_debug_categories b/tests/test_debug_categories new file mode 100755 index 0000000..d8f80ec Binary files /dev/null and b/tests/test_debug_categories differ diff --git a/tests/test_ecc_encrypt b/tests/test_ecc_encrypt new file mode 100755 index 0000000..72a1863 Binary files /dev/null and b/tests/test_ecc_encrypt differ diff --git a/tests/test_etcp_100_packets b/tests/test_etcp_100_packets new file mode 100755 index 0000000..51bcd05 Binary files /dev/null and b/tests/test_etcp_100_packets differ diff --git a/tests/test_etcp_crypto b/tests/test_etcp_crypto new file mode 100755 index 0000000..2b7b09a Binary files /dev/null and b/tests/test_etcp_crypto differ diff --git a/tests/test_etcp_minimal b/tests/test_etcp_minimal new file mode 100755 index 0000000..dc32bfd Binary files /dev/null and b/tests/test_etcp_minimal differ diff --git a/tests/test_etcp_simple_traffic b/tests/test_etcp_simple_traffic new file mode 100755 index 0000000..e995fe0 Binary files /dev/null and b/tests/test_etcp_simple_traffic differ diff --git a/tests/test_etcp_two_instances b/tests/test_etcp_two_instances new file mode 100755 index 0000000..eefeee2 Binary files /dev/null and b/tests/test_etcp_two_instances differ diff --git a/tests/test_intensive_memory_pool b/tests/test_intensive_memory_pool new file mode 100755 index 0000000..f7ae1c4 Binary files /dev/null and b/tests/test_intensive_memory_pool differ diff --git a/tests/test_ll_queue b/tests/test_ll_queue new file mode 100755 index 0000000..aa911b4 Binary files /dev/null and b/tests/test_ll_queue differ diff --git a/tests/test_memory_pool_and_config b/tests/test_memory_pool_and_config new file mode 100755 index 0000000..62bf31b Binary files /dev/null and b/tests/test_memory_pool_and_config differ diff --git a/tests/test_packet_dump b/tests/test_packet_dump new file mode 100755 index 0000000..05a1820 Binary files /dev/null and b/tests/test_packet_dump differ diff --git a/tests/test_pkt_normalizer_etcp b/tests/test_pkt_normalizer_etcp index 4c911a2..f0dbbd5 100755 Binary files a/tests/test_pkt_normalizer_etcp and b/tests/test_pkt_normalizer_etcp differ diff --git a/tests/test_pkt_normalizer_etcp.c b/tests/test_pkt_normalizer_etcp.c index 5b78e79..d476458 100644 --- a/tests/test_pkt_normalizer_etcp.c +++ b/tests/test_pkt_normalizer_etcp.c @@ -17,10 +17,10 @@ #include "../lib/debug_config.h" #define TEST_TIMEOUT_MS 5000 // 5 second timeout -#define TOTAL_PACKETS 10 // Total packets to send -#define MAX_QUEUE_SIZE 5 // Max packets in input queue +#define TOTAL_PACKETS 100 // Total packets to send +//#define MAX_QUEUE_SIZE 5 // Max packets in input queue #define MIN_PACKET_SIZE 10 // Minimum packet size -#define MAX_TEST_PACKET_SIZE 1400 // Maximum packet size - must fit in normalizer fragment (mtu-100) +#define MAX_TEST_PACKET_SIZE 2000 // Maximum packet size - must fit in normalizer fragment (mtu-100) // Packet header size: seq(2) + size(2) + checksum(2) = 6 bytes #define PACKET_HEADER_SIZE 6 @@ -240,6 +240,9 @@ static void check_received_packets_fwd(void) { // Check packets received by client (backward direction) via normalizer output static void check_received_packets_back(void) { + printf("DEBUG check_received_packets_back: client_instance=%p, client_pn=%p\n", + (void*)client_instance, (void*)client_pn); + fflush(stdout); if (!client_instance || !client_pn) return; void* data; @@ -428,7 +431,7 @@ int main() { debug_config_init(); debug_set_level(DEBUG_LEVEL_DEBUG); - debug_set_categories(DEBUG_CATEGORY_ETCP); + debug_set_categories(DEBUG_CATEGORY_ETCP | DEBUG_CATEGORY_NORMALIZER); utun_instance_set_tun_init_enabled(0); diff --git a/tests/test_pkt_normalizer_standalone b/tests/test_pkt_normalizer_standalone new file mode 100755 index 0000000..8e01dc0 Binary files /dev/null and b/tests/test_pkt_normalizer_standalone differ diff --git a/tests/test_pkt_normalizer_standalone.c b/tests/test_pkt_normalizer_standalone.c index eebe951..7b949d6 100644 --- a/tests/test_pkt_normalizer_standalone.c +++ b/tests/test_pkt_normalizer_standalone.c @@ -98,9 +98,6 @@ static void send_packets(void) { packets_sent++; } - // Force flush any pending data in packer buffer - pn_flush(pn); - printf("All %d packets queued to normalizer\n", TOTAL_PACKETS); } diff --git a/tests/test_u_async_comprehensive b/tests/test_u_async_comprehensive new file mode 100755 index 0000000..9940a13 Binary files /dev/null and b/tests/test_u_async_comprehensive differ diff --git a/tests/test_u_async_performance b/tests/test_u_async_performance new file mode 100755 index 0000000..741ced3 Binary files /dev/null and b/tests/test_u_async_performance differ