231 Commits
Author SHA1 Message Date
xtaci 41b30e042b keep kcp.buffer compatible with C version 2026-01-28 12:20:44 +08:00
xtaci 071dc4a69d 1. Fix incorrect RepeatSegs counter in parse_data() function
- Previously, the repeat flag was never set to true when duplicate packets
     were detected, causing incorrect statistics reporting
   - Added missing else branch to properly mark duplicate segments
   - Impact: Correct tracking of repeated packet statistics

2. Fix memory leak in FEC decoder auto-tune functionality
   - When FEC parameters were adjusted dynamically, the old shardSet map
     was discarded without recycling its buffer pool entries
   - Added proper cleanup loop to return old shard packets to buffer pool
     before creating new shardSet
   - Impact: Prevents memory growth during long-lived connections with
     dynamic FEC parameter adjustments

Files modified:
- kcp.go: Added else branch in parse_data() to set repeat=true for duplicates
- fec.go: Added buffer cleanup loop before shardSet recreation in decode()

All existing tests pass, including FEC encoding/decoding and lossy connection tests.
2026-01-24 21:55:49 +08:00
xtaci f53a3373f8 optimize: modernize -fix -test . 2025-12-22 13:10:47 +08:00
Coia Prant 6b9fc33ceb chores: drop unused code (#318)
* chores: drop unused fec fields

* chores: drop impossible check
2025-12-09 17:31:22 +08:00
xtaci 7fa14a0cee Squashed commit of the following:
commit 6568f08d6c
Author: binhu <jinnblue@126.com>
Date:   Mon Dec 8 22:32:29 2025 +0800

    fix(sess): revert WriteBuffers Send use kcp fragment; make TestSetMTU correct.

commit 7822300957
Author: jinnblue <jinnblue@126.com>
Date:   Mon Dec 8 00:48:01 2025 +0800

    fix(sess): panic caused by mtu, when fec/crypt opened and mss < mtu <= mtulimit

commit b651b55aec
Author: jinnblue <jinnblue@126.com>
Date:   Sun Dec 7 21:58:54 2025 +0800

    fix(sess): use correct field(wd) for write deadlines; kcp output non-blocking chPostProcessing avoid deadlocks(mu)
2025-12-08 22:45:00 +08:00
xtaci fca7e4338c Revert "fix probe in recv"
This reverts commit c22ac6f280.
2025-12-05 19:06:08 +08:00
xtaci c22ac6f280 fix probe in recv 2025-12-05 18:14:48 +08:00
xtaci 424174913b decrease IKCP_PROBE_INIT to gain a better throughtput under low latency network 2025-12-05 17:35:25 +08:00
xtaci 1399e4ce02 use nextUpdate to name the return variable from flush 2025-12-01 20:48:33 +08:00
xtaci 6e8ff05822 improve readability for flushSegments 2025-11-30 15:08:39 +08:00
xtaci 5ac42d3bea rename flag to updateRTT 2025-11-30 15:04:50 +08:00
JinnBlue b6e37c405b fix(trace): fix incorrectly trace log (#309) 2025-11-26 11:07:08 +08:00
xtaci ec8e1bf5e3 add IKCP prefix to IFLUSH_xxx 2025-11-25 21:10:56 +08:00
xtaci bbe6fe0bc1 use [type] to format debug message, and changed logoutput to log, DebugLog to debugLog 2025-11-22 20:56:09 +08:00
xtaci 8740a1c5c4 use PacketType to differentiate a regular packet or a packet from FEC 2025-11-22 20:36:42 +08:00
JinnBlue a32123b5dc feat(trace): add trace log to enhance KCP debug (#308)
* feat(trace): add trace log to enhance KCP debug

* feat(trace): update comments
2025-11-22 12:00:20 +08:00
xtaci 91e7483fc9 use any to substitute interface{} 2025-11-21 16:24:14 +08:00
xtaci b243d51f0c seperate xmitBuf into a bufferPool struct 2025-11-19 20:39:22 +08:00
xtaci 02b2f025bd make flush() function to accept an enum instead of bool for better readability 2025-11-14 13:50:42 +08:00
xtaci ee1827e7eb optimize comments 2025-11-13 18:43:58 +08:00
xtaci 2f03c7fe44 fix a loc 2025-11-13 17:04:24 +08:00
xtaci a8d0dc1955 make fastack responsive 2025-11-13 16:55:56 +08:00
xtaci 5f5faefc3d add a line of comment 2025-11-13 14:56:27 +08:00
xtaci 566ec23eed Revert "only push sn > una to ack list"
This reverts commit 154a10dd26.
2025-11-13 13:22:20 +08:00
xtaci b766e0376a Revert "keep at least one ack packet"
This reverts commit d674225789.
2025-11-13 13:22:09 +08:00
xtaci d674225789 keep at least one ack packet 2025-11-13 12:43:22 +08:00
xtaci 154a10dd26 only push sn > una to ack list 2025-11-13 12:25:53 +08:00
xtaci 8ebeca6f9e flash ack when a packet is ready 2025-11-13 12:09:47 +08:00
xtaci 42db657652 fix counting 2025-11-12 17:40:17 +08:00
xtaci 949cb75f24 add a flag to temporiarly disable fastack if RTO has not triggered 2025-11-12 16:55:57 +08:00
JinnBlue 431ff52657 fix(kcp): Shadow declaration caused by "seg" (#304) 2025-11-05 17:31:15 +08:00
JinnBlue 0eccac26e1 feat(snmp): RingBufferSndQueue/RingBufferRcvQueue/RingBufferSndBuffer replace MaxLen with the more meaningful Len. (#303) 2025-11-05 17:16:44 +08:00
xtaci 4aa82fae89 use heap to manager shard recovery in fec 2025-06-09 14:42:55 +08:00
xtaci 35a87d2df1 make de-dup O(1) 2025-06-09 10:09:15 +08:00
xtaci e6384cc211 fix segmentHeap.Less 2025-06-09 09:29:12 +08:00
xtaci b7e3b8c2b0 heapify rcv_buf 2025-06-08 23:40:28 +08:00
xtaci 0a904d16b7 write snmp info 2025-06-08 12:10:15 +08:00
xtaci 133f950491 Merge branch 'ring' 2025-06-08 11:59:48 +08:00
xtaci d41165c6d9 use range over functions and fixed some tests 2025-06-08 11:59:14 +08:00
IceFale 22f24b0c92 Adopt the usage of RingBuffer[T] for snd_buf. (#291) 2025-06-08 11:41:32 +08:00
xtaci 4ba7a87b5d update RingBuffer data in SNMP when flush() has been called 2025-06-07 22:08:16 +08:00
xtaci 18953de3b7 use ring on snd_queue 2025-06-07 11:22:47 +08:00
xtaci 87c6a0f86d use pointer in ForEach 2025-06-06 19:39:56 +08:00
xtaci 57242b8c05 use ringed rcv_queue 2025-06-06 11:47:45 +08:00
xtaci bf6f88f918 do not reserve in kcp core, reserve bytes in callback func 2024-07-31 14:57:52 +08:00
xtaci 3653cc9fea add license to source codes 2024-07-25 21:35:37 +08:00
xtaci 582575ef06 Squashed commit of the following:
commit a8ae293a9ddee042c35e2501f93fa5dfa2425302
Merge: bdaf81e 1a84985
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 22:48:13 2020 +0800

    Merge branch 'master' into autotune

commit bdaf81e88e
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 22:38:31 2020 +0800

    add loc

commit ce66a98f95
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 19:53:42 2020 +0800

    lint

commit ad7383d8a3
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 19:05:35 2020 +0800

    fix typo

commit dc0fc2364c
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 16:47:14 2020 +0800

    adjust tests

commit ec45b72c39
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 16:45:17 2020 +0800

    remove obsolete decoder in listener

commit 827aa70e29
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 16:42:42 2020 +0800

    use hierarchical defensive receiving strategy

commit f5ca6b0e3a
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 16:34:30 2020 +0800

    optimize condition

commit ff34f7683f
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 15:18:00 2020 +0800

    fix test

commit a08b274651
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 15:13:20 2020 +0800

    solve compability issue with non FEC sender

commit ab7596783b
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 15:02:34 2020 +0800

    implements autotune in fec decoder

commit 260f61b3eb
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 9 14:34:48 2020 +0800

    hack 16-bit to identify FEC from packet

commit 105bfec567
Author: xtaci <daniel820313@gmail.com>
Date:   Fri Oct 2 21:38:47 2020 +0800

    add autotune
2020-10-09 22:52:11 +08:00
xtaci 61b6a3efc7 combine if else 2020-07-02 21:23:23 +08:00
xtaci 43d2c47d8a flush when input has make a window slide 2020-07-01 18:04:55 +08:00
xtaci 2ea2218ef0 fix cwnd compute 2020-02-25 10:59:16 +08:00