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,786 @@
1
+ #define MS_CLASS "RTC::SCTP::RetransmissionQueue"
2
+ // #define MS_LOG_DEV_LEVEL 3
3
+
4
+ #include "RTC/SCTP/tx/RetransmissionQueue.hpp"
5
+ #include "Logger.hpp"
6
+ #include "RTC/SCTP/packet/chunks/DataChunk.hpp"
7
+ #include "RTC/SCTP/packet/chunks/IDataChunk.hpp"
8
+ #include "RTC/SCTP/public/SctpTypes.hpp"
9
+ #include "Utils.hpp"
10
+ #include <cmath> // std::min()
11
+ #include <numeric> // std::accumulate()
12
+ #include <string>
13
+
14
+ namespace RTC
15
+ {
16
+ namespace SCTP
17
+ {
18
+ /* Instance methods. */
19
+
20
+ RetransmissionQueue::RetransmissionQueue(
21
+ Listener* listener,
22
+ AssociationListenerInterface& associationListener,
23
+ uint32_t localInitialTsn,
24
+ uint32_t remoteAdvertisedReceiverWindowCredit,
25
+ SendQueueInterface& sendQueue,
26
+ BackoffTimerHandleInterface* t3RtxTimer,
27
+ const SctpOptions& sctpOptions,
28
+ // NOTE: I don't like default argument values in dcsctp (true and false),
29
+ // let's be explicit.
30
+ bool supportsPartialReliability,
31
+ bool useMessageInterleaving)
32
+ : listener(listener),
33
+ associationListener(associationListener),
34
+ sctpOptions(sctpOptions),
35
+ supportsPartialReliability(supportsPartialReliability),
36
+ dataChunkHeaderLength(
37
+ useMessageInterleaving ? IDataChunk::IDataChunkHeaderLength
38
+ : DataChunk::DataChunkHeaderLength),
39
+ t3RtxTimer(t3RtxTimer),
40
+ cwnd(sctpOptions.initialCwndMtus * sctpOptions.mtu),
41
+ rwnd(remoteAdvertisedReceiverWindowCredit),
42
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-7.2.1
43
+ //
44
+ // "The initial value of ssthresh MAY be arbitrarily high (for example,
45
+ // implementations MAY use the size of the receiver advertised window)."
46
+ ssthresh(this->rwnd),
47
+ sendQueue(sendQueue),
48
+ outstandingData(
49
+ this->dataChunkHeaderLength,
50
+ this->tsnUnwrapper.Unwrap(localInitialTsn - 1),
51
+
52
+ [this](uint16_t streamId, uint32_t outgoingMessageId)
53
+ {
54
+ return this->sendQueue.Discard(streamId, outgoingMessageId);
55
+ })
56
+ {
57
+ MS_TRACE();
58
+ }
59
+
60
+ RetransmissionQueue::~RetransmissionQueue()
61
+ {
62
+ MS_TRACE();
63
+ }
64
+
65
+ bool RetransmissionQueue::HandleReceivedSackChunk(uint64_t nowMs, const SackChunk* receivedSackChunk)
66
+ {
67
+ MS_TRACE();
68
+
69
+ if (!IsSackChunkValid(receivedSackChunk))
70
+ {
71
+ return false;
72
+ }
73
+
74
+ const Types::UnwrappedTsn oldLastCumulativeTsnAck =
75
+ this->outstandingData.GetLastCumulativeTsnAck();
76
+ const size_t oldUnackedPacketBytes = this->outstandingData.GetUnackedPacketBytes();
77
+ #if MS_LOG_DEV_LEVEL == 3
78
+ const size_t oldRwnd = this->rwnd;
79
+ #endif
80
+ const Types::UnwrappedTsn cumulativeTsnAck =
81
+ this->tsnUnwrapper.Unwrap(receivedSackChunk->GetCumulativeTsnAck());
82
+
83
+ if (receivedSackChunk->GetValidatedGapAckBlocks().empty())
84
+ {
85
+ UpdateRttMs(nowMs, cumulativeTsnAck);
86
+ }
87
+
88
+ // Exit fast recovery before continuing processing, in case it needs to go
89
+ // into fast recovery again due to new reported packet loss.
90
+ MayExitFastRecovery(cumulativeTsnAck);
91
+
92
+ const OutstandingData::AckInfo ackInfo = this->outstandingData.HandleSack(
93
+ cumulativeTsnAck, receivedSackChunk->GetValidatedGapAckBlocks(), IsInFastRecovery());
94
+
95
+ // Add lifecycle events for delivered messages.
96
+ for (const uint64_t lifecycleId : ackInfo.ackedLifecycleIds)
97
+ {
98
+ MS_DEBUG_TAG(
99
+ sctp,
100
+ "triggering OnAssociationLifecycleMessageDelivered() [lifecycleId:%" PRIu64 "]",
101
+ lifecycleId);
102
+
103
+ this->associationListener.OnAssociationLifecycleMessageDelivered(lifecycleId);
104
+ this->associationListener.OnAssociationLifecycleMessageEnd(lifecycleId);
105
+ }
106
+
107
+ // Add lifecycle events for abandoned messages.
108
+ for (const uint64_t lifecycleId : ackInfo.abandonedLifecycleIds)
109
+ {
110
+ MS_DEBUG_TAG(
111
+ sctp,
112
+ "triggering OnLifecycleMessageExpired() [lifecycleId:%" PRIu64 ", maybeDelivered:true]",
113
+ lifecycleId);
114
+
115
+ this->associationListener.OnAssociationLifecycleMessageExpired(
116
+ lifecycleId, /*maybeDelivered*/ true);
117
+ this->associationListener.OnAssociationLifecycleMessageEnd(lifecycleId);
118
+ }
119
+
120
+ // Update of this->outstandingData is now done. Congestion control remains.
121
+ UpdateReceiverWindow(receivedSackChunk->GetAdvertisedReceiverWindowCredit());
122
+
123
+ MS_DEBUG_DEV(
124
+ "received SACK [cumulativeTsnAck:%" PRIu32 ", oldLastCumulativeTsnAck:%" PRIu32
125
+ ", unackedPacketBytes:%zu, oldUnackedPacketBytes:%zu, rwnd:%zu, oldRwnd:%zu]",
126
+ cumulativeTsnAck.Wrap(),
127
+ oldLastCumulativeTsnAck.Wrap(),
128
+ this->outstandingData.GetUnackedPacketBytes(),
129
+ oldUnackedPacketBytes,
130
+ this->rwnd,
131
+ oldRwnd);
132
+
133
+ if (cumulativeTsnAck > oldLastCumulativeTsnAck)
134
+ {
135
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-6.3.2
136
+ //
137
+ // "Whenever a SACK is received that acknowledges the DATA chunk with
138
+ // the earliest outstanding TSN for that address, restart the T3-rtx
139
+ // timer for that address with its current RTO (if there is still
140
+ // outstanding data on that address)."
141
+ this->t3RtxTimer->Stop();
142
+
143
+ HandleIncreasedCumulativeTsnAck(oldUnackedPacketBytes, ackInfo.bytesAcked);
144
+ }
145
+
146
+ if (ackInfo.hasPacketLoss)
147
+ {
148
+ HandlePacketLoss(ackInfo.highestTsnAcked);
149
+ }
150
+
151
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-8.2
152
+ //
153
+ // "When an outstanding TSN is acknowledged [...] the endpoint shall clear
154
+ // the error counter ...".
155
+ if (ackInfo.bytesAcked > 0)
156
+ {
157
+ this->listener->OnRetransmissionQueueClearRetransmissionCounter();
158
+ }
159
+
160
+ StartT3RtxTimerIfOutstandingData();
161
+
162
+ return true;
163
+ }
164
+
165
+ void RetransmissionQueue::HandleT3RtxTimerExpiry()
166
+ {
167
+ MS_TRACE();
168
+
169
+ const size_t oldCwnd = this->cwnd;
170
+ const size_t oldUnackedPacketBytes = GetUnackedPacketBytes();
171
+
172
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-6.3.3
173
+ //
174
+ // "For the destination address for which the timer expires, adjust
175
+ // its ssthresh with rules defined in Section 7.2.3 and set the cwnd
176
+ // <- MTU."
177
+ this->ssthresh = std::max(this->cwnd / 2, 4 * this->sctpOptions.mtu);
178
+ this->cwnd = 1 * this->sctpOptions.mtu;
179
+
180
+ // Errata: https://datatracker.ietf.org/doc/html/rfc8540#section-3.11
181
+ this->partialBytesAcked = 0;
182
+
183
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-6.3.3
184
+ //
185
+ // "For the destination address for which the timer expires, set RTO
186
+ // <- RTO * 2 ("back off the timer"). The maximum value discussed in
187
+ // rule C7 above (RTO.max) may be used to provide an upper bound to this
188
+ // doubling operation."
189
+
190
+ // Already done by the BackoffTimerHandle implementation.
191
+
192
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-6.3.3
193
+ //
194
+ // "Determine how many of the earliest (i.e., lowest TSN) outstanding
195
+ // DATA chunks for the address for which the T3-rtx has expired will fit
196
+ // into a single Packet"
197
+
198
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-6.3.3
199
+ //
200
+ // "Note: Any DATA chunks that were sent to the address for which the
201
+ // T3-rtx timer expired but did not fit in one MTU (rule E3 above) should
202
+ // be marked for retransmission and sent as soon as cwnd allows (normally,
203
+ // when a SACK arrives)."
204
+ this->outstandingData.NackAll();
205
+
206
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-6.3.3
207
+ //
208
+ // "Start the retransmission timer T3-rtx on the destination address to
209
+ // which the retransmission is sent, if rule R1 above indicates to do so."
210
+
211
+ // Already done by the BackoffTimerHandle implementation.
212
+
213
+ MS_DEBUG_TAG(
214
+ sctp,
215
+ "%s timer has expired [cwnd:%zu, oldCwnd:%zu, ssthresh:%zu, unackedPacketBytes:%zu, oldUnackedPacketBytes:%zu]",
216
+ this->t3RtxTimer->GetLabel().c_str(),
217
+ this->cwnd,
218
+ oldCwnd,
219
+ this->ssthresh,
220
+ GetUnackedPacketBytes(),
221
+ oldUnackedPacketBytes);
222
+ }
223
+
224
+ std::vector<std::pair<uint32_t /*tsn*/, UserData>> RetransmissionQueue::GetChunksForFastRetransmit(
225
+ size_t maxLength)
226
+ {
227
+ MS_TRACE();
228
+
229
+ MS_ASSERT(
230
+ this->outstandingData.HasDataToBeFastRetransmitted(), "no data to be fast-retransmitted");
231
+ MS_ASSERT(
232
+ Utils::Byte::IsPaddedTo4Bytes(maxLength),
233
+ "given maxLength %zu is not divisible by 4",
234
+ maxLength);
235
+
236
+ std::vector<std::pair<uint32_t /*tsn*/, UserData>> toBeSent;
237
+
238
+ #if MS_LOG_DEV_LEVEL == 3
239
+ const size_t oldUnackedPacketBytes = GetUnackedPacketBytes();
240
+ #endif
241
+
242
+ toBeSent = this->outstandingData.GetChunksToBeFastRetransmitted(maxLength);
243
+
244
+ MS_ASSERT(!toBeSent.empty(), "toBeSent cannot be empty");
245
+
246
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-7.2.4
247
+ //
248
+ // "4) Restart the T3-rtx timer only if ... the endpoint is retransmitting
249
+ // the first outstanding DATA chunk sent to that address."
250
+ if (toBeSent[0].first == this->outstandingData.GetLastCumulativeTsnAck().GetNextValue().Wrap())
251
+ {
252
+ MS_DEBUG_DEV("first outstanding data to be retransmitted, restarting T3-rtx timer");
253
+
254
+ this->t3RtxTimer->Stop();
255
+ }
256
+
257
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-6.3.2
258
+ //
259
+ // "Every time a DATA chunk is sent to any address (including a
260
+ // retransmission), if the T3-rtx timer of that address is not running,
261
+ // start it running so that it will expire after the RTO of that address."
262
+ if (!this->t3RtxTimer->IsRunning())
263
+ {
264
+ this->t3RtxTimer->Start();
265
+ }
266
+
267
+ const size_t bytesRetransmitted = std::accumulate(
268
+ toBeSent.begin(),
269
+ toBeSent.end(),
270
+ size_t{ 0 },
271
+ [&](size_t r, const std::pair<uint32_t /*tsn*/, UserData>& data)
272
+ {
273
+ return r + GetSerializedChunkLength(data.second);
274
+ });
275
+
276
+ ++this->rtxPacketsCount;
277
+ this->rtxBytesCount += bytesRetransmitted;
278
+
279
+ #if MS_LOG_DEV_LEVEL == 3
280
+ std::string tsnList;
281
+
282
+ for (const auto& [tsn, data] : toBeSent)
283
+ {
284
+ if (!tsnList.empty())
285
+ {
286
+ tsnList += ',';
287
+ }
288
+
289
+ tsnList += std::to_string(tsn);
290
+ }
291
+
292
+ MS_DEBUG_DEV(
293
+ "fast-retransmitting TSN %s (%zu bytes) [unackedPacketBytes:%zu, oldUnackedPacketBytes:%zu]",
294
+ tsnList.c_str(),
295
+ bytesRetransmitted,
296
+ GetUnackedPacketBytes(),
297
+ oldUnackedPacketBytes);
298
+ #endif
299
+
300
+ return toBeSent;
301
+ }
302
+
303
+ std::vector<std::pair<uint32_t /*tsn*/, UserData>> RetransmissionQueue::GetChunksToSend(
304
+ uint64_t nowMs, size_t maxLength)
305
+ {
306
+ MS_TRACE();
307
+
308
+ MS_ASSERT(
309
+ Utils::Byte::IsPaddedTo4Bytes(maxLength),
310
+ "given maxLength %zu is not divisible by 4",
311
+ maxLength);
312
+
313
+ std::vector<std::pair<uint32_t /*tsn*/, UserData>> toBeSent;
314
+
315
+ const size_t oldUnackedPacketBytes = GetUnackedPacketBytes();
316
+ #if MS_LOG_DEV_LEVEL == 3
317
+ const size_t oldRwnd = this->rwnd;
318
+ #endif
319
+
320
+ // Calculate the bandwidth budget (how many bytes that is allowed to be
321
+ // sent).
322
+ const size_t maxPacketBytesAllowedByCwnd =
323
+ oldUnackedPacketBytes >= this->cwnd ? 0 : this->cwnd - oldUnackedPacketBytes;
324
+
325
+ size_t maxPacketBytesAllowedByRwnd =
326
+ Utils::Byte::PadTo4Bytes(GetRwnd() + this->dataChunkHeaderLength);
327
+
328
+ // https://datatracker.ietf.org/doc/html/rfc9260#section-6.1
329
+ //
330
+ // "However, regardless of the value of rwnd (including if it is 0), the
331
+ // data sender can always have one DATA chunk in flight to the receiver if
332
+ // allowed by cwnd (see rule B, below)."
333
+ if (this->outstandingData.GetUnackedItems() == 0)
334
+ {
335
+ maxPacketBytesAllowedByRwnd = this->sctpOptions.mtu;
336
+ }
337
+
338
+ size_t maxBytes = Utils::Byte::PadDownTo4Bytes(
339
+ std::min({ maxPacketBytesAllowedByCwnd, maxPacketBytesAllowedByRwnd, maxLength }));
340
+
341
+ toBeSent = this->outstandingData.GetChunksToBeRetransmitted(maxBytes);
342
+
343
+ const size_t bytesRetransmitted = std::accumulate(
344
+ toBeSent.begin(),
345
+ toBeSent.end(),
346
+ size_t{ 0 },
347
+ [&](size_t r, const std::pair<uint32_t /*tsn*/, UserData>& data)
348
+ {
349
+ return r + GetSerializedChunkLength(data.second);
350
+ });
351
+
352
+ maxBytes -= bytesRetransmitted;
353
+
354
+ if (!toBeSent.empty())
355
+ {
356
+ ++this->rtxPacketsCount;
357
+ this->rtxBytesCount += bytesRetransmitted;
358
+ }
359
+
360
+ while (maxBytes > this->dataChunkHeaderLength)
361
+ {
362
+ MS_ASSERT(
363
+ Utils::Byte::IsPaddedTo4Bytes(maxBytes),
364
+ "computed maxBytes %zu during the loop is not divisible by 4",
365
+ maxBytes);
366
+
367
+ std::optional<SendQueueInterface::DataToSend> dataToSend =
368
+ this->sendQueue.Produce(nowMs, maxBytes - this->dataChunkHeaderLength);
369
+
370
+ if (!dataToSend.has_value())
371
+ {
372
+ break;
373
+ }
374
+
375
+ const size_t chunkSize = GetSerializedChunkLength(dataToSend->data);
376
+
377
+ maxBytes -= chunkSize;
378
+
379
+ this->rwnd -= dataToSend->data.GetPayloadLength();
380
+
381
+ const std::optional<Types::UnwrappedTsn> tsn = this->outstandingData.Insert(
382
+ dataToSend->outgoingMessageId,
383
+ dataToSend->data,
384
+ nowMs,
385
+ this->supportsPartialReliability ? dataToSend->maxRetransmissions
386
+ : Types::MaxRetransmitsNoLimit,
387
+ this->supportsPartialReliability ? dataToSend->expiresAtMs : Types::ExpiresAtMsInfinite,
388
+ dataToSend->lifecycleId);
389
+
390
+ if (tsn.has_value())
391
+ {
392
+ if (dataToSend->lifecycleId.has_value())
393
+ {
394
+ MS_ASSERT(dataToSend->data.IsEnd(), "data.IsEnd() should return true");
395
+
396
+ this->associationListener.OnAssociationLifecycleMessageFullySent(
397
+ dataToSend->lifecycleId.value());
398
+ }
399
+
400
+ toBeSent.emplace_back(tsn->Wrap(), std::move(dataToSend->data));
401
+ }
402
+ }
403
+
404
+ // https://tools.ietf.org/html/rfc9260#section-6.3.2
405
+ //
406
+ // "Every time a DATA chunk is sent to any address (including a
407
+ // retransmission), if the T3-rtx timer of that address is not running,
408
+ // start it running so that it will expire after the RTO of that address."
409
+ if (!toBeSent.empty())
410
+ {
411
+ if (!this->t3RtxTimer->IsRunning())
412
+ {
413
+ this->t3RtxTimer->Start();
414
+ }
415
+
416
+ #if MS_LOG_DEV_LEVEL == 3
417
+ std::string tsnList;
418
+
419
+ for (const auto& [tsn, data] : toBeSent)
420
+ {
421
+ if (!tsnList.empty())
422
+ {
423
+ tsnList += ',';
424
+ }
425
+
426
+ tsnList += std::to_string(tsn);
427
+ }
428
+
429
+ const size_t bytesRetransmitted = std::accumulate(
430
+ toBeSent.begin(),
431
+ toBeSent.end(),
432
+ size_t{ 0 },
433
+ [&](size_t r, const std::pair<uint32_t, UserData>& d)
434
+ {
435
+ return r + GetSerializedChunkLength(d.second);
436
+ });
437
+
438
+ MS_DEBUG_DEV(
439
+ "sending TSN %s (%zu bytes) [unackedPacketBytes:%zu, oldUnackedPacketBytes:%zu, cwnd:%zu, rwnd:%zu, oldRwnd:%zu]",
440
+ tsnList.c_str(),
441
+ bytesRetransmitted,
442
+ GetUnackedPacketBytes(),
443
+ oldUnackedPacketBytes,
444
+ cwnd,
445
+ rwnd,
446
+ oldRwnd);
447
+ #endif
448
+ }
449
+
450
+ return toBeSent;
451
+ }
452
+
453
+ bool RetransmissionQueue::ShouldSendForwardTsn(uint64_t nowMs)
454
+ {
455
+ MS_TRACE();
456
+
457
+ if (!this->supportsPartialReliability)
458
+ {
459
+ return false;
460
+ }
461
+
462
+ this->outstandingData.ExpireOutstandingChunks(nowMs);
463
+
464
+ return this->outstandingData.ShouldSendForwardTsn();
465
+ }
466
+
467
+ void RetransmissionQueue::PrepareResetStream(uint16_t streamId)
468
+ {
469
+ MS_TRACE();
470
+
471
+ // TODO: As per TODO comment in same method in dcsctp:
472
+ //
473
+ // These calls are now only affecting the send queue. The packet buffer
474
+ // can also change behavior - for example draining the chunk producer and
475
+ // eagerly assign TSNs so that an "Outgoing SSN Reset Request" can be sent
476
+ // quickly, with a known sender last assigned TSN.
477
+
478
+ this->sendQueue.PrepareResetStream(streamId);
479
+ }
480
+
481
+ bool RetransmissionQueue::HasStreamsReadyToBeReset() const
482
+ {
483
+ MS_TRACE();
484
+
485
+ return this->sendQueue.HasStreamsReadyToBeReset();
486
+ }
487
+
488
+ std::vector<uint16_t /*streamId*/> RetransmissionQueue::BeginResetStreams()
489
+ {
490
+ MS_TRACE();
491
+
492
+ this->outstandingData.BeginResetStreams();
493
+
494
+ return this->sendQueue.GetStreamsReadyToBeReset();
495
+ }
496
+
497
+ void RetransmissionQueue::CommitResetStreams()
498
+ {
499
+ MS_TRACE();
500
+
501
+ this->sendQueue.CommitResetStreams();
502
+ }
503
+
504
+ void RetransmissionQueue::RollbackResetStreams()
505
+ {
506
+ MS_TRACE();
507
+
508
+ this->sendQueue.RollbackResetStreams();
509
+ }
510
+
511
+ size_t RetransmissionQueue::GetSerializedChunkLength(const UserData& data) const
512
+ {
513
+ MS_TRACE();
514
+
515
+ return Utils::Byte::PadTo4Bytes(this->dataChunkHeaderLength + data.GetPayloadLength());
516
+ }
517
+
518
+ bool RetransmissionQueue::IsSackChunkValid(const SackChunk* sackChunk) const
519
+ {
520
+ MS_TRACE();
521
+
522
+ // https://tools.ietf.org/html/rfc9260#section-6.2.1
523
+ //
524
+ // "If Cumulative TSN Ack is less than the Cumulative TSN Ack Point, then
525
+ // drop the SACK. Since Cumulative TSN Ack is monotonically increasing, a
526
+ // SACK whose Cumulative TSN Ack is less than the Cumulative TSN Ack Point
527
+ // indicates an out-of- order SACK."
528
+ //
529
+ // @remarks
530
+ // - Important not to drop SACKs with identical TSN to that previously
531
+ // received, as the gap-ack-blocks or dup tsn fields may have changed.
532
+ const Types::UnwrappedTsn cumulativeTsnAck =
533
+ this->tsnUnwrapper.PeekUnwrap(sackChunk->GetCumulativeTsnAck());
534
+
535
+ if (cumulativeTsnAck < this->outstandingData.GetLastCumulativeTsnAck())
536
+ {
537
+ // https://tools.ietf.org/html/rfc9260#section-6.2.1
538
+ //
539
+ // "If Cumulative TSN Ack is less than the Cumulative TSN Ack Point,
540
+ // then drop the SACK. Since Cumulative TSN Ack is monotonically
541
+ // increasing, a SACK whose Cumulative TSN Ack is less than the
542
+ // Cumulative TSN Ack Point indicates an out-of- order SACK."
543
+ return false;
544
+ }
545
+ else if (cumulativeTsnAck > this->outstandingData.GetHighestOutstandingTsn())
546
+ {
547
+ return false;
548
+ }
549
+
550
+ return std::ranges::all_of(
551
+ sackChunk->GetGapAckBlocks(),
552
+ [&](const auto& block)
553
+ {
554
+ return Types::UnwrappedTsn::AddTo(cumulativeTsnAck, block.end) <=
555
+ this->outstandingData.GetHighestOutstandingTsn();
556
+ });
557
+ }
558
+
559
+ void RetransmissionQueue::UpdateRttMs(uint64_t nowMs, Types::UnwrappedTsn cumulativeTsnAck)
560
+ {
561
+ MS_TRACE();
562
+
563
+ // RTT updating is flawed in SCTP, as explained in e.g. Pedersen J, Griwodz C,
564
+ // Halvorsen P (2006) Considerations of SCTP retransmission delays for thin
565
+ // streams.
566
+ // Due to delayed acknowledgement, the SACK may be sent much later which
567
+ // increases the calculated RTT.
568
+ //
569
+ // TODO: As per TODO comment in same method in dcsctp:
570
+ //
571
+ // Consider occasionally sending DATA chunks with I-bit set and use only
572
+ // those packets for measurement.
573
+
574
+ const auto rttMs = this->outstandingData.MeasureRtt(nowMs, cumulativeTsnAck);
575
+
576
+ if (rttMs.has_value())
577
+ {
578
+ this->listener->OnRetransmissionQueueNewRttMs(rttMs.value());
579
+ }
580
+ }
581
+
582
+ void RetransmissionQueue::MayExitFastRecovery(Types::UnwrappedTsn cumulativeTsnAck)
583
+ {
584
+ MS_TRACE();
585
+
586
+ // https://tools.ietf.org/html/rfc9260#section-7.2.4
587
+ //
588
+ // "When a SACK acknowledges all TSNs up to and including this [fast
589
+ // recovery] exit point, Fast Recovery is exited."
590
+ if (this->fastRecoveryExitTsn.has_value() && cumulativeTsnAck >= this->fastRecoveryExitTsn.value())
591
+ {
592
+ MS_DEBUG_DEV(
593
+ "exit point %" PRIu32 " reached, exiting fast recovery",
594
+ this->fastRecoveryExitTsn.value().Wrap());
595
+
596
+ this->fastRecoveryExitTsn = std::nullopt;
597
+ }
598
+ }
599
+
600
+ void RetransmissionQueue::StopT3RtxTimerOnIncreasedCumulativeTsnAck(
601
+ Types::UnwrappedTsn /*cumulativeTsnAck*/)
602
+ {
603
+ MS_TRACE();
604
+
605
+ // TODO: This method is NOT implemented in dcsctp!
606
+ //
607
+ // @see https://issues.webrtc.org/issues/505751236
608
+ }
609
+
610
+ void RetransmissionQueue::HandleIncreasedCumulativeTsnAck(
611
+ size_t unackedPacketBytes, size_t totalBytesAcked)
612
+ {
613
+ MS_TRACE();
614
+
615
+ // Allow some margin for classifying as fully utilized, due to e.g. that
616
+ // too small packets (less than kMinimumFragmentedPayload) are not sent +
617
+ // overhead.
618
+ const bool isFullyUtilized = unackedPacketBytes + this->sctpOptions.mtu >= this->cwnd;
619
+ #if MS_LOG_DEV_LEVEL == 3
620
+ const size_t oldCwnd = this->cwnd;
621
+ #endif
622
+
623
+ if (GetCongestionAlgorithmPhase() == CongestionAlgorithmPhase::SLOW_START)
624
+ {
625
+ if (isFullyUtilized && !IsInFastRecovery())
626
+ {
627
+ // https://tools.ietf.org/html/rfc9260#section-7.2.1
628
+ //
629
+ // "Only when these three conditions are met can the cwnd be
630
+ // increased; otherwise, the cwnd MUST not be increased. If these
631
+ // conditions are met, then cwnd MUST be increased by, at most, the
632
+ // lesser of 1) the total size of the previously outstanding DATA
633
+ // chunk(s) acknowledged, and 2) the destination's path MTU."
634
+ this->cwnd += std::min(totalBytesAcked, this->sctpOptions.mtu);
635
+
636
+ MS_DEBUG_DEV("SS increase [cwnd:%zu, oldCwnd:%zu]", this->cwnd, oldCwnd);
637
+ }
638
+ }
639
+ else if (GetCongestionAlgorithmPhase() == CongestionAlgorithmPhase::CONGESTION_AVOIDANCE)
640
+ {
641
+ // https://tools.ietf.org/html/rfc9260#section-7.2.2
642
+ //
643
+ // "Whenever cwnd is greater than ssthresh, upon each SACK arrival
644
+ // that advances the Cumulative TSN Ack Point, increase
645
+ // partial_bytes_acked by the total number of bytes of all new chunks
646
+ // acknowledged in that SACK including chunks acknowledged by the new
647
+ // Cumulative TSN Ack and by Gap Ack Blocks."
648
+ #if MS_LOG_DEV_LEVEL == 3
649
+ const size_t oldPba = this->partialBytesAcked;
650
+ #endif
651
+
652
+ this->partialBytesAcked += totalBytesAcked;
653
+
654
+ if (this->partialBytesAcked >= this->cwnd && isFullyUtilized)
655
+ {
656
+ // https://tools.ietf.org/html/rfc9260#section-7.2.2
657
+ //
658
+ // "When partial_bytes_acked is equal to or greater than cwnd and
659
+ // before the arrival of the SACK the sender had cwnd or more bytes of
660
+ // data outstanding (i.e., before arrival of the SACK, flightsize was
661
+ // greater than or equal to cwnd), increase cwnd by MTU, and reset
662
+ // partial_bytes_acked to (partial_bytes_acked - cwnd)."
663
+
664
+ // Errata: https://datatracker.ietf.org/doc/html/rfc8540#section-3.12
665
+ this->partialBytesAcked -= this->cwnd;
666
+ this->cwnd += this->sctpOptions.mtu;
667
+
668
+ MS_DEBUG_DEV(
669
+ "CA increase [cwnd:%zu, oldCwnd:%zu, ssthresh:%zu, pba:%zu, oldPba:%zu]",
670
+ this->cwnd,
671
+ oldCwnd,
672
+ this->ssthresh,
673
+ this->partialBytesAcked,
674
+ oldPba);
675
+ }
676
+ else
677
+ {
678
+ MS_DEBUG_DEV(
679
+ "CA unchanged [cwnd:%zu, oldCwnd:%zu, ssthresh:%zu, pba:%zu, oldPba:%zu]",
680
+ this->cwnd,
681
+ oldCwnd,
682
+ this->ssthresh,
683
+ this->partialBytesAcked,
684
+ oldPba);
685
+ }
686
+ }
687
+ }
688
+
689
+ void RetransmissionQueue::HandlePacketLoss(Types::UnwrappedTsn /*highestTsnAcked*/)
690
+ {
691
+ MS_TRACE();
692
+
693
+ // https://tools.ietf.org/html/rfc9260#section-7.2.4
694
+ //
695
+ // "If not in Fast Recovery, adjust the ssthresh and cwnd of the
696
+ // destination address(es) to which the missing DATA chunks were last
697
+ // sent, according to the formula described in Section 7.2.3."
698
+ if (!IsInFastRecovery())
699
+ {
700
+ #if MS_LOG_DEV_LEVEL == 3
701
+ const size_t oldCwnd = this->cwnd;
702
+ const size_t oldPba = this->partialBytesAcked;
703
+ #endif
704
+
705
+ this->ssthresh =
706
+ std::max(this->cwnd / 2, this->sctpOptions.minCwndMtus * this->sctpOptions.mtu);
707
+ this->cwnd = this->ssthresh;
708
+ this->partialBytesAcked = 0;
709
+
710
+ MS_DEBUG_DEV(
711
+ "packet loss detected (not fast recovery) [cwnd:%zu, oldCwnd:%zu, ssthresh:%zu, pba:%zu, oldPba:%zu]",
712
+ this->cwnd,
713
+ oldCwnd,
714
+ this->ssthresh,
715
+ this->partialBytesAcked,
716
+ oldPba);
717
+
718
+ // https://tools.ietf.org/html/rfc9260#section-7.2.4
719
+ //
720
+ // "If not in Fast Recovery, enter Fast Recovery and mark the highest
721
+ // outstanding TSN as the Fast Recovery exit point."
722
+ this->fastRecoveryExitTsn = this->outstandingData.GetHighestOutstandingTsn();
723
+
724
+ MS_DEBUG_DEV(
725
+ "fast recovery initiated with exit point %" PRIu32,
726
+ this->fastRecoveryExitTsn.value().Wrap());
727
+ }
728
+ // https://tools.ietf.org/html/rfc9260#section-7.2.4
729
+ //
730
+ // "While in Fast Recovery, the ssthresh and cwnd SHOULD NOT change for
731
+ // any destinations due to a subsequent Fast Recovery event (i.e., one
732
+ // SHOULD NOT reduce the cwnd further due to a subsequent Fast
733
+ // Retransmit)."
734
+ else
735
+ {
736
+ MS_DEBUG_DEV("packet loss detected (fast recovery), no changes");
737
+ }
738
+ }
739
+
740
+ void RetransmissionQueue::UpdateReceiverWindow(uint32_t aRwnd)
741
+ {
742
+ MS_TRACE();
743
+
744
+ this->rwnd = this->outstandingData.GetUnackedPayloadBytes() >= aRwnd
745
+ ? 0
746
+ : aRwnd - this->outstandingData.GetUnackedPayloadBytes();
747
+ }
748
+
749
+ void RetransmissionQueue::StartT3RtxTimerIfOutstandingData()
750
+ {
751
+ MS_TRACE();
752
+
753
+ // Note: Can't use `GetUnackedPacketBytes()` as that one doesn't count
754
+ // chunks to be retransmitted.
755
+
756
+ // https://tools.ietf.org/html/rfc9260#section-6.3.2
757
+ // "Whenever all outstanding data sent to an address have been
758
+ // acknowledged, turn off the T3-rtx timer of that address.
759
+ if (this->outstandingData.IsEmpty())
760
+ {
761
+ // Note: Already stopped in `StopT3RtxTimerOnIncreasedCumulativeTsnAck()`."
762
+ //
763
+ // TODO: As said above, `StopT3RtxTimerOnIncreasedCumulativeTsnAck()`
764
+ // is NOT implemented in dcsctp and of course it's never called from
765
+ // anywhere.
766
+ }
767
+ else
768
+ {
769
+ // https://tools.ietf.org/html/rfc9260#section-6.3.2
770
+ //
771
+ // "Whenever a SACK is received that acknowledges the DATA chunk with
772
+ // the earliest outstanding TSN for that address, restart the T3-rtx
773
+ // timer for that address with its current RTO (if there is still
774
+ // outstanding data on that address)."
775
+ // "Whenever a SACK is received missing a TSN that was previously
776
+ // acknowledged via a Gap Ack Block, start the T3-rtx for the
777
+ // destination address to which the DATA chunk was originally
778
+ // transmitted if it is not already running."
779
+ if (!this->t3RtxTimer->IsRunning())
780
+ {
781
+ this->t3RtxTimer->Start();
782
+ }
783
+ }
784
+ }
785
+ } // namespace SCTP
786
+ } // namespace RTC