Method for realizing file non-dropping synchronization based on optical shutter system

CN118677889APending Publication Date: 2024-09-20JIANGSU SHENWANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410556645.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-07
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

[0004]本发明目的在于针对上述问题,提出一种不落盘的传输方式,即在文件传输过程中文件无需在光闸系统内存储,文件传输以流的方式进行同步,这样既解决了文件整体传输耗时的问题,也解决了文件传输受光闸系统硬盘限制的问题

Benefits of technology

[0034] 1. During the file synchronization process, the data is not stored in the optical gate, that is, the transmission method does not drop to the disk. During the file transfer process, the files do not need to be stored in the optical gate system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118677889A
    Figure CN118677889A
Patent Text Reader

Abstract

The invention discloses a method for realizing file non-drop synchronization based on an optical shutter system, and the method comprises the steps: firstly, starting a file downloading monitoring process, which is used for obtaining remote file information, and controlling the start and stop of an uploading end program and a downloading end program; starting a file downloading process for actual file downloading and forwarding; then carrying out a file uploading monitoring process for receiving control information of a downloading end and controlling start and stop of an uploading program; and finally, carrying out a file uploading process for receiving and uploading an actual file and processing the received out-of-order data. The data is not stored in the optical shutter in the file synchronization process, namely, the file does not need to be stored in the optical shutter system in the file transmission process in a non-disk transmission mode, and the problems that the overall file transmission time is long, and file transmission is limited by a hard disk of the optical shutter system are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of data management and data synchronization, and in particular relates to a method for realizing file synchronization without disk storage based on an optical gate system. Background Art

[0002] With the popularization of computer network applications and the improvement of network security awareness, more and more units divide their internal departments into different network security domains according to different confidentiality levels. High-level network security domains cannot flow confidential information to low-level network security domains. In this case, most scenarios have the need for one-way file synchronization. For this purpose, a one-way optical gate can be used for one-way file synchronization. The file synchronization operation requires two servers and one optical gate. The files on the external network server are transmitted to the internal network server through the optical gate. Generally, the optical gate system needs to collect and store the external network files, and then transmit them to the optical gate internal network system in one direction. Then the internal network system transmits the stored files to the internal network server.

[0003] This common disk transfer method has the following problems. On the one hand, the overall file transfer takes a long time. One file transfer includes three processes: file transfer from the external network server to the external network system of the optical gate, file transfer from the external network system of the optical gate to the internal network system, and file transfer from the internal network system of the optical gate to the internal network server. On the other hand, due to the hardware limitations of the optical gate system hard disk, the transferred file cannot exceed the hard disk space of the internal and external network systems of the optical gate, otherwise all content will not be cached. In addition, there are also requirements for the format of the optical gate system hard disk file system. For example, the FAT32 format cannot store files larger than 4GB. Summary of the invention

[0004] The purpose of the present invention is to propose a non-disk transmission method to address the above problems, that is, during the file transmission process, the files do not need to be stored in the optical gate system, and the file transmission is synchronized in a stream manner. This not only solves the problem of time-consuming overall file transmission, but also solves the problem of file transmission being limited by the optical gate system hard disk.

[0005] To achieve the above purpose, the technical solution proposed by the present invention is a method for realizing file synchronization without disk storage based on an optical gate system, comprising the following steps:

[0006] Step 1: Start the file download monitoring process to obtain remote file information and control the start and stop of the upload and download programs;

[0007] Step 2: Start the file download process, which is used for actual file download and forwarding;

[0008] Step 3: Perform file upload monitoring process to receive control information from the download end and control the start and stop of the upload program;

[0009] Step 4: Perform the file upload process, which is used for actual file reception and upload, and processes the received out-of-order data.

[0010] Furthermore, the aforementioned file download monitoring process specifically includes the following steps:

[0011] Step 11: Periodically obtain the file list information of the remote server;

[0012] Step 12: traverse the file information and determine whether a file has been downloaded based on the locally stored feature file information;

[0013] Step 13: For the transferred files, determine whether they have been updated based on the time information. If updated, the upload end will be notified and the file transfer program will be started;

