mediasoup 3.19.21 → 3.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (649) hide show
  1. package/node/lib/ActiveSpeakerObserver.js +34 -1
  2. package/node/lib/AudioLevelObserver.js +35 -2
  3. package/node/lib/Channel.d.ts.map +1 -1
  4. package/node/lib/Channel.js +37 -5
  5. package/node/lib/Consumer.js +39 -6
  6. package/node/lib/DataConsumer.d.ts.map +1 -1
  7. package/node/lib/DataConsumer.js +39 -5
  8. package/node/lib/DataConsumerTypes.d.ts +1 -0
  9. package/node/lib/DataConsumerTypes.d.ts.map +1 -1
  10. package/node/lib/DataProducer.js +37 -4
  11. package/node/lib/DirectTransport.js +37 -4
  12. package/node/lib/DirectTransportTypes.d.ts +7 -2
  13. package/node/lib/DirectTransportTypes.d.ts.map +1 -1
  14. package/node/lib/Logger.js +4 -1
  15. package/node/lib/PipeTransport.d.ts +3 -1
  16. package/node/lib/PipeTransport.d.ts.map +1 -1
  17. package/node/lib/PipeTransport.js +56 -5
  18. package/node/lib/PipeTransportTypes.d.ts +28 -8
  19. package/node/lib/PipeTransportTypes.d.ts.map +1 -1
  20. package/node/lib/PlainTransport.d.ts +3 -1
  21. package/node/lib/PlainTransport.d.ts.map +1 -1
  22. package/node/lib/PlainTransport.js +54 -3
  23. package/node/lib/PlainTransportTypes.d.ts +27 -7
  24. package/node/lib/PlainTransportTypes.d.ts.map +1 -1
  25. package/node/lib/Producer.js +40 -7
  26. package/node/lib/Router.d.ts +5 -5
  27. package/node/lib/Router.d.ts.map +1 -1
  28. package/node/lib/Router.js +81 -36
  29. package/node/lib/RouterTypes.d.ts +25 -3
  30. package/node/lib/RouterTypes.d.ts.map +1 -1
  31. package/node/lib/RtpObserver.js +36 -3
  32. package/node/lib/Transport.d.ts +3 -1
  33. package/node/lib/Transport.d.ts.map +1 -1
  34. package/node/lib/Transport.js +74 -22
  35. package/node/lib/TransportTypes.d.ts +2 -1
  36. package/node/lib/TransportTypes.d.ts.map +1 -1
  37. package/node/lib/WebRtcServer.js +36 -3
  38. package/node/lib/WebRtcTransport.d.ts +3 -1
  39. package/node/lib/WebRtcTransport.d.ts.map +1 -1
  40. package/node/lib/WebRtcTransport.js +55 -4
  41. package/node/lib/WebRtcTransportTypes.d.ts +27 -7
  42. package/node/lib/WebRtcTransportTypes.d.ts.map +1 -1
  43. package/node/lib/Worker.d.ts +2 -1
  44. package/node/lib/Worker.d.ts.map +1 -1
  45. package/node/lib/Worker.js +71 -25
  46. package/node/lib/WorkerTypes.d.ts +0 -4
  47. package/node/lib/WorkerTypes.d.ts.map +1 -1
  48. package/node/lib/enhancedEvents.d.ts +2 -2
  49. package/node/lib/enhancedEvents.d.ts.map +1 -1
  50. package/node/lib/enhancedEvents.js +0 -2
  51. package/node/lib/fbs/active-speaker-observer/active-speaker-observer-options.js +34 -1
  52. package/node/lib/fbs/active-speaker-observer/dominant-speaker-notification.js +34 -1
  53. package/node/lib/fbs/audio-level-observer/audio-level-observer-options.js +34 -1
  54. package/node/lib/fbs/audio-level-observer/volume.js +34 -1
  55. package/node/lib/fbs/audio-level-observer/volumes-notification.js +34 -1
  56. package/node/lib/fbs/common/string-string-array.js +34 -1
  57. package/node/lib/fbs/common/string-string.js +34 -1
  58. package/node/lib/fbs/common/string-uint8.js +34 -1
  59. package/node/lib/fbs/common/uint16-string.js +34 -1
  60. package/node/lib/fbs/common/uint32-string.js +34 -1
  61. package/node/lib/fbs/consumer/base-consumer-dump.js +34 -1
  62. package/node/lib/fbs/consumer/consumer-dump.js +34 -1
  63. package/node/lib/fbs/consumer/consumer-layers.js +34 -1
  64. package/node/lib/fbs/consumer/consumer-score.js +34 -1
  65. package/node/lib/fbs/consumer/dump-response.js +34 -1
  66. package/node/lib/fbs/consumer/enable-trace-event-request.js +34 -1
  67. package/node/lib/fbs/consumer/fir-trace-info.js +34 -1
  68. package/node/lib/fbs/consumer/get-stats-response.js +34 -1
  69. package/node/lib/fbs/consumer/key-frame-trace-info.js +34 -1
  70. package/node/lib/fbs/consumer/layers-change-notification.js +34 -1
  71. package/node/lib/fbs/consumer/pli-trace-info.js +34 -1
  72. package/node/lib/fbs/consumer/rtp-notification.js +34 -1
  73. package/node/lib/fbs/consumer/rtp-trace-info.js +34 -1
  74. package/node/lib/fbs/consumer/score-notification.js +34 -1
  75. package/node/lib/fbs/consumer/set-preferred-layers-request.js +34 -1
  76. package/node/lib/fbs/consumer/set-preferred-layers-response.js +34 -1
  77. package/node/lib/fbs/consumer/set-priority-request.js +34 -1
  78. package/node/lib/fbs/consumer/set-priority-response.js +34 -1
  79. package/node/lib/fbs/consumer/trace-notification.js +34 -1
  80. package/node/lib/fbs/data-consumer/add-subchannel-request.js +34 -1
  81. package/node/lib/fbs/data-consumer/add-subchannel-response.js +34 -1
  82. package/node/lib/fbs/data-consumer/buffered-amount-low-notification.js +34 -1
  83. package/node/lib/fbs/data-consumer/dump-response.d.ts +5 -2
  84. package/node/lib/fbs/data-consumer/dump-response.d.ts.map +1 -1
  85. package/node/lib/fbs/data-consumer/dump-response.js +60 -16
  86. package/node/lib/fbs/data-consumer/get-buffered-amount-response.js +34 -1
  87. package/node/lib/fbs/data-consumer/get-stats-response.js +34 -1
  88. package/node/lib/fbs/data-consumer/message-notification.js +34 -1
  89. package/node/lib/fbs/data-consumer/remove-subchannel-request.js +34 -1
  90. package/node/lib/fbs/data-consumer/remove-subchannel-response.js +34 -1
  91. package/node/lib/fbs/data-consumer/send-request.js +34 -1
  92. package/node/lib/fbs/data-consumer/set-buffered-amount-low-threshold-request.js +34 -1
  93. package/node/lib/fbs/data-consumer/set-subchannels-request.js +34 -1
  94. package/node/lib/fbs/data-consumer/set-subchannels-response.js +34 -1
  95. package/node/lib/fbs/data-consumer/type.d.ts +5 -0
  96. package/node/lib/fbs/data-consumer/type.d.ts.map +1 -0
  97. package/node/lib/fbs/data-consumer/type.js +10 -0
  98. package/node/lib/fbs/data-consumer.d.ts +1 -0
  99. package/node/lib/fbs/data-consumer.d.ts.map +1 -1
  100. package/node/lib/fbs/data-consumer.js +3 -1
  101. package/node/lib/fbs/data-producer/dump-response.js +34 -1
  102. package/node/lib/fbs/data-producer/get-stats-response.js +34 -1
  103. package/node/lib/fbs/data-producer/send-notification.js +34 -1
  104. package/node/lib/fbs/direct-transport/direct-transport-options.js +34 -1
  105. package/node/lib/fbs/direct-transport/dump-response.js +34 -1
  106. package/node/lib/fbs/direct-transport/get-stats-response.js +34 -1
  107. package/node/lib/fbs/direct-transport/rtcp-notification.js +34 -1
  108. package/node/lib/fbs/lib-uring/dump.js +34 -1
  109. package/node/lib/fbs/log/log.js +34 -1
  110. package/node/lib/fbs/message/message.js +34 -1
  111. package/node/lib/fbs/notification/body.d.ts +24 -22
  112. package/node/lib/fbs/notification/body.d.ts.map +1 -1
  113. package/node/lib/fbs/notification/body.js +24 -20
  114. package/node/lib/fbs/notification/event.d.ts +27 -26
  115. package/node/lib/fbs/notification/event.d.ts.map +1 -1
  116. package/node/lib/fbs/notification/event.js +27 -26
  117. package/node/lib/fbs/notification/notification.d.ts +3 -2
  118. package/node/lib/fbs/notification/notification.d.ts.map +1 -1
  119. package/node/lib/fbs/notification/notification.js +34 -1
  120. package/node/lib/fbs/pipe-transport/connect-request.js +34 -1
  121. package/node/lib/fbs/pipe-transport/connect-response.js +34 -1
  122. package/node/lib/fbs/pipe-transport/dump-response.js +34 -1
  123. package/node/lib/fbs/pipe-transport/get-stats-response.js +34 -1
  124. package/node/lib/fbs/pipe-transport/pipe-transport-options.js +34 -1
  125. package/node/lib/fbs/plain-transport/connect-request.js +34 -1
  126. package/node/lib/fbs/plain-transport/connect-response.js +34 -1
  127. package/node/lib/fbs/plain-transport/dump-response.js +34 -1
  128. package/node/lib/fbs/plain-transport/get-stats-response.js +34 -1
  129. package/node/lib/fbs/plain-transport/plain-transport-options.js +34 -1
  130. package/node/lib/fbs/plain-transport/rtcp-tuple-notification.js +34 -1
  131. package/node/lib/fbs/plain-transport/tuple-notification.js +34 -1
  132. package/node/lib/fbs/producer/dump-response.js +34 -1
  133. package/node/lib/fbs/producer/enable-trace-event-request.js +34 -1
  134. package/node/lib/fbs/producer/fir-trace-info.js +34 -1
  135. package/node/lib/fbs/producer/get-stats-response.js +34 -1
  136. package/node/lib/fbs/producer/key-frame-trace-info.js +34 -1
  137. package/node/lib/fbs/producer/pli-trace-info.js +34 -1
  138. package/node/lib/fbs/producer/rtp-trace-info.js +34 -1
  139. package/node/lib/fbs/producer/score-notification.js +34 -1
  140. package/node/lib/fbs/producer/score.js +34 -1
  141. package/node/lib/fbs/producer/send-notification.js +34 -1
  142. package/node/lib/fbs/producer/sr-trace-info.js +34 -1
  143. package/node/lib/fbs/producer/trace-notification.js +34 -1
  144. package/node/lib/fbs/producer/video-orientation-change-notification.js +34 -1
  145. package/node/lib/fbs/request/request.js +34 -1
  146. package/node/lib/fbs/response/response.js +34 -1
  147. package/node/lib/fbs/router/close-rtp-observer-request.js +34 -1
  148. package/node/lib/fbs/router/close-transport-request.js +34 -1
  149. package/node/lib/fbs/router/create-active-speaker-observer-request.js +34 -1
  150. package/node/lib/fbs/router/create-audio-level-observer-request.js +34 -1
  151. package/node/lib/fbs/router/create-direct-transport-request.js +34 -1
  152. package/node/lib/fbs/router/create-pipe-transport-request.js +34 -1
  153. package/node/lib/fbs/router/create-plain-transport-request.js +34 -1
  154. package/node/lib/fbs/router/create-web-rtc-transport-request.js +34 -1
  155. package/node/lib/fbs/router/dump-response.js +34 -1
  156. package/node/lib/fbs/rtp-observer/add-producer-request.js +34 -1
  157. package/node/lib/fbs/rtp-observer/remove-producer-request.js +34 -1
  158. package/node/lib/fbs/rtp-packet/dump.js +34 -1
  159. package/node/lib/fbs/rtp-parameters/boolean.js +34 -1
  160. package/node/lib/fbs/rtp-parameters/codec-mapping.js +34 -1
  161. package/node/lib/fbs/rtp-parameters/double.js +34 -1
  162. package/node/lib/fbs/rtp-parameters/encoding-mapping.js +34 -1
  163. package/node/lib/fbs/rtp-parameters/integer32-array.js +34 -1
  164. package/node/lib/fbs/rtp-parameters/integer32.js +34 -1
  165. package/node/lib/fbs/rtp-parameters/parameter.js +34 -1
  166. package/node/lib/fbs/rtp-parameters/rtcp-feedback.js +34 -1
  167. package/node/lib/fbs/rtp-parameters/rtcp-parameters.js +34 -1
  168. package/node/lib/fbs/rtp-parameters/rtp-codec-parameters.js +34 -1
  169. package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.js +34 -1
  170. package/node/lib/fbs/rtp-parameters/rtp-header-extension-parameters.js +34 -1
  171. package/node/lib/fbs/rtp-parameters/rtp-mapping.js +34 -1
  172. package/node/lib/fbs/rtp-parameters/rtp-parameters.js +34 -1
  173. package/node/lib/fbs/rtp-parameters/rtx.js +34 -1
  174. package/node/lib/fbs/rtp-parameters/string.js +34 -1
  175. package/node/lib/fbs/rtp-stream/base-stats.js +34 -1
  176. package/node/lib/fbs/rtp-stream/bitrate-by-layer.js +34 -1
  177. package/node/lib/fbs/rtp-stream/dump.js +34 -1
  178. package/node/lib/fbs/rtp-stream/params.js +34 -1
  179. package/node/lib/fbs/rtp-stream/recv-stats.js +34 -1
  180. package/node/lib/fbs/rtp-stream/send-stats.js +34 -1
  181. package/node/lib/fbs/rtp-stream/stats.js +34 -1
  182. package/node/lib/fbs/rtx-stream/params.js +34 -1
  183. package/node/lib/fbs/rtx-stream/rtx-dump.js +34 -1
  184. package/node/lib/fbs/sctp-association/sctp-negotiated-capabilities.d.ts +24 -0
  185. package/node/lib/fbs/sctp-association/sctp-negotiated-capabilities.d.ts.map +1 -0
  186. package/node/lib/fbs/sctp-association/sctp-negotiated-capabilities.js +102 -0
  187. package/node/lib/fbs/sctp-association.d.ts +1 -0
  188. package/node/lib/fbs/sctp-association.d.ts.map +1 -1
  189. package/node/lib/fbs/sctp-association.js +4 -1
  190. package/node/lib/fbs/sctp-parameters/num-sctp-streams.js +34 -1
  191. package/node/lib/fbs/sctp-parameters/sctp-parameters.d.ts +14 -14
  192. package/node/lib/fbs/sctp-parameters/sctp-parameters.d.ts.map +1 -1
  193. package/node/lib/fbs/sctp-parameters/sctp-parameters.js +73 -40
  194. package/node/lib/fbs/sctp-parameters/sctp-stream-parameters.js +34 -1
  195. package/node/lib/fbs/sctp-parameters.d.ts +0 -1
  196. package/node/lib/fbs/sctp-parameters.d.ts.map +1 -1
  197. package/node/lib/fbs/sctp-parameters.js +1 -4
  198. package/node/lib/fbs/srtp-parameters/srtp-parameters.js +34 -1
  199. package/node/lib/fbs/transport/bwe-trace-info.js +34 -1
  200. package/node/lib/fbs/transport/close-consumer-request.js +34 -1
  201. package/node/lib/fbs/transport/close-data-consumer-request.js +34 -1
  202. package/node/lib/fbs/transport/close-data-producer-request.js +34 -1
  203. package/node/lib/fbs/transport/close-producer-request.js +34 -1
  204. package/node/lib/fbs/transport/consume-data-request.d.ts +1 -1
  205. package/node/lib/fbs/transport/consume-data-request.js +35 -2
  206. package/node/lib/fbs/transport/consume-request.js +34 -1
  207. package/node/lib/fbs/transport/consume-response.js +34 -1
  208. package/node/lib/fbs/transport/dump.d.ts +7 -4
  209. package/node/lib/fbs/transport/dump.d.ts.map +1 -1
  210. package/node/lib/fbs/transport/dump.js +66 -22
  211. package/node/lib/fbs/transport/enable-trace-event-request.js +34 -1
  212. package/node/lib/fbs/transport/listen-info.js +34 -1
  213. package/node/lib/fbs/transport/options.d.ts +14 -14
  214. package/node/lib/fbs/transport/options.d.ts.map +1 -1
  215. package/node/lib/fbs/transport/options.js +92 -51
  216. package/node/lib/fbs/transport/port-range.js +34 -1
  217. package/node/lib/fbs/transport/produce-data-request.js +34 -1
  218. package/node/lib/fbs/transport/produce-request.js +34 -1
  219. package/node/lib/fbs/transport/produce-response.js +34 -1
  220. package/node/lib/fbs/transport/recv-rtp-header-extensions.js +34 -1
  221. package/node/lib/fbs/transport/restart-ice-response.js +34 -1
  222. package/node/lib/fbs/transport/rtp-listener.js +34 -1
  223. package/node/lib/fbs/transport/sctp-listener.js +34 -1
  224. package/node/lib/fbs/transport/sctp-negotiated-capabilities-notification.d.ts +22 -0
  225. package/node/lib/fbs/transport/sctp-negotiated-capabilities-notification.d.ts.map +1 -0
  226. package/node/lib/fbs/transport/sctp-negotiated-capabilities-notification.js +93 -0
  227. package/node/lib/fbs/transport/sctp-state-change-notification.js +34 -1
  228. package/node/lib/fbs/transport/send-rtcp-notification.js +34 -1
  229. package/node/lib/fbs/transport/set-max-incoming-bitrate-request.js +34 -1
  230. package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.js +34 -1
  231. package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.js +34 -1
  232. package/node/lib/fbs/transport/socket-flags.js +34 -1
  233. package/node/lib/fbs/transport/stats.js +34 -1
  234. package/node/lib/fbs/transport/trace-notification.js +34 -1
  235. package/node/lib/fbs/transport/tuple.js +34 -1
  236. package/node/lib/fbs/transport.d.ts +1 -0
  237. package/node/lib/fbs/transport.d.ts.map +1 -1
  238. package/node/lib/fbs/transport.js +5 -2
  239. package/node/lib/fbs/web-rtc-server/dump-response.js +34 -1
  240. package/node/lib/fbs/web-rtc-server/ice-user-name-fragment.js +34 -1
  241. package/node/lib/fbs/web-rtc-server/ip-port.js +34 -1
  242. package/node/lib/fbs/web-rtc-server/tuple-hash.js +34 -1
  243. package/node/lib/fbs/web-rtc-transport/connect-request.js +34 -1
  244. package/node/lib/fbs/web-rtc-transport/connect-response.js +34 -1
  245. package/node/lib/fbs/web-rtc-transport/dtls-parameters.js +34 -1
  246. package/node/lib/fbs/web-rtc-transport/dtls-state-change-notification.js +34 -1
  247. package/node/lib/fbs/web-rtc-transport/dump-response.js +34 -1
  248. package/node/lib/fbs/web-rtc-transport/fingerprint.js +34 -1
  249. package/node/lib/fbs/web-rtc-transport/get-stats-response.js +34 -1
  250. package/node/lib/fbs/web-rtc-transport/ice-candidate.js +34 -1
  251. package/node/lib/fbs/web-rtc-transport/ice-parameters.js +34 -1
  252. package/node/lib/fbs/web-rtc-transport/ice-selected-tuple-change-notification.js +34 -1
  253. package/node/lib/fbs/web-rtc-transport/ice-state-change-notification.js +34 -1
  254. package/node/lib/fbs/web-rtc-transport/listen-individual.js +34 -1
  255. package/node/lib/fbs/web-rtc-transport/listen-server.js +34 -1
  256. package/node/lib/fbs/web-rtc-transport/web-rtc-transport-options.js +34 -1
  257. package/node/lib/fbs/worker/channel-message-handlers.js +34 -1
  258. package/node/lib/fbs/worker/close-router-request.js +34 -1
  259. package/node/lib/fbs/worker/close-web-rtc-server-request.js +34 -1
  260. package/node/lib/fbs/worker/create-router-request.js +34 -1
  261. package/node/lib/fbs/worker/create-web-rtc-server-request.js +34 -1
  262. package/node/lib/fbs/worker/dump-response.js +34 -1
  263. package/node/lib/fbs/worker/resource-usage-response.js +34 -1
  264. package/node/lib/fbs/worker/update-settings-request.js +34 -1
  265. package/node/lib/index.d.ts +1 -1
  266. package/node/lib/index.d.ts.map +1 -1
  267. package/node/lib/index.js +37 -5
  268. package/node/lib/ortc.js +36 -3
  269. package/node/lib/rtpParametersFbsUtils.js +34 -1
  270. package/node/lib/rtpStreamStatsFbsUtils.js +35 -2
  271. package/node/lib/sctpParametersFbsUtils.d.ts +2 -2
  272. package/node/lib/sctpParametersFbsUtils.d.ts.map +1 -1
  273. package/node/lib/sctpParametersFbsUtils.js +44 -7
  274. package/node/lib/sctpParametersTypes.d.ts +10 -46
  275. package/node/lib/sctpParametersTypes.d.ts.map +1 -1
  276. package/node/lib/srtpParametersFbsUtils.js +34 -1
  277. package/node/lib/test/test-ActiveSpeakerObserver.js +35 -2
  278. package/node/lib/test/test-AudioLevelObserver.js +35 -2
  279. package/node/lib/test/test-Consumer.js +37 -4
  280. package/node/lib/test/test-DataConsumer.js +35 -2
  281. package/node/lib/test/test-DataProducer.js +35 -2
  282. package/node/lib/test/test-DirectTransport.js +36 -8
  283. package/node/lib/test/test-PipeTransport.js +35 -2
  284. package/node/lib/test/test-PlainTransport.js +45 -12
  285. package/node/lib/test/test-Producer.js +37 -4
  286. package/node/lib/test/test-Router.js +35 -2
  287. package/node/lib/test/test-WebRtcServer.js +34 -1
  288. package/node/lib/test/test-WebRtcTransport.js +51 -22
  289. package/node/lib/test/test-Worker.js +37 -4
  290. package/node/lib/test/test-mediasoup.js +36 -3
  291. package/node/lib/test/test-multiopus.js +35 -2
  292. package/node/lib/test/test-ortc.js +34 -1
  293. package/node/lib/test/test-werift-sctp.js +39 -5
  294. package/npm-scripts.mjs +2 -2
  295. package/package.json +13 -11
  296. package/worker/deps/libwebrtc/LICENSE +5 -0
  297. package/worker/deps/libwebrtc/README.md +3 -3
  298. package/worker/deps/libwebrtc/libwebrtc/mediasoup_helpers.h +13 -10
  299. package/worker/fbs/dataConsumer.fbs +7 -2
  300. package/worker/fbs/dataProducer.fbs +1 -0
  301. package/worker/fbs/notification.fbs +2 -0
  302. package/worker/fbs/sctpAssociation.fbs +4 -0
  303. package/worker/fbs/sctpParameters.fbs +5 -12
  304. package/worker/fbs/transport.fbs +12 -8
  305. package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +13 -3
  306. package/worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp +2 -2
  307. package/worker/fuzzer/src/RTC/FuzzerSeqManager.cpp +1 -1
  308. package/worker/fuzzer/src/RTC/FuzzerTrendCalculator.cpp +5 -5
  309. package/worker/fuzzer/src/RTC/ICE/FuzzerStunPacket.cpp +9 -6
  310. package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +1 -1
  311. package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +14 -2
  312. package/worker/fuzzer/src/RTC/SCTP/association/FuzzerStateCookie.cpp +1 -1
  313. package/worker/fuzzer/src/RTC/SCTP/packet/FuzzerPacket.cpp +5 -2
  314. package/worker/fuzzer/src/fuzzer.cpp +3 -10
  315. package/worker/include/Channel/ChannelMessageRegistrator.hpp +39 -0
  316. package/worker/include/Channel/ChannelMessageRegistratorInterface.hpp +32 -0
  317. package/worker/include/Channel/ChannelRequest.hpp +1 -1
  318. package/worker/include/Channel/ChannelSocket.hpp +1 -1
  319. package/worker/include/DepLibUV.hpp +1 -1
  320. package/worker/include/DepLibUring.hpp +3 -3
  321. package/worker/include/Logger.hpp +4 -4
  322. package/worker/include/MediaSoupErrors.hpp +1 -1
  323. package/worker/include/RTC/ActiveSpeakerObserver.hpp +11 -9
  324. package/worker/include/RTC/AudioLevelObserver.hpp +7 -7
  325. package/worker/include/RTC/Consumer.hpp +3 -3
  326. package/worker/include/RTC/DataConsumer.hpp +13 -17
  327. package/worker/include/RTC/DataProducer.hpp +6 -9
  328. package/worker/include/RTC/DirectTransport.hpp +4 -6
  329. package/worker/include/RTC/DtlsTransport.hpp +13 -11
  330. package/worker/include/RTC/ICE/IceServer.hpp +8 -5
  331. package/worker/include/RTC/ICE/StunPacket.hpp +1 -1
  332. package/worker/include/RTC/KeyFrameRequestManager.hpp +15 -12
  333. package/worker/include/RTC/NackGenerator.hpp +8 -6
  334. package/worker/include/RTC/PipeConsumer.hpp +1 -2
  335. package/worker/include/RTC/PipeTransport.hpp +4 -6
  336. package/worker/include/RTC/PlainTransport.hpp +4 -6
  337. package/worker/include/RTC/PortManager.hpp +1 -1
  338. package/worker/include/RTC/Producer.hpp +3 -3
  339. package/worker/include/RTC/RTCP/FeedbackPs.hpp +1 -1
  340. package/worker/include/RTC/RTCP/FeedbackRtp.hpp +1 -1
  341. package/worker/include/RTC/RTCP/FeedbackRtpNack.hpp +1 -1
  342. package/worker/include/RTC/RTCP/ReceiverReport.hpp +1 -1
  343. package/worker/include/RTC/RTP/Packet.hpp +2 -2
  344. package/worker/include/RTC/RTP/RtpStream.hpp +17 -12
  345. package/worker/include/RTC/RTP/RtpStreamRecv.hpp +8 -6
  346. package/worker/include/RTC/RTP/RtpStreamSend.hpp +4 -1
  347. package/worker/include/RTC/RTP/RtxStream.hpp +3 -1
  348. package/worker/include/RTC/RTP/SharedPacket.hpp +1 -1
  349. package/worker/include/RTC/RateCalculator.hpp +5 -2
  350. package/worker/include/RTC/Router.hpp +7 -8
  351. package/worker/include/RTC/RtpObserver.hpp +3 -3
  352. package/worker/include/RTC/SCTP/association/Association.hpp +53 -19
  353. package/worker/include/RTC/SCTP/association/AssociationListenerDeferrer.hpp +14 -6
  354. package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +18 -14
  355. package/worker/include/RTC/SCTP/association/PacketSender.hpp +3 -3
  356. package/worker/include/RTC/SCTP/association/StateCookie.hpp +1 -1
  357. package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +49 -35
  358. package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +114 -31
  359. package/worker/include/RTC/SCTP/association/{TCBContext.hpp → TransmissionControlBlockContextInterface.hpp} +14 -8
  360. package/worker/include/RTC/SCTP/packet/Chunk.hpp +3 -3
  361. package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
  362. package/worker/include/RTC/SCTP/packet/UserData.hpp +61 -17
  363. package/worker/include/RTC/SCTP/packet/chunks/AnyDataChunk.hpp +1 -1
  364. package/worker/include/RTC/SCTP/packet/chunks/AnyForwardTsnChunk.hpp +9 -9
  365. package/worker/include/RTC/SCTP/packet/chunks/AnyInitChunk.hpp +1 -1
  366. package/worker/include/RTC/SCTP/packet/chunks/DataChunk.hpp +4 -2
  367. package/worker/include/RTC/SCTP/packet/chunks/ForwardTsnChunk.hpp +3 -3
  368. package/worker/include/RTC/SCTP/packet/chunks/IDataChunk.hpp +4 -2
  369. package/worker/include/RTC/SCTP/packet/chunks/IForwardTsnChunk.hpp +3 -3
  370. package/worker/include/RTC/SCTP/packet/chunks/InitAckChunk.hpp +1 -1
  371. package/worker/include/RTC/SCTP/packet/chunks/InitChunk.hpp +1 -1
  372. package/worker/include/RTC/SCTP/packet/chunks/SackChunk.hpp +10 -3
  373. package/worker/include/RTC/SCTP/packet/chunks/ShutdownChunk.hpp +1 -1
  374. package/worker/include/RTC/SCTP/packet/errorCauses/InvalidStreamIdentifierErrorCause.hpp +1 -1
  375. package/worker/include/RTC/SCTP/packet/errorCauses/MissingMandatoryParameterErrorCause.hpp +1 -1
  376. package/worker/include/RTC/SCTP/packet/errorCauses/NoUserDataErrorCause.hpp +1 -1
  377. package/worker/include/RTC/SCTP/packet/errorCauses/StaleCookieErrorCause.hpp +1 -1
  378. package/worker/include/RTC/SCTP/packet/parameters/AddIncomingStreamsRequestParameter.hpp +1 -1
  379. package/worker/include/RTC/SCTP/packet/parameters/AddOutgoingStreamsRequestParameter.hpp +1 -1
  380. package/worker/include/RTC/SCTP/packet/parameters/CookiePreservativeParameter.hpp +1 -1
  381. package/worker/include/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.hpp +1 -1
  382. package/worker/include/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.hpp +1 -1
  383. package/worker/include/RTC/SCTP/packet/parameters/ReconfigurationResponseParameter.hpp +1 -1
  384. package/worker/include/RTC/SCTP/packet/parameters/SsnTsnResetRequestParameter.hpp +1 -1
  385. package/worker/include/RTC/SCTP/packet/parameters/SupportedAddressTypesParameter.hpp +1 -1
  386. package/worker/include/RTC/SCTP/packet/parameters/SupportedExtensionsParameter.hpp +1 -1
  387. package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +1 -1
  388. package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +22 -2
  389. package/worker/include/RTC/SCTP/public/{AssociationListener.hpp → AssociationListenerInterface.hpp} +5 -5
  390. package/worker/include/RTC/SCTP/public/Message.hpp +26 -10
  391. package/worker/include/RTC/SCTP/public/SctpOptions.hpp +28 -19
  392. package/worker/include/RTC/SCTP/public/SctpTypes.hpp +21 -0
  393. package/worker/include/RTC/SCTP/rx/DataTracker.hpp +277 -0
  394. package/worker/include/RTC/SCTP/rx/InterleavedReassemblyStreams.hpp +116 -0
  395. package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +202 -0
  396. package/worker/include/RTC/SCTP/rx/ReassemblyStreamsInterface.hpp +83 -0
  397. package/worker/include/RTC/SCTP/rx/TraditionalReassemblyStreams.hpp +183 -0
  398. package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +595 -0
  399. package/worker/include/RTC/SCTP/tx/RetransmissionErrorCounter.hpp +3 -3
  400. package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +329 -0
  401. package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +11 -10
  402. package/worker/include/RTC/SCTP/tx/RoundRobinSendQueue.hpp +356 -0
  403. package/worker/include/RTC/SCTP/tx/SendQueueInterface.hpp +180 -0
  404. package/worker/include/RTC/SCTP/tx/StreamScheduler.hpp +235 -0
  405. package/worker/include/RTC/SenderBandwidthEstimator.hpp +5 -1
  406. package/worker/include/RTC/Serializable.hpp +11 -3
  407. package/worker/include/RTC/SimpleConsumer.hpp +1 -2
  408. package/worker/include/RTC/SimulcastConsumer.hpp +1 -2
  409. package/worker/include/RTC/SvcConsumer.hpp +1 -2
  410. package/worker/include/RTC/TcpServer.hpp +2 -2
  411. package/worker/include/RTC/Transport.hpp +65 -86
  412. package/worker/include/RTC/TransportCongestionControlClient.hpp +8 -5
  413. package/worker/include/RTC/TransportCongestionControlServer.hpp +8 -5
  414. package/worker/include/RTC/TransportTuple.hpp +1 -1
  415. package/worker/include/RTC/UdpSocket.hpp +1 -1
  416. package/worker/include/RTC/WebRtcServer.hpp +3 -3
  417. package/worker/include/RTC/WebRtcTransport.hpp +5 -7
  418. package/worker/include/Settings.hpp +2 -3
  419. package/worker/include/Shared.hpp +64 -0
  420. package/worker/include/SharedInterface.hpp +77 -0
  421. package/worker/include/Utils/UnwrappedSequenceNumber.hpp +270 -0
  422. package/worker/include/Utils.hpp +10 -4
  423. package/worker/include/Worker.hpp +6 -6
  424. package/worker/include/common.hpp +12 -12
  425. package/worker/include/handles/BackoffTimerHandle.hpp +28 -67
  426. package/worker/include/handles/BackoffTimerHandleInterface.hpp +123 -0
  427. package/worker/include/handles/TimerHandle.hpp +29 -20
  428. package/worker/include/handles/TimerHandleInterface.hpp +43 -0
  429. package/worker/meson.build +45 -29
  430. package/worker/meson_options.txt +2 -1
  431. package/worker/mocks/include/Channel/MockChannelMessageRegistrator.hpp +45 -0
  432. package/worker/mocks/include/MockShared.hpp +90 -0
  433. package/worker/mocks/include/RTC/SCTP/association/MockAssociationListener.hpp +308 -0
  434. package/worker/mocks/include/RTC/SCTP/association/MockTransmissionControlBlockContext.hpp +183 -0
  435. package/worker/mocks/include/RTC/SCTP/tx/MockSendQueue.hpp +262 -0
  436. package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +153 -0
  437. package/worker/mocks/include/handles/MockTimerHandle.hpp +74 -0
  438. package/worker/mocks/include/mockTypes.hpp +15 -0
  439. package/worker/mocks/src/Channel/MockChannelMessageRegistrator.cpp +128 -0
  440. package/worker/mocks/src/MockShared.cpp +46 -0
  441. package/worker/mocks/src/RTC/SCTP/association/MockTransmissionControlBlockContext.cpp +39 -0
  442. package/worker/mocks/src/handles/MockBackoffTimerHandle.cpp +127 -0
  443. package/worker/scripts/clang-scripts.mjs +5 -1
  444. package/worker/scripts/package-lock.json +6 -7
  445. package/worker/src/Channel/ChannelMessageRegistrator.cpp +125 -0
  446. package/worker/src/Channel/ChannelSocket.cpp +3 -4
  447. package/worker/src/DepLibUV.cpp +1 -1
  448. package/worker/src/DepLibUring.cpp +3 -1
  449. package/worker/src/Logger.cpp +1 -1
  450. package/worker/src/MediaSoupErrors.cpp +2 -0
  451. package/worker/src/RTC/ActiveSpeakerObserver.cpp +14 -14
  452. package/worker/src/RTC/AudioLevelObserver.cpp +12 -10
  453. package/worker/src/RTC/Consumer.cpp +28 -26
  454. package/worker/src/RTC/DataConsumer.cpp +61 -71
  455. package/worker/src/RTC/DataProducer.cpp +16 -11
  456. package/worker/src/RTC/DirectTransport.cpp +21 -20
  457. package/worker/src/RTC/DtlsTransport.cpp +4 -4
  458. package/worker/src/RTC/ICE/IceServer.cpp +6 -5
  459. package/worker/src/RTC/ICE/StunPacket.cpp +1 -1
  460. package/worker/src/RTC/KeyFrameRequestManager.cpp +15 -15
  461. package/worker/src/RTC/NackGenerator.cpp +6 -6
  462. package/worker/src/RTC/PipeConsumer.cpp +6 -5
  463. package/worker/src/RTC/PipeTransport.cpp +9 -22
  464. package/worker/src/RTC/PlainTransport.cpp +16 -28
  465. package/worker/src/RTC/Producer.cpp +40 -39
  466. package/worker/src/RTC/RTCP/FeedbackPsAfb.cpp +1 -1
  467. package/worker/src/RTC/RTCP/FeedbackPsRpsi.cpp +1 -2
  468. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +1 -1
  469. package/worker/src/RTC/RTCP/XR.cpp +1 -1
  470. package/worker/src/RTC/RTP/Packet.cpp +3 -1
  471. package/worker/src/RTC/RTP/ProbationGenerator.cpp +4 -4
  472. package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +1 -1
  473. package/worker/src/RTC/RTP/RtpStream.cpp +17 -10
  474. package/worker/src/RTC/RTP/RtpStreamRecv.cpp +16 -14
  475. package/worker/src/RTC/RTP/RtpStreamSend.cpp +12 -9
  476. package/worker/src/RTC/RTP/RtxStream.cpp +7 -7
  477. package/worker/src/RTC/RTP/SharedPacket.cpp +3 -3
  478. package/worker/src/RTC/RateCalculator.cpp +1 -2
  479. package/worker/src/RTC/Router.cpp +61 -38
  480. package/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp +1 -1
  481. package/worker/src/RTC/RtpObserver.cpp +2 -1
  482. package/worker/src/RTC/SCTP/LICENSE +44 -0
  483. package/worker/src/RTC/SCTP/association/Association.cpp +417 -411
  484. package/worker/src/RTC/SCTP/association/AssociationListenerDeferrer.cpp +46 -13
  485. package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +47 -43
  486. package/worker/src/RTC/SCTP/association/PacketSender.cpp +8 -8
  487. package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +113 -101
  488. package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +291 -62
  489. package/worker/src/RTC/SCTP/packet/Chunk.cpp +5 -1
  490. package/worker/src/RTC/SCTP/packet/Packet.cpp +8 -1
  491. package/worker/src/RTC/SCTP/packet/chunks/DataChunk.cpp +17 -0
  492. package/worker/src/RTC/SCTP/packet/chunks/ForwardTsnChunk.cpp +4 -4
  493. package/worker/src/RTC/SCTP/packet/chunks/IDataChunk.cpp +25 -0
  494. package/worker/src/RTC/SCTP/packet/chunks/IForwardTsnChunk.cpp +10 -7
  495. package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +21 -4
  496. package/worker/src/RTC/SCTP/packet/chunks/ShutdownCompleteChunk.cpp +1 -1
  497. package/worker/src/RTC/SCTP/packet/errorCauses/NoUserDataErrorCause.cpp +1 -1
  498. package/worker/src/RTC/SCTP/packet/errorCauses/ProtocolViolationErrorCause.cpp +2 -2
  499. package/worker/src/RTC/SCTP/packet/errorCauses/UserInitiatedAbortErrorCause.cpp +1 -1
  500. package/worker/src/RTC/SCTP/public/Message.cpp +8 -0
  501. package/worker/src/RTC/SCTP/public/SctpOptions.cpp +90 -0
  502. package/worker/src/RTC/SCTP/rx/DataTracker.cpp +471 -0
  503. package/worker/src/RTC/SCTP/rx/InterleavedReassemblyStreams.cpp +327 -0
  504. package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +288 -0
  505. package/worker/src/RTC/SCTP/rx/TraditionalReassemblyStreams.cpp +453 -0
  506. package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +912 -0
  507. package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +786 -0
  508. package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +2 -2
  509. package/worker/src/RTC/SCTP/tx/RoundRobinSendQueue.cpp +752 -0
  510. package/worker/src/RTC/SCTP/tx/StreamScheduler.cpp +257 -0
  511. package/worker/src/RTC/SenderBandwidthEstimator.cpp +7 -5
  512. package/worker/src/RTC/SimpleConsumer.cpp +11 -11
  513. package/worker/src/RTC/SimulcastConsumer.cpp +16 -16
  514. package/worker/src/RTC/SrtpSession.cpp +1 -1
  515. package/worker/src/RTC/SvcConsumer.cpp +16 -16
  516. package/worker/src/RTC/TcpConnection.cpp +1 -1
  517. package/worker/src/RTC/Transport.cpp +497 -563
  518. package/worker/src/RTC/TransportCongestionControlClient.cpp +9 -8
  519. package/worker/src/RTC/TransportCongestionControlServer.cpp +5 -5
  520. package/worker/src/RTC/WebRtcServer.cpp +5 -4
  521. package/worker/src/RTC/WebRtcTransport.cpp +44 -39
  522. package/worker/src/Settings.cpp +9 -28
  523. package/worker/src/Shared.cpp +35 -0
  524. package/worker/src/Utils/Crypto.cpp +1 -1
  525. package/worker/src/Utils/String.cpp +1 -1
  526. package/worker/src/Worker.cpp +19 -48
  527. package/worker/src/handles/BackoffTimerHandle.cpp +34 -21
  528. package/worker/src/handles/TimerHandle.cpp +5 -4
  529. package/worker/src/handles/UdpSocketHandle.cpp +1 -1
  530. package/worker/src/lib.cpp +17 -16
  531. package/worker/subprojects/catch2.wrap +6 -6
  532. package/worker/tasks.py +1 -1
  533. package/worker/test/include/RTC/ICE/iceCommon.hpp +8 -7
  534. package/worker/test/include/RTC/RTP/rtpCommon.hpp +7 -6
  535. package/worker/test/include/RTC/SCTP/sctpCommon.hpp +16 -10
  536. package/worker/test/include/catch2Macros.hpp +31 -0
  537. package/worker/test/src/RTC/ICE/TestStunPacket.cpp +3 -3
  538. package/worker/test/src/RTC/ICE/iceCommon.cpp +2 -2
  539. package/worker/test/src/RTC/RTP/Codecs/TestVP8.cpp +1 -1
  540. package/worker/test/src/RTC/RTP/Codecs/TestVP9.cpp +1 -1
  541. package/worker/test/src/RTC/RTP/TestPacket.cpp +3 -3
  542. package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +16 -9
  543. package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +38 -23
  544. package/worker/test/src/RTC/RTP/TestSharedPacket.cpp +1 -1
  545. package/worker/test/src/RTC/RTP/rtpCommon.cpp +2 -2
  546. package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +292 -0
  547. package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +1 -1
  548. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +1 -1
  549. package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +99 -0
  550. package/worker/test/src/RTC/SCTP/packet/TestChunk.cpp +1 -1
  551. package/worker/test/src/RTC/SCTP/packet/TestPacket.cpp +1 -1
  552. package/worker/test/src/RTC/SCTP/packet/chunks/TestAbortAssociationChunk.cpp +1 -1
  553. package/worker/test/src/RTC/SCTP/packet/chunks/TestCookieAckChunk.cpp +1 -1
  554. package/worker/test/src/RTC/SCTP/packet/chunks/TestCookieEchoChunk.cpp +1 -1
  555. package/worker/test/src/RTC/SCTP/packet/chunks/TestDataChunk.cpp +77 -7
  556. package/worker/test/src/RTC/SCTP/packet/chunks/TestForwardTsnChunk.cpp +35 -26
  557. package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatAckChunk.cpp +1 -1
  558. package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatRequestChunk.cpp +1 -1
  559. package/worker/test/src/RTC/SCTP/packet/chunks/TestIDataChunk.cpp +77 -7
  560. package/worker/test/src/RTC/SCTP/packet/chunks/TestIForwardTsnChunk.cpp +59 -27
  561. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitAckChunk.cpp +1 -1
  562. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +1 -1
  563. package/worker/test/src/RTC/SCTP/packet/chunks/TestOperationErrorChunk.cpp +1 -1
  564. package/worker/test/src/RTC/SCTP/packet/chunks/TestReConfigChunk.cpp +1 -1
  565. package/worker/test/src/RTC/SCTP/packet/chunks/TestSackChunk.cpp +73 -35
  566. package/worker/test/src/RTC/SCTP/packet/chunks/TestShutdownAckChunk.cpp +1 -1
  567. package/worker/test/src/RTC/SCTP/packet/chunks/TestShutdownChunk.cpp +1 -1
  568. package/worker/test/src/RTC/SCTP/packet/chunks/TestShutdownCompleteChunk.cpp +1 -1
  569. package/worker/test/src/RTC/SCTP/packet/chunks/TestUnknownChunk.cpp +1 -1
  570. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestCookieReceivedWhileShuttingDownErrorCause.cpp +1 -1
  571. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestInvalidMandatoryParameterErrorCause.cpp +1 -1
  572. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestInvalidStreamIdentifierErrorCause.cpp +1 -1
  573. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestMissingMandatoryParameterErrorCause.cpp +1 -1
  574. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestNoUserDataErrorCause.cpp +1 -1
  575. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestOutOfResourceErrorCause.cpp +1 -1
  576. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestProtocolViolationErrorCause.cpp +1 -1
  577. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestRestartOfAnAssociationWithNewAddressesErrorCause.cpp +1 -1
  578. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestStaleCookieErrorCause.cpp +1 -1
  579. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnknownErrorCause.cpp +1 -1
  580. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnrecognizedChunkTypeErrorCause.cpp +1 -1
  581. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnrecognizedParametersErrorCause.cpp +1 -1
  582. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnresolvableAddressErrorCause.cpp +1 -1
  583. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUserInitiatedAbortErrorCause.cpp +1 -1
  584. package/worker/test/src/RTC/SCTP/packet/parameters/TestAddIncomingStreamsRequestParameter.cpp +1 -1
  585. package/worker/test/src/RTC/SCTP/packet/parameters/TestAddOutgoingStreamsRequestParameter.cpp +1 -1
  586. package/worker/test/src/RTC/SCTP/packet/parameters/TestCookiePreservativeParameter.cpp +1 -1
  587. package/worker/test/src/RTC/SCTP/packet/parameters/TestForwardTsnSupportedParameter.cpp +1 -1
  588. package/worker/test/src/RTC/SCTP/packet/parameters/TestHeartbeatInfoParameter.cpp +1 -1
  589. package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv4AddressParameter.cpp +1 -1
  590. package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv6AddressParameter.cpp +1 -1
  591. package/worker/test/src/RTC/SCTP/packet/parameters/TestIncomingSsnResetRequestParameter.cpp +1 -1
  592. package/worker/test/src/RTC/SCTP/packet/parameters/TestOutgoingSsnResetRequestParameter.cpp +1 -1
  593. package/worker/test/src/RTC/SCTP/packet/parameters/TestReconfigurationResponseParameter.cpp +1 -1
  594. package/worker/test/src/RTC/SCTP/packet/parameters/TestSsnTsnResetRequestParameter.cpp +1 -1
  595. package/worker/test/src/RTC/SCTP/packet/parameters/TestStateCookieParameter.cpp +1 -1
  596. package/worker/test/src/RTC/SCTP/packet/parameters/TestSupportedAddressTypesParameter.cpp +1 -1
  597. package/worker/test/src/RTC/SCTP/packet/parameters/TestSupportedExtensionsParameter.cpp +1 -1
  598. package/worker/test/src/RTC/SCTP/packet/parameters/TestUnknownParameter.cpp +1 -1
  599. package/worker/test/src/RTC/SCTP/packet/parameters/TestUnrecognizedParameterParameter.cpp +1 -1
  600. package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +1 -1
  601. package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +1117 -0
  602. package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +565 -0
  603. package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +557 -0
  604. package/worker/test/src/RTC/SCTP/rx/TestTraditionalReassemblyStreams.cpp +555 -0
  605. package/worker/test/src/RTC/SCTP/sctpCommon.cpp +2 -2
  606. package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +1248 -0
  607. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionErrorCounter.cpp +4 -0
  608. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +2218 -0
  609. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +33 -33
  610. package/worker/test/src/RTC/SCTP/tx/TestRoundRobinSendQueue.cpp +1130 -0
  611. package/worker/test/src/RTC/SCTP/tx/TestStreamScheduler.cpp +721 -0
  612. package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +20 -30
  613. package/worker/test/src/RTC/TestNackGenerator.cpp +11 -8
  614. package/worker/test/src/RTC/TestRateCalculator.cpp +6 -7
  615. package/worker/test/src/RTC/TestSimpleConsumer.cpp +11 -11
  616. package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +15 -3
  617. package/worker/test/src/Utils/TestByte.cpp +98 -0
  618. package/worker/test/src/{RTC/SCTP/common → Utils}/TestUnwrappedSequenceNumber.cpp +2 -2
  619. package/worker/test/src/testHelpers.cpp +1 -1
  620. package/worker/test/src/tests.cpp +0 -12
  621. package/node/lib/fbs/consumer/degrade-request.d.ts +0 -30
  622. package/node/lib/fbs/consumer/degrade-request.d.ts.map +0 -1
  623. package/node/lib/fbs/consumer/degrade-request.js +0 -91
  624. package/node/lib/fbs/consumer/enable-delay-and-loss-request.d.ts +0 -24
  625. package/node/lib/fbs/consumer/enable-delay-and-loss-request.d.ts.map +0 -1
  626. package/node/lib/fbs/consumer/enable-delay-and-loss-request.js +0 -69
  627. package/node/lib/fbs/producer/degrade-request.d.ts +0 -30
  628. package/node/lib/fbs/producer/degrade-request.d.ts.map +0 -1
  629. package/node/lib/fbs/producer/degrade-request.js +0 -91
  630. package/node/lib/fbs/worker/close-notification.d.ts +0 -18
  631. package/node/lib/fbs/worker/close-notification.d.ts.map +0 -1
  632. package/node/lib/fbs/worker/close-notification.js +0 -45
  633. package/node/lib/fbs/worker/close-request.d.ts +0 -18
  634. package/node/lib/fbs/worker/close-request.d.ts.map +0 -1
  635. package/node/lib/fbs/worker/close-request.js +0 -45
  636. package/node/lib/fbs/worker/close-worker-notification.d.ts +0 -18
  637. package/node/lib/fbs/worker/close-worker-notification.d.ts.map +0 -1
  638. package/node/lib/fbs/worker/close-worker-notification.js +0 -45
  639. package/worker/include/ChannelMessageRegistrator.hpp +0 -30
  640. package/worker/include/DepUsrSCTP.hpp +0 -48
  641. package/worker/include/RTC/SCTP/TODO_SCTP.md +0 -43
  642. package/worker/include/RTC/SCTP/common/UnwrappedSequenceNumber.hpp +0 -274
  643. package/worker/include/RTC/SctpAssociation.hpp +0 -147
  644. package/worker/include/RTC/Shared.hpp +0 -23
  645. package/worker/src/ChannelMessageRegistrator.cpp +0 -119
  646. package/worker/src/DepUsrSCTP.cpp +0 -277
  647. package/worker/src/RTC/SctpAssociation.cpp +0 -1175
  648. package/worker/src/RTC/Shared.cpp +0 -23
  649. package/worker/subprojects/usrsctp.wrap +0 -8
