A data transmission method, apparatus and electronic device

By queuing business data in surveillance cameras and using different transmission protocols, and utilizing a time-slice polling mechanism to prioritize high-priority services, the problem of live streaming and alarm services competing for bandwidth in weak network environments is solved, thus ensuring the reliability of high-priority services and the normal operation of low-priority services.

CN122437814APending Publication Date: 2026-07-21SHENZHEN MICROBT ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN MICROBT ELECTRONICS TECH CO LTD
Filing Date
2025-01-20
Publication Date
2026-07-21

Smart Images

  • Figure CN122437814A_ABST
    Figure CN122437814A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data transmission method, device and electronic equipment. The method is applied to a data sending end which simultaneously processes at least two services, and comprises: sending service data generated by different services to corresponding service queues respectively; when a preset time slice arrives, reading service data of a current data volume from a service queue with the highest priority, and sending according to a corresponding transmission protocol; the current data volume is less than or equal to a maximum transmissible data volume, which is determined according to a current bandwidth and a time length of the preset time slice; subtracting the current data volume from the maximum transmissible data volume to obtain a residual transmissible data volume; and if the residual transmissible data volume is greater than 0, allocating the residual transmissible data volume to service queues which have not been sent this time according to priority. Embodiments of the present application can, in a weak network environment, preferentially guarantee the effect of high-priority services while ensuring the normal operation of low-priority services as much as possible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of surveillance camera technology, and in particular to a data transmission method, apparatus, and electronic device. Background Technology

[0002] With the rapid development of IoT, big data, and AI technologies, surveillance cameras, as a core component of intelligent security systems, have become a focus of industry attention. Live streaming and alarm functions are two important applications of surveillance cameras.

[0003] Live streaming service: Audio and video streams are captured in real-time by surveillance cameras and then pushed to a live streaming server via network transmission protocols. The live streaming server processes and distributes the audio and video streams, and user terminals receive and decode the streams through appropriate playback software or web pages to achieve real-time playback.

[0004] Alarm service: When the surveillance camera detects abnormal situations, such as intrusion, movement of objects, smoke, fire, etc., it pushes alarm data to the alarm server through network transmission protocol to notify users or relevant personnel to take appropriate measures.

[0005] Live streaming and alarm services typically use different network transmission protocols. In weak network conditions, if the two services run simultaneously, they will compete for bandwidth, which may cause both services to malfunction. Summary of the Invention

[0006] This invention provides a data transmission method, apparatus, and electronic device that can, in a weak network environment and when multiple services coexist, prioritize the performance of high-priority services while ensuring the normal operation of low-priority services as much as possible.

[0007] In a first aspect, embodiments of the present invention disclose a data transmission method applied to a data sending end, wherein the data sending end simultaneously processes at least two services, the method comprising:

[0008] The business data generated by different services are sent to the corresponding business queues, and different business queues use different transmission protocols.

[0009] When the preset time slice arrives, the service data for this data volume is read from the highest priority service queue and sent according to the corresponding transmission protocol; the current data volume is less than or equal to the maximum transmittable data volume, which is determined based on the current bandwidth of the data sending end and the duration of the preset time slice.

[0010] Subtract the current data volume from the maximum amount of data that can be sent to obtain the remaining amount of data that can be sent.

[0011] If the remaining amount of data that can be sent is greater than 0, then the remaining amount of data that can be sent is allocated to the service queues that were not sent this time according to priority.

[0012] Secondly, embodiments of the present invention disclose a data transmission apparatus applied to a data sending end, wherein the data sending end simultaneously processes at least two services, and the apparatus includes:

[0013] The data queuing module is used to send business data generated by different services to the corresponding business queues, and different business queues use different transmission protocols;

[0014] The first allocation module is used to read the current data volume from the highest priority service queue when the preset time slice arrives, and send it according to the corresponding transmission protocol; the current data volume is less than or equal to the maximum transmittable data volume, which is determined based on the current bandwidth of the data sending end and the duration of the preset time slice.

[0015] The remaining calculation module is used to subtract the current data volume from the maximum data volume that can be sent to obtain the remaining data volume that can be sent.

[0016] The second allocation module is used to allocate the remaining sendable data to the service queue that has not been sent this time according to priority if the remaining sendable data is greater than 0.

[0017] Thirdly, embodiments of the present invention disclose an electronic device, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, wherein the executable instruction causes the processor to perform the steps of the data transmission method as described above.

[0018] The embodiments of the present invention have the following advantages:

