Data transmission method and apparatus, storage medium, and electronic device
Patent Information
- Application Number
- CN202311540951.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-17
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2043-11-17
AI Technical Summary
[0004]1,虽然服务器会以片段方式发送文件,但是片段大小并存在不一致,如片段较小会因需多次开关文件流而影响文件写入效率,如片段较大,会因传输时间过长导致传输阻塞;
[0019] This application enables the acquisition of a data packet containing multiple multiplexed data fragments corresponding to an upgrade request from a shared memory region in response to an upgrade request. This is achieved by storing the data packet in the shared memory region, enabling the sharing and multiplexing of data fragments. Furthermore, the data fragment to be transmitted, corresponding to the device number of the terminal device, is determined from these multiple data fragments. The device channel of the terminal device is then used to transmit the data fragment to the terminal device. Therefore, this addresses the technical problem in related technologies of how to improve the transmission efficiency of data packets to terminal devices.
Smart Images

Figure CN117579611B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data transmission, and more specifically, to a data transmission method, apparatus, storage medium, and electronic device. Background Technology
[0002] With the continuous development of modern Internet of Things (IoT) technology, online platforms will deploy terminal device systems across the country to collect data and provide better cloud services. However, as business grows, it is necessary to upgrade the terminal device systems regularly, and the key to upgrading lies in sending upgrade data packages to the terminal device systems.
[0003] The conventional approach involves the terminal device system using a socket connection to send a file download request to the platform's server. The server then responds by directly pushing the read file. However, this approach has the following issues:
[0004] 1. Although the server sends files in fragments, the fragment sizes are inconsistent. If the fragments are small, the file writing efficiency will be affected due to the need to open and close the file stream multiple times. If the fragments are large, the transmission time will be too long and cause transmission blockage.
[0005] 2. When a large number of terminal devices simultaneously request to upgrade to the same version, a large number of duplicate file fragments will be read into the server's memory. If this exceeds the memory's capacity, a memory overflow will occur, which will then cause the server's system to crash.
[0006] In summary, there is a technical problem in the existing technology of how to improve the transmission efficiency of data packets to terminal devices.
[0007] The technical problem of how to improve the transmission efficiency of data packets to terminal devices has not been effectively solved in the existing technology. Summary of the Invention
[0008] This application provides a data transmission method, apparatus, storage medium, and electronic device to at least solve the technical problem in the related art of how to improve the transmission efficiency of data packets to terminal devices.
[0009] According to one embodiment of this application, a data transmission method is provided, comprising: in response to an upgrade request from a terminal device, obtaining a data packet corresponding to the upgrade request from a shared memory region, wherein the data packet includes multiple data fragments, the multiple data fragments being determined based on server transmission parameters and the transmission parameters of the data packet, and each of the multiple data fragments supporting multiplexing; determining a data fragment to be transmitted from the multiple data fragments that corresponds to the device number of the terminal device; and transmitting the data fragment to be transmitted to the terminal device using the device channel of the terminal device.
[0010] In an exemplary embodiment, before retrieving a data packet corresponding to an upgrade request from a shared memory region in response to an upgrade request from a terminal device, the method further includes: determining, from the server's transmission parameters, the transmission bandwidth supported by the server and the number of terminal devices supported by the server for connection; determining, from the data packet's transmission parameters, the write speed of the data packet and the maximum transmission time of the data packet; obtaining a first product between the transmission bandwidth and the maximum transmission time, and obtaining a second product between the number of terminal devices and the write speed; determining the quotient between the first product and the second product as the data capacity of each data fragment within the data packet; and splitting the data packet using the data capacity of each data fragment to obtain the plurality of data fragments, wherein each data fragment corresponds to a fragment number.
[0011] In an exemplary embodiment, a data fragment to be transmitted corresponding to the device number of the terminal device is determined from the plurality of data fragments: a first data segment list corresponding to the device number of the terminal device is determined, wherein the first data segment list includes a first data fragment that has been transmitted in the plurality of data fragments; a second data fragment other than the first data fragment is determined from the plurality of data fragments, and the second data fragment is determined as the data fragment to be transmitted.
[0012] In an exemplary embodiment, transmitting the data fragment to be transmitted to the terminal device using the device channel of the terminal device includes: determining the fragment number of the data fragment to be transmitted; if, in the case that the data fragment corresponding to the fragment number of the data fragment to be transmitted is found among all data fragments stored in the shared memory region, and if it is determined that the data fragment corresponding to the fragment number is the last data fragment to be transmitted in the data packet, then determining a target device channel corresponding to the device number from among multiple device channels; and transmitting the data fragment to be transmitted to the terminal device using the target device channel.
[0013] In one exemplary embodiment, the method further includes: if, when a data fragment corresponding to the fragment number is found among all data fragments stored in the shared memory region, if it is determined that the data fragment corresponding to the fragment number is not the last data fragment to be transmitted in the data packet, then determining the remaining available memory space in the shared memory region; if it is determined that the space capacity of the remaining available memory space is greater than the data capacity of the data fragment to be transmitted, obtaining a third data fragment from a database, wherein the third data fragment is a backup data fragment of the data fragment to be transmitted in the database; storing the third data fragment in the remaining available storage space; determining a target device channel corresponding to the device number from among multiple device channels; transmitting the data fragment to be transmitted to the terminal device using the target device channel; after transmitting the data fragment to be transmitted to the terminal device, storing the fragment number of the data fragment to be transmitted in a second data segment list corresponding to the device number of the terminal device, wherein the second data segment list includes the fragment numbers of the data fragments that have been transmitted among the multiple data fragments.
[0014] In one exemplary embodiment, the method further includes: if the space capacity of the remaining available memory space is less than or equal to the data capacity of the data fragment to be transmitted, determining whether there is an expired data fragment, wherein the expired data fragment represents a data fragment that was not transmitted to the terminal device within the maximum transmission time of the data packet; if an expired data fragment is determined to exist, deleting the expired data fragment; if no expired data fragment is determined to exist, and if it is determined that there is a next data fragment to be transmitted among the plurality of data fragments, then using the target device channel to transmit the next data fragment to be transmitted to the terminal device.
[0015] In one exemplary embodiment, the method further includes: receiving feedback information from the terminal device after receiving the data fragment to be transmitted; if it is determined that the feedback information indicates that the terminal device has successfully written the data fragment to be transmitted, deleting the fragment number of the data fragment to be transmitted from a second data fragment list, wherein the second data fragment list includes the fragment numbers of data fragments that have been transmitted in the plurality of data fragments; if it is determined that the data fragment to be transmitted is currently not occupied, deleting the data fragment to be transmitted from the shared memory region.
[0016] According to another embodiment of this application, a data transmission apparatus is provided, comprising: a data packet acquisition module, configured to acquire a data packet corresponding to the upgrade request from a shared memory region in response to an upgrade request from a terminal device, wherein the data packet includes multiple data fragments, the multiple data fragments being determined based on server transmission parameters and the transmission parameters of the data packet, and each of the multiple data fragments supporting multiplexing; a data fragment determination module, configured to determine, from the multiple data fragments, a data fragment to be transmitted corresponding to the device number of the terminal device; and a data fragment transmission module, configured to transmit the data fragment to be transmitted to the terminal device using the device channel of the terminal device.
[0017] According to yet another embodiment of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and the computer program is configured to perform the steps in any of the above method embodiments when it is run.
[0018] According to yet another embodiment of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0019] This application enables the acquisition of a data packet containing multiple multiplexed data fragments corresponding to an upgrade request from a shared memory region in response to an upgrade request. This is achieved by storing the data packet in the shared memory region, enabling the sharing and multiplexing of data fragments. Furthermore, the data fragment to be transmitted, corresponding to the device number of the terminal device, is determined from these multiple data fragments. The device channel of the terminal device is then used to transmit the data fragment to the terminal device. Therefore, this addresses the technical problem in related technologies of how to improve the transmission efficiency of data packets to terminal devices. Attached Figure Description
[0020] Figure 1 This is a hardware structure block diagram of a server device for a data transmission method according to an embodiment of this application;
[0021] Figure 2 This is a flowchart of a data transmission method according to an embodiment of this application;
[0022] Figure 3 This is a schematic diagram of a data packet according to an embodiment of this application;
[0023] Figure 4 This is a schematic diagram illustrating the principle of sending data packets within a shared memory region to different terminal devices according to an embodiment of this application;
[0024] Figure 5This is a flowchart illustrating a data transmission method according to an embodiment of this application;
[0025] Figure 6 This is a structural block diagram of a data transmission device according to an embodiment of this application. Detailed Implementation
[0026] The embodiments of this application will be described in detail below with reference to the accompanying drawings and examples.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0028] The methods and embodiments provided in this application can be executed on a server device or a similar computing device. Taking running on a server device as an example, Figure 1 This is a hardware structure block diagram of a server device for a data transmission method according to an embodiment of this application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The server device may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the server equipment described above. For example, the server equipment may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0029] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the data transmission method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thus implementing the aforementioned method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to server devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the server device. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0031] This embodiment provides a data transmission method. Figure 2 This is a flowchart of a data transmission method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps:
[0032] Step S202: In response to the upgrade request of the terminal device, a data packet corresponding to the upgrade request is obtained from the shared memory area. The data packet includes multiple data fragments, which are determined based on the server's transmission parameters and the data packet's transmission parameters. Each data fragment in the multiple data fragments supports reuse.
[0033] Understandably, for shared memory regions, the size of the shared memory region can be limited. For example, based on the transmission of data fragments, data fragments in the transmitted data packets can be periodically cleared. At the same time, data fragments can be numbered to ensure that all data fragments stored in the shared memory region are unique. This can improve the transmission efficiency of file segments under limited bandwidth and reduce the probability of blocking file transmissions on other terminal devices.
[0034] Step S204: Determine the data fragment to be transmitted from the plurality of data fragments that corresponds to the device number of the terminal device;
[0035] Step S206: Use the device channel of the terminal device to transmit the data to be transmitted in segments to the terminal device.
[0036] It is understood that the sending method for sending the data fragments to multiple terminal devices includes at least one of the following: parallel sending or independent sending. Therefore, in the above embodiment, for upgrade requests initiated by multiple terminal devices for the same data packet, the data fragments contained in the same data packet can be sent to each terminal device in parallel. It should be noted that different terminal devices may have different data fragments to be transmitted, but for each terminal device, all data fragments contained in the same data packet must be sent.
[0037] Through the above steps, in response to an upgrade request from a terminal device, a data packet containing multiple multiplexed data fragments corresponding to the upgrade request is obtained from the shared memory region; the data fragment to be transmitted, corresponding to the device number of the terminal device, is determined from the multiple data fragments; and the data fragment to be transmitted is transmitted to the terminal device using the device channel of the terminal device. This solves the technical problem in related technologies of how to improve the transmission efficiency of data packets to terminal devices.
[0038] In an exemplary embodiment, before executing the technical solution of obtaining the data packet corresponding to the upgrade request from the shared memory region in response to the upgrade request of the terminal device in step S202, a process for obtaining multiple data fragments is further implemented, specifically including the following steps: Step S11, determining the transmission bandwidth supported by the server and the number of terminal devices supported by the server from the transmission parameters of the server; determining the write speed of the data packet and the maximum transmission time of the data packet from the transmission parameters of the data packet; Step S12, obtaining a first product between the transmission bandwidth and the maximum transmission time, and obtaining a second product between the number of terminal devices and the write speed; Step S13, determining the quotient between the first product and the second product as the data capacity of each data fragment in the data packet; Step S14, splitting the data packet using the data capacity of each data fragment to obtain the multiple data fragments, wherein each data fragment corresponds to a fragment number.
[0039] Optionally, step S204 may further include: determining the data fragment to be transmitted corresponding to the device number of the terminal device from the plurality of data fragments; determining a first data segment list corresponding to the device number of the terminal device, wherein the first data segment list includes the first data fragments that have been transmitted in the plurality of data fragments; determining a second data fragment other than the first data fragment from the plurality of data fragments, and determining the second data fragment as the data fragment to be transmitted.
[0040] In an exemplary embodiment, the implementation scheme for step S206, which uses the device channel of the terminal device to transmit the data fragment to the terminal device, specifically includes the following steps: Step S21, determining the fragment number of the data fragment to be transmitted; Step S22, if the data fragment corresponding to the fragment number of the data fragment to be transmitted is found among all data fragments stored in the shared memory area, and if it is determined that the data fragment corresponding to the fragment number is the last data fragment to be transmitted in the data packet, then a target device channel corresponding to the device number is determined from among multiple device channels; Step S23, using the target device channel to transmit the data fragment to the terminal device.
[0041] In an exemplary embodiment, in addition to steps S21 to S23 described above, the method may further include: step S31, where, if the data fragment corresponding to the fragment number is found among all data fragments stored in the shared memory region, and if it is determined that the data fragment corresponding to the fragment number is not the last data fragment to be transmitted in the data packet, then the remaining available memory space in the shared memory region is determined; step S32, where, if it is determined that the space capacity of the remaining available memory space is greater than the data capacity of the data fragment to be transmitted, a third data fragment is obtained from the database, wherein the third data fragment is the data fragment to be transmitted in the database. The backup data fragments within the database; Step S33, storing the third data fragment in the remaining available storage space; Step S34, determining the target device channel corresponding to the device number from multiple device channels; Step S35, using the target device channel to transmit the data fragment to be transmitted to the terminal device; Step S36, after transmitting the data fragment to be transmitted to the terminal device, storing the fragment number of the data fragment to be transmitted in a second data segment list corresponding to the device number of the terminal device, wherein the second data segment list includes the fragment numbers of the data fragments that have been transmitted among the multiple data fragments.
[0042] Optionally, in one embodiment, the service bandwidth can be dynamically adjusted based on the remaining available memory space in the shared memory region when a terminal device accesses the network, thereby increasing the number of terminal devices that can access the network and maximizing the utilization of the shared memory region.
[0043] Furthermore, in this embodiment, if it is determined that the data fragment corresponding to the fragment number is not the last data fragment to be transmitted in the data packet, after transmitting the data fragment to be transmitted to the terminal device, the other data fragments to be transmitted among the plurality of data fragments will continue to be transmitted to the terminal device.
[0044] In an exemplary embodiment, further, while performing the above steps S31 to S36, the following implementation steps are also provided: Step S41, if it is determined that the space capacity of the remaining available memory space is less than or equal to the data capacity of the data fragment to be transmitted, determine whether there is an expired data fragment, wherein the expired data fragment represents a data fragment that was not transmitted to the terminal device within the maximum transmission time of the data packet; Step S42, if it is determined that there is an expired data fragment, delete the expired data fragment; Step S43, if it is determined that there is no expired data fragment, and if it is determined that there is a next data fragment to be transmitted among the plurality of data fragments, then use the target device channel to transmit the next data fragment to be transmitted to the terminal device.
[0045] Optionally, the process of determining the remaining available memory space of the shared memory region includes, for example, determining whether there is any remaining available space in the set shared memory region, wherein the size of the remaining available space is the difference between the total space capacity of the shared memory region and the used space capacity of the shared memory region.
[0046] Optionally, the existence of a next data fragment to be transmitted can be determined by: determining a third data fragment list corresponding to the device number of the terminal device, wherein the third data fragment list includes the fragment numbers of the data fragments to be transmitted among the plurality of data fragments. If a next fragment number following the fragment number of the data fragment to be transmitted can be read from the third data fragment list, then it is determined that a next data fragment to be transmitted exists among the plurality of data fragments.
[0047] In this embodiment, by periodically cleaning up expired data fragments, the probability of server-side data residue caused by one-way anomalies of terminal devices can be reduced.
[0048] In an exemplary embodiment, in addition to performing steps S202 to S206 as described above, the following implementation scheme is further proposed: receiving feedback information from the terminal device after receiving the data fragment to be transmitted; if it is determined that the feedback information is used to indicate that the terminal device has successfully written the data fragment to be transmitted, deleting the fragment number of the data fragment to be transmitted from the second data fragment list, wherein the second data fragment list includes the fragment numbers of data fragments that have been transmitted in the plurality of data fragments; if it is determined that the data fragment to be transmitted is currently not occupied, deleting the data fragment to be transmitted from the shared memory area.
[0049] Optionally, in one embodiment, combined with Figures 3 to 5 The following specific implementation process is proposed to illustrate the data transmission process. Figure 5This is a flowchart illustrating the data transmission method according to an embodiment of this application. The specific implementation steps are as follows:
[0050] Understandably, the following preparations are required before transmitting data:
[0051] 1. Set the size of the shared memory region, MaxShareSize, to store file fragments (i.e., data fragments in data packets) read from the file stream in the shared memory region;
[0052] 2. Create a queue listener on the server side and create a thread pool to start multiple threads to handle the process of transmitting data to multiple terminal devices;
[0053] 3. On the server side, based on the limited bandwidth, maximum number of terminal device connections, and terminal device file write rate, set the file segment size (fileSize) to be sent. Assuming the network bandwidth is set to X Mbps, the maximum number of terminal device connections is N, and the terminal device file write rate is WM / s, and assuming the system requires file segments to be transmitted completely within t seconds to prevent network congestion, the segment size (i.e., the data capacity of the aforementioned data segment) (fileSize) is calculated as follows:
[0054]
[0055] As can be seen, if the fragment size `fileSize` is a fixed value, then for a given request file, such as the data packet mentioned above, the number of data fragments in the data packet can be determined and numbered according to the order in which the data packet was split, such as... Figure 3 As shown, there are a total of n segments (equivalent to the data sharding mentioned above), where n is a positive integer.
[0056] It should be noted that by fixing the size of the data fragments in the same upgrade file data package and then numbering the data fragments, it is possible to achieve the goal of ensuring that all data fragments stored in the shared memory area are non-repeating and reusable.
[0057] Step S501: The terminal device sends an upgrade package download request to the server, initiates a socket connection establishment request, and creates a socket connection;
[0058] In step S502, the server receives a socket connection request initiated by the terminal device. First, it determines whether the maximum number of connections supported by the server has been reached (i.e., the number of terminal devices that the server supports connecting to). If yes, step S503 is executed. If no, the terminal device is prompted to try again later, and step S501 is executed again.
[0059] Step S503: If the maximum number of connections allowed by the server is not exceeded, connect to the already created socket connection, mark the terminal device as clientId, and store the clientId and the corresponding socket connection in the cache. Figure 4 As shown, the same server can connect to multiple terminal devices and send multiple fragments (equivalent to data shards) in the shared memory area to multiple terminal devices in parallel. For example, client 1 to client N each have a corresponding socket connection.
[0060] Step S504: Obtain the terminal device identifier clientId, calculate the size of the data fragment, and calculate the untransmitted file fragments (i.e., data fragments to be transmitted) based on the list of transmitted file fragment numbers corresponding to clientId (i.e., the second data fragment list mentioned above) and the total number of file fragments and transmitted file fragments, to obtain the list of untransmitted file fragments and read the first number of the list of untransmitted file fragments.
[0061] Step S505: Determine whether the data fragment corresponding to the number read in step S504 exists in the shared memory region. If it exists, proceed to step S506; otherwise, proceed to step S509.
[0062] Step S506: Use the socket connection corresponding to clientId to send the fragment of the shared memory region to the terminal device, and update the list of transmitted file fragment numbers corresponding to clientId.
[0063] Furthermore, it can be determined whether the fragment is the last file fragment; if not, the ClientId is put back into the queue of the terminal device to be sent.
[0064] In step S507, after receiving the file fragment, the terminal device calculates the starting position of the file fragment according to the number, writes the file fragment bit by bit, and sends the writing status (success or failure) back to the server.
[0065] In step S508, if the write status is successful, the association between the file segment and the ClientId is deleted, and it is determined whether the file segment is used by other threads. If the file segment does not have an associated ClientId, it proves that the file segment is not currently in use, and the file segment can be cleared in the shared memory area.
[0066] Step S509: If the shared memory does not exist, determine whether there is still available space in the shared memory region, determine the size of the used fragmented shared memory region usedShareSize, if the remaining space (MaxShareSize-usedShareSize) is greater than the fileSize of the file fragment, that is, there is still available space, then the shared memory region is not full, then proceed to step S511, otherwise proceed to step S510.
[0067] The size of the used fragmented shared memory region can be calculated based on the number N of file fragments written to the shared memory region associated with the size of the transmitted file fragments and the ClientId: usedShareSize = N * fileSize.
[0068] Understandably, when terminal devices connect, the service bandwidth can be dynamically adjusted based on the remaining memory in the shared memory area to increase the number of terminal devices that can connect.
[0069] Step S510: Read a new file segment into the shared memory area and send the newly read file segment to the terminal device. At the same time, add the number of this file segment to the list of transmitted file segment numbers.
[0070] In step S511, if the remaining space is less than the fileSize of the file segment, determine whether there is a segment that has been stored for too long. If so, clean up the expired data and continue to step S510. If there is no expired data to clean up, proceed to step S512.
[0071] Step S512: Determine whether the segment number of the next untransmitted file segment can be read from the list of untransmitted file segments. If it can be read, proceed to step S505; if it cannot be read, proceed to step S503.
[0072] By implementing the above steps, file segment sharing can be achieved in the shared memory area, which can improve the transmission efficiency of file segments under limited bandwidth conditions and reduce the probability of blocking file transmissions of other terminal devices.
[0073] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0074] This embodiment also provides a data transmission device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0075] Figure 6 This is a structural block diagram of a data transmission apparatus according to an embodiment of this application, such as... Figure 6 As shown, the device includes:
[0076] The data packet acquisition module 62 is used to acquire a data packet corresponding to the upgrade request from the shared memory area in response to the upgrade request of the terminal device. The data packet includes multiple data fragments, which are determined based on the server's transmission parameters and the data packet's transmission parameters. Each data fragment in the multiple data fragments supports reuse.
[0077] The data fragment determination module 64 is used to determine, from the plurality of data fragments, the data fragment to be transmitted that corresponds to the device number of the terminal device;
[0078] The data fragmentation transmission module 66 is used to transmit the data to be transmitted in fragments to the terminal device using the device channel of the terminal device.
[0079] The above-described apparatus, in response to an upgrade request from a terminal device, retrieves a data packet containing multiple multiplexed data fragments corresponding to the upgrade request from a shared memory region; identifies the data fragment to be transmitted from the multiple data fragments that corresponds to the device number of the terminal device; and transmits the data fragment to be transmitted to the terminal device using the device channel of the terminal device. This solves the technical problem in related technologies of how to improve the transmission efficiency of data packets to terminal devices.
[0080] In an exemplary embodiment, the data transmission device further includes a data packet splitting module for implementing the following scheme: Step S11, determining the transmission bandwidth supported by the server and the number of terminal devices supported by the server from the transmission parameters of the server; determining the write speed of the data packet and the maximum transmission time of the data packet from the transmission parameters of the data packet; Step S12, obtaining a first product between the transmission bandwidth and the maximum transmission time, and obtaining a second product between the number of terminal devices and the write speed; Step S13, determining the quotient between the first product and the second product as the data capacity of each data fragment in the data packet; Step S14, splitting the data packet using the data capacity of each data fragment to obtain the plurality of data fragments, wherein each data fragment corresponds to a fragment number.
[0081] Optionally, the data fragment determination module 64 described above is further configured to: determine the data fragment to be transmitted corresponding to the device number of the terminal device from the plurality of data fragments; determine a first data segment list corresponding to the device number of the terminal device, wherein the first data segment list includes a first data fragment that has been transmitted in the plurality of data fragments; determine a second data fragment other than the first data fragment from the plurality of data fragments, and determine the second data fragment as the data fragment to be transmitted.
[0082] In an exemplary embodiment, the data fragment transmission module 66 described above is further configured to: step S21, determine the fragment number of the data fragment to be transmitted; step S22, if the data fragment corresponding to the fragment number of the data fragment to be transmitted is found among all data fragments stored in the shared memory area, and if it is determined that the data fragment corresponding to the fragment number is the last data fragment to be transmitted in the data packet, then a target device channel corresponding to the device number is determined from among multiple device channels; step S23, transmit the data fragment to be transmitted to the terminal device using the target device channel.
[0083] In an exemplary embodiment, the data fragmentation transmission module 66, in addition to implementing steps S21 to S23, is also configured to perform: step S31, if the data fragment corresponding to the fragment number is found among all data fragments stored in the shared memory region, and if it is determined that the data fragment corresponding to the fragment number is not the last data fragment to be transmitted in the data packet, then the remaining available memory space in the shared memory region is determined; step S32, if it is determined that the space capacity of the remaining available memory space is greater than the data capacity of the data fragment to be transmitted, a third data fragment is obtained from the database, wherein the third data fragment is the data fragment to be transmitted. The data fragment is transmitted as a backup data fragment in the database; step S33, the third data fragment is stored in the remaining available storage space; step S34, the target device channel corresponding to the device number is determined from multiple device channels; step S35, the data fragment to be transmitted is transmitted to the terminal device using the target device channel; step S36, after the data fragment to be transmitted is transmitted to the terminal device, the fragment number of the data fragment to be transmitted is stored in the second data fragment list corresponding to the device number of the terminal device, wherein the second data fragment list includes the fragment numbers of the data fragments that have been transmitted among the multiple data fragments.
[0084] Optionally, in one embodiment, the data fragmentation transmission module 66 is further configured to dynamically adjust the service bandwidth based on the remaining available memory space of the shared memory region when the terminal device accesses the network, thereby increasing the number of terminal devices that can access the network and maximizing the utilization of the shared memory region.
[0085] In an exemplary embodiment, the data fragment transmission module 66, while performing steps S31 to S36, is further configured to implement the following steps: Step S41, if it is determined that the space capacity of the remaining available memory space is less than or equal to the data capacity of the data fragment to be transmitted, determine whether there is an expired data fragment, wherein the expired data fragment represents a data fragment that was not transmitted to the terminal device within the maximum transmission time of the data packet; Step S42, if it is determined that there is an expired data fragment, delete the expired data fragment; Step S43, if it is determined that there is no expired data fragment, and if it is determined that there is a next data fragment to be transmitted among the plurality of data fragments, then use the target device channel to transmit the next data fragment to be transmitted to the terminal device.
[0086] Optionally, the data fragmentation transmission module 66 described above is further configured to: determine whether there is any remaining available space in the set shared memory region, wherein the remaining available space is the difference between the total space capacity of the shared memory region and the used space capacity of the shared memory region.
[0087] In an exemplary embodiment, the data fragmentation transmission module 66 is further configured to determine whether a next data fragment to be transmitted exists by: determining a third data fragment list corresponding to the device number of the terminal device, wherein the third data fragment list includes the fragment numbers of the data fragments to be transmitted among the plurality of data fragments. If a next fragment number following the fragment number of the data fragment to be transmitted can be read from the third data fragment list, then it is determined that a next data fragment to be transmitted exists among the plurality of data fragments.
[0088] In this embodiment, by periodically cleaning up expired data fragments, the probability of server-side data residue caused by one-way anomalies of terminal devices can be reduced.
[0089] In one exemplary embodiment, the data transmission apparatus further includes a feedback information processing module, configured to: receive feedback information from the terminal device after receiving the data fragment to be transmitted; if it is determined that the feedback information indicates that the terminal device has successfully written the data fragment to be transmitted, delete the fragment number of the data fragment to be transmitted from the second data fragment list, wherein the second data fragment list includes the fragment numbers of data fragments that have been transmitted among the plurality of data fragments; and if it is determined that the data fragment to be transmitted is currently not occupied, delete the data fragment to be transmitted from the shared memory area.
[0090] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0091] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when run.
[0092] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0093] S1, in response to an upgrade request from a terminal device, a data packet corresponding to the upgrade request is obtained from a shared memory region, wherein the data packet includes multiple data fragments, the multiple data fragments are determined based on the server's transmission parameters and the data packet's transmission parameters, and each of the multiple data fragments supports reuse;
[0094] S2, determine the data fragment to be transmitted that corresponds to the device number of the terminal device from the plurality of data fragments;
[0095] S3, the data to be transmitted is fragmented and transmitted to the terminal device using the device channel of the terminal device.
[0096] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0097] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0098] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0099] S1, in response to an upgrade request from a terminal device, a data packet corresponding to the upgrade request is obtained from a shared memory region, wherein the data packet includes multiple data fragments, the multiple data fragments are determined based on the server's transmission parameters and the data packet's transmission parameters, and each of the multiple data fragments supports reuse;
[0100] S2, determine the data fragment to be transmitted that corresponds to the device number of the terminal device from the plurality of data fragments;
[0101] S3, the data to be transmitted is fragmented and transmitted to the terminal device using the device channel of the terminal device.
[0102] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0103] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0104] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0105] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.
Claims
1. A data transmission method, characterized in that, include: In response to an upgrade request from a terminal device, a data packet corresponding to the upgrade request is obtained from a shared memory region. The data packet includes multiple data fragments, which are determined based on the server's transmission parameters and the data packet's transmission parameters. Each of the multiple data fragments supports reuse. The data fragment to be transmitted corresponding to the device number of the terminal device is determined from the plurality of data fragments; The data to be transmitted is fragmented and transmitted to the terminal device using the device channel of the terminal device. Before retrieving the data packet corresponding to the upgrade request from the shared memory region in response to the upgrade request of the terminal device, the method further includes: determining the transmission bandwidth supported by the server and the number of terminal devices supported by the server from the transmission parameters of the server; determining the write speed of the data packet and the maximum transmission time of the data packet from the transmission parameters of the data packet; obtaining a first product between the transmission bandwidth and the maximum transmission time, and obtaining a second product between the number of terminal devices and the write speed; determining the quotient between the first product and the second product as the data capacity of each data fragment in the data packet; splitting the data packet using the data capacity of each data fragment to obtain the plurality of data fragments, wherein each data fragment corresponds to a fragment number; The method further includes: receiving feedback information from the terminal device after receiving the data fragment to be transmitted; if it is determined that the feedback information indicates that the terminal device has successfully written the data fragment to be transmitted, deleting the fragment number of the data fragment to be transmitted from the second data fragment list, wherein the second data fragment list includes the fragment numbers of data fragments that have been transmitted in the plurality of data fragments; if it is determined that the data fragment to be transmitted is currently not occupied, deleting the data fragment to be transmitted from the shared memory area.
2. The method according to claim 1, characterized in that, Determining the data fragment to be transmitted from the plurality of data fragments that corresponds to the device number of the terminal device includes: A first data segment list corresponding to the device number of the terminal device is determined, wherein the first data segment list includes the first data segment that has been transmitted in the plurality of data segments; A second data fragment other than the first data fragment is determined from the plurality of data fragments, and the second data fragment is determined as the data fragment to be transmitted.
3. The method according to claim 1, characterized in that, Using the device channel of the terminal device to transmit the data to be transmitted in fragments to the terminal device includes: Determine the fragment number of the data fragment to be transmitted; If the fragment corresponding to the fragment number of the data fragment to be transmitted is found among all the data fragments stored in the shared memory area, and if it is determined that the data fragment corresponding to the fragment number is the last data fragment to be transmitted in the data packet, then the target device channel corresponding to the device number is determined from multiple device channels. The target device channel is used to transmit the data to be transmitted in fragments to the terminal device.
4. The method according to claim 3, characterized in that, The method further includes: If the data fragment corresponding to the fragment number is found among all the data fragments stored in the shared memory region, and if it is determined that the data fragment corresponding to the fragment number is not the last data fragment to be transmitted in the data packet, then the remaining available memory space of the shared memory region is determined. If it is determined that the remaining available memory space has a larger capacity than the data capacity of the data fragment to be transmitted, a third data fragment is obtained from the database. The third data fragment is a backup data fragment of the data fragment to be transmitted within the database; The third data fragment is stored in the remaining available memory space; Identify the target device channel corresponding to the device number from among multiple device channels; The target device channel is used to transmit the data to be transmitted in fragments to the terminal device. After transmitting the data fragments to the terminal device, the fragment number of the data fragments to be transmitted is stored in the second data fragment list corresponding to the device number of the terminal device; The second data fragment list includes the fragment numbers of the data fragments that have been transmitted in the plurality of data fragments.
5. The method according to claim 4, characterized in that, The method further includes: If the remaining available memory space capacity is less than or equal to the data capacity of the data fragment to be transmitted, it is determined whether there is an expired data fragment, wherein the expired data fragment refers to the data fragment that was not transmitted to the terminal device within the maximum transmission time of the data packet; If expired data fragments are identified, the expired data fragments are deleted. If it is determined that there are no expired data fragments, and if it is determined that there is a next data fragment to be transmitted among the plurality of data fragments, then the next data fragment to be transmitted is transmitted to the terminal device using the target device channel.
6. A data transmission device, characterized in that, include: A data packet acquisition module is used to respond to an upgrade request from a terminal device by acquiring a data packet corresponding to the upgrade request from a shared memory area. The data packet includes multiple data fragments, which are determined based on the server's transmission parameters and the data packet's transmission parameters. Each data fragment supports reuse. A data fragment determination module is used to determine, from the plurality of data fragments, the data fragment to be transmitted that corresponds to the device number of the terminal device; A data fragmentation transmission module is used to transmit the data to be transmitted in fragments to the terminal device using the device channel of the terminal device. The data transmission device further includes a data packet splitting module, used to determine the transmission bandwidth supported by the server and the number of terminal devices supported by the server from the server's transmission parameters; determine the write speed of the data packet and the maximum transmission time of the data packet from the data packet's transmission parameters; obtain a first product between the transmission bandwidth and the maximum transmission time, and obtain a second product between the number of terminal devices and the write speed; determine the quotient between the first product and the second product as the data capacity of each data fragment in the data packet; split the data packet using the data capacity of each data fragment to obtain the plurality of data fragments, wherein each data fragment corresponds to a fragment number; The data transmission device further includes a feedback information processing module, used to receive feedback information from the terminal device after receiving the data fragment to be transmitted; if it is determined that the feedback information indicates that the terminal device has successfully written the data fragment to be transmitted, the module deletes the fragment number of the data fragment to be transmitted from the second data fragment list, wherein the second data fragment list includes the fragment numbers of data fragments that have been transmitted in the plurality of data fragments; if it is determined that the data fragment to be transmitted is currently not occupied, the module deletes the data fragment to be transmitted from the shared memory area.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of claims 1 to 5.
8. 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, it implements the steps of the method described in any one of claims 1 to 5.
Citation Information
Patent Citations
System and method for efficiently and safely upgrading switch software
CN114697312A
Firmware upgrading method and device, equipment and storage medium
CN116009918A