Data transmission method and device, equipment and medium
By caching data in memory and reading and sending file system data step by step, the problem of slow data transmission speed is solved, achieving fast transmission and efficient memory utilization.
Patent Information
- Application Number
- CN202511231876.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2025-11-14
AI Technical Summary
In existing technologies, data reading from the file system is slow during data transfer between devices, resulting in long waiting times for data requesting devices.
By caching some data in memory and reading it step by step from the file system, and combining this with the data request device's fragmented acquisition request, data can be read and sent simultaneously, and expired data in memory can be cleaned up.
It improved data transfer speed, reduced peak memory usage, and enhanced memory utilization and transfer efficiency.
Smart Images

Figure CN120957191A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a data transmission method, apparatus, device, and medium. Background Technology
[0002] Currently, the specific implementation method for data transmission between devices is as follows: the data requesting device sends a data request to the data sending device; based on the data request, the data sending device reads the requested data from the file system; and the requested data read from the file system is sent to the data requesting device all at once. However, when reading the requested data from the file system, there is a problem of slow reading speed, which leads to a long waiting time for the data requesting device. Summary of the Invention
[0003] One objective of this application is to provide a new technical solution for data transmission.
[0004] According to a first aspect of this application, a data transmission method is provided, the method being applied to a data transmitting device, comprising:
[0005] The receiving data request device sends a first fragment acquisition request for the first target data, the first fragment acquisition request including the target offset and the target data amount of the requested data;
[0006] In response to the first shard acquisition request, if the current data volume in memory is less than or equal to the first preset data volume, the second target data of the first target data that has not been read into the memory is stored in the memory. The capacity of the memory is the third preset data volume, which is less than the data volume of the first target data. The second preset data volume is the difference between the third preset data volume and the current data volume. The first preset data volume is less than or equal to the third preset data volume and greater than or equal to the target data volume.
[0007] Read the third target data, which is the target data amount starting from the target offset, from the memory, and send the third target data to the data request device;
[0008] If the target offset in the first fragment acquisition request is greater than the target offset in the second fragment acquisition request, delete the data in the memory between the target offset in the first fragment acquisition request and the target offset in the second fragment acquisition request, where the second fragment acquisition request is the first fragment acquisition request previously received by the data sending device.
[0009] Optionally, when the current data volume in memory is less than or equal to the first preset data volume, storing the second target data volume of the first target data that has not been read into the memory into the memory includes:
[0010] If the current amount of data in the memory is less than or equal to the first preset amount of data, and the amount of data in the first target data that has not been read into the memory is non-zero, then the second target data of the second preset amount of data in the first target data that has not been read into the memory is stored in the memory.
[0011] Optionally, before reading third target data of the target data amount from the target offset from the memory and sending the third target data to the data requesting device, the method further includes:
[0012] If the data in the memory does not include the third target data of the target data amount from the target offset, then the memory is cleared.
[0013] The third preset data amount, starting from the target offset, in the first target data will be stored in the memory.
[0014] Optionally, before storing the second target data (a second preset amount of data not yet read into the memory) into the memory when the current amount of data in memory is less than or equal to a first preset amount of data, the method further includes:
[0015] Obtain the bandwidth between the data sending device and the data requesting device;
[0016] The first preset data volume is determined based on the bandwidth.
[0017] Optionally, before the receiving data request device sends a first fragment acquisition request for the first target data, the method further includes:
[0018] Request memory with a capacity equal to the third preset data volume.
[0019] According to a second aspect of this application, a data transmission method is provided, the method being applied to a data requesting device, comprising:
[0020] Send a first fragment acquisition request for the first target data to the data transmission device. The first fragment acquisition request includes the target offset of the requested data and the target data volume.
[0021] Detect whether the third target data sent by the data sending device in response to the first fragment acquisition request has been received;
[0022] If the third target data is not received, the first fragment acquisition request is repeatedly sent to the data sending device;
[0023] Upon receiving the third target data, a new first fragment acquisition request is generated, and the process of sending the first fragment acquisition request for the first target data to the data sending device is repeated until the first target data is acquired.
[0024] Optionally, before sending the first fragment acquisition request for the first target data to the data sending device, the method further includes:
[0025] Obtain the bandwidth between the data sending device and the data requesting device;
[0026] The target data volume is determined based on the bandwidth.
[0027] According to a second aspect of this application, a data transmission apparatus is provided, wherein when the data transmission apparatus is applied to a data transmitting device, the data transmission apparatus includes:
[0028] The receiving module is used to receive a first fragment acquisition request for the first target data sent by the data requesting device. The first fragment acquisition request includes the target offset and the target data volume of the requested data.
[0029] A storage module is configured to, in response to the first shard acquisition request, store a second target data of a second preset data amount that has not been read into the memory in the first target data, when the current data amount in the memory is less than or equal to a first preset data amount, into the memory. The memory has a capacity of a third preset data amount, which is less than the data amount of the first target data. The second preset data amount is the difference between the third preset data amount and the current data amount. The first preset data amount is less than or equal to the third preset data amount and greater than or equal to the target data amount.
[0030] The first sending module is used to read third target data of the target data amount starting from the target offset from the memory, and send the third target data to the data requesting device;
[0031] The deletion module is used to delete data in the memory between the target offset in the first fragment acquisition request and the target offset in the second fragment acquisition request when the target offset in the first fragment acquisition request is greater than the target offset in the second fragment acquisition request. The second fragment acquisition request is the first fragment acquisition request previously received by the data sending device.
[0032] When the data transmission device is used in a data request device, the data transmission device includes:
[0033] The second sending module is used to send a first fragment acquisition request for the first target data to the data sending device. The first fragment acquisition request includes the target offset of the requested data and the target data volume.
[0034] The detection module is used to detect whether the third target data sent by the data sending device in response to the first fragment acquisition request has been received;
[0035] The second sending module is further configured to repeatedly send the first fragment acquisition request to the data sending device when the third target data is not received, and to generate a new first fragment acquisition request when the third target data is received, and to repeatedly send the first fragment acquisition request for the first target data to the data sending device until the first target data is acquired.
[0036] According to a third aspect of this application, an electronic device is provided, wherein, when the electronic device is a data transmitting device, the electronic device includes a data transmission means as described in the second aspect for use with the data transmitting device;
[0037] When the electronic device is a data requesting device, the electronic device includes a data transmission means as described in the second aspect for use with the data requesting device;
[0038] Alternatively, the electronic device includes a memory and a processor, the memory for storing computer instructions and the processor for retrieving the computer instructions from the memory to perform the method as described in any one of the first aspects.
[0039] According to a fourth aspect of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method according to any one of the first and second aspects.
[0040] This application provides a data transmission method, which, when applied to a data sending device, includes: receiving a first fragment acquisition request for first target data sent by a data requesting device, the first fragment acquisition request including a target offset and a target data volume of the requested data; responding to the first fragment acquisition request, if the current data volume in memory is less than or equal to a first preset data volume, storing a second target data volume of the first target data that has not been read into memory into memory, the memory having a capacity of a third preset data volume, the third preset data volume being less than the data volume of the first target data, the second preset data volume being the difference between the third preset data volume and the current data volume, the first preset data volume being less than or equal to the third preset data volume and greater than or equal to the target data volume; reading a third target data volume of the target data volume starting from the target offset from memory, and sending the third target data to the data requesting device; if the target offset in the first fragment acquisition request is greater than the target offset in the second fragment acquisition request, deleting data in memory between the target offset in the first fragment acquisition request and the target offset in the second fragment acquisition request, the second fragment acquisition request being the first fragment acquisition request previously received by the data sending device. This method enables data transmission that simultaneously reads data from the file system and sends it to the requesting device. Compared to directly reading the complete target data from the file system and then sending it all at once, this method offers faster transmission speeds. Furthermore, it eliminates the need to allocate memory equal to the amount of target data, thus reducing peak memory usage. Additionally, it cleans up expired data in memory, reducing memory load and improving memory utilization.
[0041] Other features and advantages of this application will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0042] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments of the present application and, together with their description, serve to explain the principles of the present application.
[0043] Figure 1 This is a flowchart illustrating a data transmission method applied to a data request device provided in this application;
[0044] Figure 2 This is a schematic flowchart of a data transmission method applied to a data transmission device provided in this application;
[0045] Figure 3 This is a schematic diagram of the structure of a data transmission device applied to a data transmission equipment provided in this application;
[0046] Figure 4 This is a schematic diagram of the structure of a data transmission device applied to a data request device provided in this application;
[0047] Figure 5 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation
[0048] Various exemplary embodiments of the present application will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present application.
[0049] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the scope of this application and its application or use.
[0050] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0051] In all the examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.
[0052] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0053] This application provides a data transmission method for transmitting data from a data sending device to a data requesting device. For example, it can be applied to transferring files from a mobile phone to a smart wearable device. When this method is applied to a data requesting device, such as... Figure 1 As shown, the method includes the following steps S1100 to S1400.
[0054] Step S1100: Send a first fragment acquisition request for the first target data to the data sending device.
[0055] The first shard acquisition request includes the target offset of the requested data and the target data volume.
[0056] In this embodiment, the data sending device and the data requesting device are connected via wired or wireless means. The data requesting device sends a first fragment acquisition request to the data sending device based on the aforementioned communication connection.
[0057] The first target data is the complete data that the data sending device wants to send to the data requesting device, and it is stored in the file system of the data sending device. In one example, the first target data is a video file. It should be noted that the data transmission method provided in this application is based on the premise that both the data sending device and the data requesting device have clearly defined the first target data. For example, before executing the data transmission method provided in this application, the user has already selected the first target data to be sent to the data requesting device on the data sending device side, the data sending device has informed the data requesting device of the offset information of the first target data (e.g., what the offsets are), and the data sending function of the data sending device and the data receiving function of the data requesting device have been enabled.
[0058] The target offset indicates the position of the requested data within the first target data. For example, when the target offset is 1000 bits, it refers to the position corresponding to the 1000th byte in the first target data. The target data size indicates the length of the requested data. The first fragment acquisition request is used to request the data sending device to send the third target data, representing the target data size starting from the position corresponding to the target offset, from the first target data to the data requesting device. The first fragment acquisition request is the fragment acquisition request currently sent by the data requesting device to the data sending device.
[0059] Corresponding to step S1100 above, when the data transmission method provided in this application is applied to a data transmission device, such as Figure 2 As shown, it includes the following steps S2100 to S2400.
[0060] Step S2100: Receive the first fragment acquisition request for the first target data sent by the data request device.
[0061] The first shard acquisition request includes the target offset of the requested data and the target data volume.
[0062] Corresponding to step S1100, after the data requesting device sends a first fragment acquisition request to the data sending device, the data sending device receives the first fragment acquisition request for the first target data sent by the data requesting device. It can be understood that the first fragment acquisition request is the fragment acquisition request currently received by the data sending device.
[0063] Furthermore, after receiving the first fragment acquisition request, the data sending device determines that the data requested by the data requesting device is the third target data in the first target data, starting from the target offset, and then executes the following step S2200.
[0064] Step S2200: In response to the first fragment acquisition request, if the current data volume in memory is less than or equal to the first preset data volume, store the second target data, which is the second preset data volume that has not been read into memory, into memory.
[0065] The memory capacity is a third preset data volume, which is less than the first target data volume. The second preset data volume is the difference between the third preset data volume and the current data volume. The first preset data volume is less than or equal to the third preset data volume and greater than or equal to the target data volume.
[0066] Based on the above step S2200, in one embodiment of this application, the data transmission method provided by this application further includes the following step S2110 before the above step S2100.
[0067] Step S2110: Request memory with a capacity of the third preset data amount.
[0068] In this embodiment, the memory is used to store a third preset data amount from the first target data read from the file system. The third preset data amount is less than the data amount of the first target data, meaning the memory capacity is less than the data amount of the first target data. Therefore, this application does not require a memory capacity equal to the data amount of the first target data, thus reducing peak memory usage.
[0069] Regarding step S2200 above, upon receiving the first fragment acquisition request from the data requesting device, if the amount of data stored in memory is less than the first preset data amount (since the first preset data amount is greater than or equal to the target data amount), there is a possibility that the data sending device cannot successfully send the target data amount to the data requesting device. Therefore, upon receiving the first fragment acquisition request, it is first determined whether the current data amount in memory is less than or equal to the first preset data amount. If the current data amount in memory is less than or equal to the first preset data amount, the second target data, which is the second preset data amount that has not been read into memory from the first target data stored in the file system, is stored in memory. The second preset data amount is the difference between the third preset data amount and the current data amount. In other words, if the current data amount in memory is less than or equal to the first preset data amount, data is first pre-filled into memory to fill the memory, and then step S2300 is executed.
[0070] Corresponding to step S2200 above, if the current amount of data in memory is greater than the first preset amount of data, then step S2300 below will be executed directly.
[0071] Step S2300: Read the third target data from the target offset starting from the memory, and send the third target data to the data request device.
[0072] By using the above step S2300, the data requested by the first fragment acquisition request can be sent to the data requesting device.
[0073] The above steps S2200 and S2300 achieve the following: First, a portion of the first target data is read from the file system and stored in memory. At the same time, a portion of the data stored in memory is sent to the data request device. This realizes a data transmission method that reads data from the file system and sends data to the data request device simultaneously. Compared with directly reading the complete first target data from the file system and then sending the complete first target data to the data request device all at once, this method has a faster transmission speed.
[0074] Corresponding to step S2300 above, due to issues such as communication quality between the data requesting device and the data sending device, the data requesting device may receive or fail to receive the third target data. Therefore, when the data transmission method provided in this application is applied to the data requesting device, the data requesting device performs the following step S1200.
[0075] Step S1200: Detect whether the third target data sent by the data sending device in response to the first fragment acquisition request has been received.
[0076] In one embodiment of this application, after sending a first fragment acquisition request, the data requesting device determines whether third target data has been received within a set time period. If the third target data is not received within the aforementioned set time period, it is determined that the third target data has not been received, and step S1300 is executed. Conversely, if the third target data is received within the aforementioned set time period, it is determined that the third target data has been received, and step S1400 is executed. The set time period is the maximum duration between the time the data requesting device sends the first fragment acquisition request and the time it receives the corresponding third target data, and can be set based on experience.
[0077] In step S1300, if the third target data is not received, the first fragment acquisition request is repeatedly sent to the data sending device.
[0078] If the third target data is not received, the same first fragment acquisition request as the first fragment acquisition request in step S1100 above is repeatedly sent to the data sending device to request the third target data requested by the first fragment acquisition request again.
[0079] Corresponding to step S1300 above, when the data transmission method provided in this application is applied to a data transmitting device, the data transmitting device repeatedly executes step S2100 above to send the third target data requested by the latest received first fragment acquisition request to the data requesting device, that is, repeatedly sending the third target data sent last time.
[0080] In step S1400, upon receiving the third target data, a new first fragment acquisition request is generated, and the process of repeatedly sending the first fragment acquisition request for the first target data to the data sending device is repeated until the first target data is acquired.
[0081] Upon receiving the third target data, a new first fragment acquisition request is generated. Step S1100 is repeated for this new first fragment acquisition request to continue acquiring the target data amount that was not acquired from the first target data. It is understood that the target offset in the new first fragment acquisition request differs from the target offset in the first fragment acquisition request already sent to the data transmission device.
[0082] Corresponding to step S1400 above, when the data transmission method provided in this application is applied to a data requesting device, the data requesting device executes the following step S2400.
[0083] Step S2400: If the target offset in the first slice acquisition request is greater than the target offset in the second slice acquisition request, delete the data in memory between the target offset in the first slice acquisition request and the target offset in the second slice acquisition request.
[0084] The second fragment acquisition request is the first fragment acquisition request previously received by the data sending device.
[0085] In this embodiment, if the target offset in the first fragment acquisition request is greater than the target offset in the second fragment acquisition request, it is determined that the data requesting device has received the third target data requested by the second fragment acquisition request, that is, it has received the data in memory between the target offsets in the first and second fragment acquisition requests. At this point, the data between the target offsets in the first and second fragment acquisition requests is deleted from memory to clean up expired data in memory, which reduces memory load and improves memory utilization.
[0086] Corresponding to step S2400 above, if the target offset in the first fragment acquisition request is equal to the target offset in the second fragment acquisition request, it is determined that the data requesting device has not received the third target data requested by the second fragment acquisition request. In this case, no data in memory is deleted.
[0087] As can be seen from the above description, in the data transmission method provided in this application, the first target data is read from the file system step by step and stored in the memory, and then the data is read from the memory to be sent to the data requesting device. Compared with reading the first target data directly from the file system, this can reduce the waiting time of the data requesting device and improve the transmission efficiency.
[0088] This application provides a data transmission method, which, when applied to a data sending device, includes: receiving a first fragment acquisition request for first target data sent by a data requesting device, the first fragment acquisition request including a target offset and a target data volume of the requested data; responding to the first fragment acquisition request, if the current data volume in memory is less than or equal to a first preset data volume, storing a second target data volume of the first target data that has not been read into memory into memory, the memory having a capacity of a third preset data volume, the third preset data volume being less than the data volume of the first target data, the second preset data volume being the difference between the third preset data volume and the current data volume, the first preset data volume being less than or equal to the third preset data volume and greater than or equal to the target data volume; reading a third target data volume of the target data volume starting from the target offset from memory, and sending the third target data to the data requesting device; if the target offset in the first fragment acquisition request is greater than the target offset in the second fragment acquisition request, deleting data in memory between the target offset in the first fragment acquisition request and the target offset in the second fragment acquisition request, the second fragment acquisition request being the first fragment acquisition request previously received by the data sending device. This method enables data transmission that simultaneously reads data from the file system and sends it to the requesting device. Compared to directly reading the complete target data from the file system and then sending it all at once, this method offers faster transmission speeds. Furthermore, it eliminates the need to allocate memory equal to the amount of target data, thus reducing peak memory usage. Additionally, it cleans up expired data in memory, reducing memory load and improving memory utilization.
[0089] In one embodiment of this application, the step S2200 above, which involves storing the second target data (the second preset data amount that was not read into memory from the first target data) into memory when the current data amount in memory is less than or equal to the first preset data amount, is specifically implemented through the following step S2210.
[0090] Step S2210: If the current data volume in memory is less than or equal to the first preset data volume, and the amount of data in the first target data that has not been read into memory is non-zero, store the second target data of the second preset data volume that has not been read into memory into memory.
[0091] In this embodiment, if the current amount of data in memory is less than or equal to the first preset data amount, and the amount of data in the first target data that has not been read into memory is non-zero, it indicates that some data in the first target data has not been read into memory. In this case, the second target data of the second preset amount that has not been read into memory is stored in memory.
[0092] It should be noted that if the current amount of data in memory is less than or equal to the first preset amount of data, and the amount of data in the first target data that has not been read into memory is non-zero, then if the amount of data in the first target data that has not been read into memory does not reach the second preset amount of data, then all the data that has not been read into memory will be read and cached into memory.
[0093] Corresponding to step S2210 above, if the current amount of data in memory is less than or equal to the first preset amount of data, and the amount of data in the first target data that has not been read into memory is 0, then it indicates that all of the first target data has been stored in memory. At this time, step S2300 above is executed.
[0094] In one embodiment of this application, in response to the random access requirements of a data requesting device, when the data transmission method provided in this application is applied to a data sending device, the data sending device first executes the following steps S2310 and S2311 before executing the above step S2300.
[0095] Step S2310: If the data in memory does not include the third target data from the target offset, clear the memory.
[0096] Step S2311: Store the third preset amount of data starting from the target offset into memory.
[0097] In this embodiment, if the data in memory does not include the third target data starting from the target offset, the memory is cleared, and the third preset data amount starting from the target offset from the first target data is re-stored in memory. This allows the data sending device to read the third target data that matches the first fragment acquisition request from memory and send it to the data requesting device. This satisfies the random access requirements of the data requesting device.
[0098] In one embodiment of this application, when the data transmission method provided in this application is applied to a data transmitting device, before the data transmitting device stores the second target data of the second preset data amount that has not been read into memory in the first target data into memory when the current data amount in memory is less than or equal to the first preset data amount in step S2200, the following steps S2220 and S2221 are further included.
[0099] Step S2220: Obtain the bandwidth between the data sending device and the data requesting device.
[0100] Step S2221: Determine the first preset data volume based on the bandwidth.
[0101] In this embodiment, step S2220 can be implemented using conventional methods for determining inter-device bandwidth. That is to say, the data transmission method provided in this application does not limit the specific implementation of step S2220.
[0102] In this embodiment, there is a corresponding relationship between the bandwidth between the data sending device and the data requesting device and the first preset data amount. This relationship can be determined based on experience or experimentation. Specifically, the larger the bandwidth between the data sending device and the data requesting device, the larger the first preset data amount. This is because a larger bandwidth indicates a faster data transmission speed between the data sending device and the data requesting device. Furthermore, a larger first preset data amount can minimize the possibility of the data sending device being unable to retrieve the third target data from memory.
[0103] In one embodiment of this application, when the data transmission method provided in this application is applied to a data requesting device, the data requesting device first executes the above-mentioned steps S1110 and S1111 before executing the above-mentioned step S1100.
[0104] Step S1110: Obtain the bandwidth between the data sending device and the data requesting device.
[0105] Step S1111: Determine the target data volume based on the bandwidth.
[0106] In this embodiment, there is a correspondence between the bandwidth between the data sending device and the data requesting device and the target data volume. This correspondence can be determined based on experience or experimentation. Specifically, the larger the bandwidth between the data sending device and the data requesting device, the larger the target data volume. This is because a larger bandwidth between the data sending device and the data requesting device indicates a faster data transmission speed between them. Therefore, a larger target data volume allows for faster transmission of the first target data.
[0107] Based on any of the above embodiments, in one embodiment of this application, after the data requesting device receives the complete first target data, it sends a stop-transmission notification to the data sending device, indicating that it will no longer request data. Furthermore, after receiving the notification, the data sending device releases its memory.
[0108] Regarding the above, taking an example where the first target data size is 5000 bits, the memory capacity (i.e., the third preset data size) is 1000 bits, the first preset data size is 100 bits, and the target data size is 100 bits, the specific process of the data transmission method provided in this application is as follows:
[0109] Step S1: Initially, the memory is empty;
[0110] Step S2, the data requesting device sends a first first fragment acquisition request to the data sending device. The first fragment acquisition request includes a target offset of 0 and a target data size of 100 bits.
[0111] In step S3, the data sending device receives a first fragment acquisition request, which includes a target offset of 0 and a target data size of 100 bits. If it determines that there is insufficient data in memory, it reads data from 0 to 1000 bits of the first target data from the file system and stores it in memory. Then, based on the first fragment acquisition request, it determines that the data with offsets from 0 to 99 is the third target data, that is, the data from 0 to 99 bits of the first target data is the third target data. At this time, it reads data from 0 to 99 bits from memory and sends it to the data requesting device.
[0112] In step S4, if the data requesting device receives 0-99 bits of data, it sends a second first fragment acquisition request to the data sending device. The first fragment acquisition request includes a target offset of 100 and a target data amount of 100 bits. If the 0-99 bits of data are not received, the first fragment acquisition request with a target offset of 0 and a target data amount of 100 bits is repeatedly sent to the data sending device.
[0113] Step S5: Taking the data requesting device receiving 0-99 bits of data as an example, the data sending device receives a first fragment acquisition request including a target offset of 100 and a target data size of 100 bits. At this time, the data 0-99 bits in memory are deleted. Then, it is determined that the data size in the current memory is 900 bits, which is greater than 100 bits, so no data is pre-filled into the memory. Further, the data with offsets from 100 to 199 is determined to be the third target data, that is, the data from the 100th bit to the 199th bit in the first target data is the third target data. At this time, the data 100-199 bits are read from the memory and sent to the data requesting device.
[0114] Step S6 continues in this manner until the data requesting device sends a first fragment retrieval request to the data sending device, which includes a target offset of 900 and a target data size of 100 bits. At this point, the current data size in memory is 100 bits, equal to the first preset data size. Based on this, the data sending device first reads bits 1000-1899 of the first target data from the file system and stores it in memory, then reads bits 900-999 of the data from memory and sends it to the data requesting device.
[0115] Step S7 continues in this manner until the data requesting device sends a first fragment acquisition request to the data sending device, which includes a target offset of 4900 and a target data size of 100 bits. At this point, the current data size in memory is 100 bits, which is equal to the first preset data size. However, since the first target data has already been fully read into memory, 4900-4999 bits of data are directly read from memory and sent to the data requesting device. This completes the full transmission of 5000 bits of the first target data. After the data requesting device receives 4900-4999 bits of data, the data sending device releases the memory.
[0116] This application also provides a data transmission device 300, which, when applied to a data transmission device, such as... Figure 3 As shown, the data transmission device 300 includes:
[0117] The receiving module 310 is used to receive a first fragment acquisition request for the first target data sent by the data requesting device. The first fragment acquisition request includes the target offset and the target data amount of the requested data.
[0118] Storage module 320 is configured to, in response to the first shard acquisition request, store second target data of a second preset data amount that has not been read into the memory in the first target data, when the current data amount in the memory is less than or equal to a first preset data amount, store the second target data of the first target data of the second preset data amount in the memory, wherein the capacity of the memory is a third preset data amount, the third preset data amount is less than the data amount of the first target data, the second preset data amount is the difference between the third preset data amount and the current data amount, and the first preset data amount is less than or equal to the third preset data amount and greater than or equal to the target data amount;
[0119] The first sending module 330 is used to read third target data of the target data amount starting from the target offset from the memory, and send the third target data to the data requesting device;
[0120] The deletion module 340 is used to delete data in the memory between the target offset in the first fragment acquisition request and the target offset in the second fragment acquisition request when the target offset in the first fragment acquisition request is greater than the target offset in the second fragment acquisition request, wherein the second fragment acquisition request is the first fragment acquisition request previously received by the data sending device.
[0121] In one embodiment of this application, the storage module 320 is specifically configured to: store a second target data of a second preset data amount that has not been read into the memory into the memory when the current data amount in the memory is less than or equal to a first preset data amount and the amount of data in the first target data that has not been read into the memory is non-zero.
[0122] In one embodiment of this application, the storage module 320 is further configured to: clear the memory if the data in the memory does not include third target data of the target data amount starting from the target offset;
[0123] The third preset data amount, starting from the target offset, in the first target data will be stored in the memory.
[0124] In one embodiment of this application, when the data transmission 300 is applied to a data transmitting device, the data transmission device 300 further includes:
[0125] The first determining module is used to obtain the bandwidth between the data sending device and the data requesting device;
[0126] The first preset data volume is determined based on the bandwidth.
[0127] When this data transmission 300 is applied to a data requesting device, such as Figure 4 As shown, the data transmission device 300 includes:
[0128] The second sending module 350 is used to send a first fragment acquisition request for the first target data to the data sending device. The first fragment acquisition request includes the target offset of the requested data and the target data volume.
[0129] The detection module 360 is used to detect whether it receives third target data sent by the data sending device in response to the first fragment acquisition request;
[0130] The second sending module 350 is further configured to repeatedly send the first fragment acquisition request to the data sending device when the third target data is not received, and to generate a new first fragment acquisition request when the third target data is received, and to repeatedly send the first fragment acquisition request for the first target data to the data sending device until the first target data is acquired.
[0131] In one embodiment of this application, when the data transmission 300 is applied to a data requesting device, the data transmission device 300 further includes:
[0132] The second determining module is used to obtain the bandwidth between the data sending device and the data requesting device;
[0133] The target data volume is determined based on the bandwidth.
[0134] This application also provides an electronic device, wherein, when the electronic device is a data transmitting device, the electronic device includes any of the above-described data transmission means applied to the data transmitting device;
[0135] When the electronic device is a data requesting device, the electronic device includes any of the data transmission means applied to the data requesting device described above;
[0136] Or, such as Figure 5 As shown, the electronic device includes a memory 510 and a processor 520. The memory 510 is used to store computer instructions, and the processor 520 is used to retrieve the computer instructions from the memory 510 to execute any of the data transmission methods described in the above method embodiments.
[0137] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the data transmission methods described in the above method embodiments.
[0138] This application may be a system, method, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of this application.
[0139] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.
[0140] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0141] The computer program instructions used to perform the operations of this application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuits, such as programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), are personalized by utilizing state information from the computer-readable program instructions. These electronic circuits can execute the computer-readable program instructions to implement various aspects of this application.
[0142] Various aspects of this application are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0143] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0144] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0145] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions. It will be well known to those skilled in the art that implementation in hardware, implementation in software, and implementation using a combination of software and hardware are equivalent.
[0146] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical applications, or technical improvements to the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein. The scope of this application is defined by the appended claims.
Claims
1. A data transmission method, characterized in that, The method is applied to a data transmission device, including: The receiving data request device sends a first fragment acquisition request for the first target data, the first fragment acquisition request including the target offset and the target data amount of the requested data; In response to the first shard acquisition request, if the current data volume in memory is less than or equal to the first preset data volume, the second target data of the first target data that has not been read into the memory is stored in the memory. The capacity of the memory is the third preset data volume, which is less than the data volume of the first target data. The second preset data volume is the difference between the third preset data volume and the current data volume. The first preset data volume is less than or equal to the third preset data volume and greater than or equal to the target data volume. Read the third target data, which is the target data amount starting from the target offset, from the memory, and send the third target data to the data request device; If the target offset in the first fragment acquisition request is greater than the target offset in the second fragment acquisition request, delete the data in the memory between the target offset in the first fragment acquisition request and the target offset in the second fragment acquisition request, where the second fragment acquisition request is the first fragment acquisition request previously received by the data sending device.
2. The method according to claim 1, characterized in that, When the current data volume in memory is less than or equal to the first preset data volume, storing the second target data volume of the first target data that has not been read into the memory into the memory includes: If the current amount of data in the memory is less than or equal to the first preset amount of data, and the amount of data in the first target data that has not been read into the memory is non-zero, then the second target data of the second preset amount of data in the first target data that has not been read into the memory is stored in the memory.
3. The method according to claim 1, characterized in that, Before reading third target data of the target data amount starting from the target offset from the memory and sending the third target data to the data requesting device, the method further includes: If the data in the memory does not include the third target data of the target data amount from the target offset, then the memory is cleared. The third preset data amount, starting from the target offset, in the first target data will be stored in the memory.
4. The method according to claim 1, characterized in that, Before storing the second target data (amount not yet read from memory) into memory when the current data amount in memory is less than or equal to a first preset data amount, the method further includes: Obtain the bandwidth between the data sending device and the data requesting device; The first preset data volume is determined based on the bandwidth.
5. The method according to claim 1, characterized in that, Before the receiving data request device sends the first fragment acquisition request for the first target data, the method further includes: Request memory with a capacity equal to the third preset data volume.
6. A data transmission method, characterized in that, The method is applied to a data request device and includes: Send a first fragment acquisition request for the first target data to the data transmission device. The first fragment acquisition request includes the target offset of the requested data and the target data volume. Detect whether the third target data sent by the data sending device in response to the first fragment acquisition request has been received; If the third target data is not received, the first fragment acquisition request is repeatedly sent to the data sending device; Upon receiving the third target data, a new first fragment acquisition request is generated, and the process of sending the first fragment acquisition request for the first target data to the data sending device is repeated until the first target data is acquired.
7. The method according to claim 6, characterized in that, Before sending the first fragment acquisition request for the first target data to the data sending device, the method further includes: Obtain the bandwidth between the data sending device and the data requesting device; The target data volume is determined based on the bandwidth.
8. A data transmission device, characterized in that, When the data transmission device is used in a data transmission device, the data transmission device includes: The receiving module is used to receive a first fragment acquisition request for the first target data sent by the data requesting device. The first fragment acquisition request includes the target offset and the target data volume of the requested data. A storage module is configured to, in response to the first shard acquisition request, store a second target data of a second preset data amount that has not been read into the memory in the first target data, when the current data amount in the memory is less than or equal to a first preset data amount, into the memory. The memory has a capacity of a third preset data amount, which is less than the data amount of the first target data. The second preset data amount is the difference between the third preset data amount and the current data amount. The first preset data amount is less than or equal to the third preset data amount and greater than or equal to the target data amount. The first sending module is used to read third target data of the target data amount starting from the target offset from the memory, and send the third target data to the data requesting device; The deletion module is used to delete data in the memory between the target offset in the first fragment acquisition request and the target offset in the second fragment acquisition request when the target offset in the first fragment acquisition request is greater than the target offset in the second fragment acquisition request. The second fragment acquisition request is the first fragment acquisition request previously received by the data sending device. When the data transmission device is used in a data request device, the data transmission device includes: The second sending module is used to send a first fragment acquisition request for the first target data to the data sending device. The first fragment acquisition request includes the target offset of the requested data and the target data volume. The detection module is used to detect whether the third target data sent by the data sending device in response to the first fragment acquisition request has been received; The second sending module is further configured to repeatedly send the first fragment acquisition request to the data sending device when the third target data is not received, and to generate a new first fragment acquisition request when the third target data is received, and to repeatedly send the first fragment acquisition request for the first target data to the data sending device until the first target data is acquired.
9. An electronic device, characterized in that, When the electronic device is a data transmitting device, the electronic device includes the data transmission means applied to the data transmitting device as described in claim 8; When the electronic device is a data requesting device, the electronic device includes the data transmission means as described in claim 8 for use with the data requesting device; Alternatively, the electronic device includes a memory and a processor, the memory for storing computer instructions, and the processor for retrieving the computer instructions from the memory to perform the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the method according to any one of claims 1-7.