I have a project I’m working on where I have to send large blobs of binary data over a network connection, and due to various restraints, it would be easiest to use TCP wrappers. In short, what I mean is that I’m managing the packets (and the binary data) by hand.
My question is simple, though: Would the packet size affect the data transfer rate? The size of the packets and the buffer would change memory usage, I understand that, but what about the actual rate at which it transfers over the network? I mean, larger packets would mean fewer packets, so that would speed it up, but I would imagine that larger packets also transfer more slowly… Do they cancel out and it doesn’t matter, or is one change greater than the other and it does make a difference? And in which direction?
I feel I should also point out, I’m also reading the data right from a file stream (one packet at a time, to be efficient with memory) and passing the binary data straight into a file stream (one packet at a time), so I don’t know if that would affect the efficiency of the setup or the effect of the change in packet size.
Any help with this would be greatly appreciated.
Each packet has some fixed overhead (e.g., the source and destination addresses). The larger each packet, the smaller that fixed overhead becomes as a percentage of the whole. Therefore, larger packets increase throughput.
That said, unless you’re really hacking into the IP stack, or setting something like TCP_NODELAY, the normal TCP implementation will try to accumulate data to send larger packets automatically.