[0014] Step 14: For files that have not been transferred, record the feature files, notify the upload end, and start the file transfer program;

[0015] Step 15: After the traversal is completed or the currently running upload program has reached the maximum number, this monitoring task ends;

[0016] Step 16: Finally, the download program status is obtained regularly. When the download program stops abnormally, the upload end will be notified and the download program will be restarted.

[0017] Furthermore, the aforementioned file download process includes the following steps:

[0018] Step 21: Start the UDP forwarding thread to forward the data to the upload end;

[0019] Step 22: Initialize the curl library and set the data download callback function;

[0020] Step 23: After receiving the data, the data download callback function puts the data into the queue in sequence;

[0021] Step 24: The udp forwarding thread takes the data from the queue, sets the index field according to the sequence, and then forwards the data.

[0022] Furthermore, the aforementioned file upload monitoring process includes the following steps:

[0023] Step 31: Process the file download event from the download end;

[0024] Step 32: store relevant file attribute information, and determine whether there is a program transferring the file. If so, stop the program and start a new file upload program;

[0025] Step 33: Process the directory creation event from the download end, and create a directory for the remote server according to the data transmitted by the download end.

[0026] Furthermore, the aforementioned file upload process includes the following steps:

[0027] Step 41: Start the udp receiving thread to receive data from the download end;

[0028] Step 42: Initialize the curl library and set the data upload callback function;

[0029] Step 43: UDP receives data from the download end, determines whether the index information of the current data and the previous data is sequential, and puts the sequential data into the queue;

[0030] Step 44: Put the unordered data into the red-black tree sorting container, and do not put the data into the queue;

[0031] Step 45: After the data in the red-black tree container is partially ordered, it is put into the queue in sequence until it is out of order or the container is empty;

[0032] Step 46: The upload callback function takes data out of the queue in sequence and writes it into the memory, and the curl library forwards the data to the server.

[0033] Compared with the prior art, the present invention has the following advantages:

[0034] 1. During the file synchronization process, the data is not stored in the optical gate, that is, the transmission method is not stored on the disk. During the file transmission process, the file does not need to be stored in the optical gate system.

[0035] 2. Since the file transfer is synchronized through streaming, this not only solves the problem of long overall file transfer time, but also solves the problem of file transfer being limited by the optical gate system hard disk. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 Flowchart for file transfer download;

[0037] Figure 2 Flowchart for file transfer upload;

[0038] Figure 3 Flowchart of the monitoring procedure for file downloads;

[0039] Figure 4 Flowchart of the monitoring procedure for file uploads. DETAILED DESCRIPTION

[0040] The invention will be further described in detail below in conjunction with the accompanying drawings.

[0041] In order to solve the problems of time-consuming overall file transmission and file transmission being limited by the hard disk of the optical gate system, the present invention proposes a method for realizing file synchronization without disk storage based on the optical gate system, which comprises the following steps: firstly, starting a file download monitoring process to obtain remote file information and control the start and stop of upload and download end programs; then starting a file download process for actual file download and forwarding; performing a file upload monitoring process to receive control information from the download end and control the start and stop of the upload program; finally, performing a file upload process to actually receive and upload files and process the received out-of-order data.

[0042] The download process of the file transfer program, such as Figure 1 As shown, the following steps are included:

[0043] 1.1 udp socket initialization, create a udp socket for forwarding file data, set the socket to blocking mode, and use the SO_SNDBUF type of setsockopt() to set the send buffer to avoid udp packet loss at the sending end. At the same time, start the thread to prepare to send udp data.

[0044] 1.2 Initialization of curl, use curl_easy_init() to create a curl handle, convert the incoming url, and the url containing special characters needs to be url encoded, such as the # character needs to be converted to %23. After successful encoding, use curl_easy_setopy() to set some content. This function sets the url, user authentication data, callback function and buffer size according to different operation types. For example, use curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,cnfs_write_callback); the callback function can be set, that is, when the ftp server sends file data, the callback function will be triggered. After the initialization is completed, use curl_easy_perform() to start interacting with the ftp server. This function will block until the data transmission is completed. After the end, you need to use curl_easy_cleanup(curl) to clear the resources.

