-
-
Save ibc/17ed95cd2f08b84222c8820b034cd391 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
set -e | |
./node-sctp-mediasoup-test.js 1000 | |
./node-sctp-mediasoup-test.js 1300 | |
./node-sctp-mediasoup-test.js 5000 | |
HIGH_WATER_MARK=20000 ./node-sctp-mediasoup-test.js 20000 | |
NUM_MSG=2 HIGH_WATER_MARK=50000 ./node-sctp-mediasoup-test.js 50000 | |
PMTU=32000 NUM_MSG=3 HIGH_WATER_MARK=50000 ./node-sctp-mediasoup-test.js 50000 | |
HIGH_WATER_MARK=150000 TIMEOUT=2 ./node-sctp-mediasoup-test.js 150000 | |
# This fails. It seems (via tshark) that mediasoup does not send much bytes | |
# to the node-sctp receiving Socket. | |
PMTU=32000 HIGH_WATER_MARK=300000 TIMEOUT=3 ./node-sctp-mediasoup-test.js 300000 |
#!/usr/bin/env node | |
const dgram = require('dgram'); | |
const mediasoup = require('mediasoup'); | |
const sctp = require('sctp'); | |
if ([ '--help', '-h' ].includes(process.argv[2])) { | |
help(); | |
process.exit(0); | |
} | |
const MSG_SIZE = Number(process.argv[2]); | |
const NUM_MSG = Number(process.env.NUM_MSG) || 1; | |
const PMTU = Number(process.env.PMTU); | |
const RWND = Number(process.env.RWND); | |
const HIGH_WATER_MARK = Number(process.env.HIGH_WATER_MARK) || 16000; | |
const TIMEOUT = Number(process.env.TIMEOUT) || 1; | |
const SRC_IP = process.env.SCR_IP || '127.0.0.1'; | |
const DST_IP = process.env.DST_IP || '127.0.0.1'; | |
if (!MSG_SIZE) { | |
console.error('[ERROR]: missing MSG_SIZE command line argument'); | |
help(); | |
process.exit(1); | |
} | |
function help() { | |
console.log(''); | |
console.log('USAGE: [NUM_MSG=X] [PMTU=X] [RWND=X] [HIGH_WATER_MARK=X] [TIMEOUT=X] [SRC_IP=X] [DST_IP=X] ./node-sctp-mediasoup-test.js MSG_SIZE'); | |
console.log(''); | |
console.log(' Command line arguments:'); | |
console.log(' - MSG_SIZE : Size in bytes of the SCTP message to be sent (mandatory)'); | |
console.log(''); | |
console.log(' Environment variables:'); | |
console.log(' - NUM_MSG : Number of messages to send all together (default: 1)'); | |
console.log(' - PMTU : PMTU for node-sctp'); | |
console.log(' - RWND : RWND for node-sctp'); | |
console.log(' - HIGH_WATER_MARK : highWaterMark value for node-sctp Socket (default: 16000)'); | |
console.log(' - TIMEOUT : Time in seconds to wait for SCTP messages delivery (default: 1)'); | |
console.log(' - SRC_IP : IP of the sending mediasoup transport (default: "127.0.0.1")'); | |
console.log(' - DST_IP : IP of the receiving mediasoup transport (default: "127.0.0.1")'); | |
console.log(''); | |
} | |
run() | |
.then(() => { | |
console.log('[INFO] test succeeds :)'); | |
process.exit(0); | |
}) | |
.catch((error) => { | |
console.error('[ERROR]: test failed: %o', error); | |
process.exit(1); | |
}); | |
async function run() { | |
console.log(); | |
console.log( | |
'[INFO] running test with MSG_SIZE:%s, NUM_MSG:%d, PMTU:%s, RWND:%s, HIGH_WATER_MARK:%s, TIMEOUT:%d, SRC_IP:%s, DST_IP:%s', | |
MSG_SIZE, | |
NUM_MSG, | |
PMTU, | |
RWND, | |
HIGH_WATER_MARK, | |
TIMEOUT, | |
SRC_IP, | |
DST_IP); | |
let outboundSctpStreamTotalSentBytes = 0; | |
let outboundSctpStreamTotalSentMessages = 0; | |
let inboundSctpStreamTotalReceivedBytes = 0; | |
let inboundSctpStreamTotalReceivedMessages = 0; | |
// Set node-sctp global defaults. | |
// if (PMTU) | |
// sctp.defaults({ PMTU: PMTU }); | |
// if (RWND) | |
// sctp.defaults({ RWND: RWND }); | |
// Create a mediasoup Worker. | |
const worker = await mediasoup.createWorker({ | |
logLevel: 'debug', | |
logTags: [ 'sctp' ] | |
}); | |
// Create a mediasoup Router. | |
const router = await worker.createRouter(); | |
// Create a mediasoup PlainRtpTransport for connecting the sending node-sctp | |
// Socket. | |
const sendTransport = await router.createPlainRtpTransport({ | |
listenIp: { ip: SRC_IP }, | |
enableSctp: true, | |
numSctpStreams: { OS: 512, MIS: 512 }, | |
maxSctpMessageSize: 4000000 // 4 MB | |
}); | |
// Node UDP socket for the sending SCTP. | |
const sendUdpSocket = dgram.createSocket({ type: 'udp4' }); | |
await new Promise(resolve => sendUdpSocket.bind(11111, SRC_IP, resolve)); | |
const localSendUdpPort = sendUdpSocket.address().port; | |
// Connect the mediasoup send PlainRtpTransport to the UDP socket. | |
await sendTransport.connect({ ip: SRC_IP, port: localSendUdpPort }); | |
// Create a node-sctp sending Socket. | |
const sendSctpSocket = sctp.connect({ | |
localPort: 5000, // Required for SCTP over plain UDP in mediasoup. | |
port: 5000, // Required for SCTP over plain UDP in mediasoup. | |
OS: sendTransport.sctpParameters.OS, | |
MIS: sendTransport.sctpParameters.MIS, | |
unordered: false, | |
udpTransport: sendUdpSocket, | |
udpPeer: { | |
address: sendTransport.tuple.localIp, | |
port: sendTransport.tuple.localPort, | |
}, | |
highWaterMark: HIGH_WATER_MARK | |
}); | |
sendSctpSocket.on('error', (error) => { | |
console.error('[ERROR] node-sctp sending Socket "error" event: %o', error); | |
process.exit(2); | |
}); | |
console.log('[INFO] waiting for the sending SCTP association to be open'); | |
// Wait for the SCTP association to be open. | |
await Promise.race([ | |
new Promise((resolve, reject) => { | |
setTimeout(() => reject(new Error('SCTP connection timeout')), 2000) | |
}), | |
new Promise(resolve => sendSctpSocket.on('connect', resolve)), | |
]); | |
console.log('[INFO] creating a node-sctp outbound Stream [streamId:1]'); | |
// Create a node-sctp outbound Stream with id 1 (don't use the implicit Stream in the | |
// node-sctp Socket). | |
const outboundSctpStream = sendSctpSocket.createStream(1); | |
// Create a mediasoup DataProducer representing the node-sctp outbound Stream. | |
console.log( | |
'[INFO] creating a mediasoup DataProducer associated to the node-sctp outbound Stream'); | |
const dataProducer = await sendTransport.produceData({ | |
sctpStreamParameters: { | |
streamId: 1, | |
ordered: true, | |
} | |
}); | |
// Create a mediasoup PlainRtpTransport for consuming SCTP data from the | |
// node-sctp outbound Stream. | |
const recvTransport = await router.createPlainRtpTransport({ | |
listenIp: { ip: DST_IP }, | |
enableSctp: true, | |
numSctpStreams: { OS: 512, MIS: 512 }, | |
maxSctpMessageSize: 4000000 // 4 MB | |
}); | |
// Node UDP socket for the receiving SCTP. | |
const recvUdpSocket = dgram.createSocket({ type: 'udp4' }); | |
await new Promise(resolve => recvUdpSocket.bind(22222, DST_IP, resolve)); | |
const localRecvUdpPort = recvUdpSocket.address().port; | |
// Connect the mediasoup receiving PlainRtpTransport to the UDP socket. | |
await recvTransport.connect({ ip: DST_IP, port: localRecvUdpPort }); | |
// Create a node-sctp receiving Socket. | |
const recvSctpSocket = sctp.connect({ | |
localPort: 5000, // Required for SCTP over plain UDP in mediasoup. | |
port: 5000, // Required for SCTP over plain UDP in mediasoup. | |
OS: recvTransport.sctpParameters.OS, | |
MIS: recvTransport.sctpParameters.MIS, | |
unordered: false, | |
udpTransport: recvUdpSocket, | |
udpPeer: { | |
address: recvTransport.tuple.localIp, | |
port: recvTransport.tuple.localPort, | |
}, | |
highWaterMark: HIGH_WATER_MARK | |
}); | |
recvSctpSocket.on('error', (error) => { | |
console.error('[ERROR] node-sctp receiving Socket "error" event: %o', error); | |
process.exit(2); | |
}); | |
console.log('[INFO] waiting for the receiving SCTP association to be open'); | |
await Promise.race([ | |
new Promise((resolve, reject) => { | |
setTimeout(() => reject(new Error('SCTP connection timeout')), 2000) | |
}), | |
new Promise(resolve => recvSctpSocket.on('connect', resolve)), | |
]); | |
let inboundSctpStreamCreated = false; | |
// Handle SCTP messages received in the node-sctp receiving Socket. | |
recvSctpSocket.on('stream', async (stream, streamId) => { | |
console.log( | |
'[INFO] node-sctp inbound Stream created in the node-sctp receiving Socket [streamId:%d]', | |
streamId); | |
if (inboundSctpStreamCreated) { | |
console.error('[ERROR] just a single node-sctp inbound Stream should be generated'); | |
process.exit(2); | |
} | |
inboundSctpStreamCreated = true; | |
stream.on('data', (buffer) => { | |
// Ensure it's a WebRTC DataChannel string. | |
if (buffer.ppid !== sctp.PPID.WEBRTC_STRING) { | |
console.error( | |
'[ERROR] non WebRTC string data received in the node-sctp inbound Stream'); | |
process.exit(2); | |
} | |
console.log( | |
'[INFO] SCTP message received in the node-sctp inbound Stream [size:%d]', | |
buffer.byteLength); | |
inboundSctpStreamTotalReceivedBytes += buffer.byteLength; | |
inboundSctpStreamTotalReceivedMessages++; | |
}); | |
}); | |
// Create a mediasoup DataConsumer representing the node-sctp inbound Stream. | |
console.log( | |
'[INFO] creating a mediasoup DataConsumer associated to the node-sctp inbound Stream'); | |
dataConsumer = await recvTransport.consumeData({ | |
dataProducerId: dataProducer.id | |
}); | |
for (let i = 0; i < NUM_MSG; ++i) { | |
sendData(outboundSctpStream, dataProducer, MSG_SIZE); | |
outboundSctpStreamTotalSentBytes += MSG_SIZE; | |
outboundSctpStreamTotalSentMessages++; | |
} | |
// Wait a bit for all bytes to be delivered. | |
await new Promise((resolve) => setTimeout(resolve, TIMEOUT * 1000)); | |
// Check sent and received bytes and SCTP messages. | |
const dataProducerStats = await dataProducer.getStats(); | |
const dataProducerTotalReceivedBytes = dataProducerStats[0].bytesReceived; | |
const dataProducerTotalReceivedMessages = dataProducerStats[0].messagesReceived; | |
const dataConsumerStats = await dataConsumer.getStats(); | |
const dataConsumerTotalSentBytes = dataConsumerStats[0].bytesSent; | |
const dataConsumerTotalSentMessages = dataConsumerStats[0].messagesSent; | |
console.log(); | |
console.log('[INFO] test results:'); | |
console.log( | |
'- node-sctp outbound Stream sent %d bytes in %d SCTP messages to mediasoup DataProducer', | |
outboundSctpStreamTotalSentBytes, | |
outboundSctpStreamTotalSentMessages); | |
console.log( | |
'- mediasoup DataProducer received %d bytes in %d SCTP messages from node-sctp outbound Stream', | |
dataProducerTotalReceivedBytes, | |
dataProducerTotalReceivedMessages); | |
console.log( | |
'- mediasoup DataConsumer sent %d bytes in %d SCTP messages to node-sctp inbound Stream', | |
dataConsumerTotalSentBytes, | |
dataConsumerTotalSentMessages); | |
console.log( | |
'- node-sctp inbound Streamm received %d bytes in %d SCTP messages from mediasoup DataConsumer', | |
inboundSctpStreamTotalReceivedBytes, | |
inboundSctpStreamTotalReceivedMessages); | |
console.log(); | |
if ( | |
outboundSctpStreamTotalSentBytes !== dataProducerTotalReceivedBytes || | |
dataProducerTotalReceivedBytes !== dataConsumerTotalSentBytes || | |
dataConsumerTotalSentBytes !== inboundSctpStreamTotalReceivedBytes || | |
outboundSctpStreamTotalSentMessages !== dataProducerTotalReceivedMessages || | |
dataProducerTotalReceivedMessages !== dataConsumerTotalSentMessages || | |
dataConsumerTotalSentMessages !== inboundSctpStreamTotalReceivedMessages | |
) { | |
throw new Error('SCTP sent and received bytes and/or messages do not match!'); | |
} | |
} | |
function sendData(outboundSctpStream, dataProducer, size) { | |
console.log( | |
'[INFO] sending a message of %d bytes from the node-sctp outbound Stream', | |
size); | |
const buffer = Buffer.alloc(size, 'X'); | |
// Set ppid of type WebRTC DataChannel string. | |
buffer.ppid = sctp.PPID.WEBRTC_STRING; | |
outboundSctpStream.write(buffer); | |
} |
For PMTU=1500 ./node-sctp-mediasoup-test.js 150000 to succeed, I guess you need to setup RWND: sctp.defaults({PMTU: PMTU, RWND: 150000}) because receiving buffer is not released until whole data chunk is not assembled.
This buffer (RWND) must be not less in size than data chunk. But supposedly this value is similar to the highWatermark of the stream, and should be auto-adjusted. The problem is I'm not sure how to deal with multiple streams.
Further tests show that "- mediasoup DataConsumer sent XXX bytes in YYY SCTP messages to node-sctp inbound Stream" but looking at Wireshark doesn't show data traffic on port 22222. That is why we get: "- node-sctp inbound Streamm received 0 bytes in 0 SCTP messages from mediasoup DataConsumer".
Does this make sense?
Hi, I don't what the highWaterMark
is. Is it the RWND
? I've tried with sctp.defaults({PMTU: PMTU, RWND: 150000})
and the tests still fail, and I do see traffic from mediasoup to the receiving node-sctp. I'm calling sctp.defaults({ PMTU: PMTU, RWND: 150000 });
in the script (I've modified it a bit to allow setting RWND
via env):
$ PMTU=1500 RWND=150000 TIMEOUT=8 ./node-sctp-mediasoup-test.js 100000
[INFO] running test with MSG_SIZE:100000, NUM_MSG:1, PMTU:1500, RWND:150000, TIMEOUT:8, SRC_IP:127.0.0.1, DST_IP:127.0.0.1
[INFO] waiting for the sending SCTP association to be open
[INFO] creating a node-sctp outbound Stream [streamId:1]
[INFO] creating a mediasoup DataProducer associated to the node-sctp outbound Stream
[INFO] waiting for the receiving SCTP association to be open
[INFO] creating a mediasoup DataConsumer associated to the node-sctp inbound Stream
[INFO] sending a message of 100000 bytes from the node-sctp outbound Stream
[INFO] test results:
- node-sctp outbound Stream sent 100000 bytes in 1 SCTP messages to mediasoup DataProducer
- mediasoup DataProducer received 100000 bytes in 1 SCTP messages from node-sctp outbound Stream
- mediasoup DataConsumer sent 100000 bytes in 1 SCTP messages to node-sctp inbound Stream
- node-sctp inbound Streamm received 0 bytes in 0 SCTP messages from mediasoup DataConsumer
[ERROR]: test failed: Error: SCTP sent and received bytes and/or messages do not match!
at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:290:11)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
[stack]: 'Error: SCTP sent and received bytes and/or messages do not match!\n' +
' at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:290:11)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:93:5)',
[message]: 'SCTP sent and received bytes and/or messages do not match!'
}
here tshark output:
$ sudo tshark -i any -n -s0 -Y 'ip.dst==127.0.0.1 and udp.port==22222'
Capturing on 'any'
19 1.369252 127.0.0.1 → 127.0.0.1 UDP 128 22984 → 22222 Len=100
20 1.369277 127.0.0.1 → 127.0.0.1 UDP 128 22984 → 22222 Len=100
21 1.369960 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 22984 Len=32
22 1.369996 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 22984 Len=32
23 1.370027 127.0.0.1 → 127.0.0.1 UDP 372 22984 → 22222 Len=344
24 1.370037 127.0.0.1 → 127.0.0.1 UDP 372 22984 → 22222 Len=344
25 1.370396 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 22984 Len=256
26 1.370424 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 22984 Len=256
27 1.370486 127.0.0.1 → 127.0.0.1 UDP 44 22984 → 22222 Len=16
28 1.370496 127.0.0.1 → 127.0.0.1 UDP 44 22984 → 22222 Len=16
239 1.382298 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
240 1.382306 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
241 1.382311 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
242 1.382316 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
243 1.382325 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
244 1.382326 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
245 1.382326 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
246 1.382326 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
247 1.389418 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
248 1.389426 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
249 1.389488 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
250 1.389522 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
251 1.389530 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
252 1.389551 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
253 1.389554 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
254 1.389556 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
255 1.389560 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
256 1.389562 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
257 1.389568 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
258 1.389574 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
259 1.391608 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
260 1.391631 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
261 1.391672 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
262 1.391680 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
263 1.391682 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
264 1.391686 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
265 1.391689 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
266 1.391694 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
267 1.391698 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
268 1.391700 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
269 1.393431 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
270 1.393451 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
271 1.393487 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
272 1.393495 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
273 1.580149 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
274 1.580170 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
275 1.580208 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
276 1.580214 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
279 1.581839 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
280 1.581856 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
// Here half a second (or similar) elapsed
282 2.395921 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
283 2.395934 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
284 2.397376 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
285 2.397410 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
// Here a second (or similar) elapsed
291 4.401517 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
292 4.401523 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
293 4.403195 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
294 4.403225 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
// Here two seconds (or similar) elapsed
322 8.401531 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
323 8.401572 127.0.0.1 → 127.0.0.1 UDP 1228 22984 → 22222 Len=1200
324 8.403636 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
325 8.403675 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 22984 Len=28
// and more
It seems that mediasop (which uses usrsctp
) is sending data to the receiving node-sctp
Socket. In fact, tshark shows that it's sending 1200*8 + 1200*10 + 1200*8 + 1200*2 + 1200*2
= 36000 bytes (far from the original 100000). IMHO the receiving node-sctp
Socket is not sending SACKs for all those bytes so mediasoup does not send more and retransmits some pending bytes.
So, which is the current status in node-sctp 0.0.19? Which of the tests above are supposed to work and which ones not? Note that there are some tests that now work and before they failed, but there are also tests that now fail and before worked.
For instance, this test works with sctp 0.0.18:
$ PMTU=1500 ./node-sctp-mediasoup-test.js 50000
[INFO] running test with MSG_SIZE:50000, NUM_MSG:1, PMTU:1500, RWND:NaN, TIMEOUT:2, SRC_IP:127.0.0.1, DST_IP:127.0.0.1
[INFO] waiting for the sending SCTP association to be open
[INFO] creating a node-sctp outbound Stream [streamId:1]
[INFO] creating a mediasoup DataProducer associated to the node-sctp outbound Stream
[INFO] waiting for the receiving SCTP association to be open
[INFO] creating a mediasoup DataConsumer associated to the node-sctp inbound Stream
[INFO] sending a message of 50000 bytes from the node-sctp outbound Stream
[INFO] node-sctp inbound Stream created in the node-sctp receiving Socket [streamId:0]
[INFO] SCTP message received in the node-sctp inbound Stream [size:50000]
[INFO] test results:
- node-sctp outbound Stream sent 50000 bytes in 1 SCTP messages to mediasoup DataProducer
- mediasoup DataProducer received 50000 bytes in 1 SCTP messages from node-sctp outbound Stream
- mediasoup DataConsumer sent 50000 bytes in 1 SCTP messages to node-sctp inbound Stream
- node-sctp inbound Streamm received 50000 bytes in 1 SCTP messages from mediasoup DataConsumer
[INFO] test succeeds :)
$ sudo tshark -i any -n -s0 -Y 'ip.dst==127.0.0.1 and udp.port==22222'
Capturing on 'any'
267 40.829112 127.0.0.1 → 127.0.0.1 UDP 128 24504 → 22222 Len=100
268 40.829134 127.0.0.1 → 127.0.0.1 UDP 128 24504 → 22222 Len=100
269 40.829719 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 24504 Len=32
270 40.829728 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 24504 Len=32
271 40.829798 127.0.0.1 → 127.0.0.1 UDP 372 24504 → 22222 Len=344
272 40.829820 127.0.0.1 → 127.0.0.1 UDP 372 24504 → 22222 Len=344
273 40.830240 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 24504 Len=256
274 40.830262 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 24504 Len=256
275 40.830389 127.0.0.1 → 127.0.0.1 UDP 44 24504 → 22222 Len=16
276 40.830416 127.0.0.1 → 127.0.0.1 UDP 44 24504 → 22222 Len=16
381 40.839026 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
382 40.839033 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
383 40.839037 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
384 40.839042 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
386 40.839054 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
387 40.839055 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
388 40.839055 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
389 40.839056 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
391 40.843803 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
392 40.843826 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
393 40.843878 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
394 40.843887 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
395 40.843893 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
396 40.843898 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
397 40.843903 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
398 40.843911 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
399 40.843911 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
400 40.843912 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
401 40.843912 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
402 40.843912 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
403 40.845983 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
404 40.845991 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
405 40.846043 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
406 40.846051 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
407 40.846059 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
408 40.846064 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
409 40.846070 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
410 40.846077 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
411 40.846078 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
412 40.846078 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
413 40.846079 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
414 40.846079 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
415 40.848052 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
416 40.848061 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
417 40.848128 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
418 40.848137 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
419 40.848143 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
420 40.848148 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
421 40.848155 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
422 40.848165 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
423 40.848166 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
424 40.848167 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
425 40.848167 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
426 40.848168 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
427 40.850073 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
428 40.850095 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
429 40.850133 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
430 40.850141 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
431 40.850146 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
432 40.850152 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
433 40.850157 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
434 40.850165 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
435 40.850165 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
436 40.850166 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
437 40.850166 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
438 40.850166 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
439 40.852020 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
440 40.852042 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
441 40.852076 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
442 40.852084 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
443 40.852088 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
444 40.852089 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
445 40.852091 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
446 40.852098 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
447 40.852098 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
448 40.852100 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
449 40.852104 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
450 40.852113 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
451 40.853989 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
452 40.854016 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
453 40.854053 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
454 40.854063 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
455 40.854070 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
456 40.854077 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
457 40.854083 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
458 40.854093 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
459 40.854095 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
460 40.854095 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
461 40.854096 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
462 40.854096 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
463 40.856076 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
464 40.856114 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
465 40.856180 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
466 40.856192 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
467 40.856201 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
468 40.856208 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
469 40.856215 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
470 40.856217 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
471 40.856218 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
472 40.856219 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
473 40.856220 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
474 40.856234 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
475 40.858409 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
476 40.858452 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
477 40.858527 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
478 40.858544 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
479 40.858545 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
480 40.858552 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
481 40.858557 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
482 40.858570 127.0.0.1 → 127.0.0.1 UDP 1228 24504 → 22222 Len=1200
483 40.858572 127.0.0.1 → 127.0.0.1 UDP 832 24504 → 22222 Len=804
484 40.858581 127.0.0.1 → 127.0.0.1 UDP 832 24504 → 22222 Len=804
485 40.862041 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
486 40.862085 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 24504 Len=28
However it fails with sctp 0.0.19:
$ PMTU=1500 ./node-sctp-mediasoup-test.js 50000
[INFO] running test with MSG_SIZE:50000, NUM_MSG:1, PMTU:1500, RWND:NaN, TIMEOUT:2, SRC_IP:127.0.0.1, DST_IP:127.0.0.1
[INFO] waiting for the sending SCTP association to be open
[INFO] creating a node-sctp outbound Stream [streamId:1]
[INFO] creating a mediasoup DataProducer associated to the node-sctp outbound Stream
[INFO] waiting for the receiving SCTP association to be open
[INFO] creating a mediasoup DataConsumer associated to the node-sctp inbound Stream
[INFO] sending a message of 50000 bytes from the node-sctp outbound Stream
[INFO] test results:
- node-sctp outbound Stream sent 50000 bytes in 1 SCTP messages to mediasoup DataProducer
- mediasoup DataProducer received 50000 bytes in 1 SCTP messages from node-sctp outbound Stream
- mediasoup DataConsumer sent 50000 bytes in 1 SCTP messages to node-sctp inbound Stream
- node-sctp inbound Streamm received 0 bytes in 0 SCTP messages from mediasoup DataConsumer
[ERROR]: test failed: Error: SCTP sent and received bytes and/or messages do not match!
at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:290:11)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
[stack]: 'Error: SCTP sent and received bytes and/or messages do not match!\n' +
' at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:290:11)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:93:5)',
[message]: 'SCTP sent and received bytes and/or messages do not match!'
}
$ sudo tshark -i any -n -s0 -Y 'ip.dst==127.0.0.1 and udp.port==22222'
Capturing on 'any'
21 1.269004 127.0.0.1 → 127.0.0.1 UDP 128 50104 → 22222 Len=100
22 1.269027 127.0.0.1 → 127.0.0.1 UDP 128 50104 → 22222 Len=100
23 1.269613 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 50104 Len=32
24 1.269649 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 50104 Len=32
25 1.269676 127.0.0.1 → 127.0.0.1 UDP 372 50104 → 22222 Len=344
26 1.269685 127.0.0.1 → 127.0.0.1 UDP 372 50104 → 22222 Len=344
27 1.269984 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 50104 Len=256
28 1.270008 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 50104 Len=256
29 1.270055 127.0.0.1 → 127.0.0.1 UDP 44 50104 → 22222 Len=16
30 1.270063 127.0.0.1 → 127.0.0.1 UDP 44 50104 → 22222 Len=16
135 1.279111 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
136 1.279119 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
137 1.279123 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
138 1.279128 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
140 1.279138 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
141 1.279139 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
142 1.279139 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
143 1.279140 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
145 1.284106 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
146 1.284128 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
147 1.284171 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
148 1.284180 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
149 1.284186 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
150 1.284191 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
151 1.284197 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
152 1.284203 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
153 1.284204 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
154 1.284205 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
155 1.284206 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
156 1.284206 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
157 1.285984 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
158 1.286005 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
159 1.286040 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
160 1.286048 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
161 1.286049 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
162 1.286054 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
163 1.286055 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
164 1.286057 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
165 1.286060 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
166 1.286069 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
167 1.287906 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
168 1.287934 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
169 1.287989 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
170 1.288002 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
171 1.472180 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
172 1.472235 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
173 1.472369 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
174 1.472402 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
175 1.474586 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
176 1.474640 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
179 2.286464 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
180 2.286499 127.0.0.1 → 127.0.0.1 UDP 1228 50104 → 22222 Len=1200
181 2.288542 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
182 2.288586 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 50104 Len=28
ok, by adding highWaterMark: 1000000
into sctp.connect()
(I've no idea what highWaterMark
is BTW) it works a bit better. Some failing tests do work, however if the number of messages is more than 1, the test fails. Well, not sure. The fact is that test fails even with a single message of 30000 bytes, and this seems to happen in the node-sctp Socket receiving side:
$ NUM_MSG=1 TIMEOUT=2 ./node-sctp-mediasoup-test.js 30000
[INFO] running test with MSG_SIZE:30000, NUM_MSG:1, PMTU:NaN, RWND:NaN, TIMEOUT:2, SRC_IP:127.0.0.1, DST_IP:127.0.0.1
[INFO] waiting for the sending SCTP association to be open
[INFO] creating a node-sctp outbound Stream [streamId:1]
[INFO] creating a mediasoup DataProducer associated to the node-sctp outbound Stream
[INFO] waiting for the receiving SCTP association to be open
[INFO] creating a mediasoup DataConsumer associated to the node-sctp inbound Stream
[INFO] sending a message of 30000 bytes from the node-sctp outbound Stream
[INFO] test results:
- node-sctp outbound Stream sent 30000 bytes in 1 SCTP messages to mediasoup DataProducer
- mediasoup DataProducer received 30000 bytes in 1 SCTP messages from node-sctp outbound Stream
- mediasoup DataConsumer sent 30000 bytes in 1 SCTP messages to node-sctp inbound Stream
- node-sctp inbound Streamm received 0 bytes in 0 SCTP messages from mediasoup DataConsumer
[ERROR]: test failed: Error: SCTP sent and received bytes and/or messages do not match!
at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:292:11)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
[stack]: 'Error: SCTP sent and received bytes and/or messages do not match!\n' +
' at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:292:11)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:93:5)',
[message]: 'SCTP sent and received bytes and/or messages do not match!'
}
With this last test NUM_MSG=1 TIMEOUT=2 ./node-sctp-mediasoup-test.js 30000 can you check wireshark traffic at port 22222?
This is the same test with TIMEOUT=4
and tshark output:
$ NUM_MSG=1 TIMEOUT=4 ./node-sctp-mediasoup-test.js 30000
[INFO] running test with MSG_SIZE:30000, NUM_MSG:1, PMTU:NaN, RWND:NaN, TIMEOUT:4, SRC_IP:127.0.0.1, DST_IP:127.0.0.1
[INFO] waiting for the sending SCTP association to be open
[INFO] creating a node-sctp outbound Stream [streamId:1]
[INFO] creating a mediasoup DataProducer associated to the node-sctp outbound Stream
[INFO] waiting for the receiving SCTP association to be open
[INFO] creating a mediasoup DataConsumer associated to the node-sctp inbound Stream
[INFO] sending a message of 30000 bytes from the node-sctp outbound Stream
[INFO] test results:
- node-sctp outbound Stream sent 30000 bytes in 1 SCTP messages to mediasoup DataProducer
- mediasoup DataProducer received 30000 bytes in 1 SCTP messages from node-sctp outbound Stream
- mediasoup DataConsumer sent 30000 bytes in 1 SCTP messages to node-sctp inbound Stream
- node-sctp inbound Streamm received 0 bytes in 0 SCTP messages from mediasoup DataConsumer
[ERROR]: test failed: Error: SCTP sent and received bytes and/or messages do not match!
at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:292:11)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
[stack]: 'Error: SCTP sent and received bytes and/or messages do not match!\n' +
' at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:292:11)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:93:5)',
[message]: 'SCTP sent and received bytes and/or messages do not match!'
}
$ sudo tshark -i any -n -s0 -Y 'ip.dst==127.0.0.1 and udp.port==22222'
Capturing on 'any'
13 0.586122 127.0.0.1 → 127.0.0.1 UDP 128 16488 → 22222 Len=100
14 0.586134 127.0.0.1 → 127.0.0.1 UDP 128 16488 → 22222 Len=100
15 0.586825 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 16488 Len=32
16 0.586848 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 16488 Len=32
17 0.586871 127.0.0.1 → 127.0.0.1 UDP 372 16488 → 22222 Len=344
18 0.586879 127.0.0.1 → 127.0.0.1 UDP 372 16488 → 22222 Len=344
19 0.587136 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 16488 Len=256
20 0.587161 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 16488 Len=256
21 0.587211 127.0.0.1 → 127.0.0.1 UDP 44 16488 → 22222 Len=16
22 0.587219 127.0.0.1 → 127.0.0.1 UDP 44 16488 → 22222 Len=16
85 0.592777 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
86 0.592783 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
87 0.592787 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
88 0.592790 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
89 0.592792 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
90 0.592796 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
91 0.592798 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
92 0.592803 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
95 0.597867 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
96 0.597892 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
97 0.597947 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
98 0.597955 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
99 0.597960 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
100 0.597966 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
101 0.597970 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
102 0.597978 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
103 0.597978 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
104 0.597979 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
105 0.597979 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
106 0.597980 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
107 0.600021 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
108 0.600048 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
109 0.600106 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
110 0.600117 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
111 0.600123 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
112 0.600131 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
113 0.600140 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
114 0.600141 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
115 0.600142 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
116 0.600142 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
117 0.602027 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
118 0.602050 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
119 0.602089 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
120 0.602100 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
121 0.788820 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
122 0.788876 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
123 0.788997 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
124 0.789030 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
125 0.791063 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
126 0.791116 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
// retransmissions here I guess:
131 1.601639 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
132 1.601658 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
133 1.603850 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
134 1.603910 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
// retransmissions here I guess:
139 3.607663 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
140 3.607704 127.0.0.1 → 127.0.0.1 UDP 1228 16488 → 22222 Len=1200
141 3.609857 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
142 3.609921 127.0.0.1 → 127.0.0.1 UDP 56 22222 → 16488 Len=28
// 4 seconds timeout expired here
$ NUM_MSG=1 TIMEOUT=4 ./node-sctp-mediasoup-test.js 30000
[INFO] running test with MSG_SIZE:30000, NUM_MSG:1, PMTU:1500, TIMEOUT:4, SRC_IP:127.0.0.1, DST_IP:127.0.0.1
[INFO] waiting for the sending SCTP association to be open
[INFO] creating a node-sctp outbound Stream [streamId:1]
[INFO] creating a mediasoup DataProducer associated to the node-sctp outbound Stream
[INFO] waiting for the receiving SCTP association to be open
[INFO] creating a mediasoup DataConsumer associated to the node-sctp inbound Stream
[INFO] sending a message of 30000 bytes from the node-sctp outbound Stream
[INFO] node-sctp inbound Stream created in the node-sctp receiving Socket [streamId:0]
[INFO] SCTP message received in the node-sctp inbound Stream [size:30000]
[INFO] test results:
- node-sctp outbound Stream sent 30000 bytes in 1 SCTP messages to mediasoup DataProducer
- mediasoup DataProducer received 30000 bytes in 1 SCTP messages from node-sctp outbound Stream
- mediasoup DataConsumer sent 30000 bytes in 1 SCTP messages to node-sctp inbound Stream
- node-sctp inbound Streamm received 30000 bytes in 1 SCTP messages from mediasoup DataConsumer
[INFO] test succeeds :)
Did you set up highWaterMark for sendSctpSocket and recvSctpSocket?
To summarize:
- use highWaterMark bigger than buffer, if you prefer to use write() to send data at once
- better use pipe() for big buffers, data will flow atomatically (still need some testing)
- check if your lib really sending data. I don't see traffic for buffers of size 400k and more
- use highWaterMark bigger than buffer, if you prefer to use write() to send data at once
Which buffer
do you mean here?
- better use pipe() for big buffers, data will flow automatically (still need some testing)
Do you need using stream.pipe(writableDestination)
in node-sctp receiving side? Will it respect SSNs and generate a single SCTP message?
- check if your lib really sending data. I don't see traffic for buffers of size 400k and more
Honestly not sure if usrsctp
supports sending so much data.... will check next days.
I've added more options to the script:
$ ./node-sctp-mediasoup-test.js -h
USAGE: [NUM_MSG=X] [PMTU=X] [RWND=X] [HIGH_WATER_MARK=X] [TIMEOUT=X] [SRC_IP=X] [DST_IP=X] ./node-sctp-mediasoup-test.js MSG_SIZE
Command line arguments:
- MSG_SIZE : Size in bytes of the SCTP message to be sent (mandatory)
Environment variables:
- NUM_MSG : Number of messages to send all together (default: 1)
- PMTU : PMTU for node-sctp
- RWND : RWND for node-sctp
- HIGH_WATER_MARK : highWaterMark value for node-sctp Socket (default: 16000)
- TIMEOUT : Time in seconds to wait for SCTP messages delivery (default: 1)
- SRC_IP : IP of the sending mediasoup transport (default: "127.0.0.1")
- DST_IP : IP of the receiving mediasoup transport (default: "127.0.0.1")
Cool, I've added a new all-tests.sh
above that runs the test with different arguments. The only failing test is the following:
$ PMTU=32000 HIGH_WATER_MARK=300000 TIMEOUT=3 ./node-sctp-mediasoup-test.js 300000
[INFO] running test with MSG_SIZE:300000, NUM_MSG:1, PMTU:32000, RWND:NaN, HIGH_WATER_MARK:300000, TIMEOUT:3, SRC_IP:127.0.0.1, DST_IP:127.0.0.1
[INFO] waiting for the sending SCTP association to be open
[INFO] creating a node-sctp outbound Stream [streamId:1]
[INFO] creating a mediasoup DataProducer associated to the node-sctp outbound Stream
[INFO] waiting for the receiving SCTP association to be open
[INFO] creating a mediasoup DataConsumer associated to the node-sctp inbound Stream
[INFO] sending a message of 300000 bytes from the node-sctp outbound Stream
[INFO] test results:
- node-sctp outbound Stream sent 300000 bytes in 1 SCTP messages to mediasoup DataProducer
- mediasoup DataProducer received 300000 bytes in 1 SCTP messages from node-sctp outbound Stream
- mediasoup DataConsumer sent 300000 bytes in 1 SCTP messages to node-sctp inbound Stream
- node-sctp inbound Streamm received 0 bytes in 0 SCTP messages from mediasoup DataConsumer
[ERROR]: test failed: Error: SCTP sent and received bytes and/or messages do not match!
at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:295:11)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
[stack]: 'Error: SCTP sent and received bytes and/or messages do not match!\n' +
' at run (/Users/ibc/tmp/node-sctp-issue/node-sctp-mediasoup-test.js:295:11)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:93:5)',
[message]: 'SCTP sent and received bytes and/or messages do not match!'
}
$ sudo tshark -i any -n -s0 -Y 'ip.dst==127.0.0.1 and udp.port==22222'
Capturing on 'any'
688 1.542536 127.0.0.1 → 127.0.0.1 UDP 128 48280 → 22222 Len=100
689 1.542540 127.0.0.1 → 127.0.0.1 UDP 128 48280 → 22222 Len=100
702 1.543201 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 48280 Len=32
703 1.543205 127.0.0.1 → 127.0.0.1 UDP 60 22222 → 48280 Len=32
704 1.543235 127.0.0.1 → 127.0.0.1 UDP 372 48280 → 22222 Len=344
705 1.543239 127.0.0.1 → 127.0.0.1 UDP 372 48280 → 22222 Len=344
708 1.543668 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 48280 Len=256
709 1.543672 127.0.0.1 → 127.0.0.1 UDP 284 22222 → 48280 Len=256
710 1.543722 127.0.0.1 → 127.0.0.1 UDP 44 48280 → 22222 Len=16
711 1.543725 127.0.0.1 → 127.0.0.1 UDP 44 48280 → 22222 Len=16
which does not seem related to node-sctp.
Related to latysheff/node-sctp#15.
Just copy the script into a folder and run
npm install mediasoup@3 sctp
before running it.Usage
Examples
All those examples should work. However some of them fail due to issues in node-sctp lib.