[0019] In weak network environments, this invention utilizes time-slice polling to allocate current bandwidth to multiple service queues according to priority. This controls the transmission of service data from different services using different transmission protocols, ensuring the reliability of high-priority services and allocating remaining bandwidth to other service queues. By setting appropriate priorities and service data sizes, it's possible to ensure the performance of high-priority services while guaranteeing the normal operation of low-priority services when multiple services coexist. For surveillance camera scenarios, current bandwidth can be prioritized for live streaming to ensure its real-time performance, and the remaining bandwidth can then be allocated to alarm services, enabling both live streaming and alarm services to operate normally in weak network environments. Attached Figure Description

[0020] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a flowchart illustrating the steps of an embodiment of the data transmission method of the present invention;

[0022] Figure 2 This is a structural block diagram of an embodiment of a data transmission device according to the present invention;

[0023] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0025] The terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, the first object can be one or more. Furthermore, the term "and / or" in the specification and claims is used to describe the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. In embodiments of this invention, the term "multiple" refers to two or more, and other quantifiers are similar.

[0026] Reference Figure 1 The diagram illustrates a flowchart of an embodiment of a data transmission method according to the present invention, applied to a data sending end, wherein the data sending end simultaneously processes at least two services, and the method may include the following steps:

[0027] Step 101: Send the service data generated by different services to the corresponding service queues respectively, and use different transmission protocols for different service queues;

[0028] Step 102: When the preset time slice arrives, read the service data of this data volume from the highest priority service queue and send it according to the corresponding transmission protocol; the current data volume is less than or equal to the maximum data volume that can be sent, and the maximum data volume that can be sent is determined according to the current bandwidth of the data sending end and the duration of the preset time slice.

[0029] Step 103: Subtract the current data volume from the maximum data volume that can be sent to obtain the remaining data volume that can be sent;

[0030] Step 104: If the remaining amount of data that can be sent is greater than 0, then allocate the remaining amount of data that can be sent to the service queue that was not sent this time according to priority.

[0031] The data transmission method provided in this invention can be applied to a data sending end, which can simultaneously handle at least two services. This invention can be applied to scenarios where the data sending end is in a weak network environment. A weak network environment refers to an environment where the network signal strength (e.g., Wi-Fi signal strength) of the data sending end (e.g., a surveillance camera) is weak or the uplink bandwidth of the data sending end is small, such as when the Wi-Fi signal strength of the data sending end is less than a preset value, or when the uplink bandwidth of the data sending end is less than a preset bandwidth. The preset bandwidth is determined according to the actual scenario and is less than the minimum bandwidth required for the data sending end to simultaneously transmit service data for multiple services. Uplink bandwidth refers to the transmission rate when sending data from the data sending end to the data receiving end. In a weak network environment, there may be bandwidth contention among various service data at the data sending end, which may affect the normal operation of each service.

[0032] The data sending end refers to the party responsible for initiating data transmission during data communication and information exchange, pushing its own or collected data to other designated targets (usually data receivers). The data sending end can be a software program running on various hardware devices, or an independent hardware device with data transmission capabilities. For example, when an instant messaging app on a smartphone sends a message, the app itself is the message data sending end; similarly, the data acquisition equipment in a meteorological monitoring station, which sends the collected meteorological data to the meteorological data center, is the meteorological data sending end.

[0033] The data sending end can process at least two services simultaneously and can obtain service data generated by different services from various sources. These sources include, but are not limited to, local file systems (such as reading document data stored on a hard drive), various sensors (such as temperature sensors collecting ambient temperature data, cameras collecting image data, etc.), and user input interfaces (such as data filled in by users in web forms).

[0034] In practice, different business data may need to be sent to different data receiving ends. Depending on the different requirements of different businesses for the reliability and real-time performance of data transmission, different business data may use different transmission protocols.

[0035] For example, the data sending end can be a surveillance camera, and the services processed by the surveillance camera simultaneously include, but are not limited to, live streaming and alarm services. Specifically, live streaming data is sent to the first server using UDP (User Datagram Protocol). Alarm data is sent to the second server using TCP (Transmission Control Protocol).

[0036] It should be noted that business data generated by different services can be sent to different data receiving ends, which can be determined based on the characteristics of the business data type. For example, live streaming business data is typically audio and video streams, requiring real-time transcoding, processing, and analysis by the data receiving end. Therefore, the first server can be a cloud computing server capable of providing powerful computing capabilities and abundant computing resources, meeting the requirements for real-time processing and analysis of live streaming business data. As another example, alarm business data mainly includes various alarm information, usually existing in the form of images, text, logs, audio, and video. The data volume is relatively smaller than that of live streaming business data, but it requires long-term storage for subsequent querying and analysis. Therefore, the second server can be an object storage server with large capacity and low cost, suitable for storing large amounts of unstructured data, and capable of meeting the long-term storage needs of alarm business data at a relatively low cost.

[0037] Furthermore, the data sending end can process different services through different service modules, and send the service data generated by different services to the corresponding service queues respectively. Different service queues can use different transmission protocols to send data.

