I am writing a protocol to transfer gigabytes of data over a network using TCP, to try to teach myself a little bit about programming on protocols. I am unsure of how to design this transfer protocol, in order to transfer the data in the fastest and most efficient way.
I am using Qt on windows.
At the moment, my design of my application protocol (the part to transfer the data) is as follows:
- First shoot the login details.
- Write the first data packet (into the socket) of 4 kilobytes, and then wait for the server to confirm it has got the packet.
- When the server confirms receiving the data packet (by writing int "1"), write the next 4 kilobytes.
- When all data has been transferred, send the md5sum of the data transferred to the server.
- If the server confirms again with an int 8, data transfer completes.
At the moment, I am not able to get speeds higher than 166KB/sec on the same computer when transferring over 127.0.0.1. I have been trying to read other protocol designs, but there is hardly any documentation on data transfer protocols that one can write for their application.
Is the protocol design that I've posted wrong or suffering from some serious issues? Should the protocol wait for each packet to be confirmed by the server or should I write it continuously?