@@ -0,0 +1,1248 @@
1
+ #include "common.hpp"
2
+ #include "RTC/SCTP/packet/UserData.hpp"
3
+ #include "RTC/SCTP/packet/chunks/DataChunk.hpp"
4
+ #include "RTC/SCTP/packet/chunks/ForwardTsnChunk.hpp"
5
+ #include "RTC/SCTP/packet/chunks/SackChunk.hpp"
6
+ #include "RTC/SCTP/public/SctpTypes.hpp"
7
+ #include "RTC/SCTP/tx/OutstandingData.hpp"
8
+ #include "Utils.hpp"
9
+ #include "test/include/RTC/SCTP/sctpCommon.hpp"
10
+ #include <catch2/catch_test_macros.hpp>
11
+ #include <stdexcept>
12
+ #include <vector>
13
+
14
+ SCENARIO("SCTP OutstandingData", "[sctp][outstandingdata]")
15
+ {
16
+ sctpCommon::ResetBuffers();
17
+
18
+ class DiscardFromSendQueueTester
19
+ {
20
+ public:
21
+ void Prepare(bool returnValue)
22
+ {
23
+ if (this->prepared)
24
+ {
25
+ throw std::runtime_error("already prepared");
26
+ }
27
+
28
+ this->prepared = true;
29
+ this->returnValue = returnValue;
30
+ }
31
+
32
+ bool Called(uint16_t streamId, uint32_t outgoingMessageId)
33
+ {
34
+ if (!this->prepared)
35
+ {
36
+ return false;
37
+ }
38
+
39
+ this->callCount++;
40
+ this->lastStreamId = streamId;
41
+ this->lastOutgoingMessageId = outgoingMessageId;
42
+
43
+ return this->returnValue;
44
+ }
45
+
46
+ void Test(
47
+ size_t expectedCallCount, uint16_t expectedLastStreamId, uint32_t expectedLastOutgoingMessageId)
48
+ {
49
+ if (!this->prepared)
50
+ {
51
+ throw std::runtime_error("not prepared");
52
+ }
53
+
54
+ REQUIRE(this->callCount == expectedCallCount);
55
+ REQUIRE(this->lastStreamId == expectedLastStreamId);
56
+ REQUIRE(this->lastOutgoingMessageId == expectedLastOutgoingMessageId);
57
+
58
+ // Reset.
59
+ this->prepared = false;
60
+ this->callCount = 0;
61
+ this->lastStreamId = 0;
62
+ this->lastOutgoingMessageId = 0;
63
+ this->returnValue = false;
64
+ }
65
+
66
+ private:
67
+ bool prepared{ false };
68
+ size_t callCount{ 0 };
69
+ uint16_t lastStreamId{ 0 };
70
+ uint32_t lastOutgoingMessageId{ 0 };
71
+ bool returnValue{ false };
72
+ };
73
+
74
+ constexpr uint64_t NowMs{ 42 };
75
+ constexpr uint32_t OutgoingMessageId{ 17 };
76
+
77
+ RTC::SCTP::Types::UnwrappedTsn::Unwrapper unwrapper;
78
+ DiscardFromSendQueueTester discardFromSendQueueTester;
79
+
80
+ auto discardFromSendQueue =
81
+ [&discardFromSendQueueTester](uint16_t streamId, uint32_t outgoingMessageId)
82
+ {
83
+ return discardFromSendQueueTester.Called(streamId, outgoingMessageId);
84
+ };
85
+
86
+ RTC::SCTP::OutstandingData buffer(
87
+ /*dataChunkHeaderLength*/ RTC::SCTP::DataChunk::DataChunkHeaderLength,
88
+ /*lastCumulativeTsnAck*/ unwrapper.Unwrap(9),
89
+ discardFromSendQueue);
90
+
91
+ SECTION("has initial state")
92
+ {
93
+ REQUIRE(buffer.IsEmpty() == true);
94
+ REQUIRE(buffer.GetUnackedPayloadBytes() == 0);
95
+ REQUIRE(buffer.GetUnackedPacketBytes() == 0);
96
+ REQUIRE(buffer.GetUnackedItems() == 0);
97
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
98
+ REQUIRE(buffer.GetLastCumulativeTsnAck().Wrap() == 9);
99
+ REQUIRE(buffer.GetNextTsn().Wrap() == 10);
100
+ REQUIRE(buffer.GetHighestOutstandingTsn().Wrap() == 9);
101
+ REQUIRE(
102
+ buffer.GetChunkStatesForTesting() ==
103
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
104
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
105
+ });
106
+ REQUIRE(buffer.ShouldSendForwardTsn() == false);
107
+ }
108
+
109
+ SECTION("insert chunk")
110
+ {
111
+ const auto tsn = buffer.Insert(
112
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false), NowMs);
113
+
114
+ REQUIRE(tsn.has_value());
115
+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
116
+ REQUIRE(tsn->Wrap() == 10);
117
+
118
+ REQUIRE(buffer.IsEmpty() == false);
119
+ REQUIRE(buffer.GetUnackedPayloadBytes() == 1);
120
+ REQUIRE(buffer.GetUnackedItems() == 1);
121
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
122
+ REQUIRE(buffer.GetLastCumulativeTsnAck().Wrap() == 9);
123
+ REQUIRE(buffer.GetNextTsn().Wrap() == 11);
124
+ REQUIRE(buffer.GetHighestOutstandingTsn().Wrap() == 10);
125
+ REQUIRE(
126
+ buffer.GetChunkStatesForTesting() ==
127
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
128
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
129
+ { 10, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
130
+ });
131
+ }
132
+
133
+ SECTION("acks single chunk")
134
+ {
135
+ buffer.Insert(
136
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false), NowMs);
137
+
138
+ const auto ackInfo = buffer.HandleSack(unwrapper.Unwrap(10), {}, false);
139
+
140
+ REQUIRE(
141
+ ackInfo.bytesAcked ==
142
+ RTC::SCTP::DataChunk::DataChunkHeaderLength + Utils::Byte::PadTo4Bytes<size_t>(1));
143
+ REQUIRE(ackInfo.highestTsnAcked.Wrap() == 10);
144
+ REQUIRE(ackInfo.hasPacketLoss == false);
145
+
146
+ REQUIRE(buffer.IsEmpty() == true);
147
+ REQUIRE(buffer.GetUnackedPayloadBytes() == 0);
148
+ REQUIRE(buffer.GetUnackedPacketBytes() == 0);
149
+ REQUIRE(buffer.GetUnackedItems() == 0);
150
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
151
+ REQUIRE(buffer.GetLastCumulativeTsnAck().Wrap() == 10);
152
+ REQUIRE(buffer.GetNextTsn().Wrap() == 11);
153
+ REQUIRE(buffer.GetHighestOutstandingTsn().Wrap() == 10);
154
+ REQUIRE(
155
+ buffer.GetChunkStatesForTesting() ==
156
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
157
+ { 10, RTC::SCTP::OutstandingData::State::ACKED },
158
+ });
159
+ }
160
+
161
+ SECTION("acks previous chunk doesn't update")
162
+ {
163
+ buffer.Insert(
164
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false), NowMs);
165
+
166
+ REQUIRE(buffer.IsEmpty() == false);
167
+ REQUIRE(buffer.GetUnackedPayloadBytes() == 1);
168
+ REQUIRE(buffer.GetUnackedItems() == 1);
169
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
170
+ REQUIRE(buffer.GetLastCumulativeTsnAck().Wrap() == 9);
171
+ REQUIRE(buffer.GetNextTsn().Wrap() == 11);
172
+ REQUIRE(buffer.GetHighestOutstandingTsn().Wrap() == 10);
173
+ REQUIRE(
174
+ buffer.GetChunkStatesForTesting() ==
175
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
176
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
177
+ { 10, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
178
+ });
179
+ }
180
+
181
+ SECTION("acks and nacks with gap-ack-blocks")
182
+ {
183
+ buffer.Insert(
184
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false), NowMs);
185
+ buffer.Insert(
186
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, true, false), NowMs);
187
+
188
+ const auto ackInfo = buffer.HandleSack(
189
+ unwrapper.Unwrap(9),
190
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
191
+ { 2, 2 }
192
+ },
193
+ false);
194
+
195
+ REQUIRE(
196
+ ackInfo.bytesAcked ==
197
+ RTC::SCTP::DataChunk::DataChunkHeaderLength + Utils::Byte::PadTo4Bytes<size_t>(1));
198
+ REQUIRE(ackInfo.highestTsnAcked.Wrap() == 11);
199
+ REQUIRE(ackInfo.hasPacketLoss == false);
200
+
201
+ // TSN 10 is still outstanding.
202
+ REQUIRE(buffer.GetUnackedPayloadBytes() == 1);
203
+ REQUIRE(buffer.GetUnackedItems() == 1);
204
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
205
+ REQUIRE(buffer.GetLastCumulativeTsnAck().Wrap() == 9);
206
+ REQUIRE(buffer.GetNextTsn().Wrap() == 12);
207
+ REQUIRE(buffer.GetHighestOutstandingTsn().Wrap() == 11);
208
+ REQUIRE(
209
+ buffer.GetChunkStatesForTesting() ==
210
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
211
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
212
+ { 10, RTC::SCTP::OutstandingData::State::NACKED },
213
+ { 11, RTC::SCTP::OutstandingData::State::ACKED },
214
+ });
215
+ }
216
+
217
+ SECTION("nacks three times with same TSN doesn't retransmit")
218
+ {
219
+ buffer.Insert(
220
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false), NowMs);
221
+
222
+ buffer.Insert(
223
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, true, false), NowMs);
224
+
225
+ const std::vector<RTC::SCTP::SackChunk::GapAckBlock> gab1 = {
226
+ { 2, 2 }
227
+ };
228
+
229
+ REQUIRE(buffer.HandleSack(unwrapper.Unwrap(9), gab1, false).hasPacketLoss == false);
230
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
231
+
232
+ REQUIRE(buffer.HandleSack(unwrapper.Unwrap(9), gab1, false).hasPacketLoss == false);
233
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
234
+
235
+ REQUIRE(buffer.HandleSack(unwrapper.Unwrap(9), gab1, false).hasPacketLoss == false);
236
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
237
+
238
+ REQUIRE(
239
+ buffer.GetChunkStatesForTesting() ==
240
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
241
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
242
+ { 10, RTC::SCTP::OutstandingData::State::NACKED },
243
+ { 11, RTC::SCTP::OutstandingData::State::ACKED },
244
+ });
245
+ }
246
+
247
+ SECTION("nacks three times results in retransmission")
248
+ {
249
+ buffer.Insert(
250
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false), NowMs);
251
+
252
+ buffer.Insert(
253
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false), NowMs);
254
+
255
+ buffer.Insert(
256
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false), NowMs);
257
+
258
+ buffer.Insert(
259
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, true, false), NowMs);
260
+
261
+ REQUIRE(
262
+ buffer
263
+ .HandleSack(
264
+ unwrapper.Unwrap(9),
265
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
266
+ { 2, 2 }
267
+ },
268
+ false)
269
+ .hasPacketLoss == false);
270
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
271
+ REQUIRE(
272
+ buffer
273
+ .HandleSack(
274
+ unwrapper.Unwrap(9),
275
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
276
+ { 2, 3 }
277
+ },
278
+ false)
279
+ .hasPacketLoss == false);
280
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
281
+
282
+ const auto ackInfo = buffer.HandleSack(
283
+ unwrapper.Unwrap(9),
284
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
285
+ { 2, 4 }
286
+ },
287
+ false);
288
+
289
+ REQUIRE(
290
+ ackInfo.bytesAcked ==
291
+ RTC::SCTP::DataChunk::DataChunkHeaderLength + Utils::Byte::PadTo4Bytes<size_t>(1));
292
+ REQUIRE(ackInfo.highestTsnAcked.Wrap() == 13);
293
+ REQUIRE(ackInfo.hasPacketLoss == true);
294
+
295
+ REQUIRE(buffer.HasDataToBeRetransmitted() == true);
296
+
297
+ REQUIRE(
298
+ buffer.GetChunkStatesForTesting() ==
299
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
300
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
301
+ { 10, RTC::SCTP::OutstandingData::State::TO_BE_RETRANSMITTED },
302
+ { 11, RTC::SCTP::OutstandingData::State::ACKED },
303
+ { 12, RTC::SCTP::OutstandingData::State::ACKED },
304
+ { 13, RTC::SCTP::OutstandingData::State::ACKED },
305
+ });
306
+
307
+ std::vector<std::pair<uint32_t, RTC::SCTP::UserData>> expectedChunksToBeFastRetransmitted;
308
+
309
+ expectedChunksToBeFastRetransmitted.emplace_back(
310
+ 10, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false));
311
+
312
+ REQUIRE(buffer.GetChunksToBeFastRetransmitted(1000) == expectedChunksToBeFastRetransmitted);
313
+ REQUIRE(buffer.GetChunksToBeRetransmitted(1000).empty() == true);
314
+ }
315
+
316
+ SECTION("nacks three times results in abandoning")
317
+ {
318
+ buffer.Insert(
319
+ OutgoingMessageId,
320
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false),
321
+ NowMs,
322
+ /*maxRetransmits*/ 0);
323
+
324
+ buffer.Insert(
325
+ OutgoingMessageId,
326
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
327
+ NowMs,
328
+ /*maxRetransmits*/ 0);
329
+
330
+ buffer.Insert(
331
+ OutgoingMessageId,
332
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
333
+ NowMs,
334
+ /*maxRetransmits*/ 0);
335
+
336
+ buffer.Insert(
337
+ OutgoingMessageId,
338
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, true, false),
339
+ NowMs,
340
+ /*maxRetransmits*/ 0);
341
+
342
+ REQUIRE(
343
+ buffer
344
+ .HandleSack(
345
+ unwrapper.Unwrap(9),
346
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
347
+ { 2, 2 }
348
+ },
349
+ false)
350
+ .hasPacketLoss == false);
351
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
352
+ REQUIRE(
353
+ buffer
354
+ .HandleSack(
355
+ unwrapper.Unwrap(9),
356
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
357
+ { 2, 3 }
358
+ },
359
+ false)
360
+ .hasPacketLoss == false);
361
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
362
+
363
+ discardFromSendQueueTester.Prepare(/*returnValue*/ false);
364
+
365
+ const auto ackInfo = buffer.HandleSack(
366
+ unwrapper.Unwrap(9),
367
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
368
+ { 2, 4 }
369
+ },
370
+ false);
371
+
372
+ discardFromSendQueueTester.Test(
373
+ /*expectedCallCount*/ 1,
374
+ /*expectedLastStreamId*/ 1,
375
+ /*expectedLastOutgoingMessageId*/ OutgoingMessageId);
376
+
377
+ REQUIRE(
378
+ ackInfo.bytesAcked ==
379
+ RTC::SCTP::DataChunk::DataChunkHeaderLength + Utils::Byte::PadTo4Bytes<size_t>(1));
380
+ REQUIRE(ackInfo.highestTsnAcked.Wrap() == 13);
381
+ REQUIRE(ackInfo.hasPacketLoss == true);
382
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
383
+ REQUIRE(buffer.GetNextTsn().Wrap() == 14);
384
+ REQUIRE(
385
+ buffer.GetChunkStatesForTesting() ==
386
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
387
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
388
+ { 10, RTC::SCTP::OutstandingData::State::ABANDONED },
389
+ { 11, RTC::SCTP::OutstandingData::State::ABANDONED },
390
+ { 12, RTC::SCTP::OutstandingData::State::ABANDONED },
391
+ { 13, RTC::SCTP::OutstandingData::State::ABANDONED },
392
+ });
393
+ }
394
+
395
+ SECTION("nacks three times results in abandoning with placeholder")
396
+ {
397
+ buffer.Insert(
398
+ OutgoingMessageId,
399
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false),
400
+ NowMs,
401
+ /*maxRetransmits*/ 0);
402
+
403
+ buffer.Insert(
404
+ OutgoingMessageId,
405
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
406
+ NowMs,
407
+ /*maxRetransmits*/ 0);
408
+
409
+ buffer.Insert(
410
+ OutgoingMessageId,
411
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
412
+ NowMs,
413
+ /*maxRetransmits*/ 0);
414
+
415
+ buffer.Insert(
416
+ OutgoingMessageId,
417
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
418
+ NowMs,
419
+ /*maxRetransmits*/ 0);
420
+
421
+ REQUIRE(
422
+ buffer
423
+ .HandleSack(
424
+ unwrapper.Unwrap(9),
425
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
426
+ { 2, 2 }
427
+ },
428
+ false)
429
+ .hasPacketLoss == false);
430
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
431
+
432
+ REQUIRE(
433
+ buffer
434
+ .HandleSack(
435
+ unwrapper.Unwrap(9),
436
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
437
+ { 2, 3 }
438
+ },
439
+ false)
440
+ .hasPacketLoss == false);
441
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
442
+
443
+ discardFromSendQueueTester.Prepare(/*returnValue*/ true);
444
+
445
+ const auto ackInfo = buffer.HandleSack(
446
+ unwrapper.Unwrap(9),
447
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
448
+ { 2, 4 }
449
+ },
450
+ false);
451
+
452
+ discardFromSendQueueTester.Test(
453
+ /*expectedCallCount*/ 1,
454
+ /*expectedLastStreamId*/ 1,
455
+ /*expectedLastOutgoingMessageId*/ OutgoingMessageId);
456
+
457
+ REQUIRE(
458
+ ackInfo.bytesAcked ==
459
+ RTC::SCTP::DataChunk::DataChunkHeaderLength + Utils::Byte::PadTo4Bytes<size_t>(1));
460
+ REQUIRE(ackInfo.highestTsnAcked.Wrap() == 13);
461
+ REQUIRE(ackInfo.hasPacketLoss == true);
462
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
463
+ REQUIRE(buffer.GetNextTsn().Wrap() == 15);
464
+ REQUIRE(
465
+ buffer.GetChunkStatesForTesting() ==
466
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
467
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
468
+ { 10, RTC::SCTP::OutstandingData::State::ABANDONED },
469
+ { 11, RTC::SCTP::OutstandingData::State::ABANDONED },
470
+ { 12, RTC::SCTP::OutstandingData::State::ABANDONED },
471
+ { 13, RTC::SCTP::OutstandingData::State::ABANDONED },
472
+ { 14, RTC::SCTP::OutstandingData::State::ABANDONED },
473
+ });
474
+ }
475
+
476
+ SECTION("expires chunk before it is inserted")
477
+ {
478
+ constexpr uint64_t ExpiresAtMs = NowMs + 1;
479
+
480
+ auto tsn = buffer.Insert(
481
+ OutgoingMessageId,
482
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false),
483
+ NowMs,
484
+ /*maxRetransmits*/ RTC::SCTP::Types::MaxRetransmitsNoLimit,
485
+ ExpiresAtMs);
486
+
487
+ REQUIRE(tsn.has_value());
488
+
489
+ tsn = buffer.Insert(
490
+ OutgoingMessageId,
491
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
492
+ NowMs,
493
+ /*maxRetransmits*/ RTC::SCTP::Types::MaxRetransmitsNoLimit,
494
+ ExpiresAtMs);
495
+
496
+ REQUIRE(tsn.has_value());
497
+
498
+ discardFromSendQueueTester.Prepare(/*returnValue*/ false);
499
+
500
+ tsn = buffer.Insert(
501
+ OutgoingMessageId,
502
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, true, false),
503
+ NowMs + 1,
504
+ /*maxRetransmits*/ RTC::SCTP::Types::MaxRetransmitsNoLimit,
505
+ ExpiresAtMs);
506
+
507
+ REQUIRE(!tsn.has_value());
508
+
509
+ discardFromSendQueueTester.Test(
510
+ /*expectedCallCount*/ 1,
511
+ /*expectedLastStreamId*/ 1,
512
+ /*expectedLastOutgoingMessageId*/ OutgoingMessageId);
513
+
514
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
515
+ REQUIRE(buffer.GetLastCumulativeTsnAck().Wrap() == 9);
516
+ REQUIRE(buffer.GetNextTsn().Wrap() == 13);
517
+ REQUIRE(buffer.GetHighestOutstandingTsn().Wrap() == 12);
518
+ REQUIRE(
519
+ buffer.GetChunkStatesForTesting() ==
520
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
521
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
522
+ { 10, RTC::SCTP::OutstandingData::State::ABANDONED },
523
+ { 11, RTC::SCTP::OutstandingData::State::ABANDONED },
524
+ { 12, RTC::SCTP::OutstandingData::State::ABANDONED },
525
+ });
526
+ }
527
+
528
+ SECTION("can generate Forward-TSN")
529
+ {
530
+ buffer.Insert(
531
+ OutgoingMessageId,
532
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false),
533
+ NowMs,
534
+ /*maxRetransmits*/ 0);
535
+
536
+ buffer.Insert(
537
+ OutgoingMessageId,
538
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
539
+ NowMs,
540
+ /*maxRetransmits*/ 0);
541
+
542
+ buffer.Insert(
543
+ OutgoingMessageId,
544
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, true, false),
545
+ NowMs,
546
+ /*maxRetransmits*/ 0);
547
+
548
+ discardFromSendQueueTester.Prepare(/*returnValue*/ false);
549
+
550
+ buffer.NackAll();
551
+
552
+ discardFromSendQueueTester.Test(
553
+ /*expectedCallCount*/ 1,
554
+ /*expectedLastStreamId*/ 1,
555
+ /*expectedLastOutgoingMessageId*/ OutgoingMessageId);
556
+
557
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
558
+ REQUIRE(
559
+ buffer.GetChunkStatesForTesting() ==
560
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
561
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
562
+ { 10, RTC::SCTP::OutstandingData::State::ABANDONED },
563
+ { 11, RTC::SCTP::OutstandingData::State::ABANDONED },
564
+ { 12, RTC::SCTP::OutstandingData::State::ABANDONED },
565
+ });
566
+ REQUIRE(buffer.ShouldSendForwardTsn() == true);
567
+
568
+ std::unique_ptr<RTC::SCTP::Packet> packet{ RTC::SCTP::Packet::Factory(
569
+ sctpCommon::FactoryBuffer, sizeof(sctpCommon::FactoryBuffer)) };
570
+
571
+ const auto* forwardTsnChunk = buffer.AddForwardTsn(packet.get());
572
+
573
+ REQUIRE(forwardTsnChunk);
574
+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
575
+ REQUIRE(forwardTsnChunk->GetNewCumulativeTsn() == 12);
576
+ }
577
+
578
+ SECTION("ack with gap blocks from RFC 9260 section 3.3.4")
579
+ {
580
+ for (int i{ 0 }; i < 8; ++i)
581
+ {
582
+ const bool isBeginning = (i == 0);
583
+ const bool isEnd = (i == 7);
584
+
585
+ buffer.Insert(
586
+ OutgoingMessageId,
587
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, isBeginning, isEnd, false),
588
+ NowMs);
589
+ }
590
+
591
+ REQUIRE(
592
+ buffer.GetChunkStatesForTesting() ==
593
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
594
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
595
+ { 10, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
596
+ { 11, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
597
+ { 12, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
598
+ { 13, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
599
+ { 14, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
600
+ { 15, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
601
+ { 16, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
602
+ { 17, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
603
+ });
604
+
605
+ buffer.HandleSack(
606
+ unwrapper.Unwrap(12),
607
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
608
+ { 2, 3 },
609
+ { 5, 5 }
610
+ },
611
+ false);
612
+
613
+ REQUIRE(
614
+ buffer.GetChunkStatesForTesting() ==
615
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
616
+ { 12, RTC::SCTP::OutstandingData::State::ACKED },
617
+ { 13, RTC::SCTP::OutstandingData::State::NACKED },
618
+ { 14, RTC::SCTP::OutstandingData::State::ACKED },
619
+ { 15, RTC::SCTP::OutstandingData::State::ACKED },
620
+ { 16, RTC::SCTP::OutstandingData::State::NACKED },
621
+ { 17, RTC::SCTP::OutstandingData::State::ACKED },
622
+ });
623
+ }
624
+
625
+ SECTION("MeasureRtt()")
626
+ {
627
+ buffer.Insert(
628
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false), NowMs);
629
+
630
+ buffer.Insert(
631
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false), NowMs + 1);
632
+
633
+ buffer.Insert(
634
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false), NowMs + 2);
635
+
636
+ constexpr uint64_t Duration{ 123 };
637
+
638
+ const auto duration = buffer.MeasureRtt(NowMs + Duration, unwrapper.Unwrap(11));
639
+
640
+ REQUIRE(duration.has_value());
641
+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
642
+ REQUIRE(duration.value() == Duration - 1);
643
+ }
644
+
645
+ SECTION("must retransmit before getting nacked again")
646
+ {
647
+ // A chunk that has been nacked and scheduled for retransmission should not
648
+ // get nacked again until it has actually been sent on the wire.
649
+ for (int i{ 0 }; i <= 10; ++i)
650
+ {
651
+ const bool isBeginning = (i == 0);
652
+ const bool isEnd = (i == 10);
653
+
654
+ buffer.Insert(
655
+ OutgoingMessageId,
656
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, isBeginning, isEnd, false),
657
+ NowMs,
658
+ /*maxRetransmits*/ 1);
659
+ }
660
+
661
+ REQUIRE(
662
+ buffer
663
+ .HandleSack(
664
+ unwrapper.Unwrap(9),
665
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
666
+ { 2, 2 }
667
+ },
668
+ false)
669
+ .hasPacketLoss == false);
670
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
671
+
672
+ REQUIRE(
673
+ buffer
674
+ .HandleSack(
675
+ unwrapper.Unwrap(9),
676
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
677
+ { 2, 3 }
678
+ },
679
+ false)
680
+ .hasPacketLoss == false);
681
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
682
+
683
+ const auto ackInfo = buffer.HandleSack(
684
+ unwrapper.Unwrap(9),
685
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
686
+ { 2, 4 }
687
+ },
688
+ false);
689
+
690
+ REQUIRE(ackInfo.hasPacketLoss == true);
691
+
692
+ REQUIRE(buffer.HasDataToBeRetransmitted() == true);
693
+
694
+ // Don't retransmit yet. S simulate congestion window blocking it.
695
+ // It still gets more SACKs indicating packet loss.
696
+ REQUIRE(
697
+ buffer
698
+ .HandleSack(
699
+ unwrapper.Unwrap(9),
700
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
701
+ { 2, 5 }
702
+ },
703
+ false)
704
+ .hasPacketLoss == false);
705
+ REQUIRE(buffer.HasDataToBeRetransmitted() == true);
706
+
707
+ REQUIRE(
708
+ buffer
709
+ .HandleSack(
710
+ unwrapper.Unwrap(9),
711
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
712
+ { 2, 6 }
713
+ },
714
+ false)
715
+ .hasPacketLoss == false);
716
+ REQUIRE(buffer.HasDataToBeRetransmitted() == true);
717
+
718
+ const auto ackInfo2 = buffer.HandleSack(
719
+ unwrapper.Unwrap(9),
720
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
721
+ { 2, 7 }
722
+ },
723
+ false);
724
+
725
+ REQUIRE(ackInfo2.hasPacketLoss == false);
726
+ REQUIRE(buffer.HasDataToBeRetransmitted() == true);
727
+
728
+ // Now retransmit.
729
+ const auto fastRetransmit = buffer.GetChunksToBeFastRetransmitted(1000);
730
+
731
+ REQUIRE(fastRetransmit.size() == 1);
732
+ REQUIRE(fastRetransmit[0].first == 10);
733
+ REQUIRE(buffer.GetChunksToBeRetransmitted(1000).empty() == true);
734
+
735
+ // TSN 10 is now lost again. It gets nacked and eventually abandoned.
736
+ REQUIRE(
737
+ buffer
738
+ .HandleSack(
739
+ unwrapper.Unwrap(9),
740
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
741
+ { 2, 8 }
742
+ },
743
+ false)
744
+ .hasPacketLoss == false);
745
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
746
+
747
+ REQUIRE(
748
+ buffer
749
+ .HandleSack(
750
+ unwrapper.Unwrap(9),
751
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
752
+ { 2, 9 }
753
+ },
754
+ false)
755
+ .hasPacketLoss == false);
756
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
757
+
758
+ const auto ackInfo3 = buffer.HandleSack(
759
+ unwrapper.Unwrap(9),
760
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
761
+ { 2, 10 }
762
+ },
763
+ false);
764
+
765
+ REQUIRE(ackInfo3.hasPacketLoss == true);
766
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
767
+ }
768
+
769
+ SECTION("lifecyle returns acked items in ack-info")
770
+ {
771
+ buffer.Insert(
772
+ 1,
773
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false),
774
+ NowMs,
775
+ RTC::SCTP::Types::MaxRetransmitsNoLimit,
776
+ RTC::SCTP::Types::ExpiresAtMsInfinite,
777
+ /*lifecycleId*/ 42);
778
+
779
+ buffer.Insert(
780
+ 2,
781
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false),
782
+ NowMs,
783
+ RTC::SCTP::Types::MaxRetransmitsNoLimit,
784
+ RTC::SCTP::Types::ExpiresAtMsInfinite,
785
+ /*lifecycleId*/ 43);
786
+
787
+ buffer.Insert(
788
+ 3,
789
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false),
790
+ NowMs,
791
+ RTC::SCTP::Types::MaxRetransmitsNoLimit,
792
+ RTC::SCTP::Types::ExpiresAtMsInfinite,
793
+ /*lifecycleId*/ 44);
794
+
795
+ const auto ackInfo1 = buffer.HandleSack(unwrapper.Unwrap(11), {}, false);
796
+
797
+ std::vector<uint64_t> expectedAckedLifecycleIds = { 42, 43 };
798
+
799
+ REQUIRE(ackInfo1.ackedLifecycleIds == expectedAckedLifecycleIds);
800
+
801
+ const auto ackInfo2 = buffer.HandleSack(unwrapper.Unwrap(12), {}, false);
802
+
803
+ expectedAckedLifecycleIds = { 44 };
804
+
805
+ REQUIRE(ackInfo2.ackedLifecycleIds == expectedAckedLifecycleIds);
806
+ }
807
+
808
+ SECTION("lifecyle returns abandoned nacked three times")
809
+ {
810
+ buffer.Insert(
811
+ OutgoingMessageId,
812
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false),
813
+ NowMs,
814
+ /*maxRetransmits*/ 0);
815
+
816
+ buffer.Insert(
817
+ OutgoingMessageId,
818
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
819
+ NowMs,
820
+ /*maxRetransmits*/ 0);
821
+
822
+ buffer.Insert(
823
+ OutgoingMessageId,
824
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
825
+ NowMs,
826
+ /*maxRetransmits*/ 0);
827
+
828
+ buffer.Insert(
829
+ OutgoingMessageId,
830
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, true, false),
831
+ NowMs,
832
+ /*maxRetransmits*/ 0);
833
+
834
+ const auto ackInfo1 = buffer.HandleSack(
835
+ unwrapper.Unwrap(9),
836
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
837
+ { 2, 2 }
838
+ },
839
+ false);
840
+
841
+ REQUIRE(ackInfo1.hasPacketLoss == false);
842
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
843
+
844
+ const auto ackInfo2 = buffer.HandleSack(
845
+ unwrapper.Unwrap(9),
846
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
847
+ { 2, 3 }
848
+ },
849
+ false);
850
+
851
+ REQUIRE(ackInfo2.hasPacketLoss == false);
852
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
853
+
854
+ discardFromSendQueueTester.Prepare(/*returnValue*/ false);
855
+
856
+ const auto ackInfo3 = buffer.HandleSack(
857
+ unwrapper.Unwrap(9),
858
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
859
+ { 2, 4 }
860
+ },
861
+ false);
862
+
863
+ discardFromSendQueueTester.Test(
864
+ /*expectedCallCount*/ 1,
865
+ /*expectedLastStreamId*/ 1,
866
+ /*expectedLastOutgoingMessageId*/ OutgoingMessageId);
867
+
868
+ REQUIRE(ackInfo3.hasPacketLoss == true);
869
+ REQUIRE(ackInfo3.abandonedLifecycleIds.empty() == true);
870
+ }
871
+
872
+ SECTION("lifecyle returns abandoned after T3 RTX timer expired")
873
+ {
874
+ buffer.Insert(
875
+ OutgoingMessageId,
876
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, false, false),
877
+ NowMs,
878
+ /*maxRetransmits*/ 0);
879
+
880
+ buffer.Insert(
881
+ OutgoingMessageId,
882
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
883
+ NowMs,
884
+ /*maxRetransmits*/ 0);
885
+
886
+ buffer.Insert(
887
+ OutgoingMessageId,
888
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false),
889
+ NowMs,
890
+ /*maxRetransmits*/ 0);
891
+
892
+ buffer.Insert(
893
+ OutgoingMessageId,
894
+ RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, true, false),
895
+ NowMs,
896
+ /*maxRetransmits*/ 0,
897
+ /*expiresAtMs*/ RTC::SCTP::Types::ExpiresAtMsInfinite,
898
+ /*lifecycleId*/ 42);
899
+
900
+ REQUIRE(
901
+ buffer.GetChunkStatesForTesting() ==
902
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
903
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
904
+ { 10, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
905
+ { 11, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
906
+ { 12, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
907
+ { 13, RTC::SCTP::OutstandingData::State::IN_FLIGHT },
908
+ });
909
+
910
+ const auto ackInfo1 = buffer.HandleSack(
911
+ unwrapper.Unwrap(9),
912
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
913
+ { 2, 4 }
914
+ },
915
+ false);
916
+
917
+ REQUIRE(ackInfo1.hasPacketLoss == false);
918
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
919
+
920
+ REQUIRE(
921
+ buffer.GetChunkStatesForTesting() ==
922
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
923
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
924
+ { 10, RTC::SCTP::OutstandingData::State::NACKED },
925
+ { 11, RTC::SCTP::OutstandingData::State::ACKED },
926
+ { 12, RTC::SCTP::OutstandingData::State::ACKED },
927
+ { 13, RTC::SCTP::OutstandingData::State::ACKED },
928
+ });
929
+
930
+ discardFromSendQueueTester.Prepare(/*returnValue*/ false);
931
+
932
+ buffer.NackAll();
933
+
934
+ discardFromSendQueueTester.Test(
935
+ /*expectedCallCount*/ 1,
936
+ /*expectedLastStreamId*/ 1,
937
+ /*expectedLastOutgoingMessageId*/ OutgoingMessageId);
938
+
939
+ REQUIRE(
940
+ buffer.GetChunkStatesForTesting() ==
941
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
942
+ { 9, RTC::SCTP::OutstandingData::State::ACKED },
943
+ { 10, RTC::SCTP::OutstandingData::State::ABANDONED },
944
+ { 11, RTC::SCTP::OutstandingData::State::ABANDONED },
945
+ { 12, RTC::SCTP::OutstandingData::State::ABANDONED },
946
+ { 13, RTC::SCTP::OutstandingData::State::ABANDONED },
947
+ });
948
+ ;
949
+ REQUIRE(buffer.ShouldSendForwardTsn() == true);
950
+
951
+ std::unique_ptr<RTC::SCTP::Packet> packet{ RTC::SCTP::Packet::Factory(
952
+ sctpCommon::FactoryBuffer, sizeof(sctpCommon::FactoryBuffer)) };
953
+
954
+ const auto* forwardTsnChunk = buffer.AddForwardTsn(packet.get());
955
+
956
+ REQUIRE(forwardTsnChunk);
957
+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
958
+ REQUIRE(forwardTsnChunk->GetNewCumulativeTsn() == 13);
959
+
960
+ const auto ackInfo2 = buffer.HandleSack(unwrapper.Unwrap(13), {}, false);
961
+
962
+ REQUIRE(ackInfo2.hasPacketLoss == false);
963
+ REQUIRE(ackInfo2.abandonedLifecycleIds == std::vector<uint64_t>{ 42 });
964
+ }
965
+
966
+ SECTION("generates Forward-TSN until next stream reset TSN")
967
+ {
968
+ // This test generates:
969
+ // * Stream 1: TSN 10, 11, 12 <RESET>
970
+ // * Stream 2: TSN 13, 14 <RESET>
971
+ // * Stream 3: TSN 15, 16
972
+ //
973
+ // Then it expires chunk 12-15, and ensures that the generated FORWARD-TSN
974
+ // only includes up till TSN 12 until the cum ack TSN has reached 12, and
975
+ // then 13 and 14 are included, and then after the cum ack TSN has reached
976
+ // 14, then 15 is included.
977
+ //
978
+ // What it shouldn't do, is to generate a FORWARD-TSN directly at the start
979
+ // with new TSN=15, and setting [(sid=1, ssn=44), (sid=2, ssn=46),
980
+ // (sid=3, ssn=47)], because that will confuse the receiver at TSN=17,
981
+ // receiving SID=1, SSN=0 (it's reset!), expecting SSN to be 45.
982
+
983
+ // TSN 10-12.
984
+ buffer.Insert(
985
+ 0,
986
+ RTC::SCTP::UserData(1, /*ssn*/ 42, 0, 0, 53, { 0x00 }, true, true, false),
987
+ NowMs,
988
+ /*maxRetransmits*/ 0);
989
+ buffer.Insert(
990
+ 1,
991
+ RTC::SCTP::UserData(1, /*ssn*/ 43, 0, 0, 53, { 0x00 }, true, true, false),
992
+ NowMs,
993
+ /*maxRetransmits*/ 0);
994
+ buffer.Insert(
995
+ 2,
996
+ RTC::SCTP::UserData(1, /*ssn*/ 44, 0, 0, 53, { 0x00 }, true, true, false),
997
+ NowMs,
998
+ /*maxRetransmits*/ 0);
999
+ buffer.BeginResetStreams();
1000
+
1001
+ // TSN 13, 14.
1002
+ buffer.Insert(
1003
+ 3,
1004
+ RTC::SCTP::UserData(2, /*ssn*/ 45, 0, 0, 53, { 0x00 }, true, true, false),
1005
+ NowMs,
1006
+ /*maxRetransmits*/ 0);
1007
+ buffer.Insert(
1008
+ 4,
1009
+ RTC::SCTP::UserData(2, /*ssn*/ 46, 0, 0, 53, { 0x00 }, true, true, false),
1010
+ NowMs,
1011
+ /*maxRetransmits*/ 0);
1012
+ buffer.BeginResetStreams();
1013
+
1014
+ // TSN 15, 16.
1015
+ buffer.Insert(
1016
+ 5,
1017
+ RTC::SCTP::UserData(3, /*ssn*/ 47, 0, 0, 53, { 0x00 }, true, true, false),
1018
+ NowMs,
1019
+ /*maxRetransmits*/ 0);
1020
+ buffer.Insert(6, RTC::SCTP::UserData(3, /*ssn*/ 48, 0, 0, 53, { 0x00 }, true, true, false), NowMs);
1021
+
1022
+ REQUIRE(buffer.ShouldSendForwardTsn() == false);
1023
+
1024
+ buffer.HandleSack(unwrapper.Unwrap(11), {}, false);
1025
+ buffer.NackAll();
1026
+
1027
+ REQUIRE(
1028
+ buffer.GetChunkStatesForTesting() ==
1029
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
1030
+ { 11, RTC::SCTP::OutstandingData::State::ACKED },
1031
+ { 12, RTC::SCTP::OutstandingData::State::ABANDONED },
1032
+ { 13, RTC::SCTP::OutstandingData::State::ABANDONED },
1033
+ { 14, RTC::SCTP::OutstandingData::State::ABANDONED },
1034
+ { 15, RTC::SCTP::OutstandingData::State::ABANDONED },
1035
+ { 16, RTC::SCTP::OutstandingData::State::TO_BE_RETRANSMITTED },
1036
+ });
1037
+ REQUIRE(buffer.ShouldSendForwardTsn() == true);
1038
+
1039
+ std::unique_ptr<RTC::SCTP::Packet> packet{ RTC::SCTP::Packet::Factory(
1040
+ sctpCommon::FactoryBuffer, sizeof(sctpCommon::FactoryBuffer)) };
1041
+
1042
+ const auto* forwardTsnChunk = buffer.AddForwardTsn(packet.get());
1043
+
1044
+ REQUIRE(forwardTsnChunk);
1045
+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
1046
+ REQUIRE(forwardTsnChunk->GetNewCumulativeTsn() == 12);
1047
+ REQUIRE(
1048
+ forwardTsnChunk->GetSkippedStreams() == std::vector<RTC::SCTP::ForwardTsnChunk::SkippedStream>{
1049
+ { 1, 44 },
1050
+ });
1051
+
1052
+ // Ack 12, allowing a FORWARD-TSN that spans to TSN=14 to be created.
1053
+ buffer.HandleSack(unwrapper.Unwrap(12), {}, false);
1054
+
1055
+ REQUIRE(buffer.ShouldSendForwardTsn() == true);
1056
+
1057
+ packet.reset(
1058
+ RTC::SCTP::Packet::Factory(sctpCommon::FactoryBuffer, sizeof(sctpCommon::FactoryBuffer)));
1059
+
1060
+ forwardTsnChunk = buffer.AddForwardTsn(packet.get());
1061
+
1062
+ REQUIRE(forwardTsnChunk);
1063
+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
1064
+ REQUIRE(forwardTsnChunk->GetNewCumulativeTsn() == 14);
1065
+ REQUIRE(
1066
+ forwardTsnChunk->GetSkippedStreams() == std::vector<RTC::SCTP::ForwardTsnChunk::SkippedStream>{
1067
+ { 2, 46 },
1068
+ });
1069
+
1070
+ // Ack 13, allowing a FORWARD-TSN that spans to TSN=14 to be created.
1071
+ buffer.HandleSack(unwrapper.Unwrap(13), {}, false);
1072
+
1073
+ REQUIRE(buffer.ShouldSendForwardTsn() == true);
1074
+
1075
+ packet.reset(
1076
+ RTC::SCTP::Packet::Factory(sctpCommon::FactoryBuffer, sizeof(sctpCommon::FactoryBuffer)));
1077
+
1078
+ forwardTsnChunk = buffer.AddForwardTsn(packet.get());
1079
+
1080
+ REQUIRE(forwardTsnChunk);
1081
+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
1082
+ REQUIRE(forwardTsnChunk->GetNewCumulativeTsn() == 14);
1083
+ REQUIRE(
1084
+ forwardTsnChunk->GetSkippedStreams() == std::vector<RTC::SCTP::ForwardTsnChunk::SkippedStream>{
1085
+ { 2, 46 },
1086
+ });
1087
+
1088
+ // Ack 14, allowing a FORWARD-TSN that spans to TSN=15 to be created.
1089
+ buffer.HandleSack(unwrapper.Unwrap(14), {}, false);
1090
+
1091
+ REQUIRE(buffer.ShouldSendForwardTsn() == true);
1092
+
1093
+ packet.reset(
1094
+ RTC::SCTP::Packet::Factory(sctpCommon::FactoryBuffer, sizeof(sctpCommon::FactoryBuffer)));
1095
+
1096
+ forwardTsnChunk = buffer.AddForwardTsn(packet.get());
1097
+
1098
+ REQUIRE(forwardTsnChunk);
1099
+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
1100
+ REQUIRE(forwardTsnChunk->GetNewCumulativeTsn() == 15);
1101
+ REQUIRE(
1102
+ forwardTsnChunk->GetSkippedStreams() == std::vector<RTC::SCTP::ForwardTsnChunk::SkippedStream>{
1103
+ { 3, 47 },
1104
+ });
1105
+
1106
+ buffer.HandleSack(unwrapper.Unwrap(15), {}, false);
1107
+
1108
+ REQUIRE(buffer.ShouldSendForwardTsn() == false);
1109
+ }
1110
+
1111
+ SECTION("treats unacked payload bytes different from packet bytes")
1112
+ {
1113
+ buffer.Insert(
1114
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false), NowMs);
1115
+
1116
+ REQUIRE(buffer.GetUnackedPayloadBytes() == 1);
1117
+ REQUIRE(
1118
+ buffer.GetUnackedPacketBytes() ==
1119
+ RTC::SCTP::DataChunk::DataChunkHeaderLength + Utils::Byte::PadTo4Bytes<size_t>(1));
1120
+ REQUIRE(buffer.GetUnackedItems() == 1);
1121
+
1122
+ buffer.Insert(
1123
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, true, true, false), NowMs);
1124
+
1125
+ REQUIRE(buffer.GetUnackedPayloadBytes() == 2);
1126
+ REQUIRE(
1127
+ buffer.GetUnackedPacketBytes() ==
1128
+ 2 * (RTC::SCTP::DataChunk::DataChunkHeaderLength + Utils::Byte::PadTo4Bytes<size_t>(1)));
1129
+ REQUIRE(buffer.GetUnackedItems() == 2);
1130
+ }
1131
+
1132
+ SECTION("fast recovery increments nack count when cumulative TSN advances")
1133
+ {
1134
+ // This test verifies that the Fast Recovery retransmission rules are
1135
+ // correctly applied when the Cumulative TSN Ack point advances. RFC 9260
1136
+ // Section 7.2.4: "If an endpoint is in Fast Recovery and a SACK arrives that
1137
+ // advances the Cumulative TSN Ack Point, the miss indications are incremented
1138
+ // for all TSNs reported missing in the SACK."
1139
+
1140
+ for (int i{ 10 }; i <= 16; ++i)
1141
+ {
1142
+ buffer.Insert(
1143
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false), NowMs);
1144
+ }
1145
+
1146
+ // SACK 1: Cumulative Ack = 10. Gap blocks for 12, 14, 16.
1147
+ // Missing: 11, 13, 15.
1148
+ // This marks 12, 14, 16 as Acked.
1149
+ // TSNs 11, 13, 15 get their 1st miss indication each.
1150
+ buffer.HandleSack(
1151
+ unwrapper.Unwrap(10),
1152
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
1153
+ { 2, 2 }, // TSN 12
1154
+ { 4, 4 }, // TSN 14
1155
+ { 6, 6 } // TSN 16
1156
+ },
1157
+ /*isInFastRecovery*/ false);
1158
+
1159
+ // SACK 2: Cumulative Ack advances to 11. Same gap blocks (12, 14, 16).
1160
+ // Endpoint is now in Fast Recovery (is_in_fast_recovery = true). Because the
1161
+ // Cumulative TSN Ack Point advanced from 10 to 11, 13 and 15 should get their
1162
+ // 2nd miss indication.
1163
+ buffer.HandleSack(
1164
+ unwrapper.Unwrap(11),
1165
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
1166
+ { 1, 1 }, // TSN 12
1167
+ { 3, 3 }, // TSN 14
1168
+ { 5, 5 } // TSN 16
1169
+ },
1170
+ /*isInFastRecovery*/ true);
1171
+
1172
+ // SACK 3: Cumulative Ack advances to 12.
1173
+ // Note: TSN 12 was already acked via gap block, so this just advances the
1174
+ // Cumulative Ack. 13 and 15 should get their 3rd miss indication and trigger
1175
+ // retransmission.
1176
+ buffer.HandleSack(
1177
+ unwrapper.Unwrap(12),
1178
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
1179
+ { 2, 2 }, // TSN 14
1180
+ { 4, 4 } // TSN 16
1181
+ },
1182
+ /*isInFastRecovery*/ true);
1183
+
1184
+ REQUIRE(
1185
+ buffer.GetChunkStatesForTesting() ==
1186
+ std::vector<std::pair<uint32_t /*tsn*/, RTC::SCTP::OutstandingData::State>>{
1187
+ { 12, RTC::SCTP::OutstandingData::State::ACKED },
1188
+ { 13, RTC::SCTP::OutstandingData::State::TO_BE_RETRANSMITTED },
1189
+ { 14, RTC::SCTP::OutstandingData::State::ACKED },
1190
+ { 15, RTC::SCTP::OutstandingData::State::TO_BE_RETRANSMITTED },
1191
+ { 16, RTC::SCTP::OutstandingData::State::ACKED },
1192
+ });
1193
+ }
1194
+
1195
+ SECTION("nack between ack blocks does not access out of bounds")
1196
+ {
1197
+ for (int i{ 0 }; i < 5; ++i)
1198
+ {
1199
+ buffer.Insert(
1200
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false), NowMs);
1201
+ }
1202
+
1203
+ // Inject a malformed SACK where the GapAckBlock exceeds the number of
1204
+ // outstanding items, potentially triggering an OOB read/write.
1205
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock> malformedBlocks = {
1206
+ { 1, 40000 },
1207
+ };
1208
+
1209
+ buffer.HandleSack(unwrapper.Unwrap(10), malformedBlocks, /*isInFastRecovery*/ false);
1210
+
1211
+ REQUIRE(buffer.HasDataToBeRetransmitted() == false);
1212
+ }
1213
+
1214
+ SECTION("handles SACKs with out of bounds TSNs")
1215
+ {
1216
+ // Send chunks with TSNs 10, 11, 12, 13, 14, 15, 16
1217
+ for (int i{ 0 }; i < 7; ++i)
1218
+ {
1219
+ buffer.Insert(
1220
+ OutgoingMessageId, RTC::SCTP::UserData(1, 0, 0, 0, 53, { 0x00 }, false, false, false), NowMs);
1221
+ }
1222
+
1223
+ // This NACKs TSN 11, 13, 15 (1st miss indication).
1224
+ buffer.HandleSack(
1225
+ unwrapper.Unwrap(10),
1226
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
1227
+ { 2, 2 }, // TSN 12
1228
+ { 4, 4 }, // TSN 14
1229
+ { 6, 6 } // TSN 16
1230
+ },
1231
+ /*isInFastRecovery*/ false);
1232
+
1233
+ REQUIRE(buffer.GetUnackedItems() == 3);
1234
+
1235
+ // The gap between block1-end (12) and block2-start (1011) causes
1236
+ // NackBetweenAckBlocks to loop TSN 13..1010, but only TSN 13..16 are valid.
1237
+ buffer.HandleSack(
1238
+ unwrapper.Unwrap(11),
1239
+ std::vector<RTC::SCTP::SackChunk::GapAckBlock>{
1240
+ { 1, 1 }, // TSN 12
1241
+ { 1000, 60000 } // TSN 1011..60011
1242
+ },
1243
+ /*isInFastRecovery*/ true);
1244
+
1245
+ // Packet 11 has been acknowledged.
1246
+ REQUIRE(buffer.GetUnackedItems() == 2);
1247
+ }
1248
+ }