[0038] For example, surveillance cameras can send live streaming data generated by live streaming services to a live streaming service queue, and alarm data generated by alarm services to an alarm service queue. Live streaming data in the live streaming service queue will be sent to the first server using the UDP transport protocol. Alarm data in the alarm service queue will be sent to the second server using the TCP transport protocol.

[0039] This invention uses time-slice polling to allocate bandwidth to multiple service queues according to priority, controlling the transmission of service data of different protocols for multiple services according to priority, ensuring the reliability of high-priority services, and allocating the remaining bandwidth to other service queues for use. When multiple services coexist, the high-priority service is prioritized while ensuring the normal operation of low-priority services as much as possible.

[0040] For ease of description, this embodiment of the invention mainly uses a surveillance camera as the data sending end, which simultaneously handles live streaming and alarm services. The application scenarios of other multi-service data sending ends are similar and can be referred to each other.

[0041] Specifically, whenever a preset time slice arrives, the service data for this data volume is read from the highest priority service queue and sent according to the corresponding transmission protocol; the current data volume is less than or equal to the maximum transmittable data volume, which is determined based on the current bandwidth of the data sending end and the duration of the preset time slice.

[0042] The duration of the preset time slice can be set according to actual needs. In this embodiment of the invention, a preset time slice of 5ms is used as an example. Of course, in specific implementations, the preset time slice can also be any duration such as 4ms, 6ms, 7ms, etc.

[0043] Taking a surveillance camera as an example, the services it handles simultaneously include, but are not limited to, live streaming and alarm services; it is assumed that the priority of the live streaming service is higher than that of the alarm service. It is understood that the priorities of different services can be set according to the actual needs of the scenario. In specific implementations, the priority of the alarm service can also be set to be higher than that of the live streaming service. This embodiment of the invention uses the example of a higher priority for the live streaming service than for the alarm service.

[0044] When 5ms arrives, the current amount of service data is read from the highest priority service queue and sent according to the corresponding transmission protocol. For example, the current amount of live streaming service data is read from the live streaming service queue and sent to the first server according to the UDP transmission protocol.

[0045] The current data volume is less than or equal to the maximum transmittable data volume, which represents the maximum amount of data that can be transmitted within the current preset time slice (e.g., within 5ms). The maximum transmittable data volume is determined based on the current bandwidth of the data transmitting end and the duration of the preset time slice.

[0046] For example, the current bandwidth of the surveillance camera is 3 Mbps (megabits per second), which is 3 × 1000 × 1000 = 3,000,000 bits per second. Since the preset time slice is 5 ms (0.005 seconds), 3 × 1000 × 1000 × 0.005 = 15,000 bits of data can be sent every 5 ms, which is equivalent to 15,000 ÷ 8 = 1875 bytes. The maximum amount of data that can be sent is 1875 bytes.

[0047] The "current data volume" refers to the amount of service data read from the highest-priority service queue for transmission within the current preset time slice. The current data volume is less than or equal to the maximum transmittable data volume. Further, the current data volume is the smaller of the maximum transmittable data volume and the amount of service data to be transmitted in the highest-priority service queue.

[0048] For example, every 5ms interval, the current amount of live streaming data can be read from the live streaming service queue and sent. Specifically, if the amount of live streaming data to be sent in the live streaming service queue is greater than or equal to the maximum transmittable data size (e.g., 1875 bytes), then the current data size is 1875 bytes. If the amount of live streaming data to be sent in the live streaming service queue is less than the maximum transmittable data size (e.g., 1875 bytes), assuming the amount of live streaming data to be sent in the live streaming service queue is 1200 bytes, then the current data size is 1200 bytes.

[0049] Assuming the amount of live streaming data to be sent in the live streaming service queue is 1200 bytes, when 5ms arrives, this 1200 bytes of live streaming data is read from the live streaming service queue and sent to the first server via the UDP transmission protocol.

[0050] Next, the current data volume (e.g., 1200 bytes) is subtracted from the maximum transmittable data volume (e.g., 1875 bytes) to obtain the remaining transmittable data volume (e.g., 675 bytes). Within this preset time slice, the remaining transmittable data volume can be allocated to the service queues that were not transmitted this time (e.g., alarm service queue).

[0051] Since the remaining amount of data that can be sent (e.g., 675 bytes) is greater than 0, the remaining amount of data that cannot be sent this time can be allocated to the service queue (e.g., alarm service queue) according to priority. Specifically, alarm service data in the alarm service queue can be sent according to the remaining amount of data that can be sent.

[0052] For example, if the amount of alarm service data to be sent in the alarm service queue is greater than or equal to the remaining sendable data amount (e.g., 675 bytes), then alarm service data of the remaining sendable data amount (e.g., 675 bytes) is read from the alarm service queue and sent to the second server via the TCP transmission protocol. The remaining unsent alarm service data will wait until the next preset time slice arrives to determine whether it can be sent.