[0045] 1.3 Processing of callback function. The callback function has four parameters, namely void* type, which indicates the pointer to the data to be written, and two size_t type parameters size and nmemb. Size indicates the size of each data block, and nmemb indicates the number of data blocks. The multiplication of the two indicates the total length of the written data. The last parameter of void* type is the user data pointer, which can be set using curl_easy_setopt(). This value is not needed here. In the callback function, a piece of memory space is first applied, and an index value is first recorded for the other side system to process disordered data, and then the data information is saved. After that, the data is put into the queue. The queue is implemented using a bidirectional linked list to ensure that the data is first in, first out, and atomic operations are used to ensure thread safety. After putting it into the queue, just return. The return value here is the total length of the data. When all data is received, the function curl_easy_perform() will end execution and the main thread will end processing.

[0046] 1.4 Processing of udp sending thread. The udp sending thread processes in an infinite loop, and mainly obtains data from the queue in the loop. Because the queue container is thread-safe, no additional operations are required. The retrieved data is directly forwarded to the other side system through the udp socket. The thread uses a variable that records the size of the processed file to accumulate the effective data length obtained from the queue. When the value reaches the file size, the loop exits and the sending thread ends.

[0047] The upload process of the file transfer program is as follows Figure 2 The following steps are shown:

[0048] 2.1 udp socket initialization, same as download process, the difference is that you need to use setsockopt()'s SO_RCVBUF type to set the socket's receiving buffer to prevent data loss on the receiving end. After setting, start the udp receiving thread.

[0049] 2.2 The initialization of curl is the same as the download process, the difference is setting the callback function for uploading data and setting it to upload operation: curl_easy_setopt(curl,CURLOPT_UPLOAD,1L).

[0050] 2.3 Processing of udp receiving thread. The udp receiving thread needs to initialize a red-black tree container and a session. The session mainly includes three values, namely the old index value, the starting index value and the ending index value, which are used to process out-of-order data. The udp receiving thread receives udp data in a loop and enters out-of-order processing after receiving valid data: if the starting index of the session is 0 and the index of the current data is equal to the old index of the session plus one, it is considered normal data and the data can be queued. If the above conditions are not met, if the starting index is 0, the starting index is set to the old index plus one, and the ending index is the index of the current data. Then, if the current index is greater than the old index, the old index is updated to the current index value, and then memory is applied to save this data and insert it into the red-black tree container. The red-black tree container compares the value according to the value. When inserting a new node, the initial state is set to red, and then it is recolored according to the parent node of the node or the sibling node of the parent node. Then it is rotated and recolored according to the color of the parent node and the uncle node. Finally, after the whole tree is balanced and satisfies all the properties of the red-black tree, the in-order traversal of the whole tree will be an ordered sequence. After insertion, determine whether the starting index is equal to the current data index. If not, exit and re-receive. If they are equal, perform in-order traversal. Whenever the data index taken out of the container is subtracted from the old index by 1, it is sequential data, put into the queue, and increment the old index. When the data index is equal to the end index, clear the values ​​of the starting index and the end index, and exit. If the data index is not subtracted from the old index by 1, the starting index is equal to the old index plus 1. The final result is that if the udp data is not lost, the data in the queue will be ordered data. When the udp reception fails a certain number of times, the udp receiving thread will also exit.

[0051] 2.4 Processing of callback function. The callback function loops to take data from the queue, which must be in order, and copies the data to the ptr pointer in the callback function parameter. If there is no data in the queue, if the udp thread is still running, it will continue to take data from the queue. If the udp thread has ended, the number of errors will be accumulated, and the program will exit when the threshold is reached.

[0052] The download monitoring process of the file transfer monitoring program is as follows Figure 3 As shown, first parse the configuration information, initialize, and then:

[0053] 3.1 Process scheduled tasks and obtain remote server file list information.

[0054] 3.2 A unique value is obtained through the MD5 digest algorithm based on the URL, file name and file size of each file, and it is determined whether the file represented by the value has been transmitted. If not, the other side system is notified through the UDP connection to start the upload program. The system on this side passes the user authentication and URL information to the download program, and starts the download program for data transmission.

