Concurrent file transmission method, system, storage medium and electronic device
By dividing the file into multiple data blocks and using multi-threaded concurrent transmission technology, combined with the breakpoint resume function, the problem of insufficient concurrent file transmission performance in the existing technology is solved, and efficient and reliable file transmission is achieved.
Patent Information
- Application Number
- CN202110721368.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-28
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-06-28
AI Technical Summary
Existing file concurrent transmission methods have insufficient transmission performance and cannot fully utilize hardware resources, resulting in low transmission efficiency.
By dividing the original file into multiple data blocks, and using multi-threaded concurrent transmission technology, combined with the breakpoint resume function, the number of concurrent transmission threads is set according to the transmission parameters and the number of CPU cores at the receiving end, and the data is monitored during the transmission process. Block transfer status to achieve efficient file transfer.
It significantly reduces the transmission time, improves the transmission efficiency, and reduces the number of failed retransmissions through breakpoint resumption, improving the reliability and efficiency of transmission.
Smart Images

Figure CN113472874B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of concurrent file transmission, and in particular relates to a concurrent file transmission method, system, storage medium and electronic equipment. Background Art
[0002] With the rapid development of the Internet, users have higher and higher requirements for network performance. For file transmission, the transmission of large files has become more and more frequent. The efficiency of transmission is what we are more concerned about. For most servers in enterprises, dozens of CPU cores and more than 100 gigabytes of memory are already standard. Most of them also support hyperthreading, and the network card can support more than 1000 megabits. Therefore, it is ideal to make full use of various hardware resources to achieve the most efficient transmission method. Concurrency and breakpoint resumable transmission can greatly improve transmission performance.
[0003] Concurrent transmission: When the machine's CPU is multi-core, if multi-threading is used in the program, the program will execute the same logic concurrently to improve efficiency.
[0004] Resume transfer: After a file transfer fails, resume transfer can start transferring the data after the failure, and stop transferring the previously successfully transferred data, thus reducing the transfer time.
[0005] File transfer and sharing is achieved by setting up an FTP server. The FTP service is based on the FTP protocol. The FTP protocol is one of the protocols in the TCP / IP protocol suite. The FTP protocol consists of two components, one is the FTP server and the other is the FTP client. The FTP server is used to store files, and users can use the FTP client to access resources located on the FTP server through the FTP protocol. When developing a website, the FTP protocol is usually used to upload web pages or programs to the Web server. In addition, since FTP transmission efficiency is very high, this protocol is generally used when transferring large files on the network. The task of the FTP protocol is to transfer files from one computer to another computer. It has nothing to do with the location of the two computers, the connection method, or even whether they use the same operating system. Assume that two computers communicate through the FTP protocol and can access the Internet. Summary of the invention
[0006] The embodiments of the present application provide a file concurrent transmission method, system, storage medium and electronic device to at least solve the problem of insufficient transmission performance in the existing file concurrent transmission method.
[0007] The present invention provides a method for concurrent file transmission, which comprises:
[0008] File receiving step: receiving the original file and transmission parameters;
[0009] File processing step: dividing the original file into multiple data blocks according to the transmission parameters;
[0010] Data block transmission step: transmitting a plurality of the data blocks concurrently to a receiving end through a network according to transmission parameters;
[0011] Data block merging step: merging the plurality of data blocks at the receiving end through a merge file service to form the original file.
[0012] The above-mentioned file concurrent transmission method further includes:
[0013] Data block transmission monitoring step: every specified time, obtain the size, transmission status and data block id of the data block that has been written to the receiving end.
[0014] The above-mentioned concurrent file transmission method, wherein the transmission parameters include: receiving end IP, remote receiving file directory, retransmission, breakpoint resume, configuration file and the number of CPU cores of the sending end;
[0015] In the file processing step, the data block size is obtained through the configuration file, and the original file is segmented according to the data block size. In the file processing step, the number of threads for concurrent transmission is set according to the number of CPU cores;
[0016] In the data block transmission step, the data block is transmitted to the remote receiving file directory of the receiving end according to the receiving end IP.
[0017] The above-mentioned file concurrent transmission method, wherein the data block transmission step includes: after the transmission of each data block is completed, the transmission status flag is set to SUCCESS; when an exception occurs during the transmission of a certain data block, the transmission status flag is set to FAILED or RUNNING, and when the breakpoint is resumed, only the data block with the transmission status flag of FAILED or RUNNING is transmitted.
[0018] The present invention also provides a file concurrent transmission system, which includes:
[0019] A file receiving module, wherein the file receiving module receives the original file and transmission parameters;
[0020] A file processing module, wherein the file processing module divides the original file into a plurality of data blocks according to the transmission parameters;
[0021] A data block transmission module, wherein the data block transmission module concurrently transmits a plurality of the data blocks to a receiving end through a network according to transmission parameters;
[0022] A data block merging module is used to merge the plurality of data blocks on the receiving end to form the original file through a merge file service.
[0023] The above-mentioned concurrent file transmission system further includes:
[0024] A data block transmission monitoring module is used to obtain the size, transmission status and data block ID of the data block written into the receiving end at a specified time interval.
[0025] The above-mentioned concurrent file transmission system, wherein the transmission parameters include: receiving end IP, remote receiving file directory, retransmission, breakpoint resume, configuration file and the number of CPU cores of the sending end;
[0026] The file processing module obtains the data block size through the configuration file, divides the original file according to the data block size, and sets the number of threads for concurrent transmission according to the number of CPU cores in the file processing module;
[0027] In the data block transmission module, the data block is transmitted to the remote receiving file directory of the receiving end according to the receiving end IP.
[0028] In the above-mentioned concurrent file transmission system, after the transmission of each data block is completed, the transmission status flag is set to SUCCESS; when an exception occurs during the transmission of a data block, the transmission status flag is set to FAILED or RUNNING, and when the breakpoint is resumed, only the data block with the transmission status flag of FAILED or RUNNING is transmitted.
[0029] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the methods for concurrent file transmission when executing the computer program.
[0030] The present invention also provides a storage medium on which a computer program is stored, wherein when the program is executed by a processor, any of the above-mentioned concurrent file transmission methods is implemented.
[0031] The beneficial effects of the present invention are:
[0032] The invention belongs to the field of data transmission in data capability. The file concurrent transmission method of the invention reduces transmission time, improves transmission efficiency, and reduces the efficiency of failed retransmission due to support of breakpoint resume transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The drawings described herein are used to provide further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application.
[0034] In the attached picture:
[0035] Figure 1 It is a technical route flow chart of the concurrent file transmission method of the present invention;
[0036] Figure 2 It is a flow chart of the concurrent file transmission method of the present invention;
[0037] Figure 3 It is a structural schematic diagram of the concurrent file transmission system of the present invention;
[0038] Figure 4 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0040] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as the content disclosed in this application is insufficient.
[0041] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0042] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0043] The present invention is described in detail below in conjunction with the various embodiments shown in the accompanying drawings, but it should be noted that these embodiments are not limitations of the present invention, and any equivalent transformations or substitutions in functions, methods, or structures made by ordinary technicians in the field based on these embodiments are all within the scope of protection of the present invention.
[0044] Before elaborating on each embodiment of the present invention in detail, the core inventive concept of the present invention is summarized and elaborated in detail through the following several embodiments.
[0045] Embodiment 1:
[0046] The present invention provides a method for concurrent file transmission. The main process of the present invention is as follows: Figure 1 As shown, the present invention fully utilizes the server's hardware and software and network resources, adopts multi-threaded concurrent transmission, and supports breakpoint resumption when transmission fails due to various uncontrollable reasons, ensuring that the space and time of the transmitted data are not wasted.
[0047] Please refer to Figure 2 , Figure 2 It is a flowchart of the concurrent file transmission method. Figure 2 As shown, the file concurrent transmission method of the present invention includes:
[0048] File receiving step S1: receiving the original file and transmission parameters;
[0049] File processing step S2: dividing the original file into multiple data blocks according to the transmission parameters;
[0050] Data block transmission step S3: transmitting the plurality of data blocks concurrently to the receiving end through the network according to the transmission parameters;
[0051] Data block merging step S4: merging the plurality of data blocks at the receiving end through a merge file service to form the original file.
[0052] Among them, it also includes:
[0053] Data block transmission monitoring step: every specified time, obtain the size, transmission status and data block id of the data block that has been written to the receiving end.
[0054] The transmission parameters include: receiving end IP, remote receiving file directory, retransmission, breakpoint resume, configuration file and the number of CPU cores of the sending end;
[0055] In the file processing step, the data block size is obtained through the configuration file, and the original file is segmented according to the data block size. In the file processing step, the number of threads for concurrent transmission is set according to the number of CPU cores;
[0056] In the data block transmission step, the data block is transmitted to the remote receiving file directory of the receiving end according to the receiving end IP.
[0057] Among them, the data block transmission step includes: after the transmission of each data block is completed, the transmission status flag is set to SUCCESS; when an exception occurs during the transmission of a data block, the transmission status flag is set to FAILED or RUNNING, and when the breakpoint is resumed, only the data block with the transmission status flag of FAILED or RUNNING is transmitted.
[0058] Specifically, the main program for large file transfer (hereinafter referred to as the "program") accepts large file data to be transferred (hereinafter referred to as the "file"), as well as transfer parameters, such as the IP of the remote receiving file server, the directory of the remote receiving file, and retransmission or breakpoint resumption. The program obtains the size of the file segmentation data block from the configuration file, and the program obtains the number of CPU cores (or the number of hyperthreads) on the current machine (the machine where the program is deployed). If the current machine is only used to send large data files and there is only this one program service, then the program can keep the number of threads for concurrent transmission consistent with the number of CPU cores when setting it. If there are other services running on the current machine, the number of cores to be used is calculated on demand (for example, the number of CPU cores divided by 2). It must be ensured that the number of concurrency in the program multiplied by the size of the data block processed by each thread cannot be greater than the total memory of the machine (when the current machine has only this one service for transmitting data).
[0059] The main logic of file transfer is that the program sets the concurrency and data block size in the previous step, and specifies the address and directory of the receiving file server. Then, it is handed over to the internal logic of the thread to handle the remote transmission task of each data block.
[0060] When transferring the files sent concurrently in the previous step over the network, the maximum bandwidth supported by the network card should be no less than the network bandwidth as much as possible, so as to achieve more efficient and faster file transfer.
[0061] The thread obtains the size of the current data block that has been written at a specified interval (such as 1 second) and updates this value to the corresponding record in the database. After the current thread processes the entire data block, the transfer status flag in the database needs to be changed to SUCCESS. When the logic inside the thread encounters an exception, it must be captured and processed. The processing mainly changes the transfer status flag in the database to FAILED.
[0062] After the transfer is completed, the program calls the file merging service on the remote file server to merge the transferred files into one large file.
[0063] Retransmission and breakpoint resume instructions:
[0064] If retransmission is required (this is often because the original file to be transferred has changed), the program needs to do the following: 1) call the service on the remote receiving file server to delete the previously transferred file; 2) delete the record of the current file id in the database (or do not delete it, but the file id needs to be distinguished when transferring the same file again); 3) perform the above operations for transferring the file.
[0065] If the transfer is resumed from a breakpoint (this is because the program returned an exception in step 4, resulting in the related thread not having completed transferring the data block of the current thread: the transfer status is FAILED, and the most extreme case is that the machine crashes: the transfer status is RUNNING), the program needs to do the following: 1) obtain the records in the database whose "transfer status" flags are FAILED and RUNNING in the current resumed file id; 2) split the file (make sure the splitting parameters are consistent with the last transmission), and only transfer the split blocks corresponding to the FAILED and RUNNING records, starting from the "transferred size" field value in the database, thus achieving the effect of resuming the transfer from a breakpoint.
[0066] Embodiment 2:
[0067] Please refer to Figure 3 , Figure 3 Schematic diagram of the structure of the concurrent file transmission system of the present invention. Figure 3 A concurrent file transmission system of the present invention, comprising:
[0068] A file receiving module, wherein the file receiving module receives the original file and transmission parameters;
[0069] A file processing module, wherein the file processing module divides the original file into a plurality of data blocks according to the transmission parameters;
[0070] A data block transmission module, wherein the data block transmission module concurrently transmits a plurality of the data blocks to a receiving end through a network according to transmission parameters;
[0071] A data block merging module is used to merge the plurality of data blocks on the receiving end to form the original file through a merge file service.
[0072] The above-mentioned concurrent file transmission system further includes:
[0073] A data block transmission monitoring module is used to obtain the size, transmission status and data block ID of the data block written into the receiving end at a specified time interval.
[0074] The above-mentioned concurrent file transmission system, wherein the transmission parameters include: receiving end IP, remote receiving file directory, retransmission, breakpoint resume, configuration file and the number of CPU cores of the sending end;
[0075] The file processing module obtains the data block size through the configuration file, divides the original file according to the data block size, and sets the number of threads for concurrent transmission according to the number of CPU cores in the file processing module;
[0076] In the data block transmission module, the data block is transmitted to the remote receiving file directory of the receiving end according to the receiving end IP.
[0077] In the above-mentioned concurrent file transmission system, after the transmission of each data block is completed, the transmission status flag is set to SUCCESS; when an exception occurs during the transmission of a data block, the transmission status flag is set to FAILED or RUNNING, and when the breakpoint is resumed, only the data block with the transmission status flag of FAILED or RUNNING is transmitted.
[0078] Embodiment three:
[0079] Combination Figure 4 As shown, this embodiment discloses a specific implementation of an electronic device. The electronic device may include a processor 81 and a memory 82 storing computer program instructions.
[0080] Specifically, the processor 81 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0081] Among them, the memory 82 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 82 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 82 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 82 may be inside or outside the data processing device. In a specific embodiment, the memory 82 is a non-volatile memory. In a specific embodiment, the memory 82 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable ProgrammableRead-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable ProgrammableRead-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0082] The memory 82 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 81 .
[0083] The processor 81 implements any one of the concurrent file transmission methods in the above embodiments by reading and executing computer program instructions stored in the memory 82 .
[0084] In some of the embodiments, the electronic device may further include a communication interface 83 and a bus 80. Figure 4 As shown, the processor 81, the memory 82, and the communication interface 83 are connected via a bus 80 and communicate with each other.
[0085] The communication interface 83 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication port 83 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.
[0086] The bus 80 includes hardware, software or both, and couples the components of the electronic device to each other. The bus 80 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 80 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 80 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0087] The electronic device can be combined based on concurrent file transmission to achieve Figure 2 Describe the method.
[0088] In addition, in combination with the file concurrent transmission method in the above embodiment, the present application embodiment can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the file concurrent transmission methods in the above embodiment is implemented.
[0089] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0090] In summary, the beneficial effects of the present invention are that the present invention reduces transmission time, improves transmission efficiency, and reduces the efficiency of failed retransmission due to support for breakpoint resume transmission.
[0091] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of protection of the invention. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the attached claims.
Claims
1. A method for concurrent file transmission, characterized in that: include: File receiving step: receiving the original file and transmission parameters, wherein the transmission parameters include: receiving end IP, remote receiving file directory, retransmission, breakpoint resume, configuration file and number of CPU cores of the sending end; File processing step: dividing the original file into multiple data blocks according to the transmission parameters, wherein in the file processing step, the data block size is obtained through the configuration file, and the original file is divided according to the data block size, and in the file processing step, the number of threads for concurrent transmission is set according to the number of CPU cores; Data block transmission step: transmitting a plurality of the data blocks to the receiving end through the network concurrently according to the transmission parameters, wherein the data blocks are transmitted to the remote receiving file directory of the receiving end according to the IP address of the receiving end; Data block merging step: merging the plurality of data blocks at the receiving end through a merge file service to form the original file.
2. The method for concurrent file transmission according to claim 1, characterized in that: Also includes: Data block transmission monitoring step: every specified time, obtain the size, transmission status and data block id of the data block that has been written to the receiving end.
3. The method for concurrent file transmission according to claim 2, characterized in that: The data block transmission step includes: after each data block is transmitted, the transmission status flag is set to SUCCESS; when an exception occurs during the transmission of a data block, the transmission status flag is set to FAILED or RUNNING, and when the transmission is resumed from the breakpoint, only the data block with the transmission status flag of FAILED or RUNNING is transmitted.
4. A concurrent file transmission system, characterized in that: include: A file receiving module, which receives the original file and transmission parameters, including: receiving end IP, remote receiving file directory, retransmission, breakpoint resume, configuration file and the number of CPU cores of the sending end; A file processing module, wherein the file processing module divides the original file into a plurality of data blocks according to the transmission parameters, wherein the file processing module obtains a data block size through the configuration file, divides the original file according to the data block size, and sets the number of threads for concurrent transmission according to the number of CPU cores in the file processing module; A data block transmission module, wherein the data block transmission module concurrently transmits a plurality of the data blocks to a receiving end through a network according to transmission parameters, wherein the data blocks are transmitted to the remote receiving file directory of the receiving end according to the IP address of the receiving end; A data block merging module is used to merge the plurality of data blocks on the receiving end to form the original file through a merge file service.
5. The concurrent file transmission system according to claim 4, characterized in that: Also includes: A data block transmission monitoring module is used to obtain the size, transmission status and data block ID of the data block written into the receiving end at a specified time interval.
6. The concurrent file transmission system according to claim 5, characterized in that: After the transmission of each data block is completed, the transmission status flag is set to SUCCESS; when an exception occurs during the transmission of a data block, the transmission status flag is set to FAILED or RUNNING. During breakpoint resumption, only the data block with the transmission status flag of FAILED or RUNNING is transmitted.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for concurrent file transmission according to any one of claims 1 to 3 is implemented.
8. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the concurrent file transmission method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
File transmission method and system
CN105100140A
File receiving method and device and file transmission system
CN105933412A
File transmission method, device and system, electronic device and storage medium
CN111245748A
File transmission method, device and equipment and computer readable storage medium
CN112351086A
File transmission method and device based on HTTP protocol
CN112398916A