[0053] For example, if the amount of alarm service data to be sent in the alarm service queue is less than the remaining amount of data that can be sent (e.g., 675 bytes), then all alarm service data is read from the alarm service queue and sent to the second server via the TCP transmission protocol.

[0054] It should be noted that each time a preset time slice arrives, the maximum amount of data that can be sent within the current preset time slice is recalculated based on the current bandwidth of the data sending end and the duration of the preset time slice. After reading the service data of this current data volume from the highest priority service queue, sending it according to the corresponding transmission protocol, and then subtracting the current data volume from the maximum amount of data that can be sent within the current preset time slice, the remaining amount of data that can be sent within the current preset time slice is obtained. This remaining amount of data that can be sent can be allocated within the current preset time slice and does not accumulate into the next preset time slice. That is, the maximum value of the remaining amount of data that can be sent is the product of the current bandwidth and the duration of the preset time slice.

[0055] For example, assuming the current bandwidth of a surveillance camera is 3 Mbps and the preset time slice duration is 5 ms, when the first 5 ms arrives, the maximum amount of data that can be sent within that 5 ms is 1875 bytes. Assuming there is no live streaming data to be sent in the live streaming queue, the remaining sendable data is 1875 bytes. This 1875 bytes can be allocated to alarm services. Assuming there is also no alarm data to be sent in the alarm service queue, the remaining sendable data reaches its maximum value, i.e., 3 × 1000 × 1000 × 0.005 = 15000 bits, which is 15000 ÷ 8 = 1875 bytes. However, this remaining 1875 bytes of sendable data will not accumulate to the next 5 ms. That is, when the second 5 ms arrives, the maximum sendable data within that 5 ms is recalculated based on the current bandwidth (3 Mbps) and the preset time slice duration (5 ms), and it is still 1875 bytes, not 1875 + 1875 = 3750 bytes.

[0056] In an optional embodiment of the present invention, the step of allocating the remaining sendable data to the service queue that has not been sent this time according to priority if the remaining sendable data is greater than 0 may include:

[0057] Step S11: If the remaining amount of data that can be sent is greater than 0, then determine the first target queue with the highest priority from the service queues that were not sent this time.

[0058] Step S12: Send the service data in the first target queue according to the remaining sendable data amount, and update the remaining sendable data amount;

[0059] Step S13: If the updated remaining transmittable data volume is greater than 0, then determine the highest priority first target queue from the remaining service queues, until all service queues are empty or the remaining transmittable data volume is 0, and wait for the next preset time slice to arrive.

[0060] In scenarios where multiple services (more than two) are processed simultaneously at the data sending end, such as a surveillance camera handling live streaming, alarms, and playback, the priorities are assumed to be live streaming, alarms, and playback, from highest to lowest. When a preset time slice arrives, the service data for the current data volume is read from the highest priority service queue (e.g., the live streaming queue) and sent according to the corresponding transmission protocol. If the remaining transmittable data volume is greater than zero, the remaining transmittable data volume is then allocated to the service queues that were not sent this time (e.g., the alarm queue and the playback queue) according to their priorities.

[0061] For example, if the alarm service has a higher priority than the playback service, then the alarm service queue is determined as the first target queue, the service data in the alarm service queue is sent according to the remaining sendable data volume, and the remaining sendable data volume is updated.

[0062] If the updated remaining transmittable data volume is greater than 0, then the highest priority first target queue (such as the replay queue) is determined from the remaining service queues (at this point only the replay service queue remains), and the service data in the replay service queue is sent according to the remaining transmittable data volume. This process continues until all service queues are empty or the remaining transmittable data volume is 0. If there is still unsent service data, the system waits for the next preset time slice to arrive to determine whether it can be sent.

[0063] In practical implementation, if the data granularity of the service data is large, sending high-priority service data at the end of each time slice will consume a large amount of bandwidth, potentially leading to no remaining bandwidth available. This, in turn, will prevent low-priority service data from being sent for an extended period, affecting the normal operation of low-priority services. The data granularity refers to the smallest unit of data sent to the data receiver. Therefore, by setting appropriate priorities and data granularity, it is possible to ensure that after the highest-priority service data is sent at the end of the preset time slice (ensuring that the remaining transmittable data is greater than 0), a small amount of available bandwidth remains. This ensures that high-priority service data can occupy more bandwidth for transmission at the end of each preset time slice, while low-priority service data can occupy a small amount of remaining bandwidth. This guarantees the normal operation of low-priority services while ensuring the reliability of high-priority services.

