This is just a question based on curiosity, but I could learn something useful.
With my Node.js server, when I received data through net.Server, I printed out the size (in bytes) of each "packet" of data.
socket.on 'data', (data) -> console.log data.length
I noticed that most of the time it is 1374 bytes. The rest of the time it is a multiple of 1374. The highest indicator that I received from 200 data events was 17,862.
Where does this number 1374 come from? And why is the data length sometimes multiple?
My best guess is that with TCP, 1,500 bytes is the most common MTU for Ethernet, and 126 other bytes make up the TCP packet header. Node.js can sometimes compress these packages together if they get them fast enough, so sometimes they come in multiples.
source share