Network forwarding method, device and equipment based on SPI virtual network card and storage medium
By implementing lightweight network processing and adaptive SPI bus scheduling in user space, combined with multi-level queue scheduling and error correction mechanisms, the problem of poor network forwarding performance in embedded audio devices is solved, achieving efficient and reliable audio data transmission.
Patent Information
- Application Number
- CN202511531292.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2026-02-10
AI Technical Summary
Existing technologies in embedded audio devices rely too heavily on the kernel network protocol stack, making it difficult to adapt to the low bandwidth and high latency characteristics of the SPI bus. This results in poor network forwarding performance, high latency, and unreliable sound quality.
Lightweight network address translation and bridging forwarding are implemented in user space. Combined with SPI bus bandwidth adaptive scheduling algorithm, multi-level weighted queue scheduling, predictive buffering and forward error correction (FEC) coding, transmission parameters are optimized to ensure high real-time performance and reliability of audio streams.
It significantly improves the network forwarding efficiency and audio service quality of embedded audio devices, achieving low-power, low-latency, and highly reliable network forwarding, thus enhancing the user experience.
Smart Images

Figure CN121508735A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of network communication, and in particular to a network forwarding method and device based on an SPI virtual network card, an equipment and a storage medium. BACKGROUND
[0002] With the popularity of the Internet of Things and intelligent audio devices, the demand for low-power and high real-time network transmission of embedded systems is increasing. As a lightweight network solution, the SPI virtual network card is widely used in resource-constrained embedded audio devices due to its simple interface and low cost, and is used to realize the network transmission and forwarding of audio data.
[0003] At present, existing network forwarding solutions mostly rely on complete operating system kernel network protocol stacks, such as the iptables tool based on the Linux kernel to implement Network Address Translation (NAT) and the bridge-utils tool to implement bridge functions. Such solutions work well on general computing platforms, but they have obvious limitations: first, they are heavily dependent on kernel modules and cannot be normally loaded and run in a deeply trimmed embedded kernel environment, resulting in the failure of basic forwarding functions; second, traditional solutions lack effective response mechanisms to the inherent physical limitations of the SPI bus, and there are generally problems of significant data transmission delay and insufficient link reliability in actual applications; finally, existing technologies lack real-time guarantee mechanisms for audio streams and cannot provide priority forwarding services for audio data in complex network environments, which seriously affects the smoothness of audio playback and user experience. SUMMARY
[0004] The present application provides a network forwarding method and device based on an SPI virtual network card, an equipment and a storage medium to solve the problem that the existing technology is excessively dependent on kernel network protocol stacks, is difficult to adapt to the low bandwidth and high delay characteristics of the SPI bus, and cannot meet the high real-time requirements of audio services, resulting in poor network forwarding performance, high delay and poor audio quality in embedded audio devices.
[0005] The first aspect of the application provides a network forwarding method based on a SPI virtual network card, applied to an embedded audio device environment, comprising: obtaining a network data packet; performing lightweight network address translation and bridge forwarding processing in a user mode according to the network data packet to obtain a forwarding decision result; performing transmission parameter dynamic adjustment processing through a SPI bus bandwidth adaptive scheduling algorithm based on the forwarding decision result to obtain optimized transmission parameters; performing data packet priority classification and multi-level weighted queue scheduling processing according to the optimized transmission parameters to obtain a data packet after priority scheduling; and performing predictive buffering and forward error correction (FEC) encoding processing based on the data packet after priority scheduling, and sending through a SPI virtual network card.
[0006] In a feasible implementation, the lightweight network address translation and bridge forwarding processing in a user mode according to the network data packet to obtain a forwarding decision result comprises: analyzing the network data packet to extract header information of a network layer and a data link layer; querying a lightweight NAT mapping table and a MAC address forwarding table maintained in a user mode according to target IP addresses and target MAC addresses in the header information to determine address conversion operations or a two-layer forwarding path to be performed by the data packet; and generating a forwarding decision result based on the query result, wherein the forwarding decision result indicates a processing mode of the data packet, including performing SNAT / DNAT conversion, cross-interface bridge forwarding or discarding, and containing corresponding output interface identification and modified address information.
[0007] In a feasible implementation, the transmission parameter dynamic adjustment processing through a SPI bus bandwidth adaptive scheduling algorithm based on the forwarding decision result to obtain optimized transmission parameters comprises: determining a target SPI virtual network card channel to be used by a data packet to be scheduled according to output interface identification in the forwarding decision result; monitoring a transmission state of the target SPI virtual network card channel in real time to collect key performance indicators of an instantaneous transmission rate, an error rate and a data packet round-trip delay; and dynamically adjusting a clock frequency and a data packet fragmentation size of the target SPI channel through a bandwidth adaptive scheduling algorithm based on the collected key performance indicators to obtain optimized transmission parameters for data transmission of the corresponding channel.
[0008] In an embodiment, the data packet priority classification and multi-level weighted queue scheduling processing according to the optimized transmission parameters comprises: pre-processing and format adapting the data packets to be scheduled according to the data packet fragmentation size in the optimized transmission parameters; parsing the protocol header information and payload characteristics of the pre-processed data packets, and classifying them into high-priority audio streams, medium-priority control streams or low-priority data streams according to a predefined rule library; and using a multi-level weighted queue scheduling mechanism to select data packets from the queues according to the preset weight proportion of different priority queues, and sending the data packets to form a priority-scheduled data packet sequence.
[0009] In an embodiment, the predictive buffering and forward error correction (FEC) encoding processing based on the priority-scheduled data packets and sending through an SPI virtual network card comprises: dynamically allocating the space size and caching strategy of the predictive buffer according to the priority attributes of the priority-scheduled data packet sequence and the link characteristics in the optimized transmission parameters; using real-time channel bit error rate-based forward error correction (FEC) encoding processing for high-priority audio data packets; using an automatic repeat request (ARQ) mechanism for medium and low-priority data packets; and sending the data packets processed through buffering and error correction through a designated SPI virtual network card channel according to the scheduling sequence.
[0010] In an embodiment, the real-time channel bit error rate-based forward error correction (FEC) encoding processing for high-priority audio data packets comprises: real-time monitoring of the transmission state of the SPI communication channel, counting the number of error bits and the total number of transmission bits, and calculating the real-time channel bit error rate; querying a pre-configured FEC parameter mapping table according to the size of the real-time channel bit error rate to determine the corresponding encoding algorithm type and redundancy information proportion; and generating a redundancy check code for the high-priority audio data packets based on the determined encoding algorithm and redundancy proportion and appending the redundancy check code to the original data packets.
[0011] In an embodiment, the automatic repeat request (ARQ) mechanism for medium and low-priority data packets comprises: assigning a unique sequence number to each medium and low-priority data packet to be sent and starting a corresponding retransmission timer; determining that the data packet is lost and adding it to a retransmission queue if an acknowledgement (ACK) from the receiving end for the sequence number is not received before the retransmission timer expires; and initiating retransmission only for the lost data packets in the retransmission queue, and not retransmitting the data packets that have successfully received an acknowledgement.
[0012] The second aspect of the application provides a network forwarding device based on a SPI virtual network card, applied to an embedded audio device environment, comprising: an acquisition module configured to acquire a network data packet; a first processing module configured to perform lightweight network address translation and bridge forwarding processing in a user mode according to the network data packet, and obtain a forwarding decision result; an adjustment module configured to perform transmission parameter dynamic adjustment processing based on the forwarding decision result through a SPI bus bandwidth adaptive scheduling algorithm, and obtain optimized transmission parameters; a scheduling module configured to perform data packet priority classification and multi-level weighted queue scheduling processing according to the optimized transmission parameters, and obtain a data packet after priority scheduling; and a second processing module configured to perform predictive buffering and forward error correction (FEC) encoding processing based on the data packet after priority scheduling, and send the data packet through a SPI virtual network card.
[0013] In a feasible implementation, the first processing module is specifically configured to: parse the network data packet, and extract header information of a network layer and a data link layer thereof; query a lightweight NAT mapping table and a MAC address forwarding table maintained in the user mode according to a target IP address and a target MAC address in the header information, to determine an address conversion operation or a two-layer forwarding path to be performed by the data packet; and generate a forwarding decision result based on the query result, wherein the forwarding decision result indicates a processing mode of the data packet, including: performing SNAT / DNAT conversion, cross-interface bridge forwarding or discarding, and contains a corresponding output interface identifier and modified address information.
[0014] In a feasible implementation, the adjustment module is specifically configured to: determine a target SPI virtual network card channel to be used by a data packet to be scheduled according to an output interface identifier in the forwarding decision result; monitor a transmission state of the target SPI virtual network card channel in real time, and collect key performance indicators including an instantaneous transmission rate, an error rate and a data packet round-trip delay; and based on the collected key performance indicators, dynamically adjust a clock frequency and a data packet fragmentation size of the target SPI channel by using a bandwidth adaptive scheduling algorithm, to obtain optimized transmission parameters for data transmission of the corresponding channel.
[0015] In a feasible implementation, the scheduling module is specifically configured to: preprocess and format adapt the data packet to be scheduled according to a data packet fragmentation size in the optimized transmission parameters; parse protocol header information and payload characteristics of the preprocessed data packet, and classify it into a high-priority audio stream, a medium-priority control stream or a low-priority data stream according to a pre-defined rule library; and adopt a multi-level weighted queue scheduling mechanism, select data packets from each queue according to a weight proportion preset for different priority queues, and send the data packets to form a data packet sequence after priority scheduling.
[0016] In one feasible implementation, the second processing module includes: an allocation unit, configured to dynamically allocate the space size and caching strategy of the predictive buffer according to the priority attributes of the data packet sequence after priority scheduling and the link characteristics in the optimized transmission parameters; a first processing unit, configured to perform forward error correction (FEC) coding processing on high-priority audio data packets based on real-time channel bit error rate; a second processing unit, configured to perform selective retransmission (ARQ) mechanism on medium- and low-priority data packets; and a sending unit, configured to send the buffered and error-corrected data packets through a specified SPI virtual network interface card channel according to the scheduling sequence.
[0017] In one feasible implementation, the first processing unit is specifically used to: monitor the transmission status of the SPI communication channel in real time, count the number of error bits and the total number of transmitted bits, and calculate the real-time channel bit error rate; based on the magnitude of the real-time channel bit error rate, query the pre-configured FEC parameter mapping table to determine the corresponding encoding algorithm type and redundancy information ratio; and based on the determined encoding algorithm and redundancy ratio, generate a redundancy check code for high-priority audio data packets and append it to the original data packets.
[0018] In one feasible implementation, the second processing unit is specifically used to: assign a unique sequence number to each low-priority data packet sent and start a corresponding retransmission timer; if no acknowledgment (ACK) response for the sequence number is received from the receiving end before the retransmission timer expires, the data packet is determined to be lost and added to the retransmission queue; retransmission is initiated only for lost data packets in the retransmission queue, and data packets that have been successfully acknowledged are not retransmitted.
[0019] A third aspect of the present invention provides an electronic device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor invokes the instructions in the memory to cause the electronic device to execute the network forwarding method based on the SPI virtual network card described above.
[0020] A fourth aspect of the present invention provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the network forwarding method based on the SPI virtual network interface card described above.
[0021] The technical solution provided by this invention involves: acquiring network data packets; performing lightweight network address translation and bridging forwarding processing in user space based on the network data packets to obtain forwarding decision results; dynamically adjusting transmission parameters using an SPI bus bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters; classifying data packets by priority and performing multi-level weighted queue scheduling processing to obtain priority-scheduled data packets based on the optimized transmission parameters; performing predictive buffering and forward error correction (FEC) encoding processing on the priority-scheduled data packets and sending them through an SPI virtual network interface card. In this embodiment, lightweight user-space processing eliminates dependence on kernel modules, enabling the system to operate stably in resource-constrained embedded environments; SPI bandwidth adaptive scheduling and dynamic parameter optimization significantly improve bus utilization and real-time transmission performance; and the combination of multi-level priority queues and predictive error correction mechanisms effectively ensures audio stream transmission quality, achieving low-power, low-latency, and highly reliable network forwarding, greatly improving the user experience of embedded audio devices. Attached Figure Description
[0022] Figure 1 This is a schematic diagram of an embodiment of the network forwarding method based on an SPI virtual network card in this invention. Figure 2 This is a schematic diagram of another embodiment of the network forwarding method based on the SPI virtual network card in this invention; Figure 3 This is a schematic diagram of an embodiment of a network forwarding device based on an SPI virtual network card in this invention. Figure 4 This is a schematic diagram of another embodiment of the network forwarding device based on the SPI virtual network card in this invention; Figure 5 This is a schematic diagram of one embodiment of the electronic device in this invention. Detailed Implementation
[0023] This invention provides a network forwarding method, apparatus, device, and storage medium based on an SPI virtual network card. It implements a lightweight network forwarding engine, adaptive SPI bus bandwidth scheduling, and audio stream priority guarantee mechanism in user space, which significantly improves the network forwarding efficiency, data transmission real-time performance, and audio service quality of embedded audio devices.
[0024] The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" or "having" and any variations thereof are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] It is understood that the executing entity of this invention can be a network forwarding device based on an SPI virtual network card, or it can be a terminal or a server; no specific limitation is made here. This embodiment of the invention will be described using a server as an example.
[0026] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1 One embodiment of the network forwarding method based on the SPI virtual network card in this invention includes: 101. Obtain network data packets; This solution is applied to embedded audio device environments. The TUN device file is opened in the user-space program, and then the virtual interface is configured using the ioctl system call, setting it to TUN mode and specifying a custom network interface name. After configuration, the program adds the file descriptor corresponding to the TUN interface to the epoll event listener. When external network packets arrive at this virtual interface, epoll detects that the file descriptor is in a readable state, reads the complete raw network packets from the file descriptor, and stores these packets in a pre-allocated user-space buffer.
[0027] 102. Based on the network data packets, perform lightweight network address translation and bridging forwarding in user space to obtain the forwarding decision result; When a network packet arrives, the forwarding engine first parses its Ethernet header. If the destination MAC address is a broadcast address or not in the current MAC table, it enters the bridging process, learns the source MAC address and inserts or updates the hash table entry, then queries the forwarding table based on the destination MAC. If a match is found, the forwarding port is determined; otherwise, flooding is performed. For IP packets that need to be routed, the NAT processing module extracts TCP / UDP and IP header information, queries the NAT session table using the source IP, source port, and protocol type as keys. If it is a new connection, a unique external port number is assigned and a mapping table entry is created. Then, the source or destination IP address and port of the packet are modified, and the checksum is recalculated. Finally, the forwarding engine generates a forwarding decision based on the table lookup results, which includes the destination port, the modified packet, and instructions on whether to drop the packet, thus completing efficient packet forwarding without kernel intervention.
[0028] 103. Based on the forwarding decision results, the transmission parameters are dynamically adjusted using the SPI bus bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters; Based on the output interface identifier in the forwarding decision result, the target SPI virtual network interface channel to be used by the data packet to be scheduled is determined; the transmission status of the target SPI virtual network interface channel is monitored in real time, and the actual throughput and theoretical bandwidth are collected to calculate the real-time bandwidth utilization rate, while monitoring key performance indicators such as bit error rate and transmission delay; based on the collected key performance indicators, the following SPI bandwidth adaptive scheduling algorithm is used to dynamically adjust the clock frequency and data packet fragment size of the target SPI channel to obtain optimized transmission parameters for data transmission in the corresponding channel, including SPI clock frequency, data packet length, number of retries and timing interval.
[0029] Clock frequency adaptive formula:
[0030] The constraints are ,
[0031] in, The adjustment coefficient has a range of values from 0 to 1. This is the SPI clock frequency for the next cycle. This is the SPI clock frequency for the current cycle. For target bandwidth utilization, This represents the current actual bandwidth utilization rate. , and For the minimum and maximum clock frequencies supported by the SPI controller, This represents the maximum frequency change between adjacent periods to prevent sudden frequency changes.
[0032] Adaptive formula for packet fragment size: The constraints are
[0033] in, The size of the data packet fragments for the next cycle. The size of the data packet fragments in the current period. To adjust the coefficient, and These are the lower and upper limits for the fragment size, respectively.
[0034] Cooperative adjustment mechanism: This algorithm uses the same control signal (i.e., bandwidth utilization deviation) The transmission parameters are adjusted in a coordinated manner.
[0035] When the channel quality is good (low bit error rate, low latency) and bandwidth utilization is insufficient, the algorithm will simultaneously increase the clock frequency and increase the fragment size, thereby significantly improving the effective throughput. At the same time, based on the good channel conditions, the number of retries is reduced and the frame timing interval is shortened to further reduce transmission latency.
[0036] When the channel quality deteriorates (high bit error rate, high latency) or the utilization rate is too high, the algorithm will simultaneously reduce the clock frequency and reduce the fragment size. Reducing the frequency can enhance signal integrity, while reducing the fragment size can reduce the probability of single transmission failure. At the same time, the number of retries is increased and the frame timing interval is extended to allow more time for retransmission and signal stabilization. The two work together to significantly improve transmission reliability at the cost of sacrificing some bandwidth.
[0037] 104. Based on the optimized transmission parameters, perform packet priority classification and multi-level weighted queue scheduling to obtain priority-scheduled data packets; Based on the packet fragment size (i.e., packet length) in the optimized transmission parameters, the data packets to be scheduled are preprocessed and format adapted. For packets exceeding the fragment size, fragmentation is performed, dividing them into multiple data blocks that meet the size requirements; for packets smaller than the fragment size requirement, padding and alignment are performed to ensure that the payload of each SPI transmission matches the optimal carrying capacity of the current channel, thereby improving bus transmission efficiency. After format adaptation, the data packets are deeply parsed to extract their protocol header information and payload characteristics, and classified into high-priority audio streams, medium-priority control streams, or low-priority data streams according to a predefined rule base. Subsequently, a multi-level weighted queue scheduling mechanism (deficit polling DRR) is used to process the classified data packets. This scheduling mechanism is directly constrained by the "timing interval" in the optimized transmission parameters. The scheduler uses this timing interval as the basic scheduling cycle, and within each cycle, it allocates a byte quota that can be sent to each queue according to the preset weight ratio for different priority queues.
[0038] Multilevel Weighted Queue Scheduling Algorithm (Deficit Round Robin DRR) Formula:
[0039]
[0040] Let be the quota (in bytes) for queue i at time t. Let be the remaining quota for queue i at the previous time step. The length of the data packets sent to queue i. Let be the weight of queue i, and MTU be the maximum transmission unit.
[0041] This is a boolean value indicating whether queue i has sending permission. Queue i has sending permission when its current quota is sufficient to cover the length of the next data packet to be sent, and does not have sending permission when its current quota is insufficient to cover the length of the next data packet to be sent.
[0042] 105. Based on the priority-scheduled data packets, perform predictive buffering and forward error correction (FEC) encoding processing, and send them through the SPI virtual network card.
[0043] Based on the priority attributes of the data packet sequence after priority scheduling and the link characteristics reflected in the optimized transmission parameters (such as stability derived from bit error rate and latency), the size and caching strategy of the predictive buffer are dynamically allocated. The timing interval parameter directly affects the calculation of the buffer depth; the larger the interval, the larger the buffer required to smooth jitter.
[0044] Forward Error Correction (FEC) is used for high-priority data packets: the processing fully utilizes optimized transmission parameters. On the one hand, the FEC encoder segments and encodes the audio payload according to the data packet length in the parameters; on the other hand, when the channel conditions are poor, a lower SPI clock frequency and a higher number of retries may be output. In this case, FEC will use stronger error correction coding to cooperate with it, forming a triple reliability guarantee of "frequency reduction + retry + FEC".
[0045] Selective retransmission (ARQ) is used for low- and medium-priority data packets: This mechanism directly uses the "number of retries" in the optimized transmission parameters as the upper limit of its maximum number of retransmissions, and sets the timeout of the retransmission timer according to the "timing interval" to ensure that the retransmission behavior is consistent with the timing characteristics of the current link and avoid unnecessary waiting or overly aggressive retransmission.
[0046] A more lenient "best effort" strategy is adopted for low-priority data packets, with the maximum number of retransmissions set to be lower than that for medium-priority data packets (for example, medium-priority packets are retried 3 times, while low-priority packets are retried only once), or no retransmissions are performed at all. This further ensures that system resources are not consumed excessively on non-critical services.
[0047] Finally, the buffered and error-corrected data packets are transmitted strictly according to the scheduling sequence, using a dynamically adjusted SPI clock frequency and data packet length, through the designated SPI virtual network interface channel. The driver layer precisely configures the SPI controller, applying these optimized parameters to achieve efficient and reliable data transmission.
[0048] In this embodiment of the invention, user-space lightweight processing eliminates the dependence on kernel modules, enabling the system to run stably in resource-constrained embedded environments. Through SPI bandwidth adaptive scheduling and dynamic parameter optimization, bus utilization and transmission real-time performance are significantly improved. Combined with multi-level priority queues and predictive error correction mechanisms, the audio stream transmission quality is effectively guaranteed. Overall, low-power, low-latency, and highly reliable network forwarding is achieved, greatly enhancing the user experience of embedded audio devices.
[0049] Please see Figure 2 Another embodiment of the network forwarding method based on the SPI virtual network card in this invention includes: 201. Obtain network data packets; 202. Based on the network data packets, perform lightweight network address translation and bridging forwarding in user space to obtain the forwarding decision result; The network data packets are parsed to extract their network layer and data link layer header information. Based on the destination IP address and destination MAC address in the header information, the lightweight NAT mapping table and MAC address forwarding table maintained in user space are queried to determine the address translation operation or Layer 2 forwarding path that the data packet should perform. Based on the query results, a forwarding decision result is generated, which indicates the data packet processing method, including: performing SNAT / DNAT translation, cross-interface bridging forwarding, or dropping, and includes the corresponding output interface identifier and modified address information.
[0050] The parsing process begins at the data link layer, stripping the Ethernet frame header to obtain the source and destination MAC addresses. It then delves into the network layer, parsing the IP packet header structure to extract crucial fields such as protocol type, source IP address, and destination IP address. After parsing, the system queries a lightweight NAT mapping table maintained in user space based on the destination IP address. This table uses a hash structure to store session entries, with each entry recording the mapping relationship between internal IP and port to external IP and port. If a match is found, an SNAT or DNAT translation decision is generated, and the address information to be modified is recorded. Simultaneously, the system queries a MAC address forwarding table based on the destination MAC address. This table maintains the correspondence between MAC addresses and ports through dynamic learning. If the MAC address exists in the table, it determines which physical or virtual interface the packet should be forwarded from at Layer 2; otherwise, a broadcast forwarding decision is generated. Finally, the system synthesizes the above query results to generate a forwarding decision, explicitly indicating what operation to perform on the packet, such as performing SNAT translation and sending it from the eth0 interface, performing cross-interface bridging forwarding to wlan0, or simply discarding it. The forwarding decision also includes the output interface identifier and the source or destination IP address and port number to be modified.
[0051] 203. Based on the forwarding decision results, the transmission parameters are dynamically adjusted using the SPI bus bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters; Based on the output interface identifier in the forwarding decision result, the target SPI virtual network interface channel to be used by the data packet to be scheduled is determined; the transmission status of the target SPI virtual network interface channel is monitored in real time, and key performance indicators such as instantaneous transmission rate, bit error rate and data packet round-trip delay are collected; based on the collected key performance indicators, the clock frequency and data packet fragmentation size of the target SPI channel are dynamically adjusted using a bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters for data transmission in the corresponding channel.
[0052] After obtaining the forwarding decision result, the target SPI virtual network interface channel to be used for the data packet to be sent is determined according to the output interface identifier. Each SPI virtual network interface channel has an independent sending queue and state machine, thereby realizing transmission isolation and resource allocation between multiple channels.
[0053] Real-time transmission status monitoring of the target channel is initiated. The monitoring module samples key performance indicators such as instantaneous transmission rate, bit error rate, and data packet round-trip delay of the channel at millisecond intervals. The transmission rate is calculated by counting the number of bytes successfully acknowledged per unit time. The bit error rate is estimated based on the number of CRC check errors or response retransmissions. The data packet round-trip delay is obtained by recording the difference between the sending timestamp and the receiving acknowledgment timestamp.
[0054] Based on continuously collected performance metrics, the system invokes a bandwidth adaptive scheduling algorithm to dynamically adjust transmission parameters. This algorithm is based on the feedback regulation principle in control theory, comparing the current actual bandwidth utilization with the target utilization. If the actual utilization remains below a set threshold, the SPI clock frequency is increased proportionally, and the data packet fragment size is appropriately increased to improve effective throughput. If an increase in bit error rate or a significant increase in latency is detected, the clock frequency is gradually reduced and the fragment size is decreased to sacrifice some bandwidth for higher transmission stability. Each parameter adjustment is constrained by the maximum change amplitude to prevent system oscillation.
[0055] Finally, the algorithm outputs a set of optimized transmission parameters, including precise SPI clock frequency values, packet fragment size, frame interval, and number of retransmission attempts. These parameters will be applied to the driver layer of the target SPI channel as the basis for hardware configuration of subsequent data transmission, thereby achieving adaptive optimization of the channel's transmission performance.
[0056] 204. Based on the optimized transmission parameters, perform packet priority classification and multi-level weighted queue scheduling to obtain priority-scheduled data packets; Based on the packet fragmentation size in the optimized transmission parameters, the data packets to be scheduled are preprocessed and format adapted; the protocol header information and payload characteristics of the preprocessed data packets are parsed, and they are classified into high-priority audio streams, medium-priority control streams, or low-priority data streams according to a predefined rule base; a multi-level weighted queue scheduling mechanism is adopted, and data packets are selected from each queue according to their weights based on the preset weight ratios for different priority queues, forming a priority-scheduled data packet sequence.
[0057] After obtaining the optimized transmission parameters, the data packets to be scheduled are preprocessed and format adapted according to the specified data packet fragment size. For data packets whose length exceeds the fragment size, fragmentation is performed to divide them into multiple data blocks that meet the size requirements. Necessary sequence identifiers and offset information are added to each fragment to ensure that the receiving end can correctly reassemble them. At the same time, data packets smaller than the fragment requirements are padded and aligned to improve bus transmission efficiency.
[0058] After format adaptation is completed, the data packets are subjected to deep parsing to extract key information and payload characteristics from their protocol headers. The parsing process includes identifying the protocol type in the IP header, detecting the source and destination port numbers, analyzing the encoding format and data pattern of the payload, and matching the parsing results with a predefined rule base. The rule base clearly defines the classification criteria: for example, UDP data packets with destination port numbers in the range of 16384 to 32767 and using the RTP protocol are classified as high-priority audio streams; SIP, RTCP, and other protocol data packets used for session establishment or control are classified as medium-priority control streams; and other common TCP data streams and background traffic are classified as low-priority data streams.
[0059] A multi-level weighted queue scheduling mechanism is employed to process the classified data packets. This mechanism assigns preset bandwidth weights to queues of different priorities; for example, high, medium, and low priorities occupy 60%, 30%, and 10% of the available bandwidth, respectively. The scheduler, based on a deficit round-robin algorithm, allocates a quota of bytes that can be sent to each queue in each scheduling cycle. High-priority queues not only enjoy a higher bandwidth ratio but also receive priority in sending opportunities, thus ensuring their low-latency and low-jitter transmission characteristics. The scheduler strictly selects data packets from each queue according to the weight ratio, ultimately outputting a priority-scheduled data packet sequence that satisfies both the bandwidth allocation strategy and ensures the quality of critical services.
[0060] 205. Based on the priority attributes of the data packet sequence after priority scheduling and the link characteristics in the optimized transmission parameters, dynamically allocate the space size and caching strategy of the predictive buffer; Based on the priority attributes of different data packets in the priority-scheduled data packet sequence, and combined with the actual characteristics of the current SPI link reflected by the optimized transmission parameters, the space of the predictive buffer is dynamically allocated and corresponding caching strategies are formulated. For high-priority audio data packets, independent and sufficient buffer space is allocated, and a low-latency caching strategy is adopted to ensure that the data packets can immediately enter the transmission queue, minimizing queuing time. Medium-priority control data packets share a common buffer pool, the size of which is dynamically adjusted according to the average link latency, and a first-in-first-out queue management method is adopted to control memory usage while ensuring continuity. Low-priority data packets can only use the remaining buffer space, and some data packets are allowed to be dropped when system resources are tight to ensure the performance of high-priority services. At the same time, the round-trip latency and jitter of the SPI link are continuously monitored, and the overall buffer size is dynamically adjusted. When the link latency increases or jitter is significant, the buffer depth is appropriately increased to smooth the data flow. When the link status is good, the buffer size is reduced to reduce transmission latency. Through this dynamic buffer management mechanism based on priority and link status, differentiated quality of service guarantees can be provided for data of different importance under various network conditions.
[0061] 206. High-priority audio data packets are processed using forward error correction (FEC) coding based on real-time channel bit error rate; The transmission status of the SPI communication channel is monitored in real time, the number of error bits and the total number of transmitted bits are counted, and the real-time channel bit error rate is calculated. Based on the magnitude of the real-time channel bit error rate, the pre-configured FEC parameter mapping table is queried to determine the corresponding encoding algorithm type and redundancy information ratio. Based on the determined encoding algorithm and redundancy ratio, a redundancy check code is generated for high-priority audio data packets and appended to the original data packets.
[0062] The SPI controller obtains real-time transmission statistics through its built-in status register, continuously accumulating the number of CRC check errors and the total number of successfully transmitted bits in each transmission cycle. The driver calculates the ratio of the number of error bits to the total number of transmitted bits within a fixed time window, such as every 100 milliseconds, to obtain the real-time channel bit error rate.
[0063] The system obtains the current channel bit error rate (BER) value through real-time monitoring and uses it as a key index to query a predefined FEC parameter mapping table. This dynamically determines the forward error correction coding type and redundancy ratio to be used. The mapping table divides the continuous BER range into multiple discrete quality intervals and explicitly configures the corresponding error correction strategy and redundancy for each interval. Specifically, when the BER is below the first threshold, the Reed-Solomon coding algorithm is selected according to the mapping table, and a first redundancy ratio is configured, such as 10% redundancy. If the BER rises to the middle interval between the first and second thresholds, Reed-Solomon coding is still used, but the redundancy ratio is increased to the second redundancy ratio according to the mapping table, such as 25%. When the BER further deteriorates and exceeds the second threshold, the mapping table requires the system to switch to a combination of convolutional coding and Viterbi decoding algorithms with stronger anti-interference capabilities, and simultaneously activates a significantly improved third redundancy ratio, such as 40% redundancy. Through this structured lookup mechanism, the system can automatically, quickly, and accurately select the most suitable error correction strategy and redundancy configuration based on real-time channel conditions, and always achieve the optimal balance between data reliability and transmission overhead in complex and changing transmission environments.
[0064] If Reed-Solomon coding is used, the audio data packet is segmented according to symbol length, corresponding parity symbol blocks are calculated and generated, and parity symbols are appended to the end of the original data packet according to the redundancy ratio requirements. If convolutional coding is used, the data stream is encoded through a shift register network to generate redundancy parity bits and insert them into specific positions in the data packet. After encoding, an error correction protocol identifier field is added to the header of the data packet to indicate the decoding scheme used by the receiver. The resulting enhanced data packet contains both the original audio payload and redundancy parity information, and its length increases proportionally according to the redundancy ratio, providing error protection for high-quality audio transmission in unreliable channels.
[0065] 207. Selective retransmission ARQ mechanism is used for medium and low priority data packets; Each low-priority data packet is assigned a unique sequence number and a corresponding retransmission timer is started. If no acknowledgment (ACK) is received from the receiver for the sequence number before the retransmission timer expires, the data packet is considered lost and added to the retransmission queue. Retransmission is only initiated for lost data packets in the retransmission queue, and data packets that have been successfully acknowledged are not retransmitted.
[0066] Assign a globally unique incrementing sequence number to each low-to-medium priority data packet to be sent, and store the data packet, its sequence number, and its sending timestamp together in the unacknowledged buffer; start a corresponding retransmission timer, the timeout of which is dynamically calculated based on the average round-trip delay of the network, and is usually set to two to three times the average round-trip time.
[0067] After transmission is completed, wait for the receiving end to return an acknowledgment (ACK). The ACK packet contains the sequence number information of the successfully received data. If an ACK with the corresponding sequence number is received before the retransmission timer expires, the system immediately stops the retransmission timer for that packet and removes it from the unacknowledged buffer, which is considered a successful transmission.
[0068] If the retransmission timer expires and no corresponding ACK is received, the data packet is determined to have been lost. Its sequence number is then added to the retransmission queue. The retransmission manager will prioritize processing the sequence numbers in the retransmission queue and retransmit a copy of the original data packet from the unacknowledged buffer based on the sequence number. After each retransmission, the system will reset the retransmission timer, but will use an exponential backoff strategy to gradually extend the timeout period in order to avoid exacerbating network congestion.
[0069] For data packets for which ACK confirmation has been successfully received, a copy is no longer retained, nor are they retransmitted. This selective retransmission mechanism ensures that only actually lost data packets are retransmitted, effectively guaranteeing the reliability of data transmission while significantly reducing unnecessary network bandwidth consumption. It is particularly suitable for low-to-medium priority data stream transmission scenarios where real-time requirements are low but reliability must be guaranteed.
[0070] 208. After buffering and error correction, the data packets are sent through the specified SPI virtual network card channel according to the scheduling sequence.
[0071] Data packets that have completed buffer management and error correction are strictly organized according to the transmission sequence output by the multi-level scheduler. This sequence allocates transmission opportunities to medium and low priority data packets according to a preset weight ratio, while ensuring that high-priority audio data packets have absolute priority. High-priority packets always occupy the front position of the transmission window to ensure that they are processed first. Medium-priority control packets are inserted into the transmission gap according to the polling rhythm. Low-priority data packets can only enter the transmission window when the high-priority queue is empty and there are no packets to be sent in the medium-priority queue.
[0072] The driver layer locks the corresponding hardware transmission queue based on the target SPI virtual network card channel identifier specified in the data packet. The transmission engine configures the SPI controller according to the channel optimization parameters. All priority data packets are split into standard data frames and written to the transmission FIFO via DMA. Although low and medium priority packets need to wait for the transmission opportunity, once they enter the transmission process, their physical transmission treatment is exactly the same as that of high priority packets, and they all enjoy full CRC check and hardware acceleration support.
[0073] In this embodiment of the invention, the user-space lightweight processing architecture effectively eliminates the dependence on kernel modules, significantly reduces system resource consumption and power consumption, and improves deployment flexibility in embedded environments. With the help of SPI bus bandwidth adaptive scheduling and dynamic parameter optimization, the bus utilization efficiency is greatly improved and the transmission latency is reduced. The multi-level priority scheduling mechanism ensures the real-time transmission of audio streams, and combined with predictive buffering and intelligent error correction strategies, data loss caused by SPI channel interference is effectively suppressed, comprehensively enhancing the reliability, real-time performance, and service quality of network forwarding and audio services.
[0074] The network forwarding method based on an SPI virtual network interface card (NIC) in the embodiments of the present invention has been described above. The network forwarding device based on an SPI virtual NIC in the embodiments of the present invention will be described below. Please refer to [link / reference]. Figure 3 One embodiment of the network forwarding device based on the SPI virtual network card in this invention includes: Module 301 is used to acquire network data packets; The first processing module 302 is used to perform lightweight network address translation and bridging forwarding processing in user space based on network data packets to obtain forwarding decision results; The adjustment module 303 is used to dynamically adjust the transmission parameters based on the forwarding decision results using the SPI bus bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters. The scheduling module 304 is used to perform packet priority classification and multi-level weighted queue scheduling based on optimized transmission parameters to obtain packet priority-scheduled data. The second processing module 305 is used to perform predictive buffering and forward error correction (FEC) encoding on the data packets after priority scheduling, and then send them through the SPI virtual network card.
[0075] In this embodiment of the invention, user-space lightweight processing eliminates the dependence on kernel modules, enabling the system to run stably in resource-constrained embedded environments. Through SPI bandwidth adaptive scheduling and dynamic parameter optimization, bus utilization and transmission real-time performance are significantly improved. Combined with multi-level priority queues and predictive error correction mechanisms, the audio stream transmission quality is effectively guaranteed. Overall, low-power, low-latency, and highly reliable network forwarding is achieved, greatly enhancing the user experience of embedded audio devices.
[0076] Please see Figure 4 Another embodiment of the network forwarding device based on the SPI virtual network card in this invention includes: Module 301 is used to acquire network data packets; The first processing module 302 is used to perform lightweight network address translation and bridging forwarding processing in user space based on network data packets to obtain forwarding decision results; The adjustment module 303 is used to dynamically adjust the transmission parameters based on the forwarding decision results using the SPI bus bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters. The scheduling module 304 is used to perform packet priority classification and multi-level weighted queue scheduling based on optimized transmission parameters to obtain packet priority-scheduled data. The second processing module 305 is used to perform predictive buffering and forward error correction (FEC) encoding on the data packets after priority scheduling, and then send them through the SPI virtual network card.
[0077] Optionally, the first processing module 302 can be specifically used for: The network data packets are parsed to extract their network layer and data link layer header information. Based on the destination IP address and destination MAC address in the header information, the lightweight NAT mapping table and MAC address forwarding table maintained in user space are queried to determine the address translation operation or Layer 2 forwarding path that the data packet should perform. Based on the query results, a forwarding decision result is generated, which indicates the data packet processing method, including: performing SNAT / DNAT translation, cross-interface bridging forwarding, or dropping, and includes the corresponding output interface identifier and modified address information.
[0078] Optionally, the adjustment module 303 can be specifically used for: Based on the output interface identifier in the forwarding decision result, the target SPI virtual network interface channel to be used by the data packet to be scheduled is determined; the transmission status of the target SPI virtual network interface channel is monitored in real time, and key performance indicators such as instantaneous transmission rate, bit error rate and data packet round-trip delay are collected; based on the collected key performance indicators, the clock frequency and data packet fragmentation size of the target SPI channel are dynamically adjusted using a bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters for data transmission in the corresponding channel.
[0079] Optionally, the scheduling module 304 can be specifically used for: Based on the packet fragmentation size in the optimized transmission parameters, the data packets to be scheduled are preprocessed and format adapted; the protocol header information and payload characteristics of the preprocessed data packets are parsed, and they are classified into high-priority audio streams, medium-priority control streams, or low-priority data streams according to a predefined rule base; a multi-level weighted queue scheduling mechanism is adopted, and data packets are selected from each queue according to their weights based on the preset weight ratios for different priority queues, forming a priority-scheduled data packet sequence.
[0080] Optionally, the second processing module 305 includes: The allocation unit 3051 is used to dynamically allocate the space size and caching strategy of the predictive buffer according to the priority attributes of the data packet sequence after priority scheduling and the link characteristics in the optimized transmission parameters. The first processing unit 3052 is used to perform forward error correction (FEC) coding on high-priority audio data packets based on real-time channel bit error rate. The second processing unit 3053 is used to employ a selective retransmission ARQ mechanism for medium and low priority data packets. The transmitting unit 3054 is used to transmit the data packets, after buffering and error correction, through the specified SPI virtual network card channel according to the scheduling sequence.
[0081] Optionally, the first processing unit 3052 may be specifically used for: The transmission status of the SPI communication channel is monitored in real time, the number of error bits and the total number of transmitted bits are counted, and the real-time channel bit error rate is calculated. Based on the magnitude of the real-time channel bit error rate, the pre-configured FEC parameter mapping table is queried to determine the corresponding encoding algorithm type and redundancy information ratio. Based on the determined encoding algorithm and redundancy ratio, a redundancy check code is generated for high-priority audio data packets and appended to the original data packets.
[0082] Optionally, the second processing unit 3053 may be specifically used for: Each low-priority data packet is assigned a unique sequence number and a corresponding retransmission timer is started. If no acknowledgment (ACK) is received from the receiver for the sequence number before the retransmission timer expires, the data packet is determined to be lost and added to the retransmission queue. Retransmission is only initiated for lost data packets in the retransmission queue, and data packets that have been successfully acknowledged are not retransmitted.
[0083] In this embodiment of the invention, the user-space lightweight processing architecture effectively eliminates the dependence on kernel modules, significantly reduces system resource consumption and power consumption, and improves deployment flexibility in embedded environments. With the help of SPI bus bandwidth adaptive scheduling and dynamic parameter optimization, the bus utilization efficiency is greatly improved and the transmission latency is reduced. The multi-level priority scheduling mechanism ensures the real-time transmission of audio streams, and combined with predictive buffering and intelligent error correction strategies, data loss caused by SPI channel interference is effectively suppressed, comprehensively enhancing the reliability, real-time performance, and service quality of network forwarding and audio services.
[0084] above Figure 3 and Figure 4 The network forwarding device based on the SPI virtual network card in this embodiment of the invention will be described in detail from the perspective of modular functional entities. The electronic device in this embodiment of the invention will be described in detail from the perspective of hardware processing.
[0085] See Figure 5 As shown, the electronic device includes a processor 500 and a memory 501. The memory 501 stores machine-executable instructions that can be executed by the processor 500. The processor 500 executes the machine-executable instructions to implement the network forwarding method based on the SPI virtual network card described above.
[0086] Furthermore, Figure 5 The electronic device shown also includes a bus 502 and a communication interface 503. The processor 500, the communication interface 503 and the memory 501 are connected via the bus 502.
[0087] The memory 501 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 503 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 502 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0088] The processor 500 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 500 or by instructions in software form. The processor 500 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 501. The processor 500 reads the information in memory 501 and, in conjunction with its hardware, completes the method steps of the aforementioned embodiment.
[0089] The present invention also provides an electronic device, the computer device including a memory and a processor, the memory storing computer-readable instructions, which, when executed by the processor, cause the processor to perform the steps of the network forwarding method based on the SPI virtual network card in the above embodiments.
[0090] The present invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when the instructions are executed on a computer, cause the computer to perform the steps of the network forwarding method based on the SPI virtual network card.
[0091] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0092] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0093] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A network forwarding method based on an SPI virtual network interface card, characterized in that, The network forwarding method based on the SPI virtual network card, applied in embedded audio device environments, includes: Acquire network data packets; Based on the network data packets, lightweight network address translation and bridging forwarding processing are performed in user space to obtain forwarding decision results; Based on the forwarding decision results, the transmission parameters are dynamically adjusted using the SPI bus bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters. Based on the optimized transmission parameters, data packet priority classification and multi-level weighted queue scheduling are performed to obtain priority-scheduled data packets. Based on the prioritized data packets, predictive buffering and forward error correction (FEC) encoding are performed, and the packets are sent via the SPI virtual network interface card.
2. The network forwarding method based on SPI virtual network card according to claim 1, characterized in that, The step of performing lightweight network address translation and bridging forwarding processing in user space based on the network data packets to obtain forwarding decision results includes: The network data packets are parsed to extract their network layer and data link layer header information; Based on the target IP address and target MAC address in the header information, the lightweight NAT mapping table and MAC address forwarding table maintained in user space are queried respectively to determine the address translation operation or Layer 2 forwarding path that the data packet should perform. Based on the query results, a forwarding decision result is generated. The forwarding decision result indicates the processing method of the data packet, including: performing SNAT / DNAT translation, cross-interface bridging forwarding, or dropping, and includes the corresponding output interface identifier and modified address information.
3. The network forwarding method based on SPI virtual network card according to claim 1, characterized in that, Based on the forwarding decision result, the transmission parameters are dynamically adjusted using the SPI bus bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters, including: Based on the output interface identifier in the forwarding decision result, determine the target SPI virtual network interface channel that the data packet to be scheduled will use; Real-time monitoring of the transmission status of the target SPI virtual network card channel, and collection of key performance indicators such as instantaneous transmission rate, bit error rate and data packet round-trip delay; Based on the collected key performance indicators, a bandwidth adaptive scheduling algorithm is used to dynamically adjust the clock frequency and data packet fragmentation size of the target SPI channel to obtain optimized transmission parameters for data transmission in the corresponding channel.
4. The network forwarding method based on SPI virtual network card according to claim 1, characterized in that, The step of performing packet priority classification and multi-level weighted queue scheduling based on the optimized transmission parameters to obtain priority-scheduled data packets includes: Based on the data packet fragmentation size in the optimized transmission parameters, the data packets to be scheduled are preprocessed and format adapted. Parse the protocol header information and payload characteristics of the preprocessed data packets, and classify them into high-priority audio streams, medium-priority control streams, or low-priority data streams according to a predefined rule base; A multi-level weighted queue scheduling mechanism is adopted. Based on the weight ratio preset for different priority queues, data packets are selected from each queue according to their weights for transmission, forming a data packet sequence after priority scheduling.
5. The network forwarding method based on SPI virtual network card according to claim 1, characterized in that, The data packets scheduled based on the priority are subjected to predictive buffering and forward error correction (FEC) encoding, and then sent through the SPI virtual network interface card, including: Based on the priority attributes of the data packet sequence after priority scheduling and the link characteristics in the optimized transmission parameters, the space size and caching strategy of the predictive buffer are dynamically allocated. High-priority audio data packets are processed using forward error correction (FEC) coding based on real-time channel bit error rate. For low- and medium-priority data packets, a selective retransmission ARQ mechanism is used. The data packets, after being buffered and error-corrected, are sent through the designated SPI virtual network interface card channel according to the scheduling sequence.
6. The network forwarding method based on an SPI virtual network card according to claim 5, characterized in that, The process of applying forward error correction (FEC) coding based on real-time channel bit error rate to high-priority audio data packets includes: The transmission status of the SPI communication channel is monitored in real time, the number of error bits and the total number of transmitted bits are counted, and the real-time channel bit error rate is calculated. Based on the real-time channel bit error rate, the pre-configured FEC parameter mapping table is queried to determine the corresponding coding algorithm type and redundancy information ratio; Based on the determined encoding algorithm and redundancy ratio, a redundancy check code is generated for high-priority audio data packets and appended to the original data packets.
7. The network forwarding method based on an SPI virtual network card according to claim 5, characterized in that, The selective retransmission ARQ mechanism is used for low-priority data packets, including: Assign a unique sequence number to each low-priority data packet sent and start the corresponding retransmission timer; If no acknowledgment (ACK) response for the sequence number is received from the receiver before the retransmission timer expires, the data packet is determined to be lost and added to the retransmission queue. Retransmission is initiated only for lost data packets in the retransmission queue; data packets that have been successfully received and acknowledged are not retransmitted.
8. A network forwarding device based on an SPI virtual network card, applied in an embedded audio device environment, characterized in that, The network forwarding device based on the SPI virtual network card, used in embedded audio device environments, includes: The acquisition module is used to acquire network data packets; The first processing module is used to perform lightweight network address translation and bridging forwarding processing in user space based on the network data packets to obtain forwarding decision results; The adjustment module is used to dynamically adjust the transmission parameters based on the forwarding decision result using the SPI bus bandwidth adaptive scheduling algorithm to obtain optimized transmission parameters. The scheduling module is used to perform packet priority classification and multi-level weighted queue scheduling processing based on the optimized transmission parameters to obtain packet data after priority scheduling. The second processing module is used to perform predictive buffering and forward error correction (FEC) encoding on the data packets after priority scheduling, and then send them through the SPI virtual network card.
9. An electronic device, characterized in that, The electronic device includes: a memory and at least one processor, wherein the memory stores instructions; The at least one processor invokes the instructions in the memory to cause the electronic device to execute the network forwarding method based on the SPI virtual network card as described in any one of claims 1-7.
10. A computer-readable storage medium storing instructions thereon, characterized in that, When the instruction is executed by the processor, it implements the network forwarding method based on the SPI virtual network card as described in any one of claims 1-7.