[0064] In a weak network environment, this invention uses time-slice polling to allocate bandwidth to multiple service queues according to priority. This allows for the control of sending service data from different transmission protocols for multiple services according to priority, ensuring the reliability of high-priority services, and allocating the remaining bandwidth to other service queues. When multiple services coexist, this prioritizes the performance of high-priority services while ensuring the normal operation of low-priority services as much as possible.

[0065] In an optional embodiment of the present invention, the method may further include:

[0066] Step S21: Periodically use a preset algorithm to detect the current bandwidth of the data sending end;

[0067] Step S22: Calculate the maximum amount of data that can be sent based on the current bandwidth and the duration of the preset time slice.

[0068] The current bandwidth refers to the bandwidth for transmitting data from the data sender to the data receiver (i.e., the uplink bandwidth), which is the speed at which data is uploaded.

[0069] The data sender can periodically use a preset algorithm to actively probe the current bandwidth. This embodiment of the invention does not limit the preset algorithm. For example, the GCC (Google Congestion Control) algorithm can be used to probe bandwidth. GCC is a congestion control algorithm that combines latency estimation and packet loss, probing network bandwidth by sending and receiving TCP packets.

[0070] The detection process of the GCC algorithm is as follows: First, calculate the theoretical amount of data to be transmitted based on the target bandwidth, transmission interval, and number of transmissions; then, calculate the actual amount of data transmitted based on the amount of data lost; finally, calculate the current bandwidth based on the reception time fed back by the data receiver, the transmission time of the sender, and the actual amount of data transmitted.

[0071] The target bandwidth is an estimated bandwidth. For example, assuming a target bandwidth of 6 Mbps, a transmission interval of 5 ms, and 3 transmissions, the theoretical data transmission volume per transmission (bytes) is: Target bandwidth (bps) × Transmission interval (s) ÷ 8. That is, 6 × 1000 × 1000 × 0.005 ÷ 8 = 3750 bytes. With 3 transmissions, the theoretical data transmission volume (bytes) is: Data transmission volume per transmission (bytes) × Number of transmissions. That is, 3750 × 3 = 11250 bytes.

[0072] If there is no packet loss during data transmission, the actual amount of data transmitted equals the theoretical amount of data sent. If packet loss occurs, the actual amount of data transmitted = theoretical amount of data sent - amount of data lost. For example, if the theoretical amount of data to be sent is 11250 bytes, and there is no packet loss, then the actual amount of data transmitted is 11250 bytes.

[0073] Each time the data sender transmits data to the data receiver, the receiver records the time of receipt and reports the reception time back to the sender. Based on the reception time reported by the receiver and the sender's own transmission time, the sender can calculate the actual data transmission time. Therefore, the current bandwidth can be calculated based on the actual amount of data transmitted and the actual transmission time. Specifically, current bandwidth (bps) = actual data transmission amount (bits) ÷ actual transmission time (s). If the actual data transmission amount is 11250 bytes and the actual transmission time is 30ms (0.03s), then the detected current bandwidth is: 11250 × 8 ÷ 0.03 = 3000000bps, or 3mbps. Therefore, the maximum amount of data that can be sent within a preset time slice (e.g., 5ms) is: 3 × 1000 × 1000 ÷ 8 ÷ 1000 × 5 = 1875 bytes.

[0074] It should be noted that, in specific implementations, other algorithms such as the PathChirp algorithm, Iperf algorithm, TCP Vegas algorithm, and BBR algorithm can also be used to detect the current bandwidth of the data sender. This embodiment of the invention does not impose any restrictions on this.

[0075] In an optional embodiment of the present invention, the method may further include:

[0076] Step S31: If the remaining amount of data that can be sent is equal to 0, then wait for the next preset time slice to arrive;

[0077] Step S32: When the first time period arrives, if there is a second target queue that has not sent data within the first time period, then store the service data in the second target queue into the preset space and wait for retransmission.

[0078] Step S33: When the second time period arrives, discard the unsent service data in the preset space.

[0079] In this embodiment of the invention, when the preset time slice arrives, the service data for this data volume is read from the highest priority service queue (such as the live streaming service queue) and sent according to the corresponding transmission protocol. Then, the remaining transmittable data volume is calculated. If the remaining transmittable data volume is greater than 0, the remaining transmittable data volume is allocated to the service queues that have not yet sent data according to their priorities.

[0080] If the remaining transmittable data is 0, it is necessary to wait for the next preset time slice to arrive. When the next preset time slice arrives, the data for this data volume is read from the highest priority service queue (such as the live streaming service queue) and sent according to the corresponding transmission protocol. Then, the remaining transmittable data is calculated. If the remaining transmittable data is still 0, then only the highest priority service data can be sent, and the service data in the other service queues will never be allocated available bandwidth, resulting in a long period of transmission failure.

