Data processing method and apparatus, device, and storage medium
By allocating N cache spaces for each service on the receiving end, and storing and reading data packets using modulus operations, the parsing errors caused by out-of-order data packets are solved, and efficient data sorting and resource utilization are achieved.
Patent Information
- Application Number
- PCT/CN2025/070082
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-03
- Filing Date
- 2025-01-02
- Publication Date
- 2025-07-10
AI Technical Summary
During data transmission, the transmission order of data packets is inconsistent with the arrangement order of packet sequence numbers, resulting in errors in the receiver's parsing. The existing technology requires additional sorting algorithms, resulting in large system resource overhead.
By allocating N cache spaces for each service on the receiving end, modulus operation is used to store data packets in the cache space according to the packet sequence number, and read the cache space content in sequence, the sorting processing of data packets is realized.
无需额外排序算法,实现了数据包的按序排列,避免解析错误,节省系统资源开销,并提高缓存空间的利用率。
Smart Images

Figure CN2025070082_10072025_PF_FP_ABST
Abstract
Description
Data processing method, device, equipment and storage medium
[0001] This application claims priority to Chinese patent application number 202410008942.8, filed on January 3, 2024, entitled “Data processing method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of the present application relate to the field of data processing technology, and in particular to a data processing method, apparatus, device, and storage medium. Background Art
[0003] During data transmission, the order in which data packets are transmitted may differ from the order in which their sequence numbers are arranged. For example, when transmitting data packets over UDP (User Datagram Protocol), the receiving end may experience confusion in the sequence numbers of received data packets, leading to parsing errors when the receiving end parses the data packets. Therefore, a data processing method is urgently needed to sort the sequence numbers of received data packets to avoid data parsing errors. Summary of the Invention
[0004] The present invention provides a data processing method, apparatus, device, and storage medium for obtaining multiple data packets arranged according to packet sequence numbers. The technical solution is as follows:
[0005] In a first aspect, a data processing method is provided. The method is applied to a first device, wherein the first device includes at least one set of cache spaces, where the set of cache spaces includes N cache spaces, and the N cache spaces are used to cache data packets of a service, where N is a positive integer. The method includes:
[0006] Upon receiving any data packet of any service, store the data packet in an Mth cache space among N cache spaces corresponding to the service, where the data packet includes a packet sequence number, where M is a modulo value of the packet sequence number of the data packet and N, and the packet sequence number is a natural number;
[0007] The contents stored in the N cache spaces corresponding to any one of the services are read in sequence to obtain a plurality of data packets of the any one of the services arranged according to packet sequence numbers.
[0008] In one possible implementation, storing any data packet in the Mth cache space among the N cache spaces corresponding to any service includes: determining the value of a packet pointer as M based on the packet sequence number of any data packet and the modulus value of N, the value of the packet pointer being used to indicate the storage location of the data packet of any service, and one packet pointer value corresponding to one cache space; determining the Mth cache space among the N cache spaces corresponding to any service based on the value of the packet pointer being M, storing any data packet in the Mth cache space, and the size of a cache space being not less than the size of a data packet.
[0009] In one possible embodiment, the first device includes a packet fetch pointer, the value of which is used to indicate the reading position of the data packet of any one of the services, and one packet fetch pointer value corresponds to a cache space; the sequential reading of the contents stored in the N cache spaces corresponding to any one of the services includes: when the value of the packet fetch pointer changes, determining the reading position in the N cache spaces corresponding to any one of the services based on the value of the packet fetch pointer and the modulo value of N, the initial value of the packet fetch pointer being the packet sequence number of the first data packet of any one of the services; reading the contents stored in the cache space corresponding to the reading position; increasing the value of the packet fetch pointer by a first step length, and determining that the value of the packet fetch pointer changes until the data packet transmission of any one of the services is completed, and the difference in the packet sequence numbers between any adjacent data packets of any one of the services is the same and the same as the first step length.
[0010] In one possible embodiment, reading the content stored in the cache space corresponding to the read position includes: if the content stored in the cache space corresponding to the read position contains a data packet, reading the data packet stored in the cache space corresponding to the read position, and the packet sequence number of the data packet corresponding to the read position is the value of the packet pointer; if the content stored in the cache space corresponding to the read position is empty, reading the content stored in the cache space corresponding to the read position again, and if the duration of reading the cache space corresponding to the read position exceeds a first time threshold, reading the content stored in the cache space corresponding to the read position as empty.
[0011] In a possible embodiment, the method further includes: if the duration of reading the cache space corresponding to the reading position exceeds a second time threshold, determining that a data packet in the cache space corresponding to the reading position has been lost, and the second time threshold is less than the first time threshold; sending a packet loss retransmission instruction to the second device that sends any of the services, the packet loss retransmission instruction instructs the second device to re-send the data packet whose packet sequence number is the value of the packet pointer to the first device.
[0012] In a possible embodiment, after determining that a data packet in the cache space corresponding to the read position has been lost, the method further includes: obtaining at least one of the number of received packets, the number of lost packets, or the packet loss rate of any of the services, wherein the number of received packets is obtained based on statistics of the data packets read, the number of lost packets is obtained based on statistics of the data packets determined to have been lost, and the packet loss rate is obtained based on the number of received packets and the number of lost packets.
[0013] In a possible embodiment, increasing the value of the packet fetch pointer by the first step length includes: when the value of the packet fetch pointer does not exceed the numerical threshold, increasing the value of the packet fetch pointer by the first step length; after reading the content stored in the cache space corresponding to the read position, it also includes: when the value of the packet fetch pointer exceeds the numerical threshold, setting the value of the packet fetch pointer to the initial value.
[0014] In a possible implementation manner, the any service is a video service, and N is determined based on at least one of a frame rate, a bit rate, or a delay requirement of the video service.
[0015] In one possible embodiment, storing any data packet in the Mth cache space among the N cache spaces corresponding to any service includes: if any data packet passes the validity check, storing any data packet in the Mth cache space among the N cache spaces corresponding to any service, the validity check is used to verify whether any data packet satisfies the packet format of the data packet, or the validity check is used to verify whether the checksum information carried by any data packet is correct.
[0016] On the other hand, a data processing apparatus is further provided. The apparatus is applied to a first device, the first device including at least one set of cache spaces, the set of cache spaces including N cache spaces, the N cache spaces being used to cache data packets of a service, where N is a positive integer, the apparatus including:
[0017] a storage module, configured to, upon receiving any data packet of any service, store the data packet in an Mth cache space among N cache spaces corresponding to the service, wherein the data packet includes a corresponding packet sequence number, where M is a modulo value of the packet sequence number of the data packet and N, and the packet sequence number is a natural number;
[0018] The reading module is used to sequentially read the contents stored in the N cache spaces corresponding to any one of the services to obtain a plurality of data packets of the any one of the services arranged according to packet sequence numbers.
[0019] In one possible embodiment, the storage module is used to determine the value of the packet pointer as M based on the packet sequence number of any data packet and the modulus value of N, the value of the packet pointer is used to indicate the storage location of the data packet of any service, and one packet pointer value corresponds to one cache space; according to the value of the packet pointer as M, the Mth cache space among the N cache spaces corresponding to any service is determined, and any data packet is stored in the Mth cache space, and the size of a cache space is not less than the size of a data packet.
[0020] In one possible embodiment, the first device includes a packet fetch pointer, the value of the packet fetch pointer is used to indicate the reading position of the data packet of any one of the services, and one packet fetch pointer value corresponds to a cache space; the reading module is used to determine the reading position in the N cache spaces corresponding to any one of the services according to the value of the packet fetch pointer and the modulo value of N when the value of the packet fetch pointer changes, and the initial value of the packet fetch pointer is the packet sequence number of the first data packet of any one of the services; read the content stored in the cache space corresponding to the reading position; increase the value of the packet fetch pointer by the first step length, and determine that the value of the packet fetch pointer changes until the data packet transmission of any one of the services is completed, and the difference in the packet sequence numbers between any adjacent data packets of any one of the services is the same and the same as the first step length.
[0021] In a possible embodiment, the reading module is used to read the data packet stored in the cache space corresponding to the reading position if the content stored in the cache space corresponding to the reading position contains a data packet, and the packet sequence number of the data packet corresponding to the reading position is the value of the packet pointer; if the content stored in the cache space corresponding to the reading position is empty, read the content stored in the cache space corresponding to the reading position again, and if the duration of reading the cache space corresponding to the reading position exceeds a first time threshold, the content stored in the cache space corresponding to the reading position is read to be empty.
[0022] In one possible embodiment, the device also includes: a determination module, used to determine that a data packet in the cache space corresponding to the read position has been lost if the duration of reading the cache space corresponding to the read position exceeds a second time threshold, and the second time threshold is less than the first time threshold; a sending module, used to send a packet loss retransmission instruction to the second device that sends any of the services, and the packet loss retransmission instruction instructs the second device to re-send the data packet whose packet sequence number is the value of the packet pointer to the first device.
[0023] In a possible embodiment, the device further includes: an acquisition module for obtaining at least one of the number of received packets, the number of lost packets, or the packet loss rate of any of the services, wherein the number of received packets is obtained based on the statistics of the read data packets, the number of lost packets is obtained based on the statistics of the data packets determined to have lost packets, and the packet loss rate is obtained based on the number of received packets and the number of lost packets.
[0024] In one possible implementation, the reading module is used to increase the value of the packet fetch pointer by a first step length when the value of the packet fetch pointer does not exceed a numerical threshold; the reading module is also used to set the value of the packet fetch pointer to the initial value when the value of the packet fetch pointer exceeds the numerical threshold.
[0025] In a possible implementation manner, the any service is a video service, and N is determined based on at least one of a frame rate, a bit rate, or a delay requirement of the video service.
[0026] In one possible embodiment, the storage module is used to store any data packet in the Mth cache space among the N cache spaces corresponding to any service if any data packet passes the validity check, and the validity check is used to verify whether any data packet meets the packet format of the data packet, or the validity check is used to verify whether the checksum information carried by any data packet is correct.
[0027] On the other hand, a computer device is also provided, comprising a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor so that the computer device implements the data processing method described in any of the above aspects.
[0028] On the other hand, a non-volatile computer-readable storage medium is provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor so that the computer implements the data processing method described in any of the above aspects.
[0029] In another aspect, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the data processing method described in any of the above aspects.
[0030] The technical solutions provided by the embodiments of the present application bring at least the following beneficial effects:
[0031] The technical solution provided by the present application sets up multiple cache spaces corresponding to any business, and stores the received data packets of any business according to the modulo value of the packet sequence number and the number of cache spaces, so that the received data packets can be cached in multiple cache spaces in the order of the packet sequence number. Therefore, by reading the contents stored in N cache spaces in sequence, multiple data packets arranged according to the packet sequence number can be obtained. This method realizes the sorting of data packets according to the packet sequence number through the storage and reading process, avoiding data parsing errors caused by disorder. Since there is no need to use an additional sorting algorithm, the system resource overhead caused by the additional sorting algorithm is also saved. In addition, through the modulo operation, the data packet of any packet sequence number can be cached in any cache space of the multiple cache spaces set, which can ensure the circular reuse of the multiple cache spaces and improve resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0033] FIG1 is a schematic diagram of an implementation environment of a data processing method provided in an embodiment of the present application;
[0034] FIG2 is a flow chart of a data processing method provided in an embodiment of the present application;
[0035] FIG3 is a schematic diagram of a data processing process provided by an embodiment of the present application;
[0036] FIG4 is a schematic diagram of another data processing process provided by an embodiment of the present application;
[0037] FIG5 is a schematic diagram of another data processing process provided by an embodiment of the present application;
[0038] FIG6 is a schematic diagram of a retransmission process of data processing provided in an embodiment of the present application;
[0039] FIG7 is a schematic diagram of another data processing process provided by an embodiment of the present application;
[0040] FIG8 is a schematic diagram of a data processing scenario provided in an embodiment of the present application;
[0041] FIG9 is a schematic diagram of another data processing scenario provided in an embodiment of the present application;
[0042] FIG10 is a schematic structural diagram of a data processing device provided in an embodiment of the present application;
[0043] FIG11 is a schematic structural diagram of a server provided in an embodiment of the present application;
[0044] FIG12 is a schematic structural diagram of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0046] It should be noted that the terms "first", "second", etc. (if any) in the specification of the present application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application.
[0047] During data transmission, packets are the basic unit of data. To ensure data integrity and accuracy, packets are accompanied by information such as sequence numbers. The receiving end can sort multiple packets according to the sequence numbers to ensure accurate data reception. However, in some cases, the transmission order of the packets may differ from the order in which the sequence numbers are assigned.
[0048] For example, consider UDP-based data transmission. UDP is a connectionless protocol that doesn't provide packet sequencing or retransmission mechanisms for lost packets. Therefore, in poor network conditions or congestion, UDP packets may arrive out of order at the receiving end. This means that the order in which UDP packets are transmitted may not align with the sequence numbers. If the receiving end directly processes these out-of-order packets, data parsing errors may occur, impacting the normal operation of applications.
[0049] Related technologies use a buffer to temporarily store out-of-order data packets and then employ an additional sorting algorithm to sort them. However, the application of this additional sorting algorithm results in complex system resource overhead. These additional sorting algorithms can include bubble sort, selection sort, or insertion sort. Therefore, a more efficient data processing method is urgently needed to address the issue of out-of-order data packets.
[0050] The present embodiment provides a data processing method that, without requiring an additional sorting algorithm, implements sorting of the sequence numbers of received data packets through a storage and read process. Please refer to FIG1 , which illustrates a schematic diagram of an implementation environment for the data processing method provided in the present embodiment. The implementation environment may include: a computer device 11.
[0051] The embodiments of the present application do not limit the product form of the computer device 11. Regardless of the product form, the computer device 11 includes at least one set of cache spaces, each set of cache spaces including N cache spaces, and the N cache spaces are used to cache data packets for a service, where N is a positive integer. For any service, the computer device 11 stores the received data packets of the service in the N cache spaces corresponding to the service in the order of the packet sequence number modulo the number of cache spaces, and then reads the contents stored in the N cache spaces in the order of the packet sequence number, thereby obtaining multiple data packets for the service sorted by the packet sequence number.
[0052] For example, the computer device 11 can be a terminal or a server. Alternatively, the terminal can be any electronic product that can interact with a user through one or more methods such as a keyboard, touchpad, touch screen, remote control, voice interaction, or handwriting device, such as a PC (Personal Computer), a mobile phone, a smart phone, a PDA (Personal Digital Assistant), a wearable device, a PPC (Pocket PC), a tablet computer, a smart car computer, a smart TV, a smart speaker, etc. The server can be a single server, a server cluster consisting of multiple servers, or a cloud computing service center.
[0053] Those skilled in the art should understand that the above-mentioned computer devices 11, terminals and servers are only examples. Other existing or future computer devices 11, terminals or servers that are applicable to this application should also be included in the scope of protection of this application and are included here by reference.
[0054] This embodiment of the present application provides a data processing method. Taking a first device as an example, the method is performed. The first device includes at least one cache space group, where the cache space group includes N cache spaces, and the N cache spaces are used to cache data packets for a service, where N is a positive integer. The method can be applied to the implementation environment shown in Figure 1. For example, the first device is computer device 11 shown in Figure 1. As shown in Figure 2, the data processing method includes but is not limited to the following steps 201 and 202.
[0055] Step 201, when any data packet of any service is received, any data packet is stored in the Mth cache space among the N cache spaces corresponding to any service, and any data packet includes a packet sequence number, M is the modulus value of the packet sequence number of any data packet and N, and the packet sequence number is a natural number.
[0056] In an embodiment of the present application, a first device may allocate a set of cache spaces corresponding to a service, wherein the set of cache spaces includes N cache spaces, and the N cache spaces are used to temporarily store received data packets of the corresponding service. The capacity of the cache spaces for different services or for the same service may be the same or different. Optionally, the capacity of the cache spaces may be determined based on the size of the data packets transmitted by the different services, so that each of the N cache spaces corresponding to any service has sufficient capacity to store a complete data packet of any service.
[0057] The value of N can be the same or different between the N cache spaces corresponding to different services. If the value of N is set too small, the amount of cache space may be insufficient to accommodate all out-of-order data packets, thereby affecting the accuracy of data processing; if the value of N is set too large, it may result in a waste of cache resources. Optionally, the value of N can be determined based on at least one of service requirements, network conditions, or the cache capacity of the first device.
[0058] For example, if any of the services is a video service, since the frame rate, bit rate, and latency directly affect the video viewing experience in a video service, when determining the amount of cache space N, N can be determined based on at least one of the frame rate, bit rate, or latency requirements of the video service. The frame rate of a video represents the number of frames displayed per second, and a high frame rate means a smoother video. If the frame rate requirement for a video service is high, it means that more data packets need to be processed per second, so a larger N value may be required to ensure sufficient cache space to store the data packets.
[0059] Bitrate refers to the number of bits transmitted per second in a video service. A higher bitrate generally means higher video quality, but it also requires more bandwidth and processing power. For high-bitrate video services, a larger N value may be required to address potential packet out-of-order issues. Latency refers to the time it takes for a data packet to be transmitted from the video source to be played back at the video sink.
[0060] Real-time video services, such as video conferencing or live streaming, often have strict latency requirements and may require a smaller N value to reduce the waiting time for packets in the buffer. In practice, multiple experiments and adjustments may be necessary based on actual network conditions and service requirements to find the optimal N value. Alternatively, a dynamic adjustment strategy can be employed to dynamically adjust the N value based on actual packet arrival conditions and processing speed to achieve better results.
[0061] Exemplarily, the first device can be any node in the network other than the sending node. For example, the first device can be an intermediate forwarding node or a receiving node. The intermediate forwarding node can be a network device such as a router or a switch, and the receiving node can be a terminal or a server. The first device can receive data packets for different services sent by different sending nodes or the same sending node. For any service, the data packets transmitted by the service include a packet sequence number, and the packet sequence number of any data packet is used to identify the position of the data packet among all data packets sent by the service.
[0062] When the first device acts as an intermediate forwarding node, it can also communicate data with other devices. The first device can send processed data packets to other devices. Communication can be based on various protocols, such as TCP (Transfer Control Protocol) and UDP. Providing cache space on the first device allows it to act as a centralized processing node, centrally managing and processing data packets from different services, thereby improving data processing efficiency and accuracy.
[0063] After receiving any data packet of any service, the first device does not directly store the data packet in a buffer in the order of the packet sequence number. Instead, the first device uses a method based on a modulo operation to determine the storage location of the data packet. For example, after receiving any data packet of any service, the first device calculates the modulo value of the packet sequence number of the data packet and N, denoting it as M, and stores the data packet in the Mth cache space of the cache space group. M is a natural number between 0 and N-1.
[0064] The modulo operation calculates the remainder between the packet sequence number and N. Due to the nature of the modulo operation, when the packet sequence number increases to a certain level, it will restart from 0. Therefore, even if the packet sequence number is much larger than N, it can still be mapped to the range of 0 to N-1. This allows the N cache spaces to be recycled through the modulo operation, effectively improving cache space utilization.
[0065] For example, assuming N is 5, there are five cache spaces: cache space 0, cache space 1, cache space 2, cache space 3, and cache space 4. When a data packet with a sequence number of 2 is received, the modulo value of 2 and 5 is calculated to be 2, and the data packet is stored in cache space 2. When a data packet with a sequence number of 6 is received, the modulo value of 6 and 5 is calculated to be 1, and the data packet is stored in cache space 1. When a data packet with a sequence number of 5 is received, the modulo value of 5 and 5 is calculated to be 0, and the data packet is stored in cache space 0.
[0066] In an embodiment of the present application, N cache spaces are arranged in sequence. The Mth cache space can be arranged in a left-to-right order or a top-to-bottom order, which is not limited in this embodiment of the present application. Regardless of the order in which the Mth cache space is arranged, the order in which the N cache spaces are read in sequence is the same as the sorting order of the Mth cache space. For example, if the Mth cache space is arranged in a left-to-right order, then reading the N cache spaces in sequence is equivalent to reading the N cache spaces in a left-to-right order.
[0067] In one possible implementation, the process of storing any data packet in the Mth cache space among N cache spaces corresponding to any service includes: determining a packet pointer value of M based on the packet sequence number of any data packet and the modulus value of N, the packet pointer value being used to indicate the storage location of the data packet of any service, and one packet pointer value corresponding to one cache space; determining the Mth cache space among the N cache spaces corresponding to any service based on the packet pointer value of M; and storing any data packet in the Mth cache space, wherein the size of a cache space is not less than the size of a data packet.
[0068] During data packet storage, the packet pointer is an identifier that indicates which of N cache spaces the packet should be stored in. The packet pointer is designed to ensure that data packets are accurately and orderly stored in the corresponding cache space, providing a stable foundation for subsequent data processing. When a data packet is received, it is necessary to determine which cache space the packet should be stored in. This is achieved by calculating the modulo value of the packet's sequence number and N. The result of this modulo operation is denoted as M, which is the value of the packet pointer. This modulo operation can map an infinite number of packet sequence numbers to a finite number of N cache spaces.
[0069] Once the packet pointer value is determined to be M, the cache space in which the data packet should be stored can be determined. Each packet pointer value corresponds to a cache space, so M corresponds to the Mth cache space. This correspondence is fixed, ensuring that the data packet is accurately stored in the predetermined location and stored in the Mth cache space. The size of each cache space is designed to be at least the size of a data packet, ensuring that the data packet can be stored completely in the cache space without data overflow or loss.
[0070] In one possible implementation, the process of storing any data packet in the Mth cache space among the N cache spaces corresponding to any service includes storing the data packet in the Mth cache space among the N cache spaces corresponding to any service if the data packet passes a validity check. The validity check can filter out invalid data packets, preventing them from interfering with or disrupting subsequent data processing. This ensures that the data packet being processed is valid, avoiding the processing of invalid data packets and wasting processing resources.
[0071] That is, before any data packet is stored in the Mth buffer space among the N buffer spaces corresponding to any service, a validity check is performed on the data packet. If the data packet passes the validity check, the data packet is stored in the Mth buffer space among the N buffer spaces corresponding to the service. If the data packet fails the validity check, the data packet is discarded.
[0072] The validity check of a data packet includes multiple aspects of verification. Optionally, the validity check is used to check whether any data packet meets the packet format of the data packet, or the validity check is used to check whether the checksum information carried by any data packet is correct. For example, it is possible to check whether the packet format of the data packet is correct. Each service will define the corresponding data packet format, including the length of the data packet, header information, payload structure, etc. By checking whether the data packet format matches the predefined format, it can be determined whether the data packet complies with the specification. If the format of the data packet is incorrect, then the data packet is invalid and needs to be discarded. For example, the RTP (Real-time Transport Protocol) packet needs to be larger than 12 bytes.
[0073] If a data packet passes the validity check, it is stored in the corresponding cache space for subsequent data processing. Consider that even if a data packet passes the check, it may still be invalid or damaged. For example, the data packet may have lost some bits during the storage process. Therefore, in the subsequent data processing process, other error detection and correction mechanisms may need to be implemented to ensure the integrity and accuracy of the data. The embodiments of the present application do not limit the subsequent data processing process.
[0074] Furthermore, for certain services with high real-time requirements, latency may need to be considered alongside validity verification. If the validity verification process takes too long, it may increase packet processing latency, impacting the real-time nature of the service. Therefore, in practical applications, the trade-off between validity verification complexity and processing latency must be considered based on service requirements and network conditions to select the appropriate validity verification method.
[0075] Step 202 : Read the contents stored in N cache spaces corresponding to any service in sequence to obtain a plurality of data packets of any service arranged according to packet sequence numbers.
[0076] When multiple data packets of any service are stored in N cache spaces according to step 201, the first device needs to read the contents of the N cache spaces to reconstruct the original data stream. Because the multiple data packets are sequentially stored in the N storage spaces based on the modulus value of the packet sequence number and N, the multiple data packets arranged according to the packet sequence number can be obtained by sequentially and cyclically reading the contents stored in the N storage spaces, thereby ensuring data integrity and accuracy.
[0077] Optionally, the method for sequentially reading the contents stored in the N cache spaces corresponding to any service can be to start reading from the cache space corresponding to the packet sequence number of the first data packet received for any service and the modulus value of N, the first data packet being stored in the cache space; taking out the first data packet, and based on the arrangement of the data including the packet sequence number, continuing to read the cache space corresponding to the next packet sequence number of the first data packet and the modulus value of N, until all the packet sequence numbers of any service are read; and obtaining multiple data packets arranged according to the packet sequence number of any service. The embodiment of the present application does not limit the arrangement of the packet sequence number. For example, the packet sequence number can be arranged using natural numbers according to the order in which the data packets are transmitted in the network, for example, 0, 1, 2, 3...; or, the packet sequence number can be arranged using natural numbers with a fixed step length according to the order in which the data packets are transmitted in the network, for example, 1, 3, 5, 7..., and the fixed step length is 2.
[0078] For example, let N be 3, and the packet numbers are arranged as 0, 1, and 2. The three cache spaces are the 0th cache space, the 1st cache space, and the 2nd cache space. The data packet with the packet number 0 is stored in the 0th cache space based on the remainder of 0 and 3 being 0; the data packet with the packet number 1 is stored in the 1st cache space based on the remainder of 1 and 3 being 1; the data packet with the packet number 2 is stored in the 2nd cache space based on the remainder of 2 and 3 being 2. Therefore, since the packet numbers are 0, 1, and 2, the contents of the three cache spaces can be read in the order of the 0th cache space, the 1st cache space, and the 2nd cache space, resulting in multiple data packets arranged according to the packet numbers 0, 1, and 2.
[0079] When sequentially reading the contents stored in the N cache spaces corresponding to any service, the first cache space to be read may be determined based on the packet sequence number of the first data packet received for any service. For example, if the packet sequence number of the first data packet of any service is 0, the first cache space to be read may be the 0th cache space; if the packet sequence number of the first data packet of any service is 1, the first cache space to be read may be the 1st cache space.
[0080] To ensure that read packets are arranged according to their sequence numbers, the N buffer spaces must be read in strict sequence. This means that skipping buffer spaces or changing the reading order is not permitted, as this can lead to data confusion and loss. Therefore, in practical applications, some measures must be taken to ensure the correct reading order, such as using pointers or indexes to track the current reading position.
[0081] In an embodiment of the present application, the first device includes a packet fetch pointer, the value of which is used to indicate a read position of a data packet of any service, and one packet fetch pointer value corresponds to a cache space. The process of sequentially reading the contents stored in N cache spaces corresponding to any service includes, when the value of the packet fetch pointer changes, determining the read position in the N cache spaces corresponding to any service based on the value of the packet fetch pointer and the modulo value of N, the initial value of the packet fetch pointer being the packet sequence number of the first data packet of any service; reading the contents stored in the cache space corresponding to the read position; increasing the value of the packet fetch pointer by the first step length, and determining that the value of the packet fetch pointer has changed, until the data packet transmission of any service is completed, and the difference in the packet sequence numbers between any adjacent data packets of any service is the same and the same as the first step length.
[0082] Since the packet pointer can indicate which cache space the content is currently being read from, and each time a read is completed, the value of the packet pointer increases by the first step length, which is the same as the difference in packet sequence numbers between any adjacent data packets of any service, reading the data packets through the packet pointer ensures that the read data packets are arranged according to the packet sequence numbers, thereby ensuring the accuracy and consistency of the read data.
[0083] When the value of the packet fetch pointer changes, it means that the reading of the previous cache space has been completed, and it is necessary to execute the reading of the cache space corresponding to the value of the current packet fetch pointer and the modulo value of N. That is, the value of the packet fetch pointer is mapped to one of the N cache spaces to ensure that all cache spaces can be read cyclically. After the reading position is determined, the content stored in the cache space corresponding to the position is read. After the reading is completed, the value of the packet fetch pointer needs to be updated based on the first step. By updating the value of the packet fetch pointer, it can be determined that the value of the packet fetch pointer has changed, and the above reading operation will continue to be cyclic.
[0084] If the value of the packet fetch pointer does not change, it can be considered that the transmission of all data packets of any service has been completed, and the read operation will no longer be cyclically executed. Optionally, the scenario in which the value of the packet fetch pointer no longer changes can be that the first device no longer receives data packets of any service, in which case the value of the packet fetch pointer no longer changes; or the first device receives the last packet of data packets of any service, in which case the value of the packet fetch pointer no longer changes; or the first device receives a completion instruction sent by any service, in which case the value of the packet fetch pointer no longer changes.
[0085] Refer to the schematic diagram of a data processing process shown in Figure 3. Taking any service as an audio and video service as an example, the stream formed by the data packets of the audio and video service is the audio and video push stream. For any data packet in the received audio and video push stream, the any data packet can be a UDP data packet. The value of the packet pointer P1 is determined by the modulo operation result of the packet sequence number of any data packet and N; based on the value of the packet pointer P1, the any data packet is stored in N cache spaces; thereafter, it is read out from the N cache spaces through the packet pointer P2, and then a plurality of data packets arranged according to the packet sequence number are obtained to output ordered audio and video packets.
[0086] In addition, during data processing, packet loss rate statistics and packet loss retransmission operations can be performed. Packet loss rate statistics refer to the proportion of data packets lost during network transmission due to network congestion or transmission errors. Packet loss rate statistics can be used to evaluate network quality. Packet loss retransmission is a network transmission mechanism. When the streaming end receives a retransmission instruction sent by the receiving end, it will resend the data packet corresponding to the retransmission instruction to the receiving end to ensure that the receiving end can receive the complete data. Packet loss retransmission can improve the reliability and stability of network transmission. The implementation methods of packet loss rate statistics and packet loss retransmission can be found in the relevant description below and will not be repeated here.
[0087] Referring to another data processing process diagram shown in FIG4 , for a received out-of-order input queue, the out-of-order input queue may be, for example, data packets S1, S3, S2, S4, etc., and an ordered output queue may be output through the data processing process, and the ordered data queue may be, for example, data packets S1, S2, S3, S4, etc.
[0088] For the data processing process of Figure 4, please refer to the schematic diagram of another data processing process shown in Figure 5. Taking a group of cache spaces including 16 cache spaces 0-15 as an example, for each data packet, it can be stored in the 16 cache spaces according to the packet sequence number through the packet pointer P1. For example, S1 is stored in the first cache space, etc., and through the single-direction circular packet pointer P2, it can be read cyclically according to the packet sequence number to output ordered data packets.
[0089] Optionally, the process of increasing the value of the packet fetch pointer by the first step includes, if the value of the packet fetch pointer does not exceed a numerical threshold, increasing the value of the packet fetch pointer by the first step. After reading the content stored in the cache space corresponding to the read position, the process also includes, if the value of the packet fetch pointer exceeds the numerical threshold, setting the value of the packet fetch pointer to an initial value.
[0090] When the value of the packet fetch pointer does not exceed the preset numerical threshold, the value of the packet fetch pointer is increased by the first step length. When the value of the packet fetch pointer reaches or exceeds the numerical threshold, the processing method will be different. The numerical threshold can be understood as a boundary value of the numerical value, which is used to prevent the value of the packet fetch pointer from growing indefinitely and exceeding the valid range of the numerical value. Once the value of the packet fetch pointer reaches or exceeds the numerical threshold, it needs to be reset. In actual applications, the setting of the numerical threshold needs to be determined according to the specific situation, and factors such as the size of the cache space, the number and distribution of data packets should be taken into account to ensure the integrity and accuracy of the cyclic reading. The embodiment of the present application does not limit the specific value of the numerical threshold. For example, the numerical threshold is 65536. The reset method can be to reset the value of the packet fetch pointer to the initial value. The initial value is the packet sequence number of the first data packet of any business, which means that the reading process will be carried out from the cache space where the first data packet is located.
[0091] Among them, the process of reading the content stored in the cache space corresponding to the read position includes: if the content stored in the cache space corresponding to the read position contains a data packet, reading the data packet stored in the cache space corresponding to the read position, and the packet sequence number of the data packet corresponding to the read position is the value of the packet pointer; if the content stored in the cache space corresponding to the read position is empty, reading the content stored in the cache space corresponding to the read position again, if the duration of reading the cache space corresponding to the read position exceeds the first time threshold, the content stored in the cache space corresponding to the read position is empty.
[0092] When the read position is determined, the first device will check whether the cache space corresponding to the position stores a data packet. If a data packet exists, the data packet is read directly. Since the change in the value of the packet pointer is the same as the change in the packet sequence number, the value of the packet pointer is the same as the packet sequence number of the data packet corresponding to the read position. If the content stored in the cache space corresponding to the read position is empty, for example, the data packet sending delay at the read position has not arrived, or the data packet at the read position is lost, the content stored in the cache space corresponding to the read position will be empty; since the data packet cannot be read directly, an attempt will be made to read the content of the cache space again, that is, to wait for the data packet at the read position to arrive at the first device and be stored in the read position by the first device. The re-reading process may be repeated multiple times until the data packet is read or a certain time limit is reached.
[0093] Continuously check whether the duration of reading the cache space exceeds the preset first time threshold. The first time threshold can be understood as the maximum time limit for waiting to read the data packet. If the data packet still cannot be read within the first time threshold, it can be determined that the cache space is empty, that is, no data is read. When it is determined that the content stored in the cache space is empty, you can choose to skip this position and continue to read the next cache space, or adopt other error handling mechanisms to handle abnormal situations. In actual applications, it is necessary to set an appropriate first time threshold according to the specific situation to ensure that the situation of empty cache space can be handled reasonably. In addition, if a large amount of cache space is empty frequently, it may be necessary to further investigate the cause and optimize it.
[0094] If the duration of reading the cache space corresponding to the read position exceeds a second time threshold, it is determined that packet loss has occurred in the cache space corresponding to the read position, and the second time threshold is less than the first time threshold; a packet loss retransmission instruction is sent to the second device sending any service, instructing the second device to resend the packet whose sequence number is the value of the packet pointer to the first device. The second time threshold is a time limit shorter than the first time threshold. If packet loss is determined to have occurred, a packet loss retransmission instruction is sent to the second device sending the packet, so that the second device resends the packet determined to have been lost to the first device based on the packet loss retransmission instruction. That is, after determining that the packet corresponding to the read position has been lost, the first device will continue to wait for the arrival of the retransmitted packet.
[0095] The packet loss retransmission instruction includes the sequence number of the data packet to be resent. By reading the sequence number of the data packet corresponding to the read position, the second device can accurately determine which data packet to resend. Upon receiving the packet loss retransmission instruction, the second device resends the corresponding data packet based on the sequence number in the instruction.
[0096] When the first device receives the retransmitted data packet, it stores the received retransmitted data packet in the corresponding buffer space according to the packet sequence number so that it can be read in sequence later. Because the packet sequence number of the retransmitted data packet is the same as the packet sequence number of the initially transmitted data packet, even if a data packet is lost, the lost data packet can be recovered by retransmission, thereby maintaining the integrity and accuracy of the data stream.
[0097] The second time threshold should be set based on specific circumstances. It should be short enough to detect possible packet loss, but not too short to avoid misidentifying normal network latency or other temporary read issues as packet loss. For example, the first and second time thresholds can be defined based on the time it takes for a packet fetch pointer to cyclically read N cache spaces. For example, the first time threshold can be the time it takes to cyclically read N-1 cache spaces, and the second time threshold can be less than or equal to half the first time threshold.
[0098] Referring to FIG6 , a schematic diagram of a data processing retransmission process is shown. Taking the first device as the media end and the second device as the streaming end as an example, for the RTP or UDP data packets sent by the streaming end of the audio and video service, the media end stores the data packets in the corresponding positions of the N cache spaces through the packet pointer P1, and reads them from the N cache spaces through the packet pointer P2, and outputs the ordered audio and video packets to the playback end in sequence. Among them, the media end can be set at the playback end, or it can be connected to the playback end by wired or wireless means. For the data packets that are lost, the retransmission module of the media end can send a packet loss retransmission request to the streaming end when the packet loss is determined.
[0099] When it is determined that packet loss has occurred in the cache space corresponding to the read position, some statistical information can be obtained to help more comprehensively understand the packet loss situation. The statistical information may include the number of packets received, the number of packets lost, and the packet loss rate for any service. For example, after determining that packet loss has occurred in the cache space corresponding to the read position, the method further includes: obtaining at least one of the number of packets received, the number of packets lost, or the packet loss rate for any service, wherein the number of packets received is obtained based on the statistics of the packets read, the number of packets lost is obtained based on the statistics of the packets determined to have experienced packet loss, and the packet loss rate is obtained based on the number of packets received and the number of packets lost.
[0100] The number of received packets is calculated based on the data packets read. Each time a data packet is successfully read, the number of received packets count is increased accordingly. Therefore, the number of received packets can reflect the number of data packets actually successfully received. The number of lost packets is calculated based on the data packets that are confirmed to have been lost. When a data packet is determined to have been lost, the number of lost packets count is increased accordingly. Therefore, the number of lost packets can reflect the number of data packets lost during transmission. The packet loss rate is a calculated indicator used to measure the severity of packet loss. The packet loss rate can be obtained by comparing the number of lost packets with the number of received packets. For example, the number of lost packets is divided by the number of received packets to obtain a ratio value. The ratio value indicates the packet loss situation, such as the degree of packet loss.
[0101] Obtaining statistical information allows for a more comprehensive analysis and assessment of data transmission. For example, a high packet loss rate may indicate network transmission issues or errors in packet processing. Further investigation can be conducted to address the problem, such as optimizing network transmission protocols or remediating packet processing logic. Furthermore, statistical information can be used for performance monitoring and troubleshooting. By comparing and analyzing packet transmission status over different time periods or for different services, anomalies or potential issues can be identified promptly, allowing preventive measures to be taken to avoid data transmission interruptions or degradation.
[0102] Referring to Figure 7, another data processing process diagram is shown. Taking a UDP audio / video data packet as an example, the UDP audio / video data packet is received via the UDP listening service and the packet sequence number is calculated. A buffer index value is then calculated using a modular operation. This buffer index value serves as the packet storage pointer P1. The audio / video data packet is stored in N buffer spaces using the packet storage pointer P1, and the data packet is retrieved according to the packet sequence number using the packet retrieval pointer P2. This data processing process also utilizes a packet loss statistics module and a packet loss retransmission module. Before the data processing process begins, these modules, along with the N buffer spaces, must be initialized to prevent legacy data from interfering with the current data processing process.
[0103] Packet sequence initialization P2 means initializing the initial P2 with the smallest packet sequence number so that P2 corresponds to the first data packet. The value of the P2 pointer is obtained after the modulo operation, that is, P2 and N are modulo operated, and the obtained value corresponds to one of the N cache spaces. For data packets that are not lost, the data packet is output. For data packets that are lost, the packet sequence number is input into the packet loss statistics module. The packet loss statistics module performs relevant operations on packet loss rate statistics based on the input packet sequence number, and the packet sequence number is input into the packet loss retransmission module. The packet loss retransmission module performs relevant operations on packet loss retransmission based on the input packet sequence number.
[0104] For ease of understanding, the method provided by the embodiment of the present application is illustrated using a data processing scenario as shown in Figure 8. As shown in Figure 8, RTP / UDP data packets are collected, and the validity of the audio and video packets is checked through the UDP service. If the audio and video packets are invalid, the next packet reception is waited for. If the audio and video packets are valid, the packet sequence number S and P1 are calculated, and the data packets are stored in N cache spaces P1. The implementation of this process can be referred to the relevant description of step 201 above.
[0105] Taking N buffer spaces of length L as an example, the P2 pointer is initialized and the P2 MOD L data is read. That is, a modulo operation is performed on P2 and N to obtain the value. If the buffer space corresponding to the modulo operation value is not empty, P2 MOD L is reset to empty and P2 is incremented by 1. If P2 is greater than the threshold, P2 is set to 0. If P2 is less than or equal to the threshold, the UDP service is re-invoked. The P2 pointer is initialized and the P2 MOD L data is read. If the buffer space corresponding to the P2 MOD L value is empty, the number of packet waiting times C is marked, that is, the duration of the corresponding buffer space is read. If C is less than the threshold, that is, the duration does not exceed the first time threshold, the next packet is received and the duration reaches the first time threshold. If the duration exceeds the second time threshold, the packet loss statistics service is called through the packet loss marking interface to calculate the packet loss rate, and a packet loss retransmission request is sent through the UDP service. In addition, before performing the data processing process, the packet loss statistics module, packet loss retransmission module and N cache spaces need to be initialized to avoid interference of historical legacy data in the current data processing process. The implementation method of this process can refer to the relevant instructions of step 202 above and will not be repeated here.
[0106] Exemplarily, another data processing scenario shown in FIG9 is taken as an example to illustrate the method provided in the embodiment of the present application. As shown in FIG9, the data processing scenario includes different processing processes corresponding to the camera, UDP service, packet loss statistics, packet loss retransmission and N cache spaces, wherein live streaming refers to the process of transmitting audio and video data to the network, and UDP listening receives streaming data through the network protocol UDP. After receiving the data, data deserialization is required to restore the data packet to the original data structure or object, and ensure the order and integrity of the data by calculating the packet sequence number and updating the packet sequence number. Modulo operation is used to calculate the packet pointer, and the data packet is placed in the corresponding cache space to ensure the orderly storage of the data. The implementation method of this process can refer to the relevant description of step 201 above.
[0107] Furthermore, in a scenario, packet loss can be determined based on duration or packet count. If no packet loss has occurred, the data is output according to the packet sequence number. If packet loss has occurred, the receiving end pushes a message containing the sequence number of the lost data packet, informing the camera which data packets failed to be successfully transmitted. A packet loss retransmission message is then encapsulated and pushed to the camera, requesting the camera to resend the lost data packet. After receiving the packet loss retransmission message, the camera pushes the lost data packet again according to the data packet indicated in the retransmission message, and the lost data packet is retrieved by the UDP listening service. The implementation of this process can be found in the relevant description of step 202 above and will not be repeated here.
[0108] In summary, the data processing method provided by the embodiment of the present application sets corresponding multiple cache spaces for any business, and stores the received data packets of any business according to the modulo value of the packet sequence number and the number of cache spaces, so that the received data packets can be cached in multiple cache spaces in the order of the size of the packet sequence number. Therefore, by reading the contents stored in N cache spaces in sequence, multiple data packets arranged according to the packet sequence number can be obtained. This method realizes the sorting of data packets according to the packet sequence number through the storage and reading process, avoiding data parsing errors caused by disorder. Since there is no need to use an additional sorting algorithm, the system resource overhead caused by the additional sorting algorithm is also saved. Moreover, through the modulo operation, the data packet of any packet sequence number can be cached in any cache space of the set multiple cache spaces, which can ensure the circular reuse of the multiple cache spaces and improve resource utilization.
[0109] Referring to FIG. 10 , FIG. 10 is a schematic structural diagram of a data processing apparatus provided in an embodiment of the present application. As shown in FIG. 10 , the apparatus is applied to a first device. The first device includes at least one set of cache spaces, where one set of cache spaces includes N cache spaces, and the N cache spaces are used to cache data packets of a service, where N is a positive integer. The apparatus includes:
[0110] The storage module 1001 is configured to, upon receiving any data packet of any service, store the data packet in an Mth cache space among N cache spaces corresponding to the service, wherein the data packet includes a corresponding packet sequence number, where M is a modulo value of the packet sequence number of the data packet and N, and the packet sequence number is a natural number;
[0111] The reading module 1002 is used to sequentially read the contents stored in the N cache spaces corresponding to any service to obtain a plurality of data packets of any service arranged according to packet sequence numbers.
[0112] In one possible implementation, the storage module 1001 is used to determine the value of a packet pointer as M based on the modulus value of the packet sequence number of any data packet and N, where the value of the packet pointer is used to indicate the storage location of the data packet of any service, and one packet pointer value corresponds to one cache space; based on the value of the packet pointer as M, the Mth cache space among the N cache spaces corresponding to any service is determined, and any data packet is stored in the Mth cache space, where the size of a cache space is not less than the size of a data packet.
[0113] In one possible implementation, the first device includes a packet fetch pointer, the value of which is used to indicate a read location for a data packet of any service, and one packet fetch pointer value corresponds to one cache space. A reading module 1002 is configured to, when the value of the packet fetch pointer changes, determine a read location in the N cache spaces corresponding to any service based on the value of the packet fetch pointer modulo N, the initial value of the packet fetch pointer being the packet sequence number of the first data packet of any service, read the contents stored in the cache space corresponding to the read location, increment the value of the packet fetch pointer by the first step length, and determine that the value of the packet fetch pointer has changed until the data packet transmission of any service is completed and the difference in the packet sequence numbers between any adjacent data packets of any service is the same and the same as the first step length.
[0114] In one possible implementation, the reading module 1002 is used to read the data packet stored in the cache space corresponding to the reading position if the content stored in the cache space corresponding to the reading position contains a data packet, and the packet sequence number of the data packet corresponding to the reading position is the value of the packet pointer; if the content stored in the cache space corresponding to the reading position is empty, read the content stored in the cache space corresponding to the reading position again, and if the duration of reading the cache space corresponding to the reading position exceeds the first time threshold, the content stored in the cache space corresponding to the reading position is empty.
[0115] In a possible implementation, the device further includes:
[0116] The determination module is configured to determine that a data packet in the cache space corresponding to the read position has been lost if a duration of reading the cache space corresponding to the read position exceeds a second time threshold, and the second time threshold is less than the first time threshold.
[0117] The sending module is used to send a packet loss retransmission instruction to the second device sending any service, and the packet loss retransmission instruction instructs the second device to resend the data packet whose packet sequence number is the value of the packet pointer to the first device.
[0118] In a possible implementation, the device further includes:
[0119] An acquisition module is used to obtain at least one of the number of received packets, the number of lost packets, or the packet loss rate of any service. The number of received packets is obtained based on the statistics of the read data packets, the number of lost packets is obtained based on the statistics of the data packets determined to have lost packets, and the packet loss rate is obtained based on the number of received packets and the number of lost packets.
[0120] In one possible implementation, the reading module 1002 is configured to increase the value of the packet fetching pointer by a first step length if the value of the packet fetching pointer does not exceed a numerical threshold. The reading module 1002 is further configured to set the value of the packet fetching pointer to an initial value if the value of the packet fetching pointer exceeds the numerical threshold.
[0121] In a possible implementation, any service is a video service, and N is determined based on at least one of a frame rate, a bit rate, or a delay requirement of the video service.
[0122] In one possible implementation, the storage module 1001 is used to store any data packet in the Mth cache space among the N cache spaces corresponding to any service when any data packet passes the validity check, and the validity check is used to verify whether any data packet meets the packet format of the data packet, or the validity check is used to verify whether the checksum information carried by any data packet is correct.
[0123] In summary, the data processing device provided by the present application sets up multiple cache spaces corresponding to any business, and stores the received data packets of any business according to the modulo value of the packet sequence number and the number of cache spaces, so that the received data packets can be cached in multiple cache spaces in the order of the packet sequence number. Therefore, by reading the contents stored in N cache spaces in sequence, multiple data packets arranged according to the packet sequence number can be obtained. The device realizes the sorting of data packets according to the packet sequence number through the storage and reading process, avoiding data parsing errors caused by disorder. Since there is no need to use an additional sorting algorithm, the system resource overhead caused by the additional sorting algorithm is also saved. In addition, through the modulo operation, the data packet of any packet sequence number can be cached in any cache space of the set multiple cache spaces, which can ensure the circular reuse of the multiple cache spaces and improve resource utilization.
[0124] It should be noted that the data processing device provided in the embodiment of FIG10 is merely an example of the division of the above-mentioned functional modules when implementing its functions. In actual functions, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments are based on the same concept, and their specific implementation process can be found in the method embodiments.
[0125] Figure 11 is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server may have relatively large differences due to different configurations or performances, and may include one or more processors 1101 and one or more memories 1102, wherein the one or more memories 1102 store at least one computer program, and the at least one computer program is loaded and executed by the one or more processors 1101 to enable the server to implement the data processing methods provided in the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server may also include other components for implementing device functions, which will not be described in detail here.
[0126] Figure 12 is a schematic diagram of the structure of a terminal provided in an embodiment of the present application. The terminal may be, for example, a smartphone, a tablet computer, a player, a laptop computer, or a desktop computer. The terminal may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.
[0127] Typically, the terminal includes: a processor 1201 and a memory 1202 .
[0128] The processor 1201 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1201 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1201 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1201 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1201 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0129] The memory 1202 may include one or more computer-readable storage media, which may be non-transitory. The memory 1202 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1202 is used to store at least one instruction, which is executed by the processor 1201 to enable the terminal to implement the data processing method provided in the method embodiment of the present application.
[0130] In some embodiments, the terminal may optionally include a peripheral device interface 1203 and at least one peripheral device. The processor 1201, memory 1202, and peripheral device interface 1203 may be connected via a bus or signal lines. Each peripheral device may be connected to the peripheral device interface 1203 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 1204, a display screen 1205, a camera assembly 1206, an audio circuit 1207, and a power supply 1208.
[0131] The peripheral device interface 1203 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 1201 and the memory 1202. In some embodiments, the processor 1201, the memory 1202, and the peripheral device interface 1203 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1201, the memory 1202, and the peripheral device interface 1203 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0132] The RF circuit 1204 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1204 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1204 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the RF circuit 1204 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The RF circuit 1204 can communicate with other terminals via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, metropolitan area networks, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1204 may also include circuits related to Near Field Communication (NFC), which is not limited in this application.
[0133] Display screen 1205 is used to display a user interface (UI). This UI can include graphics, text, icons, videos, and any combination thereof. When display screen 1205 is a touchscreen display, it can also capture touch signals on or above the surface of display screen 1205. These touch signals can be input as control signals to processor 1201 for processing. Display screen 1205 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there can be a single display screen 1205, located on the front panel of the terminal. In other embodiments, there can be at least two display screens 1205, located on different surfaces of the terminal or in a foldable design. In still other embodiments, display screen 1205 can be a flexible display screen, located on a curved or foldable surface of the terminal. Display screen 1205 can also be configured as a non-rectangular, irregular shape, also known as a special-shaped screen. Display screen 1205 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0134] The camera assembly 1206 is used to capture images or videos. Optionally, the camera assembly 1206 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1206 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0135] The audio circuit 1207 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals to be input into the processor 1201 for processing, or input into the radio frequency circuit 1204 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, each disposed at different parts of the terminal. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert electrical signals from the processor 1201 or the radio frequency circuit 1204 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1207 may also include a headphone jack.
[0136] Power supply 1208 is used to power various components in the terminal. Power supply 1208 can be AC power, DC power, disposable batteries, or rechargeable batteries. When power supply 1208 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0137] In some embodiments, the terminal further includes one or more sensors 1209 , including but not limited to: an acceleration sensor 1210 , a gyroscope sensor 1211 , a pressure sensor 1212 , an optical sensor 1213 , and a proximity sensor 1214 .
[0138] The accelerometer 1210 can detect the magnitude of acceleration along the three coordinate axes of the coordinate system established by the terminal. For example, the accelerometer 1210 can be used to detect the components of gravity acceleration along the three coordinate axes. The processor 1201 can control the display screen 1205 to display the user interface in a landscape or portrait view based on the gravity acceleration signal collected by the accelerometer 1210. The accelerometer 1210 can also be used to collect game or user motion data.
[0139] The gyroscope sensor 1211 can detect the terminal's body orientation and rotation angle. It can also work with the accelerometer 1210 to collect the user's 3D movements of the terminal. Based on the data collected by the gyroscope sensor 1211, the processor 1201 can implement the following functions: motion sensing (such as changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0140] The pressure sensor 1212 can be set in the side frame of the terminal and / or the lower layer of the display screen 1205. When the pressure sensor 1212 is set in the side frame of the terminal, it can detect the user's grip signal of the terminal, and the processor 1201 performs left and right hand recognition or shortcut operations based on the grip signal collected by the pressure sensor 1212. When the pressure sensor 1212 is set in the lower layer of the display screen 1205, the processor 1201 controls the operable controls on the UI interface based on the user's pressure operation on the display screen 1205. Operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0141] Optical sensor 1213 is used to detect ambient light intensity. In one embodiment, processor 1201 can control the display brightness of display screen 1205 based on the ambient light intensity detected by optical sensor 1213. Specifically, when the ambient light intensity is high, the display brightness of display screen 1205 is increased; when the ambient light intensity is low, the display brightness of display screen 1205 is decreased. In another embodiment, processor 1201 can also dynamically adjust the shooting parameters of camera assembly 1206 based on the ambient light intensity detected by optical sensor 1213.
[0142] Proximity sensor 1214, also known as a distance sensor, is typically located on the front panel of the terminal. Proximity sensor 1214 is used to detect the distance between the user and the front of the terminal. In one embodiment, when proximity sensor 1214 detects that the distance between the user and the front of the terminal is gradually decreasing, processor 1201 controls display screen 1205 to switch from the screen-on state to the screen-off state. When proximity sensor 1214 detects that the distance between the user and the front of the terminal is gradually increasing, processor 1201 controls display screen 1205 to switch from the screen-off state to the screen-on state.
[0143] Those skilled in the art will understand that the structure shown in FIG12 does not constitute a limitation on the terminal, and may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0144] In an exemplary embodiment, a computer device is further provided, comprising a processor and a memory, wherein the memory stores at least one computer program. The at least one computer program is loaded and executed by one or more processors to enable the computer device to implement any of the above-mentioned data processing methods.
[0145] In an exemplary embodiment, a non-transitory computer-readable storage medium is also provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor of a computer device to enable the computer to implement any of the above-mentioned data processing methods.
[0146] In one possible implementation, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0147] In an exemplary embodiment, a computer program product or computer program is also provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the above-described data processing methods.
[0148] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the relevant data in the data processing process involved in this application was obtained with full authorization.
[0149] It should be understood that the term "plurality" used herein refers to two or more. "And / or" describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates an "or" relationship between the associated objects.
[0150] The above description is merely an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A data processing method, characterized in that The method is applied to a first device, which includes at least one set of cache spaces. One set of cache spaces includes N cache spaces, and the N cache spaces are used to cache data packets of a service. N is a positive integer. The method includes: When receiving any data packet of any service, store the any data packet in the M-th cache space among the N cache spaces corresponding to the any service. The any data packet includes a packet sequence number, and M is the modulo value of the packet sequence number of the any data packet and N. The packet sequence number is a natural number. Read the content stored in the N cache spaces corresponding to the any service in sequence to obtain multiple data packets of the any service arranged according to the packet sequence number.
2. The method according to claim 1, characterized in that, The storing the any data packet in the M-th cache space among the N cache spaces corresponding to the any service includes: Based on the modulo value of the packet sequence number of the any data packet and N, determine that the value of the packet storage pointer is M. The value of the packet storage pointer is used to indicate the storage location of the data packets of the any service, and one value of the packet storage pointer corresponds to one cache space. According to the value of the packet storage pointer being M, determine the M-th cache space among the N cache spaces corresponding to the any service, and store the any data packet in the M-th cache space. The size of one cache space is not less than the size of one data packet.
3. The method according to claim 1, wherein, The first device includes a packet fetching pointer, and the value of the packet fetching pointer is used to indicate the reading location of the data packets of the any service. One value of the packet fetching pointer corresponds to one cache space. The reading the content stored in the N cache spaces corresponding to the any service in sequence includes: When the value of the packet fetching pointer changes, determine the reading location among the N cache spaces corresponding to the any service according to the modulo value of the value of the packet fetching pointer and N. The initial value of the packet fetching pointer is the packet sequence number of the first data packet of the any service. Read the content stored in the cache space corresponding to the reading location. Increase the value of the packet fetching pointer by a first step length, and determine that the value of the packet fetching pointer changes until the data packets of the any service are transmitted completely. The difference between the packet sequence numbers of any two adjacent data packets of the any service is the same and is the same as the first step length.
4. The method according to claim 3, wherein The reading the content stored in the cache space corresponding to the reading location includes: If there is a data packet in the content stored in the cache space corresponding to the reading location, read the data packet stored in the cache space corresponding to the reading location. The packet sequence number of the data packet corresponding to the reading location is the value of the packet fetching pointer. If the content stored in the cache space corresponding to the reading location is empty, read the content stored in the cache space corresponding to the reading location again. If the duration of reading the cache space corresponding to the reading location exceeds a first time threshold, read that the content stored in the cache space corresponding to the reading location is empty.
5. The method according to claim 4, wherein The method further includes: If the duration of reading the cache space corresponding to the reading location exceeds a second time threshold, determine that the data packet in the cache space corresponding to the reading location is lost. The second time threshold is less than the first time threshold. Send a packet loss retransmission instruction to a second device that sends any of the services, where the packet loss retransmission instruction instructs the second device to re-send a data packet with a packet sequence number equal to the value of the packet fetch pointer to the first device.
6. The method according to claim 5, characterized in that After determining that a data packet in the buffer space corresponding to the read position is lost, it further includes: Obtain at least one of the received packet count, packet loss count, or packet loss rate of any of the services. The received packet count is statistically obtained based on the read data packets, the packet loss count is statistically obtained based on the determined lost data packets, and the packet loss rate is obtained based on the received packet count and the packet loss count.
7. The method according to claim 3, characterized in that, The step of increasing the value of the packet fetch pointer by a first step length includes: When the value of the packet fetch pointer does not exceed the numerical threshold, increase the value of the packet fetch pointer by the first step length; After reading the content stored in the buffer space corresponding to the read position, it further includes: When the value of the packet fetch pointer exceeds the numerical threshold, set the value of the packet fetch pointer to the initial value.
8. The method according to any one of claims 1-7, characterized in that, Any of the services is a video service, and N is determined based on at least one of the frame rate, bit rate, or latency requirement of the video service.
9. The method according to any one of claims 1-7, characterized in that, The step of storing any data packet in the M-th buffer space among N buffer spaces corresponding to any service includes: When any data packet passes the validity check, store the data packet in the M-th buffer space among N buffer spaces corresponding to any service. The validity check is used to verify whether any data packet meets the packet format of the data packet, or the validity check is used to verify whether the checksum information carried by any data packet is correct.
10. A data processing device, characterized in that, The device is applied to a first device. The first device includes at least one set of buffer spaces. A set of buffer spaces includes N buffer spaces, and the N buffer spaces are used to buffer data packets of one service. N is a positive integer. The device includes: A storage module, configured to, when receiving any data packet of any service, store the data packet in the M-th buffer space among N buffer spaces corresponding to any service. Any data packet includes a corresponding packet sequence number, and M is the modulo value of the packet sequence number of any data packet and N. The packet sequence number is a natural number; A reading module, configured to sequentially read the content stored in N buffer spaces corresponding to any service to obtain multiple data packets of any service arranged in the order of packet sequence numbers.
11. A computer device, characterized in that, The computer device includes a processor and a memory. At least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor so that the computer device implements the data processing method according to any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium, characterized in that, At least one computer program is stored in the computer-readable storage medium, and the at least one computer program is loaded and executed by a processor so that a computer implements the data processing method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Network data packet processing method and apparatus, and network processing device
CN104821924A
Business processing method, electronic device, electronic equipment and medium
CN114116536A
High-speed bus data caching method, device and equipment and storage medium
CN114896189A
Data processing method and device, equipment and storage medium
CN118018502A
Memory leakage recovery method for packet memory and buffer processing unit
JP2002057712A