[0055] 3.3 Scheduled Tasks Scheduled scanning to see if the program ends abnormally. If the program ends abnormally, the peer end will be notified again and the download program will be started to download again.

[0056] The upload monitoring process of the file transfer monitoring program is as follows Figure 4 As shown, the following steps are included:

[0057] 4.1 Receive messages from internal channels.

[0058] 4.2 To start the transfer message, you need to determine whether the file is being transferred, terminate the current task and start the forwarding program as needed.

[0059] 4.3 To stop transmitting messages, you need to stop the corresponding transmission program.

[0060] It loops and receives data from the download monitoring end, and handles different events, including program startup, program termination, and directory creation events. It parses the main parameters based on the received data information, such as user authentication data, URL, and other data, and passes them to the file upload program and starts the upload program. It creates a directory event and uses the -Q "MKD" parameter of the curl command to send a command to create a directory to the server.

[0061] The above contents are further detailed descriptions of the present invention in combination with specific preferred technical solutions, and the specific implementation of the present invention cannot be considered to be limited to these descriptions. It should be pointed out that for ordinary technicians in this technical field, several improvements can be made without departing from the principle of the present invention, and these improvements should also be regarded as falling within the scope of protection of the present invention.

Claims

1. A method for realizing file synchronization without disk storage based on a light gate system. Features The following steps are involved: Step 1: Start the file download monitoring process to obtain remote file information and control the start and stop of the upload and download programs; Step 2: Start the file download process, which is used for actual file download and forwarding; Step 3: Perform file upload monitoring process to receive control information from the download end and control the start and stop of the upload program; Step 4: Perform the file upload process, which is used for actual file reception and upload, and processes the received out-of-order data.

2. The method for realizing file synchronization without disk storage based on the optical gate system according to claim 1, It is characterized in that The file download monitoring process includes the following steps: Step 1: Periodically obtain the file list information of the remote server; Step 2: Traverse the file information and determine whether a file has been downloaded based on the locally stored feature file information; Step 3: For the transferred files, determine whether they have been updated based on the time information. If updated, the upload end will be notified and the file transfer program will be started; Step 4: For files that have not been transferred, record the feature files, notify the upload end, and start the file transfer program; Step 5: After the traversal is completed or the currently running upload program has reached the maximum number, this monitoring task ends; Step 6: Finally, get the download program status regularly. When the download program stops abnormally, notify the upload end and restart the download program.

3. The method for realizing file synchronization without disk storage based on the optical gate system according to claim 1, It is characterized in that The file download process includes the following steps: Step 1: Start the UDP forwarding thread to forward data to the upload end; Step 2: Initialize the curl library and set the data download callback function; Step 3: After receiving the data, the data download callback function puts the data into the queue in sequence; Step 4: The UDP forwarding thread takes data from the queue, sets the index field according to the sequence, and then forwards the data.

4. The method for realizing file synchronization without disk storage based on the optical gate system according to claim 1, It is characterized in that The file upload monitoring process includes the following steps: Step 1: Process the file download event from the download end; Step 2: Store relevant file attribute information and determine whether there is a program transferring the file. If so, stop the program and start a new file upload program. Step 3: Process the directory creation event from the download end, and create a directory for the remote server based on the data transmitted by the download end.

5. The method for realizing file synchronization without disk storage based on the optical gate system according to claim 1, It is characterized in that The file upload process includes the following steps: Step 1: Start the udp receiving thread to receive data from the download end; Step 2: Initialize the curl library and set the data upload callback function; Step 3: UDP receives data from the download end, determines whether the index information of this data and the previous data is sequential, and puts the sequential data into the queue; Step 4: Put the unordered data into the red-black tree sorting container, and do not put the data into the queue; Step 5: After the data in the red-black tree container is partially ordered, it is put into the queue in sequence until it is out of order or the container is empty; Step 6: The upload callback function takes data out of the queue in sequence and writes it into the memory. The curl library forwards the data to the server.