[0081] To address this issue, this embodiment of the invention includes a retransmission mechanism. Specifically, when the first duration arrives (the first duration is longer than the duration of a preset time slice), if a second target queue exists that has not sent data within the first duration, the service data in the second target queue is stored in a preset space, awaiting retransmission. The preset space can be a storage space allocated internally by the data sending end, or it can be an external storage space connected to the data sending end, such as a TF card (TransFlash Card).

[0082] If service data in a certain service queue (second target queue) has not been sent for a long period (first duration), the service data in the second target queue is stored in a preset space, waiting to be retransmitted when the network is idle. Furthermore, when the second duration (second duration is longer than the first duration) arrives, the unsent service data in the preset space can be discarded to avoid historical data occupying the preset space for a long time.

[0083] Among them, retransmission refers to the process where, after a preset time slice arrives and the current amount of business data is sent to the highest priority business queue, if the remaining amount of data that can be sent is greater than 0, then the business data in the preset space is sent first.

[0084] Furthermore, in addition to setting a retransmission mechanism, embodiments of the present invention can also set a data packet upper limit for service data. For example, for service data of different services, the size of a single data packet is set to not exceed the data packet upper limit of that service, and this data packet upper limit is a value less than the maximum transmittable data volume. For example, the maximum size of a single data packet for live streaming service data is set to 1500 bytes. Furthermore, if the size of a single data packet for a certain service exceeds the data packet upper limit of that service, the single data packet is split. For example, if a data packet for live streaming service data exceeds 1500 bytes, the data packet is split into at least two data packets, and each of the split data packets is less than the data packet upper limit of 1500 bytes.

[0085] In an optional embodiment of the present invention, the method may further include:

[0086] When specified service data is generated, and the specified service data is less than the specified size, the specified service data is sent directly according to the transmission protocol corresponding to the specified service.

[0087] The designated service data refers to service data that does not require control according to the data transmission methods described in steps 101 to 104. Designated service data is typically service data with a high importance level and a small data volume. For example, alarm service data may include alarm image data, alarm audio data, and alarm video data. For instance, in a specific implementation, alarm image data can be used as designated service data. The size of alarm image data is typically around 20 kilobytes, and even if it is sent directly by preempting bandwidth, it will not have a significant impact.

[0088] For example, during the operation of a surveillance camera, when the alarm service module detects an alarm event such as intrusion, object movement, smoke, or fire, it can generate alarm service data, including at least one of alarm image data, alarm audio data, and alarm video data. For alarm image data smaller than a specified size, it can be directly sent to the second server via TCP without entering the alarm service queue; for alarm image data exceeding the specified size, it is still sent to the alarm service queue for processing.

[0089] For alarm audio data, alarm video data, and other alarm service data, they are sent to the alarm service queue for queuing and sent in the order of entry into the queue.

[0090] It should be noted that the alarm image data mentioned above is only used as an example to illustrate the specified business data. The embodiments of the present invention do not limit the type of specified business data, nor do they limit the specified size.

[0091] In an optional embodiment of the present invention, the method may further include:

[0092] Step S41: Detect whether network congestion has occurred based on the feedback message from the data receiver;

[0093] Step S42: If network congestion is detected, reduce the maximum amount of data that can be sent.

[0094] In practice, if the specified size of the designated service data is appropriate, it usually will not affect the network. However, if the specified size is set too large, or if the designated service data is sent multiple times consecutively, it will cause bandwidth contention with the service queue, potentially leading to network congestion.

[0095] To address this issue, the data sender can detect network congestion based on feedback messages from the data receiver. Each time the data receiver receives data from the sender, it sends a feedback message containing the time it received the data. Therefore, the sender can calculate the actual data transmission time by comparing the receiver's feedback time with its own transmission time, thus determining whether network congestion has occurred.

[0096] If network congestion is detected, the maximum amount of data that can be sent can be reduced to alleviate the network congestion.

[0097] Furthermore, the maximum transmittable data amount can be reduced according to the degree of network congestion. For example, for mild congestion, the maximum transmittable data amount can be reduced by a first percentage. For moderate congestion, the maximum transmittable data amount can be reduced by a second percentage. For severe congestion, the maximum transmittable data amount can be reduced by a third percentage. The first, second, and third percentages can be set according to actual needs.

[0098] Understandably, the maximum amount of data that can be sent can be restored once network congestion is detected to have eased.

[0099] This invention calculates the maximum transmittable data volume for each preset time slice to control the priority of data streams from different protocols across multiple services, ensuring the reliability of high-priority services. For example, in a weak network environment, when a preset time slice is reached, live streaming data can be transmitted first, while alarm data can use the remaining bandwidth (i.e., the remaining transmittable data volume), prioritizing the reliability of live streaming services.

