werift 0.26.0 → 0.28.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.
- package/README.md +182 -8
- package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
- package/lib/common/src/binary.d.ts +1 -3
- package/lib/common/src/binary.js +8 -6
- package/lib/common/src/binary.js.map +1 -1
- package/lib/common/src/binaryData.js +2 -1
- package/lib/common/src/binaryData.js.map +1 -1
- package/lib/common/src/event.d.ts +26 -0
- package/lib/common/src/event.js +87 -2
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/log.js +5 -7
- package/lib/common/src/log.js.map +1 -1
- package/lib/common/src/network.d.ts +6 -1
- package/lib/common/src/network.js +8 -2
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/transport.d.ts +12 -5
- package/lib/common/src/transport.js +13 -7
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/alert.d.ts +49 -0
- package/lib/dtls/src/alert.js +103 -0
- package/lib/dtls/src/alert.js.map +1 -0
- package/lib/dtls/src/client.js +15 -1
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/cipher.d.ts +1 -1
- package/lib/dtls/src/context/cipher.js +6 -3
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +2 -0
- package/lib/dtls/src/context/dtls.js +11 -2
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +17 -1
- package/lib/dtls/src/context/transport.js +40 -3
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight1.js +2 -1
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +8 -3
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +6 -1
- package/lib/dtls/src/flight/flight.js +18 -5
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +4 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +6 -2
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +17 -13
- package/lib/dtls/src/handshake/const.js +16 -14
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.js +4 -2
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +2 -1
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +2 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +4 -2
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +14 -7
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +2 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/finished.js +2 -1
- package/lib/dtls/src/handshake/message/finished.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +6 -3
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.js +12 -6
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +4 -2
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js +16 -8
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +2 -2
- package/lib/dtls/src/handshake/random.js +5 -2
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/index.d.ts +3 -1
- package/lib/dtls/src/index.js +10 -1
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +52 -33
- package/lib/dtls/src/record/const.js +51 -36
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.js +12 -6
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +10 -5
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.js +4 -2
- package/lib/dtls/src/record/message/plaintext.js.map +1 -1
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +50 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +19 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +134 -2
- package/lib/dtls/src/socket.js +326 -8
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidate.d.ts +1 -1
- package/lib/ice/src/candidate.js +24 -12
- package/lib/ice/src/candidate.js.map +1 -1
- package/lib/ice/src/candidateError.d.ts +155 -0
- package/lib/ice/src/candidateError.js +246 -0
- package/lib/ice/src/candidateError.js.map +1 -0
- package/lib/ice/src/candidateGatherer.d.ts +127 -0
- package/lib/ice/src/candidateGatherer.js +745 -0
- package/lib/ice/src/candidateGatherer.js.map +1 -0
- package/lib/ice/src/consent.d.ts +49 -0
- package/lib/ice/src/consent.js +258 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/dns/lookup.d.ts +10 -1
- package/lib/ice/src/dns/lookup.js +42 -7
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +21 -5
- package/lib/ice/src/exceptions.js +58 -13
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/ice.d.ts +254 -58
- package/lib/ice/src/ice.js +979 -945
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +328 -14
- package/lib/ice/src/iceBase.js +254 -38
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +1 -0
- package/lib/ice/src/index.js +1 -0
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/checkMessages.d.ts +41 -0
- package/lib/ice/src/internal/checkMessages.js +63 -0
- package/lib/ice/src/internal/checkMessages.js.map +1 -0
- package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
- package/lib/ice/src/internal/defaultRoute.js +134 -0
- package/lib/ice/src/internal/defaultRoute.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +17 -0
- package/lib/ice/src/internal/hostInterfaces.js +77 -0
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
- package/lib/ice/src/internal/hostPreference.d.ts +24 -0
- package/lib/ice/src/internal/hostPreference.js +38 -0
- package/lib/ice/src/internal/hostPreference.js.map +1 -0
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
- package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
- package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
- package/lib/ice/src/internal/selectAddresses.js +37 -18
- package/lib/ice/src/internal/selectAddresses.js.map +1 -1
- package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
- package/lib/ice/src/nomination/regularNomination.js +311 -0
- package/lib/ice/src/nomination/regularNomination.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +138 -0
- package/lib/ice/src/nomination/selectionReplacement.js +371 -0
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
- package/lib/ice/src/provisional.d.ts +139 -0
- package/lib/ice/src/provisional.js +468 -0
- package/lib/ice/src/provisional.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +9 -2
- package/lib/ice/src/stun/protocol.js +16 -17
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +1 -1
- package/lib/ice/src/stun/tcpProtocol.js +7 -7
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +30 -1
- package/lib/ice/src/stun/transaction.js +90 -19
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/credential.d.ts +49 -0
- package/lib/ice/src/turn/credential.js +78 -0
- package/lib/ice/src/turn/credential.js.map +1 -0
- package/lib/ice/src/turn/protocol.d.ts +31 -10
- package/lib/ice/src/turn/protocol.js +127 -51
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +16 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.d.ts +2 -0
- package/lib/ice-server/src/stun/attributes.js +11 -1
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +44 -17
- package/lib/ice-server/src/stun/const.js +31 -19
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +29 -4
- package/lib/ice-server/src/stun/message.js +115 -24
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/index.mjs +35121 -22337
- package/lib/nonstandard/index.mjs +3169 -1399
- package/lib/polyfill/dom.mjs +24650 -12365
- package/lib/polyfill/index.mjs +24650 -12365
- package/lib/rtp/src/codec/assertPayload.d.ts +4 -0
- package/lib/rtp/src/codec/assertPayload.js +12 -0
- package/lib/rtp/src/codec/assertPayload.js.map +1 -0
- package/lib/rtp/src/codec/av1.js +2 -0
- package/lib/rtp/src/codec/av1.js.map +1 -1
- package/lib/rtp/src/codec/h264.js +35 -43
- package/lib/rtp/src/codec/h264.js.map +1 -1
- package/lib/rtp/src/codec/vp8.js +11 -5
- package/lib/rtp/src/codec/vp8.js.map +1 -1
- package/lib/rtp/src/codec/vp9.js +12 -0
- package/lib/rtp/src/codec/vp9.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/container.js +2 -1
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js +2 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/h264.d.ts +21 -17
- package/lib/rtp/src/extra/container/mp4/h264.js +26 -24
- package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/index.d.ts +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/writer.d.ts +90 -0
- package/lib/rtp/src/extra/container/ogg/writer.js +300 -0
- package/lib/rtp/src/extra/container/ogg/writer.js.map +1 -0
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js +6 -3
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +5 -0
- package/lib/rtp/src/extra/processor/depacketizer.js +28 -2
- package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/extra/processor/dtx.js +4 -2
- package/lib/rtp/src/extra/processor/dtx.js.map +1 -1
- package/lib/rtp/src/extra/processor/index.d.ts +2 -0
- package/lib/rtp/src/extra/processor/index.js +2 -0
- package/lib/rtp/src/extra/processor/index.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBuffer.d.ts +29 -6
- package/lib/rtp/src/extra/processor/jitterBuffer.js +101 -111
- package/lib/rtp/src/extra/processor/jitterBuffer.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js +2 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js.map +1 -1
- package/lib/rtp/src/extra/processor/lipsync.d.ts +63 -0
- package/lib/rtp/src/extra/processor/lipsync.js +202 -51
- package/lib/rtp/src/extra/processor/lipsync.js.map +1 -1
- package/lib/rtp/src/extra/processor/mp4.d.ts +0 -6
- package/lib/rtp/src/extra/processor/mp4.js +6 -3
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/mute.js +4 -2
- package/lib/rtp/src/extra/processor/mute.js.map +1 -1
- package/lib/rtp/src/extra/processor/nack.js +4 -2
- package/lib/rtp/src/extra/processor/nack.js.map +1 -1
- package/lib/rtp/src/extra/processor/ntpTime.js +4 -6
- package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/ogg.d.ts +72 -0
- package/lib/rtp/src/extra/processor/ogg.js +221 -0
- package/lib/rtp/src/extra/processor/ogg.js.map +1 -0
- package/lib/rtp/src/extra/processor/oggCallback.d.ts +21 -0
- package/lib/rtp/src/extra/processor/oggCallback.js +97 -0
- package/lib/rtp/src/extra/processor/oggCallback.js.map +1 -0
- package/lib/rtp/src/extra/processor/rtpCallback.js +2 -1
- package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpStream.js +2 -1
- package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpTime.js +2 -1
- package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/webm.js +14 -7
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/index.d.ts +8 -0
- package/lib/rtp/src/index.js +8 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.js +8 -4
- package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.d.ts +58 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js +143 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +35 -13
- package/lib/rtp/src/rtcp/rtpfb/twcc.js +132 -54
- package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.d.ts +13 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js +29 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.d.ts +41 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js +89 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js.map +1 -0
- package/lib/rtp/src/rtcp/sr.js +1 -0
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +49 -0
- package/lib/rtp/src/rtp/continuity.js +120 -0
- package/lib/rtp/src/rtp/continuity.js.map +1 -0
- package/lib/rtp/src/rtp/headerExtension.js +41 -21
- package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
- package/lib/rtp/src/rtp/padding.d.ts +17 -0
- package/lib/rtp/src/rtp/padding.js +37 -0
- package/lib/rtp/src/rtp/padding.js.map +1 -0
- package/lib/rtp/src/rtp/red/encoder.d.ts +10 -0
- package/lib/rtp/src/rtp/red/encoder.js +14 -1
- package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
- package/lib/rtp/src/rtp/red/packet.js +24 -8
- package/lib/rtp/src/rtp/red/packet.js.map +1 -1
- package/lib/rtp/src/rtp/rtp.d.ts +24 -1
- package/lib/rtp/src/rtp/rtp.js +70 -29
- package/lib/rtp/src/rtp/rtp.js.map +1 -1
- package/lib/rtp/src/rtp/rtx.js +3 -0
- package/lib/rtp/src/rtp/rtx.js.map +1 -1
- package/lib/rtp/src/rtp/sendHeaderExtensions.d.ts +36 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js +85 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js.map +1 -0
- package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
- package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
- package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
- package/lib/rtp/src/srtp/cipher/ctr.js +4 -2
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/index.js +8 -4
- package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
- package/lib/rtp/src/srtp/context/context.js +6 -3
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtcp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtcp.js +33 -0
- package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtp.js +34 -10
- package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
- package/lib/rtp/src/srtp/error.d.ts +8 -0
- package/lib/rtp/src/srtp/error.js +13 -1
- package/lib/rtp/src/srtp/error.js.map +1 -1
- package/lib/rtp/src/srtp/packet.js +4 -1
- package/lib/rtp/src/srtp/packet.js.map +1 -1
- package/lib/rtp/src/srtp/replay.d.ts +24 -0
- package/lib/rtp/src/srtp/replay.js +75 -0
- package/lib/rtp/src/srtp/replay.js.map +1 -0
- package/lib/rtp/src/srtp/session.js +2 -1
- package/lib/rtp/src/srtp/session.js.map +1 -1
- package/lib/rtp/src/srtp/srtcp.js +2 -1
- package/lib/rtp/src/srtp/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/srtp.js +2 -1
- package/lib/rtp/src/srtp/srtp.js.map +1 -1
- package/lib/rtp/src/util.js +2 -1
- package/lib/rtp/src/util.js.map +1 -1
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +31 -8
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/const.d.ts +25 -17
- package/lib/sctp/src/const.js +23 -19
- package/lib/sctp/src/const.js.map +1 -1
- package/lib/sctp/src/param.d.ts +6 -2
- package/lib/sctp/src/param.js +22 -8
- package/lib/sctp/src/param.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +85 -0
- package/lib/sctp/src/sctp.js +707 -126
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/sctp/src/transport.js +4 -2
- package/lib/sctp/src/transport.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +385 -28
- package/lib/webrtc/src/api/peerConfig.js +121 -14
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +77 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +10 -0
- package/lib/webrtc/src/dataChannel.js +24 -4
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/helper.d.ts +8 -0
- package/lib/webrtc/src/helper.js +40 -4
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
- package/lib/webrtc/src/media/codecCompatibility.js +338 -12
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/index.d.ts +10 -0
- package/lib/webrtc/src/media/index.js +70 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +246 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +61 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +218 -63
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +241 -40
- package/lib/webrtc/src/media/router.js +676 -205
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
- package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
- package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
- package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
- package/lib/webrtc/src/media/routing/routeTable.js +95 -0
- package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
- package/lib/webrtc/src/media/rtpReceiver.d.ts +252 -2
- package/lib/webrtc/src/media/rtpReceiver.js +833 -44
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +191 -70
- package/lib/webrtc/src/media/rtpSender.js +631 -448
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +19 -3
- package/lib/webrtc/src/media/rtpTransceiver.js +74 -9
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/bandwidthEstimator.d.ts +249 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js +144 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.d.ts +20 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js +26 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.d.ts +70 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js +175 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.d.ts +18 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js +44 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.d.ts +79 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js +289 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.d.ts +87 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js +429 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.d.ts +21 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js +84 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.d.ts +37 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js +74 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.d.ts +383 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js +408 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.d.ts +406 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js +1391 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.d.ts +19 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js +75 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.d.ts +68 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js +201 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js +72 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.d.ts +41 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js +99 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.d.ts +247 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js +1042 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js +132 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.d.ts +305 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js +1073 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.d.ts +60 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js +151 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.d.ts +44 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js +246 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/index.d.ts +7 -0
- package/lib/webrtc/src/media/sender/estimators/index.js +19 -0
- package/lib/webrtc/src/media/sender/estimators/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.d.ts +64 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js +216 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.d.ts +117 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js +250 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js.map +1 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.d.ts +40 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js +153 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js.map +1 -0
- package/lib/webrtc/src/media/sender/padding.d.ts +45 -0
- package/lib/webrtc/src/media/sender/padding.js +134 -0
- package/lib/webrtc/src/media/sender/padding.js.map +1 -0
- package/lib/webrtc/src/media/sender/pendingRtp.d.ts +35 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js +120 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js.map +1 -0
- package/lib/webrtc/src/media/sender/rtpWire.d.ts +13 -0
- package/lib/webrtc/src/media/sender/rtpWire.js +38 -0
- package/lib/webrtc/src/media/sender/rtpWire.js.map +1 -0
- package/lib/webrtc/src/media/sender/sendPacer.d.ts +27 -0
- package/lib/webrtc/src/media/sender/sendPacer.js +110 -0
- package/lib/webrtc/src/media/sender/sendPacer.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderBWE.d.ts +8 -33
- package/lib/webrtc/src/media/sender/senderBWE.js +5 -154
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderStats.d.ts +101 -0
- package/lib/webrtc/src/media/sender/senderStats.js +317 -0
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
- package/lib/webrtc/src/media/track.d.ts +29 -2
- package/lib/webrtc/src/media/track.js +32 -5
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/bundleTopology.d.ts +1 -5
- package/lib/webrtc/src/negotiation/bundleTopology.js +15 -11
- package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -1
- package/lib/webrtc/src/negotiation/descriptionValidation.js +12 -6
- package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -1
- package/lib/webrtc/src/negotiation/negotiationNeeded.js +2 -1
- package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js +10 -5
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +24 -7
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +67 -27
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +8 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +40 -8
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +43 -5
- package/lib/webrtc/src/negotiationTransaction.js +129 -13
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.js +4 -3
- package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.d.ts +32 -8
- package/lib/webrtc/src/nonstandard/recorder/index.js +81 -20
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +9 -7
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js +2 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.d.ts +32 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js +185 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js.map +1 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +8 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +108 -6
- package/lib/webrtc/src/peerConnection.js +357 -36
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +2 -1
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +2 -0
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +2 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +46 -14
- package/lib/webrtc/src/sctpManager.js +92 -25
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +69 -0
- package/lib/webrtc/src/sdp.js +151 -20
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +85 -4
- package/lib/webrtc/src/sdpManager.js +214 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +89 -4
- package/lib/webrtc/src/secureTransportManager.js +184 -26
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +82 -4
- package/lib/webrtc/src/transceiverManager.js +239 -41
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +147 -1
- package/lib/webrtc/src/transport/dtls.js +446 -50
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +71 -90
- package/lib/webrtc/src/transport/ice.js +250 -42
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +25 -0
- package/lib/webrtc/src/transport/sctp.js +153 -22
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +69 -3
- package/lib/webrtc/src/utils.js +105 -16
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +9 -6
package/lib/sctp/src/sctp.js
CHANGED
|
@@ -60,6 +60,8 @@ const SCTPConnectionStates = [
|
|
|
60
60
|
"connected",
|
|
61
61
|
"connecting",
|
|
62
62
|
];
|
|
63
|
+
/** Shared empty payload of abandoned DATA chunks. */
|
|
64
|
+
const EMPTY_PAYLOAD = Buffer.alloc(0);
|
|
63
65
|
class SCTP {
|
|
64
66
|
get peerRwnd() {
|
|
65
67
|
// RFC 9260 §6.2.1(D-ii): available receiver window = a_rwnd - outstanding DATA.
|
|
@@ -70,13 +72,13 @@ class SCTP {
|
|
|
70
72
|
enumerable: true,
|
|
71
73
|
configurable: true,
|
|
72
74
|
writable: true,
|
|
73
|
-
value:
|
|
75
|
+
value: void 0
|
|
74
76
|
});
|
|
75
77
|
Object.defineProperty(this, "port", {
|
|
76
78
|
enumerable: true,
|
|
77
79
|
configurable: true,
|
|
78
80
|
writable: true,
|
|
79
|
-
value:
|
|
81
|
+
value: void 0
|
|
80
82
|
});
|
|
81
83
|
Object.defineProperty(this, "flush", {
|
|
82
84
|
enumerable: true,
|
|
@@ -145,6 +147,13 @@ class SCTP {
|
|
|
145
147
|
writable: true,
|
|
146
148
|
value: false
|
|
147
149
|
});
|
|
150
|
+
/** An INIT from the peer was accepted (answered with INIT_ACK). */
|
|
151
|
+
Object.defineProperty(this, "receivedInit", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
configurable: true,
|
|
154
|
+
writable: true,
|
|
155
|
+
value: false
|
|
156
|
+
});
|
|
148
157
|
Object.defineProperty(this, "hmacKey", {
|
|
149
158
|
enumerable: true,
|
|
150
159
|
configurable: true,
|
|
@@ -303,12 +312,19 @@ class SCTP {
|
|
|
303
312
|
writable: true,
|
|
304
313
|
value: false
|
|
305
314
|
});
|
|
315
|
+
/** FORWARD-TSN kept until the peer's SACK covers it, so a lost one can be resent. */
|
|
306
316
|
Object.defineProperty(this, "forwardTsnChunk", {
|
|
307
317
|
enumerable: true,
|
|
308
318
|
configurable: true,
|
|
309
319
|
writable: true,
|
|
310
320
|
value: void 0
|
|
311
321
|
});
|
|
322
|
+
Object.defineProperty(this, "forwardTsnPending", {
|
|
323
|
+
enumerable: true,
|
|
324
|
+
configurable: true,
|
|
325
|
+
writable: true,
|
|
326
|
+
value: false
|
|
327
|
+
});
|
|
312
328
|
Object.defineProperty(this, "flightSize", {
|
|
313
329
|
enumerable: true,
|
|
314
330
|
configurable: true,
|
|
@@ -375,6 +391,20 @@ class SCTP {
|
|
|
375
391
|
writable: true,
|
|
376
392
|
value: new common_1.FifoQueue()
|
|
377
393
|
});
|
|
394
|
+
/** Gap-acked or reneged chunks that still need SACK reneging checks. */
|
|
395
|
+
Object.defineProperty(this, "renegingCandidateCount", {
|
|
396
|
+
enumerable: true,
|
|
397
|
+
configurable: true,
|
|
398
|
+
writable: true,
|
|
399
|
+
value: 0
|
|
400
|
+
});
|
|
401
|
+
/** Chunks marked for retransmission; zero avoids scanning sentQueue on each SACK. */
|
|
402
|
+
Object.defineProperty(this, "retransmitCount", {
|
|
403
|
+
enumerable: true,
|
|
404
|
+
configurable: true,
|
|
405
|
+
writable: true,
|
|
406
|
+
value: 0
|
|
407
|
+
});
|
|
378
408
|
Object.defineProperty(this, "transmitting", {
|
|
379
409
|
enumerable: true,
|
|
380
410
|
configurable: true,
|
|
@@ -414,6 +444,31 @@ class SCTP {
|
|
|
414
444
|
writable: true,
|
|
415
445
|
value: []
|
|
416
446
|
});
|
|
447
|
+
/** Result returned for the incoming request reconfigResponseSeq; resent to a retransmitted request. */
|
|
448
|
+
Object.defineProperty(this, "lastReconfigResult", {
|
|
449
|
+
enumerable: true,
|
|
450
|
+
configurable: true,
|
|
451
|
+
writable: true,
|
|
452
|
+
value: void 0
|
|
453
|
+
});
|
|
454
|
+
/** The peer answered our outstanding reset request with In progress (RFC 6525 §5.2.7). */
|
|
455
|
+
Object.defineProperty(this, "reconfigRequestInProgress", {
|
|
456
|
+
enumerable: true,
|
|
457
|
+
configurable: true,
|
|
458
|
+
writable: true,
|
|
459
|
+
value: false
|
|
460
|
+
});
|
|
461
|
+
/**
|
|
462
|
+
* RFC 6525 §5.2.2 deferred reset: an incoming Outgoing SSN Reset Request whose
|
|
463
|
+
* Sender's Last Assigned TSN has not been received yet. DATA for the reset
|
|
464
|
+
* streams beyond lastTsn belongs to the new streams and is held until the reset.
|
|
465
|
+
*/
|
|
466
|
+
Object.defineProperty(this, "deferredReset", {
|
|
467
|
+
enumerable: true,
|
|
468
|
+
configurable: true,
|
|
469
|
+
writable: true,
|
|
470
|
+
value: void 0
|
|
471
|
+
});
|
|
417
472
|
// rtt calculation
|
|
418
473
|
Object.defineProperty(this, "srtt", {
|
|
419
474
|
enumerable: true,
|
|
@@ -479,6 +534,23 @@ class SCTP {
|
|
|
479
534
|
writable: true,
|
|
480
535
|
value: void 0
|
|
481
536
|
});
|
|
537
|
+
/**
|
|
538
|
+
* Fires at the earliest expiry of a message in outboundQueue, so expired
|
|
539
|
+
* messages are abandoned even if nothing else (SACK, window update, send)
|
|
540
|
+
* runs transmit.
|
|
541
|
+
*/
|
|
542
|
+
Object.defineProperty(this, "outboundExpiryHandle", {
|
|
543
|
+
enumerable: true,
|
|
544
|
+
configurable: true,
|
|
545
|
+
writable: true,
|
|
546
|
+
value: void 0
|
|
547
|
+
});
|
|
548
|
+
Object.defineProperty(this, "outboundExpiryAt", {
|
|
549
|
+
enumerable: true,
|
|
550
|
+
configurable: true,
|
|
551
|
+
writable: true,
|
|
552
|
+
value: void 0
|
|
553
|
+
});
|
|
482
554
|
/**Re-configuration Timer */
|
|
483
555
|
Object.defineProperty(this, "timerReconfigHandle", {
|
|
484
556
|
enumerable: true,
|
|
@@ -547,6 +619,8 @@ class SCTP {
|
|
|
547
619
|
for (const chunk of chunks) {
|
|
548
620
|
this.outboundQueue.push(chunk);
|
|
549
621
|
}
|
|
622
|
+
if (expiry !== undefined)
|
|
623
|
+
this.armOutboundExpiry(expiry);
|
|
550
624
|
if (ordered) {
|
|
551
625
|
this.outboundStreamSeq[streamId] = (0, common_1.uint16Add)(streamSeqNum, 1);
|
|
552
626
|
}
|
|
@@ -624,21 +698,63 @@ class SCTP {
|
|
|
624
698
|
return;
|
|
625
699
|
this.timer3Handle = undefined;
|
|
626
700
|
// # mark retransmit or abandoned chunks
|
|
701
|
+
// RFC 9260 §6.3.3 (E3): only outstanding chunks; gap-acked ones are kept
|
|
702
|
+
// for reneging but not retransmitted.
|
|
627
703
|
this.sentQueue.forEach((chunk) => {
|
|
704
|
+
if (chunk.acked || chunk.abandoned)
|
|
705
|
+
return;
|
|
628
706
|
if (!this.maybeAbandon(chunk)) {
|
|
629
|
-
chunk
|
|
707
|
+
this.setRetransmitPending(chunk, true);
|
|
630
708
|
}
|
|
709
|
+
this.flightSizeDecrease(chunk);
|
|
631
710
|
});
|
|
632
711
|
this.updateAdvancedPeerAckPoint();
|
|
712
|
+
// An unacknowledged FORWARD-TSN may have been lost; resend it.
|
|
713
|
+
if (this.forwardTsnChunk) {
|
|
714
|
+
this.forwardTsnPending = true;
|
|
715
|
+
}
|
|
633
716
|
// # adjust congestion window
|
|
634
717
|
this.fastRecoveryExit = undefined;
|
|
635
|
-
this.flightSize = 0;
|
|
636
718
|
this.partialBytesAcked = 0;
|
|
637
719
|
this.ssthresh = Math.max(Math.floor(this.cwnd / 2), 4 * this.maxPayloadSize);
|
|
638
720
|
this.cwnd = this.maxPayloadSize;
|
|
639
721
|
this.transmit();
|
|
640
722
|
}
|
|
641
723
|
});
|
|
724
|
+
/**
|
|
725
|
+
* Abandons every expired message still in outboundQueue, wherever it is.
|
|
726
|
+
* Chunks stay in place so TSN order is kept: transmit() moves them to
|
|
727
|
+
* sentQueue unsent when they reach the head, and FORWARD-TSN skips them.
|
|
728
|
+
* Their send() resolves now, without waiting for earlier messages.
|
|
729
|
+
*/
|
|
730
|
+
Object.defineProperty(this, "outboundExpiryExpired", {
|
|
731
|
+
enumerable: true,
|
|
732
|
+
configurable: true,
|
|
733
|
+
writable: true,
|
|
734
|
+
value: () => {
|
|
735
|
+
this.outboundExpiryHandle = undefined;
|
|
736
|
+
this.outboundExpiryAt = undefined;
|
|
737
|
+
if (this.isStopped)
|
|
738
|
+
return;
|
|
739
|
+
let nextExpiry;
|
|
740
|
+
for (const chunk of this.outboundQueue) {
|
|
741
|
+
if (chunk.abandoned || chunk.expiry === undefined)
|
|
742
|
+
continue;
|
|
743
|
+
if (this.isExpired(chunk)) {
|
|
744
|
+
this.markAbandoned(chunk);
|
|
745
|
+
this.resolveSendWaiterOutOfOrder(chunk);
|
|
746
|
+
}
|
|
747
|
+
else if (nextExpiry === undefined || chunk.expiry < nextExpiry) {
|
|
748
|
+
nextExpiry = chunk.expiry;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (nextExpiry !== undefined)
|
|
752
|
+
this.armOutboundExpiry(nextExpiry);
|
|
753
|
+
this.transmit().catch((err) => {
|
|
754
|
+
log("transmit on outbound expiry failed", err.message);
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
});
|
|
642
758
|
Object.defineProperty(this, "timerReconfigHandleExpired", {
|
|
643
759
|
enumerable: true,
|
|
644
760
|
configurable: true,
|
|
@@ -646,9 +762,13 @@ class SCTP {
|
|
|
646
762
|
value: async () => {
|
|
647
763
|
if (this.isStopped)
|
|
648
764
|
return;
|
|
649
|
-
|
|
765
|
+
// RFC 6525 §5.2.7: no error count while the peer reports In progress.
|
|
766
|
+
if (this.reconfigRequestInProgress)
|
|
767
|
+
this.timerReconfigFailures = 0;
|
|
768
|
+
else
|
|
769
|
+
this.timerReconfigFailures++;
|
|
650
770
|
// back off
|
|
651
|
-
this.rto = Math.ceil(this.rto * 1.5);
|
|
771
|
+
this.rto = Math.min(Math.ceil(this.rto * 1.5), SCTP_RTO_MAX);
|
|
652
772
|
if (this.timerReconfigFailures > SCTP_MAX_ASSOCIATION_RETRANS) {
|
|
653
773
|
log("timerReconfigFailures", this.timerReconfigFailures);
|
|
654
774
|
this.setState(const_1.SCTP_STATE.CLOSED);
|
|
@@ -683,6 +803,8 @@ class SCTP {
|
|
|
683
803
|
this.heartbeatStart();
|
|
684
804
|
}
|
|
685
805
|
});
|
|
806
|
+
this.transport = transport;
|
|
807
|
+
this.port = port;
|
|
686
808
|
this.mtu = options.mtu ?? exports.DEFAULT_SCTP_MTU;
|
|
687
809
|
validateSctpMtu(this.mtu);
|
|
688
810
|
this.maxPayloadSize = maxPayloadSizeForMtu(this.mtu);
|
|
@@ -722,7 +844,14 @@ class SCTP {
|
|
|
722
844
|
if (chunks.length != 1) {
|
|
723
845
|
throw new Error();
|
|
724
846
|
}
|
|
725
|
-
|
|
847
|
+
// RFC 9260 §8.5.1 (A): an INIT carries verification tag 0. An older
|
|
848
|
+
// werift (<= 0.26) that answered our INIT before its own start() then
|
|
849
|
+
// sends its INIT with the tag it learned from ours; only a peer that
|
|
850
|
+
// received our INIT knows that tag, so accept it as well.
|
|
851
|
+
expectedTag =
|
|
852
|
+
verificationTag === this.localVerificationTag
|
|
853
|
+
? this.localVerificationTag
|
|
854
|
+
: 0;
|
|
726
855
|
}
|
|
727
856
|
else {
|
|
728
857
|
expectedTag = this.localVerificationTag;
|
|
@@ -734,6 +863,9 @@ class SCTP {
|
|
|
734
863
|
for (const chunk of chunks) {
|
|
735
864
|
await this.receiveChunk(chunk);
|
|
736
865
|
}
|
|
866
|
+
// Messages of this packet are delivered by now, so the last message before
|
|
867
|
+
// the reset boundary reaches onReceive before onReconfigStreams.
|
|
868
|
+
await this.maybePerformDeferredReset();
|
|
737
869
|
if (this.sackNeeded) {
|
|
738
870
|
// RFC 9260 delayed ACK guidance is per packet ("every second packet").
|
|
739
871
|
if (this.sackHasNewDataInPacket) {
|
|
@@ -775,8 +907,8 @@ class SCTP {
|
|
|
775
907
|
return;
|
|
776
908
|
const gaps = [];
|
|
777
909
|
let gapNext;
|
|
778
|
-
|
|
779
|
-
const pos = (
|
|
910
|
+
sortTsns(this.sackMisOrdered, this.lastReceivedTsn).forEach((tsn) => {
|
|
911
|
+
const pos = tsnDistance(this.lastReceivedTsn, tsn);
|
|
780
912
|
if (tsn === gapNext) {
|
|
781
913
|
gaps[gaps.length - 1][1] = pos;
|
|
782
914
|
}
|
|
@@ -807,12 +939,28 @@ class SCTP {
|
|
|
807
939
|
break;
|
|
808
940
|
case chunk_1.InitChunk.type:
|
|
809
941
|
{
|
|
810
|
-
|
|
942
|
+
// RFC 9260 §5.2.1: an initiator that receives the peer's INIT in
|
|
943
|
+
// COOKIE-WAIT / COOKIE-ECHOED (both sides sent INIT) answers it
|
|
944
|
+
// with an INIT_ACK.
|
|
945
|
+
if (!this.isServer && !this.isInitiating)
|
|
811
946
|
return;
|
|
812
947
|
const init = chunk;
|
|
948
|
+
this.receivedInit = true;
|
|
813
949
|
log("receive init", init);
|
|
814
|
-
|
|
815
|
-
|
|
950
|
+
// Take the peer's initial TSN only before the handshake got past
|
|
951
|
+
// it (CLOSED / COOKIE-WAIT). In COOKIE-ECHOED our INIT_ACK handling
|
|
952
|
+
// already took it, and once ESTABLISHED a delayed duplicate INIT
|
|
953
|
+
// must not rewind the cumulative TSN of DATA received since.
|
|
954
|
+
// A different initiate tag is a restarted peer: start its TSNs over.
|
|
955
|
+
if (this.associationState === const_1.SCTP_STATE.CLOSED ||
|
|
956
|
+
this.associationState === const_1.SCTP_STATE.COOKIE_WAIT ||
|
|
957
|
+
init.initiateTag !== this.remoteVerificationTag) {
|
|
958
|
+
this.lastReceivedTsn = tsnMinusOne(init.initialTsn);
|
|
959
|
+
this.reconfigResponseSeq = tsnMinusOne(init.initialTsn);
|
|
960
|
+
// Reset requests of the previous TSN space no longer apply.
|
|
961
|
+
this.lastReconfigResult = undefined;
|
|
962
|
+
this.deferredReset = undefined;
|
|
963
|
+
}
|
|
816
964
|
this.remoteVerificationTag = init.initiateTag;
|
|
817
965
|
this.ssthresh = init.advertisedRwnd;
|
|
818
966
|
this.peerAdvertisedRwnd = init.advertisedRwnd;
|
|
@@ -863,11 +1011,14 @@ class SCTP {
|
|
|
863
1011
|
break;
|
|
864
1012
|
}
|
|
865
1013
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
1014
|
+
// Enter COOKIE_ECHOED and arm T1 before handing the chunk off: a
|
|
1015
|
+
// duplicate INIT_ACK or an early COOKIE_ACK during the send must see
|
|
1016
|
+
// the new state, and a failed send is packet loss that T1 recovers.
|
|
869
1017
|
this.timer1Start(echo);
|
|
870
1018
|
this.setState(const_1.SCTP_STATE.COOKIE_ECHOED);
|
|
1019
|
+
await this.sendChunk(echo).catch((err) => {
|
|
1020
|
+
log("send echo failed; T1 retransmits", err.message);
|
|
1021
|
+
});
|
|
871
1022
|
}
|
|
872
1023
|
break;
|
|
873
1024
|
case chunk_1.SackChunk.type:
|
|
@@ -912,8 +1063,14 @@ class SCTP {
|
|
|
912
1063
|
break;
|
|
913
1064
|
case chunk_1.CookieEchoChunk.type:
|
|
914
1065
|
{
|
|
915
|
-
|
|
1066
|
+
// An initiator accepts the COOKIE_ECHO that follows its INIT_ACK
|
|
1067
|
+
// to a colliding INIT (RFC 9260 §5.2.1).
|
|
1068
|
+
if (!this.isServer &&
|
|
1069
|
+
!(this.receivedInit &&
|
|
1070
|
+
(this.isInitiating ||
|
|
1071
|
+
this.associationState === const_1.SCTP_STATE.ESTABLISHED))) {
|
|
916
1072
|
return;
|
|
1073
|
+
}
|
|
917
1074
|
const data = chunk;
|
|
918
1075
|
const cookie = data.body;
|
|
919
1076
|
const digest = (0, crypto_1.createHmac)("sha1", this.hmacKey)
|
|
@@ -938,10 +1095,20 @@ class SCTP {
|
|
|
938
1095
|
return;
|
|
939
1096
|
}
|
|
940
1097
|
const ack = new chunk_1.CookieAckChunk();
|
|
941
|
-
|
|
942
|
-
|
|
1098
|
+
// Our own INIT / COOKIE_ECHO (collision) is superseded by the
|
|
1099
|
+
// association the peer's cookie established.
|
|
1100
|
+
this.timer1Cancel();
|
|
1101
|
+
// RFC 9260 §5.1 (D): move to ESTABLISHED when replying. Hand off the
|
|
1102
|
+
// COOKIE_ACK first so it precedes DATA flushed by the connected
|
|
1103
|
+
// event. A failed send is packet loss: the initiator retransmits
|
|
1104
|
+
// COOKIE_ECHO and this association (same cookie key) answers again.
|
|
1105
|
+
const sending = this.sendChunk(ack).catch((err) => {
|
|
1106
|
+
log("send cookieAck failed; peer retransmits", err.message);
|
|
943
1107
|
});
|
|
944
|
-
this.
|
|
1108
|
+
if (this.associationState !== const_1.SCTP_STATE.ESTABLISHED) {
|
|
1109
|
+
this.setState(const_1.SCTP_STATE.ESTABLISHED);
|
|
1110
|
+
}
|
|
1111
|
+
await sending;
|
|
945
1112
|
}
|
|
946
1113
|
break;
|
|
947
1114
|
case chunk_1.CookieAckChunk.type:
|
|
@@ -996,47 +1163,30 @@ class SCTP {
|
|
|
996
1163
|
switch (param.type) {
|
|
997
1164
|
case param_1.OutgoingSSNResetRequestParam.type:
|
|
998
1165
|
{
|
|
999
|
-
|
|
1000
|
-
// # send response
|
|
1001
|
-
const response = new param_1.ReconfigResponseParam(p.requestSequence, param_1.reconfigResult.ReconfigResultSuccessPerformed);
|
|
1002
|
-
this.reconfigResponseSeq = p.requestSequence;
|
|
1003
|
-
await this.sendReconfigParam(response);
|
|
1004
|
-
// # mark closed inbound streams
|
|
1005
|
-
await Promise.all(p.streams.map(async (streamId) => {
|
|
1006
|
-
delete this.inboundStreams[streamId];
|
|
1007
|
-
if (this.outboundStreamSeq[streamId]) {
|
|
1008
|
-
// Only add to reconfigQueue if not already present
|
|
1009
|
-
if (!this.reconfigQueue.includes(streamId)) {
|
|
1010
|
-
this.reconfigQueue.push(streamId);
|
|
1011
|
-
}
|
|
1012
|
-
// await this.sendResetRequest(streamId);
|
|
1013
|
-
}
|
|
1014
|
-
}));
|
|
1015
|
-
await this.transmitReconfigRequest();
|
|
1016
|
-
// # close data channel
|
|
1017
|
-
this.onReconfigStreams.execute(p.streams);
|
|
1166
|
+
await this.receiveOutgoingSSNResetRequest(param);
|
|
1018
1167
|
}
|
|
1019
1168
|
break;
|
|
1020
1169
|
case param_1.ReconfigResponseParam.type:
|
|
1021
1170
|
{
|
|
1022
1171
|
const reset = param;
|
|
1023
|
-
|
|
1172
|
+
const isCurrentRequest = reset.responseSequence === this.reconfigRequest?.requestSequence;
|
|
1173
|
+
if (reset.result === param_1.reconfigResult.InProgress) {
|
|
1174
|
+
if (isCurrentRequest) {
|
|
1175
|
+
// The peer deferred the reset (RFC 6525 §5.2.2). Keep the request so the
|
|
1176
|
+
// Re-configuration timer retransmits it; the peer answered, so this is
|
|
1177
|
+
// not a reachability failure.
|
|
1178
|
+
log("OutgoingSSNResetRequestParam in progress");
|
|
1179
|
+
this.reconfigRequestInProgress = true;
|
|
1180
|
+
// RFC 6525 §5.2.7 H2: restart the timer for this request.
|
|
1181
|
+
this.timerReconfigCancel();
|
|
1182
|
+
this.timerReconfigHandleStart();
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
else if (reset.result !== param_1.reconfigResult.ReconfigResultSuccessPerformed) {
|
|
1024
1186
|
log("OutgoingSSNResetRequestParam failed", Object.keys(param_1.reconfigResult).find((key) => param_1.reconfigResult[key] === reset.result));
|
|
1025
1187
|
}
|
|
1026
|
-
else if (
|
|
1027
|
-
|
|
1028
|
-
delete this.outboundStreamSeq[streamId];
|
|
1029
|
-
return streamId;
|
|
1030
|
-
});
|
|
1031
|
-
this.onReconfigStreams.execute(streamIds);
|
|
1032
|
-
this.reconfigRequest = undefined;
|
|
1033
|
-
this.timerReconfigCancel();
|
|
1034
|
-
// Reset RTO backoff on successful reconfiguration
|
|
1035
|
-
this.rto = SCTP_RTO_INITIAL;
|
|
1036
|
-
this.timerReconfigFailures = 0;
|
|
1037
|
-
if (this.reconfigQueue.length > 0) {
|
|
1038
|
-
await this.transmitReconfigRequest();
|
|
1039
|
-
}
|
|
1188
|
+
else if (isCurrentRequest) {
|
|
1189
|
+
await this.completeOutgoingReset();
|
|
1040
1190
|
}
|
|
1041
1191
|
}
|
|
1042
1192
|
break;
|
|
@@ -1044,13 +1194,143 @@ class SCTP {
|
|
|
1044
1194
|
{
|
|
1045
1195
|
const add = param;
|
|
1046
1196
|
this._inboundStreamsCount += add.newStreams;
|
|
1047
|
-
const res = new param_1.ReconfigResponseParam(add.requestSequence,
|
|
1197
|
+
const res = new param_1.ReconfigResponseParam(add.requestSequence, param_1.reconfigResult.ReconfigResultSuccessPerformed);
|
|
1048
1198
|
this.reconfigResponseSeq = add.requestSequence;
|
|
1199
|
+
this.lastReconfigResult = res.result;
|
|
1049
1200
|
await this.sendReconfigParam(res);
|
|
1050
1201
|
}
|
|
1051
1202
|
break;
|
|
1052
1203
|
}
|
|
1053
1204
|
}
|
|
1205
|
+
/** The peer answered our outstanding reset request with Success - Performed. */
|
|
1206
|
+
async completeOutgoingReset() {
|
|
1207
|
+
const streamIds = this.reconfigRequest.streams.map((streamId) => {
|
|
1208
|
+
delete this.outboundStreamSeq[streamId];
|
|
1209
|
+
return streamId;
|
|
1210
|
+
});
|
|
1211
|
+
this.onReconfigStreams.execute(streamIds);
|
|
1212
|
+
this.reconfigRequest = undefined;
|
|
1213
|
+
this.reconfigRequestInProgress = false;
|
|
1214
|
+
this.timerReconfigCancel();
|
|
1215
|
+
// Reset RTO backoff on successful reconfiguration
|
|
1216
|
+
this.rto = SCTP_RTO_INITIAL;
|
|
1217
|
+
this.timerReconfigFailures = 0;
|
|
1218
|
+
if (this.reconfigQueue.length > 0) {
|
|
1219
|
+
await this.transmitReconfigRequest();
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
/** RFC 6525 §4.1: an empty stream list means every stream. */
|
|
1223
|
+
resetTargetStreams(request) {
|
|
1224
|
+
if (request.streams.length > 0)
|
|
1225
|
+
return request.streams;
|
|
1226
|
+
return [
|
|
1227
|
+
...new Set([
|
|
1228
|
+
...Object.keys(this.inboundStreams).map(Number),
|
|
1229
|
+
...Object.keys(this.outboundStreamSeq).map(Number),
|
|
1230
|
+
]),
|
|
1231
|
+
];
|
|
1232
|
+
}
|
|
1233
|
+
/** RFC 6525 §5.2.1 sequence check, then §5.2.2 immediate or deferred reset. */
|
|
1234
|
+
async receiveOutgoingSSNResetRequest(request) {
|
|
1235
|
+
const respond = (result) => this.sendReconfigParam(new param_1.ReconfigResponseParam(request.requestSequence, result));
|
|
1236
|
+
if (request.requestSequence === this.reconfigResponseSeq) {
|
|
1237
|
+
// Retransmission of an already processed request: resend the same result.
|
|
1238
|
+
await respond(this.lastReconfigResult ?? param_1.reconfigResult.BadSequenceNumber);
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
// Only one request is deferred at a time, so it is the expected one.
|
|
1242
|
+
const pending = this.deferredReset;
|
|
1243
|
+
const expected = pending
|
|
1244
|
+
? pending.request.requestSequence
|
|
1245
|
+
: tsnPlusOne(this.reconfigResponseSeq);
|
|
1246
|
+
if (request.requestSequence !== expected) {
|
|
1247
|
+
await respond(param_1.reconfigResult.BadSequenceNumber);
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
// RFC 6525 §5.2.2 E1: the peer has received our outstanding request. The
|
|
1251
|
+
// reset itself completes only with the peer's response, and that response
|
|
1252
|
+
// may be lost, so keep retransmitting the request (the peer answers a
|
|
1253
|
+
// retransmission with the same result) instead of stopping the timer. The
|
|
1254
|
+
// peer is reachable, so like In progress the expiries are not failures.
|
|
1255
|
+
if (this.reconfigRequest &&
|
|
1256
|
+
request.responseSequence === this.reconfigRequest.requestSequence) {
|
|
1257
|
+
this.reconfigRequestInProgress = true;
|
|
1258
|
+
this.timerReconfigCancel();
|
|
1259
|
+
this.timerReconfigHandleStart();
|
|
1260
|
+
}
|
|
1261
|
+
const target = pending?.request ?? request;
|
|
1262
|
+
if (!this.reachedResetBoundary(target)) {
|
|
1263
|
+
// Some DATA up to Sender's Last Assigned TSN is still missing. A
|
|
1264
|
+
// retransmitted request is evaluated again, so reconfigResponseSeq stays.
|
|
1265
|
+
this.deferredReset ?? (this.deferredReset = { request: target, heldChunks: [] });
|
|
1266
|
+
await respond(param_1.reconfigResult.InProgress);
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
const { transmitReverseReset } = this.performIncomingStreamReset(target);
|
|
1270
|
+
await respond(param_1.reconfigResult.ReconfigResultSuccessPerformed);
|
|
1271
|
+
await transmitReverseReset();
|
|
1272
|
+
}
|
|
1273
|
+
reachedResetBoundary(request) {
|
|
1274
|
+
return (this.lastReceivedTsn !== undefined &&
|
|
1275
|
+
(0, common_1.uint32Gte)(this.lastReceivedTsn, request.lastTsn));
|
|
1276
|
+
}
|
|
1277
|
+
async maybePerformDeferredReset() {
|
|
1278
|
+
const pending = this.deferredReset;
|
|
1279
|
+
if (!pending || !this.reachedResetBoundary(pending.request))
|
|
1280
|
+
return;
|
|
1281
|
+
// RFC 6525 §5.2.2: answer Success - Performed once the deferred reset is done.
|
|
1282
|
+
const { transmitReverseReset } = this.performIncomingStreamReset(pending.request);
|
|
1283
|
+
await this.sendReconfigParam(new param_1.ReconfigResponseParam(pending.request.requestSequence, param_1.reconfigResult.ReconfigResultSuccessPerformed));
|
|
1284
|
+
await transmitReverseReset();
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Resets the inbound streams of `request` synchronously, so no DATA received
|
|
1288
|
+
* while awaiting can reach the old streams. Returns the asynchronous part,
|
|
1289
|
+
* the reset of our own outgoing streams.
|
|
1290
|
+
*/
|
|
1291
|
+
performIncomingStreamReset(request) {
|
|
1292
|
+
const heldChunks = this.deferredReset?.request === request
|
|
1293
|
+
? this.deferredReset.heldChunks
|
|
1294
|
+
: [];
|
|
1295
|
+
this.deferredReset = undefined;
|
|
1296
|
+
this.reconfigResponseSeq = request.requestSequence;
|
|
1297
|
+
this.lastReconfigResult = param_1.reconfigResult.ReconfigResultSuccessPerformed;
|
|
1298
|
+
const resetStreams = this.resetTargetStreams(request);
|
|
1299
|
+
for (const streamId of resetStreams) {
|
|
1300
|
+
const inboundStream = this.inboundStreams[streamId];
|
|
1301
|
+
if (inboundStream) {
|
|
1302
|
+
// Incomplete messages of the old stream are discarded.
|
|
1303
|
+
for (const chunk of inboundStream.reassembly) {
|
|
1304
|
+
this.advertisedRwnd += chunk.userData.length;
|
|
1305
|
+
}
|
|
1306
|
+
delete this.inboundStreams[streamId];
|
|
1307
|
+
}
|
|
1308
|
+
if (this.outboundStreamSeq[streamId]) {
|
|
1309
|
+
// Only add to reconfigQueue if not already present
|
|
1310
|
+
if (!this.reconfigQueue.includes(streamId)) {
|
|
1311
|
+
this.reconfigQueue.push(streamId);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
// # close data channel
|
|
1316
|
+
this.onReconfigStreams.execute(resetStreams);
|
|
1317
|
+
// DATA beyond the boundary belongs to the reset streams (SSN starts at 0).
|
|
1318
|
+
const streamIds = new Set();
|
|
1319
|
+
for (const chunk of heldChunks) {
|
|
1320
|
+
this.getInboundStream(chunk.streamId).addChunk(chunk);
|
|
1321
|
+
streamIds.add(chunk.streamId);
|
|
1322
|
+
}
|
|
1323
|
+
for (const streamId of streamIds) {
|
|
1324
|
+
this.deliverMessages(this.getInboundStream(streamId));
|
|
1325
|
+
}
|
|
1326
|
+
return { transmitReverseReset: () => this.transmitReconfigRequest() };
|
|
1327
|
+
}
|
|
1328
|
+
deliverMessages(inboundStream) {
|
|
1329
|
+
for (const message of inboundStream.popMessages()) {
|
|
1330
|
+
this.advertisedRwnd += message[2].length;
|
|
1331
|
+
this.receive(...message);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1054
1334
|
receiveDataChunk(chunk) {
|
|
1055
1335
|
this.sackNeeded = true;
|
|
1056
1336
|
if (this.markReceived(chunk.tsn)) {
|
|
@@ -1068,13 +1348,19 @@ class SCTP {
|
|
|
1068
1348
|
// RFC 9260 permits immediate SACK on gap/loss indicators.
|
|
1069
1349
|
this.sackImmediate = true;
|
|
1070
1350
|
}
|
|
1071
|
-
const inboundStream = this.getInboundStream(chunk.streamId);
|
|
1072
|
-
inboundStream.addChunk(chunk);
|
|
1073
1351
|
this.advertisedRwnd -= chunk.userData.length;
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1352
|
+
const pending = this.deferredReset;
|
|
1353
|
+
if (pending &&
|
|
1354
|
+
(pending.request.streams.length === 0 ||
|
|
1355
|
+
pending.request.streams.includes(chunk.streamId)) &&
|
|
1356
|
+
(0, common_1.uint32Gt)(chunk.tsn, pending.request.lastTsn)) {
|
|
1357
|
+
// RFC 6525 §5.2.2: hold DATA for the new stream until the reset is performed.
|
|
1358
|
+
pending.heldChunks.push(chunk);
|
|
1359
|
+
return;
|
|
1077
1360
|
}
|
|
1361
|
+
const inboundStream = this.getInboundStream(chunk.streamId);
|
|
1362
|
+
inboundStream.addChunk(chunk);
|
|
1363
|
+
this.deliverMessages(inboundStream);
|
|
1078
1364
|
}
|
|
1079
1365
|
async receiveSackChunk(chunk) {
|
|
1080
1366
|
// """
|
|
@@ -1091,18 +1377,23 @@ class SCTP {
|
|
|
1091
1377
|
(0, common_1.uint32Gte)(this.lastSackedTsn, this.sentQueue.peek().tsn)) {
|
|
1092
1378
|
const sChunk = this.sentQueue.shift();
|
|
1093
1379
|
done++;
|
|
1094
|
-
|
|
1380
|
+
this.setRetransmitPending(sChunk, false);
|
|
1381
|
+
if (!sChunk.abandoned && (sChunk.acked || sChunk.reneged)) {
|
|
1382
|
+
this.renegingCandidateCount--;
|
|
1383
|
+
}
|
|
1384
|
+
if (!sChunk.acked) {
|
|
1095
1385
|
doneBytes += sChunk.bookSize;
|
|
1096
|
-
this.flightSizeDecrease(sChunk);
|
|
1097
1386
|
}
|
|
1387
|
+
this.flightSizeDecrease(sChunk);
|
|
1098
1388
|
if (done === 1 && sChunk.sentCount === 1) {
|
|
1099
1389
|
this.updateRto(receivedTime - sChunk.sentTime);
|
|
1100
1390
|
}
|
|
1101
1391
|
}
|
|
1102
1392
|
// # handle gap blocks
|
|
1103
1393
|
let loss = false;
|
|
1394
|
+
const seen = new Set();
|
|
1395
|
+
let highestNewlyAcked = chunk.cumulativeTsn;
|
|
1104
1396
|
if (chunk.gaps.length > 0) {
|
|
1105
|
-
const seen = new Set();
|
|
1106
1397
|
let highestSeenTsn;
|
|
1107
1398
|
chunk.gaps.forEach((gap) => {
|
|
1108
1399
|
for (let pos = gap[0]; pos < gap[1] + 1; pos++) {
|
|
@@ -1110,34 +1401,58 @@ class SCTP {
|
|
|
1110
1401
|
seen.add(highestSeenTsn);
|
|
1111
1402
|
}
|
|
1112
1403
|
});
|
|
1113
|
-
let highestNewlyAcked = chunk.cumulativeTsn;
|
|
1114
1404
|
for (const sChunk of this.sentQueue) {
|
|
1115
1405
|
if ((0, common_1.uint32Gt)(sChunk.tsn, highestSeenTsn)) {
|
|
1116
1406
|
break;
|
|
1117
1407
|
}
|
|
1118
1408
|
if (seen.has(sChunk.tsn) && !sChunk.acked) {
|
|
1409
|
+
if (!sChunk.abandoned && !sChunk.reneged) {
|
|
1410
|
+
this.renegingCandidateCount++;
|
|
1411
|
+
}
|
|
1119
1412
|
doneBytes += sChunk.bookSize;
|
|
1120
1413
|
sChunk.acked = true;
|
|
1414
|
+
sChunk.reneged = false;
|
|
1415
|
+
// A pending retransmission is moot once the peer holds the chunk.
|
|
1416
|
+
this.setRetransmitPending(sChunk, false);
|
|
1121
1417
|
this.flightSizeDecrease(sChunk);
|
|
1122
1418
|
highestNewlyAcked = sChunk.tsn;
|
|
1123
1419
|
}
|
|
1124
1420
|
}
|
|
1125
|
-
|
|
1421
|
+
}
|
|
1422
|
+
// # detect reneging (RFC 9260 6.2.1 D-iii)
|
|
1423
|
+
// A chunk gap-acked before but missing from this SACK was dropped by the
|
|
1424
|
+
// peer: it is outstanding again, and every SACK still missing it counts one
|
|
1425
|
+
// miss indication towards Fast Retransmit. Chunks up to HTNA are struck by
|
|
1426
|
+
// the loop below, so only the ones beyond it are struck here.
|
|
1427
|
+
let reneged = false;
|
|
1428
|
+
if (this.renegingCandidateCount > 0) {
|
|
1429
|
+
for (const sChunk of this.sentQueue) {
|
|
1430
|
+
// Abandoned chunks are never retransmitted nor counted in flight again.
|
|
1431
|
+
if (seen.has(sChunk.tsn) || sChunk.abandoned)
|
|
1432
|
+
continue;
|
|
1433
|
+
if (sChunk.acked) {
|
|
1434
|
+
sChunk.acked = false;
|
|
1435
|
+
sChunk.reneged = true;
|
|
1436
|
+
// Outstanding again, so it is counted in flight until resent or acked.
|
|
1437
|
+
this.flightSizeIncrease(sChunk);
|
|
1438
|
+
}
|
|
1439
|
+
if (!sChunk.reneged)
|
|
1440
|
+
continue;
|
|
1441
|
+
reneged = true;
|
|
1442
|
+
if (!sChunk.retransmit &&
|
|
1443
|
+
(chunk.gaps.length === 0 || (0, common_1.uint32Gt)(sChunk.tsn, highestNewlyAcked))) {
|
|
1444
|
+
loss = this.strikeChunk(sChunk) || loss;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
// # strike missing chunks prior to HTNA
|
|
1449
|
+
if (chunk.gaps.length > 0) {
|
|
1126
1450
|
for (const sChunk of this.sentQueue) {
|
|
1127
1451
|
if ((0, common_1.uint32Gt)(sChunk.tsn, highestNewlyAcked)) {
|
|
1128
1452
|
break;
|
|
1129
1453
|
}
|
|
1130
1454
|
if (!seen.has(sChunk.tsn)) {
|
|
1131
|
-
sChunk
|
|
1132
|
-
if (sChunk.misses === 3) {
|
|
1133
|
-
sChunk.misses = 0;
|
|
1134
|
-
if (!this.maybeAbandon(sChunk)) {
|
|
1135
|
-
sChunk.retransmit = true;
|
|
1136
|
-
}
|
|
1137
|
-
sChunk.acked = false;
|
|
1138
|
-
this.flightSizeDecrease(sChunk);
|
|
1139
|
-
loss = true;
|
|
1140
|
-
}
|
|
1455
|
+
loss = this.strikeChunk(sChunk) || loss;
|
|
1141
1456
|
}
|
|
1142
1457
|
}
|
|
1143
1458
|
}
|
|
@@ -1172,9 +1487,13 @@ class SCTP {
|
|
|
1172
1487
|
else if (done > 0) {
|
|
1173
1488
|
this.timer3Restart();
|
|
1174
1489
|
}
|
|
1490
|
+
else if (reneged && !this.timer3Handle) {
|
|
1491
|
+
this.timer3Start();
|
|
1492
|
+
}
|
|
1175
1493
|
// RFC 9260 §6.2.1(D-ii): keep latest peer a_rwnd; available window is derived via flightSize.
|
|
1176
1494
|
this.peerAdvertisedRwnd = chunk.advertisedRwnd;
|
|
1177
1495
|
this.updateAdvancedPeerAckPoint();
|
|
1496
|
+
this.settleForwardTsn(chunk.cumulativeTsn);
|
|
1178
1497
|
await this.onSackReceived();
|
|
1179
1498
|
await this.transmit();
|
|
1180
1499
|
}
|
|
@@ -1188,7 +1507,7 @@ class SCTP {
|
|
|
1188
1507
|
// # advance cumulative TSN
|
|
1189
1508
|
this.lastReceivedTsn = chunk.cumulativeTsn;
|
|
1190
1509
|
this.sackMisOrdered = new Set([...this.sackMisOrdered].filter(isObsolete));
|
|
1191
|
-
for (const tsn of
|
|
1510
|
+
for (const tsn of sortTsns(this.sackMisOrdered, this.lastReceivedTsn)) {
|
|
1192
1511
|
if (tsn === tsnPlusOne(this.lastReceivedTsn)) {
|
|
1193
1512
|
this.lastReceivedTsn = tsn;
|
|
1194
1513
|
}
|
|
@@ -1199,20 +1518,31 @@ class SCTP {
|
|
|
1199
1518
|
// # filter out obsolete entries
|
|
1200
1519
|
this.sackDuplicates = this.sackDuplicates.filter(isObsolete);
|
|
1201
1520
|
this.sackMisOrdered = new Set([...this.sackMisOrdered].filter(isObsolete));
|
|
1202
|
-
// # update reassembly
|
|
1521
|
+
// # update reassembly (RFC 3758 3.6)
|
|
1203
1522
|
for (const [streamId, streamSeqNum] of chunk.streams) {
|
|
1204
1523
|
const inboundStream = this.getInboundStream(streamId);
|
|
1205
|
-
// #
|
|
1206
|
-
|
|
1207
|
-
|
|
1524
|
+
// # deliver stranded complete messages, drop broken ones, then advance
|
|
1525
|
+
const { messages, prunedSize } = inboundStream.forwardSequenceNumber(streamSeqNum);
|
|
1526
|
+
this.advertisedRwnd += prunedSize;
|
|
1527
|
+
for (const message of [...messages, ...inboundStream.popMessages()]) {
|
|
1208
1528
|
this.advertisedRwnd += message[2].length;
|
|
1209
1529
|
this.receive(...message);
|
|
1210
1530
|
}
|
|
1211
1531
|
}
|
|
1212
|
-
// #
|
|
1213
|
-
Object.values(this.inboundStreams)
|
|
1214
|
-
this.advertisedRwnd += inboundStream.
|
|
1215
|
-
}
|
|
1532
|
+
// # unordered chunks covered by the cumulative TSN will never complete
|
|
1533
|
+
for (const inboundStream of Object.values(this.inboundStreams)) {
|
|
1534
|
+
this.advertisedRwnd += inboundStream.pruneUnorderedChunks(chunk.cumulativeTsn);
|
|
1535
|
+
}
|
|
1536
|
+
const pending = this.deferredReset;
|
|
1537
|
+
if (pending) {
|
|
1538
|
+
pending.heldChunks = pending.heldChunks.filter((held) => {
|
|
1539
|
+
// Only DATA the FORWARD-TSN skipped is dropped; later received DATA stays.
|
|
1540
|
+
if ((0, common_1.uint32Gt)(held.tsn, chunk.cumulativeTsn))
|
|
1541
|
+
return true;
|
|
1542
|
+
this.advertisedRwnd += held.userData.length;
|
|
1543
|
+
return false;
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1216
1546
|
}
|
|
1217
1547
|
updateRto(R) {
|
|
1218
1548
|
if (!this.srtt) {
|
|
@@ -1242,7 +1572,7 @@ class SCTP {
|
|
|
1242
1572
|
return true;
|
|
1243
1573
|
}
|
|
1244
1574
|
this.sackMisOrdered.add(tsn);
|
|
1245
|
-
for (const tsn of
|
|
1575
|
+
for (const tsn of sortTsns(this.sackMisOrdered, this.lastReceivedTsn)) {
|
|
1246
1576
|
if (tsn === tsnPlusOne(this.lastReceivedTsn)) {
|
|
1247
1577
|
this.lastReceivedTsn = tsn;
|
|
1248
1578
|
}
|
|
@@ -1256,8 +1586,24 @@ class SCTP {
|
|
|
1256
1586
|
return false;
|
|
1257
1587
|
}
|
|
1258
1588
|
resolveSendWaiters(sentChunk) {
|
|
1589
|
+
this.dropDoneSendWaiters();
|
|
1259
1590
|
if (this.sendWaiters.peek()?.chunk === sentChunk) {
|
|
1260
1591
|
this.sendWaiters.shift().resolve();
|
|
1592
|
+
this.dropDoneSendWaiters();
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
dropDoneSendWaiters() {
|
|
1596
|
+
while (this.sendWaiters.peek()?.done)
|
|
1597
|
+
this.sendWaiters.shift();
|
|
1598
|
+
}
|
|
1599
|
+
/** Resolves the send() of an expired queued message ahead of earlier ones (rare, O(n)). */
|
|
1600
|
+
resolveSendWaiterOutOfOrder(chunk) {
|
|
1601
|
+
for (const waiter of this.sendWaiters) {
|
|
1602
|
+
if (waiter.chunk === chunk && !waiter.done) {
|
|
1603
|
+
waiter.done = true;
|
|
1604
|
+
waiter.resolve();
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1261
1607
|
}
|
|
1262
1608
|
}
|
|
1263
1609
|
/** Settles every pending send() so no caller is left waiting after close. */
|
|
@@ -1293,11 +1639,11 @@ class SCTP {
|
|
|
1293
1639
|
// Transmit outbound data.
|
|
1294
1640
|
// """
|
|
1295
1641
|
// # send FORWARD TSN
|
|
1296
|
-
if (this.forwardTsnChunk) {
|
|
1642
|
+
if (this.forwardTsnChunk && this.forwardTsnPending) {
|
|
1643
|
+
this.forwardTsnPending = false;
|
|
1297
1644
|
await this.sendChunk(this.forwardTsnChunk).catch((err) => {
|
|
1298
1645
|
log("send forwardTsn failed", err.message);
|
|
1299
1646
|
});
|
|
1300
|
-
this.forwardTsnChunk = undefined;
|
|
1301
1647
|
if (!this.timer3Handle) {
|
|
1302
1648
|
this.timer3Start();
|
|
1303
1649
|
}
|
|
@@ -1306,33 +1652,59 @@ class SCTP {
|
|
|
1306
1652
|
? 2 * this.maxPayloadSize
|
|
1307
1653
|
: 4 * this.maxPayloadSize;
|
|
1308
1654
|
const cwnd = Math.min(this.flightSize + burstSize, this.cwnd);
|
|
1655
|
+
// Set when expired data is abandoned here, so the FORWARD-TSN goes out.
|
|
1656
|
+
let abandoned = false;
|
|
1309
1657
|
let retransmitEarliest = true;
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
1658
|
+
if (this.retransmitCount > 0) {
|
|
1659
|
+
for (const dataChunk of this.sentQueue) {
|
|
1660
|
+
if (dataChunk.retransmit && (dataChunk.acked || dataChunk.abandoned)) {
|
|
1661
|
+
// Acked or abandoned after being marked; nothing to resend.
|
|
1662
|
+
this.setRetransmitPending(dataChunk, false);
|
|
1314
1663
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1664
|
+
if (dataChunk.retransmit) {
|
|
1665
|
+
// The lifetime may have run out while the chunk waited for cwnd.
|
|
1666
|
+
if (this.isExpired(dataChunk) && this.maybeAbandon(dataChunk)) {
|
|
1667
|
+
abandoned = true;
|
|
1668
|
+
continue;
|
|
1669
|
+
}
|
|
1670
|
+
if (this.fastRecoveryTransmit) {
|
|
1671
|
+
this.fastRecoveryTransmit = false;
|
|
1672
|
+
}
|
|
1673
|
+
else if (this.flightSize >= cwnd) {
|
|
1674
|
+
break;
|
|
1675
|
+
}
|
|
1676
|
+
this.flightSizeIncrease(dataChunk);
|
|
1677
|
+
dataChunk.misses = 0;
|
|
1678
|
+
this.setRetransmitPending(dataChunk, false);
|
|
1679
|
+
dataChunk.reneged = false;
|
|
1680
|
+
dataChunk.sentCount++;
|
|
1681
|
+
await this.sendChunk(dataChunk).catch((err) => {
|
|
1682
|
+
log("send data failed", err.message);
|
|
1683
|
+
});
|
|
1684
|
+
if (retransmitEarliest) {
|
|
1685
|
+
this.timer3Restart();
|
|
1686
|
+
}
|
|
1327
1687
|
}
|
|
1688
|
+
retransmitEarliest = false;
|
|
1328
1689
|
}
|
|
1329
|
-
retransmitEarliest = false;
|
|
1330
1690
|
}
|
|
1331
1691
|
// Drain queued outbound DATA; retransmission pacing is controlled by RTO/T3.
|
|
1332
|
-
while (this.outboundQueue.length > 0
|
|
1333
|
-
this.flightSize < cwnd &&
|
|
1334
|
-
this.peerRwnd > 0) {
|
|
1692
|
+
while (this.outboundQueue.length > 0) {
|
|
1335
1693
|
const chunk = this.outboundQueue.peek();
|
|
1694
|
+
// A message that expired while waiting for cwnd/rwnd is never sent; its
|
|
1695
|
+
// TSNs are already assigned, so it is abandoned and skipped by FORWARD-TSN.
|
|
1696
|
+
// A message the expiry timer already abandoned in place goes the same way.
|
|
1697
|
+
if (chunk.abandoned || this.isExpired(chunk)) {
|
|
1698
|
+
this.outboundQueue.shift();
|
|
1699
|
+
this.sentQueue.push(chunk);
|
|
1700
|
+
this.resolveSendWaiters(chunk);
|
|
1701
|
+
this.abandonMessage(this.sentQueue.length - 1);
|
|
1702
|
+
abandoned = true;
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
1705
|
+
if (this.flightSize >= cwnd || this.peerRwnd <= 0) {
|
|
1706
|
+
break;
|
|
1707
|
+
}
|
|
1336
1708
|
if (chunk.bookSize > this.peerRwnd && this.flightSize > 0) {
|
|
1337
1709
|
break;
|
|
1338
1710
|
}
|
|
@@ -1350,6 +1722,14 @@ class SCTP {
|
|
|
1350
1722
|
this.timer3Start();
|
|
1351
1723
|
}
|
|
1352
1724
|
}
|
|
1725
|
+
if (abandoned) {
|
|
1726
|
+
this.updateAdvancedPeerAckPoint();
|
|
1727
|
+
// Send the FORWARD-TSN in the next round of transmit().
|
|
1728
|
+
if (this.forwardTsnPending)
|
|
1729
|
+
this.transmitRequested = true;
|
|
1730
|
+
}
|
|
1731
|
+
if (this.outboundQueue.length === 0)
|
|
1732
|
+
this.outboundExpiryCancel();
|
|
1353
1733
|
this.flush.execute();
|
|
1354
1734
|
}
|
|
1355
1735
|
async transmitReconfigRequest() {
|
|
@@ -1363,6 +1743,7 @@ class SCTP {
|
|
|
1363
1743
|
const param = new param_1.OutgoingSSNResetRequestParam(this.reconfigRequestSeq, this.reconfigResponseSeq, tsnMinusOne(this.localTsn), streams);
|
|
1364
1744
|
this.reconfigRequestSeq = tsnPlusOne(this.reconfigRequestSeq);
|
|
1365
1745
|
this.reconfigRequest = param;
|
|
1746
|
+
this.reconfigRequestInProgress = false;
|
|
1366
1747
|
await this.sendReconfigParam(param);
|
|
1367
1748
|
this.timerReconfigHandleStart();
|
|
1368
1749
|
}
|
|
@@ -1385,11 +1766,26 @@ class SCTP {
|
|
|
1385
1766
|
await this.transmit();
|
|
1386
1767
|
}
|
|
1387
1768
|
}
|
|
1769
|
+
// flightSize always equals the bookSize sum of inFlight chunks in sentQueue,
|
|
1770
|
+
// so both helpers are idempotent per chunk.
|
|
1388
1771
|
flightSizeIncrease(chunk) {
|
|
1772
|
+
if (chunk.inFlight)
|
|
1773
|
+
return;
|
|
1774
|
+
chunk.inFlight = true;
|
|
1389
1775
|
this.flightSize += chunk.bookSize;
|
|
1390
1776
|
}
|
|
1777
|
+
/** No-op for chunks not counted in flightSize, so every exit path can call it. */
|
|
1391
1778
|
flightSizeDecrease(chunk) {
|
|
1392
|
-
|
|
1779
|
+
if (!chunk.inFlight)
|
|
1780
|
+
return;
|
|
1781
|
+
chunk.inFlight = false;
|
|
1782
|
+
this.flightSize -= chunk.bookSize;
|
|
1783
|
+
}
|
|
1784
|
+
setRetransmitPending(chunk, pending) {
|
|
1785
|
+
if (chunk.retransmit === pending)
|
|
1786
|
+
return;
|
|
1787
|
+
chunk.retransmit = pending;
|
|
1788
|
+
this.retransmitCount += pending ? 1 : -1;
|
|
1393
1789
|
}
|
|
1394
1790
|
// # timers
|
|
1395
1791
|
/**t1 is wait for initAck or cookieAck */
|
|
@@ -1438,6 +1834,25 @@ class SCTP {
|
|
|
1438
1834
|
// RFC 9260 requires restarting T3-rtx with current RTO (seconds -> JS ms).
|
|
1439
1835
|
this.timer3Handle = setTimeout(this.timer3Expired, this.rto * 1000);
|
|
1440
1836
|
}
|
|
1837
|
+
/** Arms the outbound expiry timer for `expiry` unless an earlier one is armed. */
|
|
1838
|
+
armOutboundExpiry(expiry) {
|
|
1839
|
+
if (this.isStopped)
|
|
1840
|
+
return;
|
|
1841
|
+
if (this.outboundExpiryHandle && this.outboundExpiryAt <= expiry)
|
|
1842
|
+
return;
|
|
1843
|
+
this.outboundExpiryCancel();
|
|
1844
|
+
this.outboundExpiryAt = expiry;
|
|
1845
|
+
this.outboundExpiryHandle = setTimeout(this.outboundExpiryExpired,
|
|
1846
|
+
// setTimeout overflows above 2^31 - 1 ms; a later expiry re-arms on fire.
|
|
1847
|
+
Math.min(Math.max(0, expiry - Date.now()), 0x7fffffff));
|
|
1848
|
+
}
|
|
1849
|
+
outboundExpiryCancel() {
|
|
1850
|
+
if (this.outboundExpiryHandle) {
|
|
1851
|
+
clearTimeout(this.outboundExpiryHandle);
|
|
1852
|
+
this.outboundExpiryHandle = undefined;
|
|
1853
|
+
}
|
|
1854
|
+
this.outboundExpiryAt = undefined;
|
|
1855
|
+
}
|
|
1441
1856
|
timer3Cancel() {
|
|
1442
1857
|
if (this.timer3Handle) {
|
|
1443
1858
|
clearTimeout(this.timer3Handle);
|
|
@@ -1488,14 +1903,30 @@ class SCTP {
|
|
|
1488
1903
|
this.heartbeatInterval = interval;
|
|
1489
1904
|
this.heartbeatRestart();
|
|
1490
1905
|
}
|
|
1906
|
+
/** Drops the FORWARD-TSN once acknowledged; otherwise keeps T3 running to resend it. */
|
|
1907
|
+
settleForwardTsn(sackedTsn) {
|
|
1908
|
+
if (!this.forwardTsnChunk)
|
|
1909
|
+
return;
|
|
1910
|
+
if ((0, common_1.uint32Gte)(sackedTsn, this.forwardTsnChunk.cumulativeTsn)) {
|
|
1911
|
+
this.forwardTsnChunk = undefined;
|
|
1912
|
+
this.forwardTsnPending = false;
|
|
1913
|
+
if (this.sentQueue.length === 0)
|
|
1914
|
+
this.timer3Cancel();
|
|
1915
|
+
}
|
|
1916
|
+
else if (!this.timer3Handle) {
|
|
1917
|
+
this.timer3Start();
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1491
1920
|
updateAdvancedPeerAckPoint() {
|
|
1492
1921
|
if ((0, common_1.uint32Gt)(this.lastSackedTsn, this.advancedPeerAckTsn)) {
|
|
1493
1922
|
this.advancedPeerAckTsn = this.lastSackedTsn;
|
|
1494
1923
|
}
|
|
1495
1924
|
let done = 0;
|
|
1496
|
-
|
|
1925
|
+
// Carry over streams of an unacknowledged FORWARD-TSN that this one replaces.
|
|
1926
|
+
const streams = Object.fromEntries(this.forwardTsnChunk?.streams ?? []);
|
|
1497
1927
|
while (this.sentQueue.length > 0 && this.sentQueue.peek().abandoned) {
|
|
1498
1928
|
const chunk = this.sentQueue.shift();
|
|
1929
|
+
this.flightSizeDecrease(chunk);
|
|
1499
1930
|
this.advancedPeerAckTsn = chunk.tsn;
|
|
1500
1931
|
done++;
|
|
1501
1932
|
if (!(chunk.flags & SCTP_DATA_UNORDERED)) {
|
|
@@ -1503,6 +1934,7 @@ class SCTP {
|
|
|
1503
1934
|
}
|
|
1504
1935
|
}
|
|
1505
1936
|
if (done) {
|
|
1937
|
+
this.forwardTsnPending = true;
|
|
1506
1938
|
this.forwardTsnChunk = new chunk_1.ForwardTsnChunk(0, undefined);
|
|
1507
1939
|
this.forwardTsnChunk.cumulativeTsn = this.advancedPeerAckTsn;
|
|
1508
1940
|
this.forwardTsnChunk.streams = Object.entries(streams).map(([k, v]) => [
|
|
@@ -1514,28 +1946,83 @@ class SCTP {
|
|
|
1514
1946
|
maybeAbandon(chunk) {
|
|
1515
1947
|
if (chunk.abandoned)
|
|
1516
1948
|
return true;
|
|
1949
|
+
// The peer already holds an acked chunk (gap SACK); abandoning it would
|
|
1950
|
+
// make the FORWARD-TSN discard data the receiver could deliver.
|
|
1951
|
+
if (chunk.acked)
|
|
1952
|
+
return false;
|
|
1517
1953
|
const abandon = (!!chunk.maxRetransmits && chunk.maxRetransmits < chunk.sentCount) ||
|
|
1518
|
-
(
|
|
1954
|
+
this.isExpired(chunk);
|
|
1519
1955
|
if (!abandon)
|
|
1520
1956
|
return false;
|
|
1521
|
-
const chunkPos = this.sentQueue.findIndex((v) => v
|
|
1957
|
+
const chunkPos = this.sentQueue.findIndex((v) => v === chunk);
|
|
1958
|
+
if (chunkPos < 0)
|
|
1959
|
+
return false;
|
|
1960
|
+
this.abandonMessage(chunkPos);
|
|
1961
|
+
return true;
|
|
1962
|
+
}
|
|
1963
|
+
/** Counts a miss indication; on the third, marks the chunk for Fast Retransmit (or abandons it). */
|
|
1964
|
+
strikeChunk(chunk) {
|
|
1965
|
+
chunk.misses++;
|
|
1966
|
+
if (chunk.misses < 3)
|
|
1967
|
+
return false;
|
|
1968
|
+
chunk.misses = 0;
|
|
1969
|
+
if (!this.maybeAbandon(chunk)) {
|
|
1970
|
+
this.setRetransmitPending(chunk, true);
|
|
1971
|
+
}
|
|
1972
|
+
chunk.acked = false;
|
|
1973
|
+
this.flightSizeDecrease(chunk);
|
|
1974
|
+
return true;
|
|
1975
|
+
}
|
|
1976
|
+
isExpired(chunk) {
|
|
1977
|
+
return chunk.expiry !== undefined && chunk.expiry <= Date.now();
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
1980
|
+
* An abandoned chunk is never sent or retransmitted again, so its payload is
|
|
1981
|
+
* released; bookSize and the TSN / stream metadata FORWARD-TSN needs stay.
|
|
1982
|
+
*/
|
|
1983
|
+
markAbandoned(chunk) {
|
|
1984
|
+
if (!chunk.abandoned && (chunk.acked || chunk.reneged)) {
|
|
1985
|
+
this.renegingCandidateCount--;
|
|
1986
|
+
}
|
|
1987
|
+
chunk.abandoned = true;
|
|
1988
|
+
this.setRetransmitPending(chunk, false);
|
|
1989
|
+
chunk.userData = EMPTY_PAYLOAD;
|
|
1990
|
+
}
|
|
1991
|
+
/** Marks every fragment of the message at sentQueue[chunkPos] abandoned. */
|
|
1992
|
+
abandonMessage(chunkPos) {
|
|
1993
|
+
// Abandon the whole message: walk back to its first fragment and forward
|
|
1994
|
+
// to its last fragment (RFC 3758 3.5 A3).
|
|
1522
1995
|
for (let pos = chunkPos; pos >= 0; pos--) {
|
|
1523
1996
|
const oChunk = this.sentQueue.at(pos);
|
|
1524
|
-
oChunk
|
|
1525
|
-
oChunk
|
|
1526
|
-
if (oChunk.flags &
|
|
1997
|
+
this.markAbandoned(oChunk);
|
|
1998
|
+
this.flightSizeDecrease(oChunk);
|
|
1999
|
+
if (oChunk.flags & SCTP_DATA_FIRST_FRAG) {
|
|
1527
2000
|
break;
|
|
1528
2001
|
}
|
|
1529
2002
|
}
|
|
2003
|
+
let lastFragReached = false;
|
|
1530
2004
|
for (let pos = chunkPos; pos < this.sentQueue.length; pos++) {
|
|
1531
2005
|
const oChunk = this.sentQueue.at(pos);
|
|
1532
|
-
oChunk
|
|
1533
|
-
oChunk
|
|
2006
|
+
this.markAbandoned(oChunk);
|
|
2007
|
+
this.flightSizeDecrease(oChunk);
|
|
1534
2008
|
if (oChunk.flags & SCTP_DATA_LAST_FRAG) {
|
|
2009
|
+
lastFragReached = true;
|
|
1535
2010
|
break;
|
|
1536
2011
|
}
|
|
1537
2012
|
}
|
|
1538
|
-
|
|
2013
|
+
// The remaining fragments may still be waiting in outboundQueue (cwnd/rwnd
|
|
2014
|
+
// limited). Sending them would leave the receiver with a headless message,
|
|
2015
|
+
// so move them to sentQueue as abandoned without transmitting; they are then
|
|
2016
|
+
// covered by the FORWARD-TSN like the rest of the message.
|
|
2017
|
+
while (!lastFragReached && this.outboundQueue.length > 0) {
|
|
2018
|
+
const oChunk = this.outboundQueue.shift();
|
|
2019
|
+
this.markAbandoned(oChunk);
|
|
2020
|
+
this.sentQueue.push(oChunk);
|
|
2021
|
+
this.resolveSendWaiters(oChunk);
|
|
2022
|
+
if (oChunk.flags & SCTP_DATA_LAST_FRAG) {
|
|
2023
|
+
lastFragReached = true;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
1539
2026
|
}
|
|
1540
2027
|
static getCapabilities() {
|
|
1541
2028
|
return new RTCSctpCapabilities(65536);
|
|
@@ -1546,15 +2033,25 @@ class SCTP {
|
|
|
1546
2033
|
async start(remotePort) {
|
|
1547
2034
|
if (!this.started) {
|
|
1548
2035
|
this.started = true;
|
|
1549
|
-
|
|
2036
|
+
// Keep "connected" when the peer's INIT already established it.
|
|
2037
|
+
if (this.associationState !== const_1.SCTP_STATE.ESTABLISHED) {
|
|
2038
|
+
this.setConnectionState("connecting");
|
|
2039
|
+
}
|
|
1550
2040
|
if (remotePort) {
|
|
1551
2041
|
this.setRemotePort(remotePort);
|
|
1552
2042
|
}
|
|
1553
|
-
|
|
2043
|
+
// The peer's INIT may already have established the association
|
|
2044
|
+
// before start(); a new INIT would reset it.
|
|
2045
|
+
if (!this.isServer && this.associationState === const_1.SCTP_STATE.CLOSED) {
|
|
1554
2046
|
await this.init();
|
|
1555
2047
|
}
|
|
1556
2048
|
}
|
|
1557
2049
|
}
|
|
2050
|
+
/** Waiting for INIT_ACK / COOKIE_ACK of our own INIT. */
|
|
2051
|
+
get isInitiating() {
|
|
2052
|
+
return (this.associationState === const_1.SCTP_STATE.COOKIE_WAIT ||
|
|
2053
|
+
this.associationState === const_1.SCTP_STATE.COOKIE_ECHOED);
|
|
2054
|
+
}
|
|
1558
2055
|
async init() {
|
|
1559
2056
|
const init = new chunk_1.InitChunk();
|
|
1560
2057
|
init.initiateTag = this.localVerificationTag;
|
|
@@ -1564,14 +2061,17 @@ class SCTP {
|
|
|
1564
2061
|
init.initialTsn = this.localTsn;
|
|
1565
2062
|
this.setExtensions(init.params);
|
|
1566
2063
|
log("send init", init);
|
|
2064
|
+
// # start T1 timer and enter COOKIE-WAIT state
|
|
2065
|
+
// Before handing INIT off, so an INIT_ACK that arrives while the send is
|
|
2066
|
+
// still pending is not dropped by the COOKIE_WAIT guard, and a failed
|
|
2067
|
+
// send is packet loss that T1 retransmits (or closes after max retries).
|
|
2068
|
+
this.timer1Start(init);
|
|
2069
|
+
this.setState(const_1.SCTP_STATE.COOKIE_WAIT);
|
|
1567
2070
|
try {
|
|
1568
2071
|
await this.sendChunk(init);
|
|
1569
|
-
// # start T1 timer and enter COOKIE-WAIT state
|
|
1570
|
-
this.timer1Start(init);
|
|
1571
|
-
this.setState(const_1.SCTP_STATE.COOKIE_WAIT);
|
|
1572
2072
|
}
|
|
1573
2073
|
catch (error) {
|
|
1574
|
-
log("send init failed", error
|
|
2074
|
+
log("send init failed; T1 retransmits", error?.message);
|
|
1575
2075
|
}
|
|
1576
2076
|
}
|
|
1577
2077
|
setExtensions(params) {
|
|
@@ -1589,7 +2089,10 @@ class SCTP {
|
|
|
1589
2089
|
if (this.remotePort === undefined) {
|
|
1590
2090
|
throw new Error("invalid remote port");
|
|
1591
2091
|
}
|
|
1592
|
-
const packet = (0, chunk_1.serializePacket)(this.localPort, this.remotePort,
|
|
2092
|
+
const packet = (0, chunk_1.serializePacket)(this.localPort, this.remotePort,
|
|
2093
|
+
// RFC 9260 §8.5.1: INIT is always sent with verification tag 0, also
|
|
2094
|
+
// when an INIT answered before start() taught us the peer's tag.
|
|
2095
|
+
chunk.type === chunk_1.InitChunk.type ? 0 : this.remoteVerificationTag, chunk);
|
|
1593
2096
|
await this.transport.send(packet);
|
|
1594
2097
|
}
|
|
1595
2098
|
setState(state) {
|
|
@@ -1609,10 +2112,13 @@ class SCTP {
|
|
|
1609
2112
|
this.timer3Cancel();
|
|
1610
2113
|
this.timerReconfigCancel();
|
|
1611
2114
|
this.heartbeatCancel();
|
|
2115
|
+
this.outboundExpiryCancel();
|
|
1612
2116
|
if (this.sackTimeout) {
|
|
1613
2117
|
clearTimeout(this.sackTimeout);
|
|
1614
2118
|
this.sackTimeout = undefined;
|
|
1615
2119
|
}
|
|
2120
|
+
// Drop a deferred incoming stream reset and the DATA held for it.
|
|
2121
|
+
this.deferredReset = undefined;
|
|
1616
2122
|
this.setConnectionState("closed");
|
|
1617
2123
|
this.removeAllListeners();
|
|
1618
2124
|
this.releaseSendWaiters();
|
|
@@ -1641,6 +2147,7 @@ class SCTP {
|
|
|
1641
2147
|
clearTimeout(this.timer1Handle);
|
|
1642
2148
|
clearTimeout(this.timer2Handle);
|
|
1643
2149
|
clearTimeout(this.timer3Handle);
|
|
2150
|
+
this.outboundExpiryCancel();
|
|
1644
2151
|
clearTimeout(this.timerReconfigHandle);
|
|
1645
2152
|
clearTimeout(this.timerHeartbeatHandle);
|
|
1646
2153
|
clearTimeout(this.sackTimeout);
|
|
@@ -1716,8 +2223,8 @@ class InboundStream {
|
|
|
1716
2223
|
break;
|
|
1717
2224
|
}
|
|
1718
2225
|
else {
|
|
2226
|
+
// The partial message is broken; this chunk may start the next one.
|
|
1719
2227
|
startPos = undefined;
|
|
1720
|
-
pos++;
|
|
1721
2228
|
continue;
|
|
1722
2229
|
}
|
|
1723
2230
|
}
|
|
@@ -1739,8 +2246,12 @@ class InboundStream {
|
|
|
1739
2246
|
if (ordered && chunk.streamSeqNum === this.streamSequenceNumber) {
|
|
1740
2247
|
this.streamSequenceNumber = (0, common_1.uint16Add)(this.streamSequenceNumber, 1);
|
|
1741
2248
|
}
|
|
2249
|
+
// The next message starts at the removed one's position and need not
|
|
2250
|
+
// be TSN-contiguous with it, so restart the search there.
|
|
1742
2251
|
pos = startPos;
|
|
2252
|
+
startPos = undefined;
|
|
1743
2253
|
yield [chunk.streamId, chunk.protocol, userData];
|
|
2254
|
+
continue;
|
|
1744
2255
|
}
|
|
1745
2256
|
else {
|
|
1746
2257
|
pos++;
|
|
@@ -1748,6 +2259,67 @@ class InboundStream {
|
|
|
1748
2259
|
expectedTsn = tsnPlusOne(expectedTsn);
|
|
1749
2260
|
}
|
|
1750
2261
|
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Applies a FORWARD-TSN entry (RFC 3758 3.6): ordered messages with SSN up to
|
|
2264
|
+
* `ssn` are no longer waited for. Complete ones are returned for delivery in
|
|
2265
|
+
* order, incomplete ones are dropped, and the expected SSN moves past `ssn`
|
|
2266
|
+
* (never backwards, so a stale/duplicated entry is harmless).
|
|
2267
|
+
*/
|
|
2268
|
+
forwardSequenceNumber(ssn) {
|
|
2269
|
+
const messages = [];
|
|
2270
|
+
let prunedSize = 0;
|
|
2271
|
+
let fragments = [];
|
|
2272
|
+
const dropFragments = () => {
|
|
2273
|
+
for (const c of fragments)
|
|
2274
|
+
prunedSize += c.userData.length;
|
|
2275
|
+
fragments = [];
|
|
2276
|
+
};
|
|
2277
|
+
this.reassembly = this.reassembly.filter((chunk) => {
|
|
2278
|
+
if (chunk.flags & SCTP_DATA_UNORDERED ||
|
|
2279
|
+
(0, common_1.uint16Gt)(chunk.streamSeqNum, ssn)) {
|
|
2280
|
+
return true;
|
|
2281
|
+
}
|
|
2282
|
+
const prev = fragments[fragments.length - 1];
|
|
2283
|
+
if (chunk.flags & SCTP_DATA_FIRST_FRAG) {
|
|
2284
|
+
dropFragments();
|
|
2285
|
+
}
|
|
2286
|
+
else if (!prev ||
|
|
2287
|
+
chunk.tsn !== tsnPlusOne(prev.tsn) ||
|
|
2288
|
+
chunk.streamSeqNum !== prev.streamSeqNum) {
|
|
2289
|
+
dropFragments();
|
|
2290
|
+
prunedSize += chunk.userData.length;
|
|
2291
|
+
return false;
|
|
2292
|
+
}
|
|
2293
|
+
fragments.push(chunk);
|
|
2294
|
+
if (chunk.flags & SCTP_DATA_LAST_FRAG) {
|
|
2295
|
+
messages.push([
|
|
2296
|
+
chunk.streamId,
|
|
2297
|
+
chunk.protocol,
|
|
2298
|
+
Buffer.concat(fragments.map((c) => c.userData)),
|
|
2299
|
+
]);
|
|
2300
|
+
fragments = [];
|
|
2301
|
+
}
|
|
2302
|
+
return false;
|
|
2303
|
+
});
|
|
2304
|
+
dropFragments();
|
|
2305
|
+
const nextSsn = (0, common_1.uint16Add)(ssn, 1);
|
|
2306
|
+
if ((0, common_1.uint16Gt)(nextSsn, this.streamSequenceNumber)) {
|
|
2307
|
+
this.streamSequenceNumber = nextSsn;
|
|
2308
|
+
}
|
|
2309
|
+
return { messages, prunedSize };
|
|
2310
|
+
}
|
|
2311
|
+
/** Removes unordered chunks with TSN up to `tsn`. */
|
|
2312
|
+
pruneUnorderedChunks(tsn) {
|
|
2313
|
+
let size = 0;
|
|
2314
|
+
this.reassembly = this.reassembly.filter((chunk) => {
|
|
2315
|
+
if (chunk.flags & SCTP_DATA_UNORDERED && (0, common_1.uint32Gte)(tsn, chunk.tsn)) {
|
|
2316
|
+
size += chunk.userData.length;
|
|
2317
|
+
return false;
|
|
2318
|
+
}
|
|
2319
|
+
return true;
|
|
2320
|
+
});
|
|
2321
|
+
return size;
|
|
2322
|
+
}
|
|
1751
2323
|
pruneChunks(tsn) {
|
|
1752
2324
|
// """
|
|
1753
2325
|
// Prune chunks up to the given TSN.
|
|
@@ -1773,13 +2345,22 @@ class RTCSctpCapabilities {
|
|
|
1773
2345
|
enumerable: true,
|
|
1774
2346
|
configurable: true,
|
|
1775
2347
|
writable: true,
|
|
1776
|
-
value:
|
|
2348
|
+
value: void 0
|
|
1777
2349
|
});
|
|
2350
|
+
this.maxMessageSize = maxMessageSize;
|
|
1778
2351
|
}
|
|
1779
2352
|
}
|
|
1780
2353
|
exports.RTCSctpCapabilities = RTCSctpCapabilities;
|
|
1781
2354
|
function tsnMinusOne(a) {
|
|
1782
|
-
return (a - 1) % SCTP_TSN_MODULO;
|
|
2355
|
+
return (a - 1 + SCTP_TSN_MODULO) % SCTP_TSN_MODULO;
|
|
2356
|
+
}
|
|
2357
|
+
/** Serial-number distance from `base` to `tsn` (RFC 1982), 0..2^32-1. */
|
|
2358
|
+
function tsnDistance(base, tsn) {
|
|
2359
|
+
return (tsn - base + SCTP_TSN_MODULO) % SCTP_TSN_MODULO;
|
|
2360
|
+
}
|
|
2361
|
+
/** Sorts TSNs in serial-number order after `base`, so the order holds across a wrap. */
|
|
2362
|
+
function sortTsns(tsns, base) {
|
|
2363
|
+
return [...tsns].sort((a, b) => tsnDistance(base, a) - tsnDistance(base, b));
|
|
1783
2364
|
}
|
|
1784
2365
|
function tsnPlusOne(a) {
|
|
1785
2366
|
return (a + 1) % SCTP_TSN_MODULO;
|