File Transmission Protocol
DeOSS establishes a secure and reliable file transfer mechanism based on the reliable transmission-oriented TCP protocol. The file transfer protocol is shown in Figure 1. When the application service layer initiates a file sending or a receiving request, it first establishes a TCP connection with the receiving/sending party and then establishes a file fragment byte stream transmission channel through the handshake mechanism of the DeOSS file transfer protocol. The main procedure is as follows:
1. The sender generates a random number and then uses the account private key signature to package the random number, signature, and file information (file name, number of fragments, etc.) into a Header message block and send it to the receiver.
2. The receiver parses the Header message block, creates a corresponding cache file in the cache area, packages the file name and status value into an Ack message block, and sends it back to the sender.
3. The sender receives the Ack message block, confirms that the file name and status are correct, and then starts to transmit the file. Each file is transmitted to the receiver in fixed-size blocks in sequence, and the transmission ends with an End message block.
4. The receiver receives all the file blocks, then assembles them, compares them with the information in the Header message block, and sends an Ack message block back to the sender for confirmation. If an exception occurs, an Error message block is returned.
The sender receives and parses the Ack message block, and reports the transmission result to the upper service. If an error occurs during transmission, the file transfer protocol will not actively retransmit the file, so as not to consume a lot of bandwidth.
Figure 1 Data transmission protocol
Each time a file-sending or receiving request is initiated, the requester will start the message-sending and receiving process through the loop, and communicate with the upper-layer program through the respective channels. Only one message is allowed to be delivered each time (the message size is not fixed) to prevent the file blocking and disordering problem. When the process starts, the handler routine will be started by default as the server monitors the message block in real time.