[0100] Furthermore, in the event of a specified anomaly in a high-priority service (such as live streaming), to ensure the reliability of the high-priority service, the execution of low-priority services can be suspended. The specified anomaly affects the basic operation of the high-priority service. For example, in a weak network environment, if an alarm service is executed simultaneously during live streaming, it may cause anomalies such as buffering or degraded image quality. In this case, the alarm service can be suspended. That is, in the event of a specified anomaly in a high-priority service (such as live streaming), only the high-priority service (such as live streaming) is executed. During this time, the high-priority service can exclusively occupy bandwidth. Once the specified anomaly is resolved, the low-priority service (such as alarm service) can resume execution simultaneously.

[0101] Furthermore, during the suspension of low-priority services, the business data generated by the low-priority services during the suspension period can be stored in a pre-set space (such as TF) and awaited to be retransmitted.

[0102] In summary, this embodiment of the invention, in a weak network environment, allocates current bandwidth to multiple service queues according to priority through time-slice polling. It controls the transmission of service data from multiple different services using different transmission protocols, ensuring the reliability of high-priority services and allocating remaining bandwidth to other service queues. By setting appropriate priorities and service data sizes, it is possible to ensure the effectiveness of high-priority services while guaranteeing the normal operation of low-priority services when multiple services coexist. For surveillance camera scenarios, current bandwidth can be prioritized for live streaming services to ensure their real-time performance, and the remaining bandwidth can then be allocated to alarm services, enabling both live streaming and alarm services to operate normally in weak network environments.

[0103] For the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0104] Reference Figure 2 The diagram illustrates a structural block diagram of an embodiment of a data transmission device according to the present invention. The device is applied to a data transmitting end, which simultaneously processes at least two services. The device may include:

[0105] The data queuing module 201 is used to send the business data generated by different services to the corresponding business queues, and different business queues use different transmission protocols.

[0106] The first allocation module 202 is used to read the current data volume from the highest priority service queue when the preset time slice arrives, and send it according to the corresponding transmission protocol; the current data volume is less than or equal to the maximum transmittable data volume, which is determined based on the current bandwidth of the data sending end and the duration of the preset time slice.

[0107] The remaining calculation module 203 is used to subtract the current data volume from the maximum transmittable data volume to obtain the remaining transmittable data volume;

[0108] The second allocation module 204 is used to allocate the remaining sendable data to the service queue that has not been sent this time according to priority if the remaining sendable data is greater than 0.

[0109] Optionally, the second allocation module includes:

[0110] The target determination submodule is used to determine the highest priority first target queue from the service queues that have not been sent this time if the remaining amount of data that can be sent is greater than 0.

[0111] The target allocation submodule is used to send the service data in the first target queue according to the remaining sendable data volume, and update the remaining sendable data volume;

[0112] The remaining allocation submodule is used to determine the highest priority first target queue from the remaining service queues if the updated remaining sendable data volume is greater than 0, until all service queues are empty or the remaining sendable data volume is 0, and wait for the next preset time slice to arrive.

[0113] Optionally, the device further includes:

[0114] A bandwidth detection module is used to periodically detect the current bandwidth of the data sending end using a preset algorithm;

[0115] The maximum transmittable data volume calculation module is used to calculate the maximum transmittable data volume based on the current bandwidth and the duration of the preset time slice.

[0116] Optionally, the device further includes:

[0117] The waiting-to-send module is used to wait for the next preset time slice to arrive if the remaining amount of data that can be sent is equal to 0.

[0118] The data retransmission module is used to store the service data in the second target queue into a preset space when the first time period arrives, if there is a second target queue that has not sent data within the first time period, and wait for retransmission.

[0119] The data clearing module is used to discard unsent service data in the preset space when the second time period arrives.

[0120] Optionally, the device further includes:

[0121] The preemptive transmission module is used to directly transmit the specified service data according to the transmission protocol corresponding to the specified service when the specified service data is generated and the specified service data is less than a specified size.

[0122] Optionally, the device further includes:

[0123] The network detection module is used to detect whether network congestion has occurred based on feedback messages from the data receiving end.

[0124] The maximum transmittable data volume adjustment module is used to reduce the maximum transmittable data volume if network congestion is detected.

[0125] Optionally, the data sending end is a surveillance camera, and the services processed by the surveillance camera simultaneously include live streaming and alarm services; the priority of the live streaming service is higher than the priority of the alarm service.

[0126] Optionally, the data transmitter is in a weak network environment, where the weak network environment refers to the Wi-Fi signal strength of the data transmitter being less than a preset value or the uplink bandwidth of the data transmitter being less than a preset bandwidth.

