Commit 8026b20
committed
fix: Implement robust ACK handling and retransmission
- Update `build.zig.zon` to use `#` for `git+https` URLs.
- Refactor connection ACK tracking to manage `next_expected_packet`, `last_ack_sent`, `largest_peer_acked_packet`, `pending_ack`, and `received_packets`.
- Implement `recordReceivedPacket` to accurately track received packet numbers and return whether the packet is new.
- Add `scheduleAck`, `markAckSent`, and `getLargestPeerAckedPacket` to manage ACK state.
- Enhance `AckFrame` encoding and decoding to support multiple ACK ranges using QUIC's format.
- Improve `Stream::receiveData` to handle overlapping retransmits and deliver buffered chunks correctly.
- Add `bufferOutOfOrderChunk` to manage out-of-order stream data, replacing older chunks if new data overlaps.
- Modify `QuicTransport::processFrames` to determine if a frame is ACK-eliciting.
- Change `QuicTransport::sendPacket` to track retransmittable packets and enforce inflight capacity limits.
- Add `waitForInflightCapacity` to prevent unbounded inflight packets.
- Implement `buildAckFrameLayout` to construct ACK frames with proper range encoding based on received packets.
- Add `handleAckFrame`, `reapAckedPacketsForAckFrame`, and `packetAckedByAckFrame` to process received ACKs.
- Implement `fastRetransmitAckGaps` to retransmit lost packets indicated by ACK gaps.
- Implement `retransmitExpiredPackets` for timeout-based retransmissions using exponential backoff.
- Update `QuicTransport::flush` to call `retransmitExpiredPackets` before sending new data.
- Refactor `sendPacket` to `sendRawPacket` for sending individual UDP datagrams without encryption/framing.
- Add tests for new ACK and retransmission logic, including handling ACK-only payloads, fast retransmits, and continuous large writes.1 parent 3d1f135 commit 8026b20
5 files changed
Lines changed: 903 additions & 62 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
60 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
| |||
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| 85 | + | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
| |||
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
149 | | - | |
150 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
151 | 165 | | |
152 | 166 | | |
153 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
154 | 189 | | |
155 | 190 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
160 | 195 | | |
161 | 196 | | |
162 | 197 | | |
| |||
179 | 214 | | |
180 | 215 | | |
181 | 216 | | |
182 | | - | |
183 | | - | |
| 217 | + | |
184 | 218 | | |
185 | 219 | | |
186 | 220 | | |
187 | 221 | | |
188 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
189 | 233 | | |
190 | 234 | | |
191 | 235 | | |
| |||
255 | 299 | | |
256 | 300 | | |
257 | 301 | | |
258 | | - | |
259 | | - | |
260 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
261 | 305 | | |
262 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
263 | 379 | | |
264 | 380 | | |
265 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
202 | 204 | | |
203 | | - | |
204 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
205 | 214 | | |
| 215 | + | |
206 | 216 | | |
207 | 217 | | |
208 | 218 | | |
| |||
215 | 225 | | |
216 | 226 | | |
217 | 227 | | |
218 | | - | |
219 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
220 | 239 | | |
221 | 240 | | |
222 | 241 | | |
223 | 242 | | |
224 | | - | |
| 243 | + | |
225 | 244 | | |
226 | 245 | | |
227 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
228 | 251 | | |
229 | | - | |
230 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
231 | 263 | | |
232 | | - | |
233 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
234 | 293 | | |
235 | 294 | | |
236 | 295 | | |
| |||
332 | 391 | | |
333 | 392 | | |
334 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
335 | 422 | | |
336 | 423 | | |
337 | 424 | | |
| |||
0 commit comments