Commit Graph
12 Commits
Author SHA1 Message Date
Evgeny 61fee27478 congestion: burst-based BW measurement + adaptive inflight (slow start/cong avoidance/loss response)
New features:
- get_time_us() in lib/u_async.c/h for µs-precision timing
- Burst measurement (ETCP_SECTION_MEAS_TS 0x07, MEAS_RESP 0x08, FILLER 0x09)
  - 12 MTU packets sent at line rate, receiver measures inter-packet gaps
  - Burst triggered when link saturated + min 500ms interval
  - Result: measured BW -> bandwidth for shaper, burst_target_bdp for window cap
- 3-phase adaptive inflight in link_stats_timer_cb:
  - Slow start: windows doubles each RTT, exits on loss/RTT spike/threshold
  - Congestion avoidance: additive increase, proportional RTT shrink, multiplicative loss shrink
  - Burst target cap: inflight_lim <= burst_target_bdp * 1.1
- Dynamic optimal_inflight = sum(link->inflight_lim_bytes), recalculated on change
- Adaptive win_timebase = rtt/2 (was hardcoded 10ms)

Fixes:
- dummynet.c: shaper formula fixed (80000 -> 80)
- dummynet.c: queue_data_put call fixed (3 args -> 2)
- etcp.c: SIZE ERROR format string (missing log_name argument)
- etcp_request_pkt: FILLER leaves room for PAYLOAD overhead

Tests:
- test_etcp_congestion.c: single-threaded, 5-phase BW/delay/loss test
  - sender + receiver + dummynet in one uasync
  - CSV metrics output every 100ms
- All 29 existing tests pass
2026-04-26 00:17:32 +03:00
jeka 5816fbea70 1 2026-03-08 17:19:38 +03:00
jeka 15c7968c8c mem 2026-03-06 01:36:57 +03:00
jeka de053a00c0 cleanup tests (winsock) 2026-03-04 17:27:33 +03:00
jeka fcdd07ba94 фиксы тестов (winsock) 2026-03-04 15:30:32 +03:00
Evgeny 20a3eaf73c Fix remaining test files: replace POSIX headers with platform_compat.h 2026-02-15 13:25:05 +03:00
Evgeny 3ddfb79338 Backup before replacing all printf with DEBUG_ macros in tests 2026-01-26 17:52:50 +03:00
Evgeny 1bafe6a681 Backup before fixing etcp_connections list addition 2026-01-26 17:40:51 +03:00
Evgeny d0268563a1 Fix uasync socket counting bug causing test failures
Root cause: Use-after-free bug due to stale pointers after realloc()
- Socket array growth via realloc() moved memory to new location
- Test stored old pointers that became invalid after memory move
- Caused memory corruption and socket counting failures

Solution: Modified test to avoid storing stale pointers
- Store file descriptors instead of raw pointers
- Use lookup approach to get current pointers during removal
- Eliminates use-after-free issue entirely

Results: All uasync tests now pass without memory leaks
- test_u_async_performance: 25/25 sockets (was failing before)
- No more socket counting mismatches or corruption
- Clean memory stats and proper cleanup
2026-01-25 14:18:30 +03:00
Evgeny d74f76a5a0 Fix: Resolved double free in timeout_heap_pop() and test_etcp_simple_traffic bind conflict
- Fixed incorrect init_connections() call in test_etcp_simple_traffic.c (was calling server_instance instead of client_instance)
- Fixed double free in timeout_heap_pop() when handling deleted elements
- Enhanced NULL pointer safety in uasync_print_resources() by removing complex heap manipulation
- Added debug logging to timeout_heap_pop() for better error tracking

Test results: test_etcp_simple_traffic now passes without double free errors
2026-01-25 10:47:02 +03:00
Evgeny 3f0a23aa93 Fix build: rename u_async to lib, add missing constants, out-of-tree build support 2026-01-18 16:18:28 +03:00
Evgeny 8d9340c949 Refactor: Move mainloop from utun_instance to main
Major architectural changes:
- utun_instance_run() now does single iteration instead of mainloop
- Added tun_read_callback() to handle TUN device packets
- Added utun_instance_register_sockets() for uasync integration
- Mainloop moved to main() with proper signal handling
- Removed parse config file functions from debug_config
- all fprintf replaced with DEBUG_* macros

Files changed:
- src/utun.c: Added mainloop, signal handlers, proper init order
- src/utun_instance.c: Added callback, socket registration, single-run
- src/utun_instance.h: Added declarations, tun_socket_id field
- u_async/debug_config.c: Removed file parsing and auto-reload
- u_async/debug_config.h: Removed file functions, added categories
- changelog.txt: Added all changes

Breaking changes:
- debug_parse_config_file() removed (use debug_parse_config() only)
- etcp crypto integration needs fixing (separate issue)

AGENTS.md principles followed:
- No backward compatibility preserved
- Removed 103+ lines of legacy code
- Added statistics tracking
- Clean architecture: create -> init -> register -> run -> destroy
2026-01-18 14:28:57 +03:00