[0127] In weak network environments, this invention utilizes time-slice polling to allocate current bandwidth to multiple service queues according to priority. This controls the transmission of service data from different services using different transmission protocols, ensuring the reliability of high-priority services and allocating remaining bandwidth to other service queues. By setting appropriate priorities and service data sizes, it's possible to ensure the performance of high-priority services while guaranteeing the normal operation of low-priority services when multiple services coexist. For surveillance camera scenarios, current bandwidth can be prioritized for live streaming to ensure its real-time performance, and the remaining bandwidth can then be allocated to alarm services, enabling both live streaming and alarm services to operate normally in weak network environments.

[0128] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0129] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0130] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0131] Reference Figure 3 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Figure 3 As shown, the electronic device includes: a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface communicate with each other through the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform the steps of the data transmission method described in the foregoing embodiments.

[0132] This invention provides a non-transitory computer-readable storage medium that, when the instructions in the storage medium are executed by a program or processor of a terminal, enables the terminal to perform the steps of the data transmission method described in the foregoing embodiments.

[0133] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0134] Furthermore, the beneficial effects of using the same method will not be repeated here. For technical details not disclosed in the computer program products or computer program embodiments involved in this application, please refer to the description of the method embodiments of this application.

[0135] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.

[0136] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

[0137] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0138] The present invention has provided a detailed description of a data transmission method, apparatus, and electronic device. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A data transmission method, characterized in that, Applied to a data sending end, wherein the data sending end simultaneously processes at least two services, the method includes: The business data generated by different services are sent to the corresponding business queues, and different business queues use different transmission protocols. When the preset time slice arrives, the service data for this data volume is read from the highest priority service queue and sent according to the corresponding transmission protocol; the current data volume is less than or equal to the maximum transmittable data volume, which is determined based on the current bandwidth of the data sending end and the duration of the preset time slice. Subtract the current data volume from the maximum amount of data that can be sent to obtain the remaining amount of data that can be sent. If the remaining amount of data that can be sent is greater than 0, then the remaining amount of data that can be sent is allocated to the service queues that were not sent this time according to priority.

2. The method according to claim 1, characterized in that, If the remaining amount of data that can be sent is greater than 0, then the remaining amount of data that cannot be sent this time is allocated to the service queue according to priority, including: If the remaining amount of data that can be sent is greater than 0, then the highest priority first target queue is determined from the service queues that were not sent this time; Send the service data in the first target queue according to the remaining sendable data volume, and update the remaining sendable data volume; If the updated remaining transmittable data volume is greater than 0, then the highest priority first target queue is determined from the remaining service queues, until all service queues are empty or the remaining transmittable data volume is 0, and then the system waits for the next preset time slice to arrive.

3. The method according to claim 1, characterized in that, The method further includes: The current bandwidth of the data sending end is periodically detected using a preset algorithm; The maximum amount of data that can be sent is calculated based on the current bandwidth and the duration of the preset time slice.

4. The method according to claim 1, characterized in that, The method further includes: If the remaining amount of data that can be sent is equal to 0, then wait for the next preset time slice to arrive; When the first time period arrives, if there is a second target queue that has not sent data within the first time period, the service data in the second target queue is stored in the preset space and awaits retransmission. When the second time interval arrives, discard any unsent service data in the preset space.

5. The method according to claim 1, characterized in that, The method further includes: When specified service data is generated, and the specified service data is less than the specified size, the specified service data is sent directly according to the transmission protocol corresponding to the specified service.

6. The method according to claim 1, characterized in that, The method further includes: Detect network congestion based on feedback messages from the data receiver; If network congestion is detected, the maximum amount of data that can be sent is reduced.

7. The method according to any one of claims 1 to 6, characterized in that, The data sending end is a surveillance camera, and the surveillance camera simultaneously processes live streaming and alarm services; the live streaming service has a higher priority than the alarm service.

8. The method according to any one of claims 1 to 6, characterized in that, The data transmitter is in a weak network environment, which means that the Wi-Fi signal strength of the data transmitter is less than a preset value or the uplink bandwidth of the data transmitter is less than a preset bandwidth.

9. A data transmission device, characterized in that, The device is applied to a data transmitting end, which simultaneously processes at least two services, and includes: The data queuing module is used to send business data generated by different services to the corresponding business queues, and different business queues use different transmission protocols; The first allocation module is used to read the current data volume from the highest priority service queue when the preset time slice arrives, and send it according to the corresponding transmission protocol; the current data volume is less than or equal to the maximum transmittable data volume, which is determined based on the current bandwidth of the data sending end and the duration of the preset time slice. The remaining calculation module is used to subtract the current data volume from the maximum data volume that can be sent to obtain the remaining data volume that can be sent. The second allocation module is used to allocate the remaining sendable data to the service queue that has not been sent this time according to priority if the remaining sendable data is greater than 0.

10. An electronic device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the steps of the data transfer method as described in any one of claims 1 to 8.