Single-port dual-protocol stack vehicle Ethernet multi-segment isolation test method and system
By using a single-port dual-protocol-stack testing method, independent testing of multiple segments of automotive Ethernet was achieved on a resource-constrained embedded MCU. This solved the problems of excessive hardware resource consumption and low testing accuracy, and improved the stability and accuracy of the testing equipment.
Patent Information
- Application Number
- CN202611433092.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-15
- Publication Date
- 2026-11-17
AI Technical Summary
Existing vehicle Ethernet multi-segment testing solutions suffer from excessive hardware resource consumption, high testing costs, low testing accuracy, and poor stability. In particular, they cannot achieve multi-physical network port expansion and protocol stack-level logical isolation on resource-constrained embedded MCUs.
The test method of single network interface dual protocol stack is adopted. By differentiating the registration of dual network interfaces, configuring the parameters of independent network segments of dual protocol stacks, and using a single-threaded packet cloning and distribution module, hardware resource sharing and protocol state isolation of the main and auxiliary network interfaces are realized, and communication of different network segments is handled separately.
Without adding physical network port hardware, independent testing of dual network segments was achieved, reducing hardware costs, improving testing accuracy and stability, and adapting to the needs of lightweight and miniaturized vehicle-mounted testing equipment.
Smart Images

Figure CN123122965A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automotive Ethernet testing and diagnostic technology, specifically to a method and system for testing multi-segment isolation of single-port dual-protocol stack automotive Ethernet. Background Technology
[0002] In the automotive Ethernet network architecture, the vehicle terminal, vehicle controller, and uplink interactive devices are typically assigned to different IP network segments. These are generally divided into core business communication segments that carry vehicle data interaction, and auxiliary diagnostic segments used for device parameter configuration, fault diagnosis, and function verification. In automotive Ethernet performance testing, connectivity verification, and function diagnostic scenarios, test equipment needs to simultaneously connect to target devices on two different network segments, independently completing communication connectivity tests, message response verification, packet loss anomaly statistics, and other tests for each segment. This meets the differentiated testing needs of the entire vehicle across multiple network segments.
[0003] Currently, the industry mainly employs two conventional solutions for multi-segment testing of automotive Ethernet, but both have significant technical flaws and engineering limitations. The traditional mainstream solution involves configuring a separate physical network port for each segment under test, along with independent MAC hardware and PHY transceiver channels, or using external multi-port switches or gateways to achieve multi-segment expansion. This solution requires a large amount of MCU hardware pins, RMII / MII communication resources, and board layout space, significantly increasing the R&D and production costs of the test hardware and also increasing the size of the device board. For resource-constrained embedded MCUs such as the STM32F407, which only have a single Ethernet MAC peripheral and extremely limited pin and SRAM memory resources, they cannot support multi-physical port expansion deployments, resulting in poor hardware adaptability and failing to meet the design requirements of lightweight and miniaturized automotive test equipment.
[0004] Another existing solution is the IP aliasing technology that configures multiple IP addresses on a single physical network interface. This simulates multi-segment communication test scenarios by binding multiple network segment IP addresses to a single network interface. However, this technology essentially mounts multiple IP addresses under the same protocol stack instance. The ARP cache tables, neighbor status tables, routing rules, and protocol operation states of the two network segments are highly coupled and interrelated, making it impossible to achieve logical isolation between the two network segments at the protocol stack level. In actual testing, problems such as cross-segment packet interference, ARP reply conflicts, and overlapping protocol states are prone to occur. It is impossible to independently observe, reset, and statistically analyze the sent and received packets, packet loss anomalies, and communication status of each network segment. It is difficult to accurately simulate the real test scenario of two independent vehicle terminals accessing different network segments, resulting in extremely low test accuracy and reliability.
[0005] Furthermore, in embedded automotive platforms with limited pins and memory, directly deploying two complete protocol stack instances for multi-segment isolation testing lacks mature and controllable engineering implementation solutions for dual-path distribution of received packets, memory resource scheduling, and fault tolerance and degradation. Traditional dual-protocol stack deployment cannot achieve synchronous, side-effect-free delivery of single-frame packets to both stacks. Moreover, when system memory pool resources are scarce or packet cloning fails, issues such as dual-segment synchronous packet loss and overall test service paralysis easily occur, lacking tiered fault tolerance and graceful degradation mechanisms. Simultaneously, existing automotive Ethernet testing equipment is not adapted to the hardware architecture of the switching chip supplying the MAC reference clock, and its power-on timing design is unreasonable, failing to achieve stable step-by-step startup of the clock, hardware, and chip. This easily leads to MAC initialization failures, incomplete PHY initialization, and random hardware link anomalies, severely impacting the stability and reliability of multi-segment isolation testing.
[0006] Therefore, this application proposes a single-port dual-protocol stack vehicle Ethernet multi-segment isolation testing method and system. Summary of the Invention
[0007] To overcome the shortcomings of the existing technology, this application provides a single-port dual-protocol-stack vehicle Ethernet multi-segment isolation testing method and system, applicable to embedded devices with a single physical Ethernet media access controller, achieving true isolation testing of two network segments at the protocol stack level without adding additional physical network port hardware. The specific technical solution adopted is as follows.
[0008] A single-port dual-protocol stack vehicle-mounted Ethernet multi-segment isolation test system includes: a dual-network interface differential registration module, a dual-protocol stack independent segment parameter configuration isolation module, and a single-threaded packet cloning and distribution independent processing module.
[0009] The dual network interface differentiated registration module is used to register independent primary and secondary network interfaces, and to control the secondary network interface to reuse the hardware resources of the primary network interface without repeating hardware initialization.
[0010] The dual-protocol stack independent network segment parameter configuration isolation module is used to control the main network interface and the auxiliary network interface to share the same medium access control address and Ethernet transceiver hardware, and bind to different Internet protocol network segments respectively, each maintaining independent address resolution protocol status and Internet protocol status.
[0011] The single-threaded packet cloning and distribution independent processing module is used to perform condition judgment and cloning processing on the received original packets through the system's only packet receiving thread. The original packets are delivered to the main network interface and the cloned copies are delivered to the auxiliary network interface, so that the two network interface instances can complete the packet response processing according to their own network segment rules.
[0012] Through the above technical solution, a test system is built that includes a dual-network interface differentiated registration module, a dual-protocol stack independent network segment parameter configuration isolation module, and a single-threaded packet cloning and distribution independent processing module. Relying on the collaborative work of these modules, a conflict-free registration of dual-network interface instances, logical isolation of dual-network segment protocol domains, and independent dual-path distribution processing of single-packet cloning are achieved under a single physical Ethernet hardware architecture. The system features high hardware reuse rate, no redundant hardware configuration, and reliable software isolation. It can stably achieve multi-segment independent vehicle Ethernet testing under a single physical network port, reducing test hardware costs and improving the accuracy and stability of multi-segment isolation testing.
[0013] This application provides a single-port dual-protocol stack vehicle Ethernet multi-segment isolation testing method for embedded devices equipped with a single-path physical Ethernet media access controller, including the following steps.
[0014] Register the primary network interface and the secondary network interface; the primary network interface and the secondary network interface are independent of each other.
[0015] The primary network interface and the secondary network interface share the same media access control address; the primary network interface and the secondary network interface share the same set of Ethernet transceiver hardware.
[0016] The primary network interface and the secondary network interface are bound to different Internet Protocol (IP) segments, and each of the primary and secondary network interfaces maintains its own independent Address Resolution Protocol (ARP) status and Internet Protocol (IP) status.
[0017] The system uses a single receiving thread to perform conditional judgment and cloning processing on each received original packet to obtain a packet clone copy; the original packet is delivered to the main network interface, and the packet clone copy is delivered to the auxiliary network interface.
[0018] The primary network interface and the secondary network interface respond to the packets according to the rules of the network segment they are bound to.
[0019] The above technical solution, by registering independent primary and secondary network interfaces, allows the primary and secondary network interfaces to share the same Media Access Control (MAC) address and the same set of Ethernet transceiver hardware. Simultaneously, they are bound to different Internet Protocol (IP) segments and each maintains its own independent Address Resolution Protocol (ARP) state and IP address state. A single packet receiving thread performs conditional checks and cloning on each received original packet, delivering the original packet and its clone to the primary and secondary network interfaces respectively. Each interface instance then responds to the packets according to its bound network segment rules. Based on embedded device hardware equipped with only a single physical Ethernet MAC, independent dual-segment testing can be achieved without adding physical Ethernet hardware, completing logical isolation at the dual protocol stack level. This effectively solves the drawback of traditional single-port devices that can only perform single-segment testing, requiring additional hardware for multi-segment testing, thus reducing hardware deployment costs and device size.
[0020] As an optional solution in this application, the main network interface performs a complete Ethernet hardware initialization, completes the register configuration of the Media Access Controller and Direct Memory Access Controller, enables the peripheral clock, configures the Ethernet interrupt enable and priority, and creates a unique packet receiving thread; the auxiliary network interface completes the registration using a derived initialization operation, reuses the hardware resources of the main network interface, and does not perform a hardware initialization operation.
[0021] The above technical solution performs complete Ethernet hardware initialization through the main network interface, configuring the registers of the Media Access Controller (MAC) and Direct Memory Access Controller (DMI), enabling peripheral clocks, configuring Ethernet interrupt enable and priority, creating a unique packet receiving thread, and completing the complete initialization and exclusive locking of the underlying Ethernet hardware resources. The secondary network interface uses a derived initialization operation to complete registration, reusing the hardware resources of the main network interface without performing hardware initialization. This effectively avoids register configuration conflicts, DMA parameter anomalies, and hardware initialization errors caused by repeated initialization of Ethernet hardware through dual interfaces, ensuring the stability of the underlying Ethernet hardware operation and achieving efficient reuse of hardware resources.
[0022] As an optional solution in this application, the auxiliary network interface calls the lightweight derived registration function to complete the software registration, skipping the underlying hardware initialization entry point throughout the process, without performing hardware initialization configuration, without performing direct memory access controller register initialization, without enabling peripheral clocks, and without creating new threads.
[0023] The above technical solution completes software registration by calling a lightweight derived registration function through the secondary network interface, skipping the underlying hardware initialization entry point entirely. It avoids hardware initialization configuration, direct memory access controller register initialization, enabling peripheral clocks, and creating new threads. This completely avoids anomalies such as hardware resource contention, thread conflicts, and redundant peripheral clock configurations caused by secondary hardware initialization via the secondary network interface, significantly reducing system resource overhead during the secondary network interface registration process and adapting to the lightweight operation requirements of embedded devices.
[0024] As an optional solution in this application, the secondary network interface performs a memory copy of the media access control address field to replicate the media access control address of the primary network interface; reuses the maximum transmission unit, broadcast flag, address resolution protocol enable flag, multicast identifier, and link state parameters of the primary network interface; the secondary network interface is equipped with Internet Protocol output callback and underlying frame transmission callback, without binding to an independent hardware channel or applying for an independent direct memory access controller descriptor.
[0025] The above technical solution involves copying the Media Access Control (MAC) address field in memory through the secondary network interface, replicating the MAC address of the primary network interface, thus avoiding switch port learning drift and packet forwarding errors caused by multiple MAC addresses. It reuses the maximum transmission unit, broadcast flag, address resolution protocol enable flag, multicast identifier, and link status parameters of the primary network interface, ensuring consistency of network operating parameters between the two interfaces. By mounting Internet Protocol (IP) output callbacks and underlying frame transmission callbacks, without binding to independent hardware channels or requesting independent direct memory access controller (DMI) descriptors, the two interfaces can share the same hardware transmission channel, eliminating DMA queue overflow and out-of-order packet problems caused by concurrent transmission through multiple hardware channels.
[0026] As an optional solution in this application, when the physical link of the main network interface is ready, the protocol stack enable and link ready state of the secondary network interface are activated simultaneously, and changes in the link and protocol state of the secondary network interface do not affect the working state of the main network interface in the reverse direction.
[0027] When the primary network interface link is disconnected, the secondary network interface link is simultaneously set to the disconnected state, and the address resolution protocol cache table and neighbor status table of the secondary network interface are cleared.
[0028] Through the above technical solution, when the physical link of the main network interface is ready, the protocol stack enablement and link ready state of the secondary network interface are activated synchronously. Furthermore, changes in the link and protocol state of the secondary network interface do not negatively affect the working state of the main network interface, achieving unidirectional linkage and isolation between the primary and secondary interfaces. When the link of the main network interface is disconnected, the link of the secondary network interface is simultaneously set to the disconnected state, and the address resolution protocol cache table and neighbor state table of the secondary network interface are cleared. This avoids communication anomalies and packet crosstalk caused by expired protocol states remaining on the secondary network interface after a main interface link failure, ensuring synchronized and non-interfering operation of the two interfaces and improving the accuracy of multi-segment testing.
[0029] As an optional solution in this application, after receiving the packet, the receiving thread checks the link working status of the secondary network interface. Only when the secondary network interface is in the ready and enabled state is the packet cloning operation performed. The received packets are checked for frame length, cyclic redundancy check, and frame header validity. Only valid frames participate in the cloning and distribution.
[0030] The above technical solution involves detecting the link status of the secondary network interface after receiving packets via the receiving thread. Packet cloning is only performed when the secondary network interface is in a ready-enabled state, avoiding resource waste caused by invalid cloning operations. By performing frame length, cyclic redundancy check, and frame header validity checks on received packets, only valid frames participate in cloning and distribution. This effectively filters out incomplete, erroneous, and interfering frames during transmission, preventing parsing errors and protocol status abnormalities caused by abnormal packets entering the dual-protocol stack parsing process, thus improving the integrity and reliability of dual-network segment packet processing.
[0031] As an optional solution in this application, it also includes the following steps for handling memory-constrained scenarios: before each cloning, the remaining amount of the buffer pool is detected in real time, and the primary network interface is given priority to preempt memory; when the memory pool is exhausted and cloning fails, the cloned copy corresponding to the secondary network interface is discarded, and the original packets are retained for processing by the primary network interface.
[0032] The above technical solution involves real-time monitoring of the remaining buffer pool before each cloning, granting the primary network interface priority to preempt memory access. If cloning fails due to memory pool exhaustion, the cloned copy corresponding to the secondary network interface is discarded, while the original packets are retained for processing by the primary network interface. This achieves tiered fault tolerance and graceful degradation in memory-constrained scenarios, prioritizing the normal operation of core primary network segment test services and avoiding the problem of simultaneous packet loss across both network segments and overall test service paralysis when memory resources are scarce. It is also suitable for operating scenarios with limited memory resources in automotive embedded devices.
[0033] As an optional solution in this application, a two-layer independent quantitative statistical mechanism is adopted for memory-constrained scenarios: the first layer is independent send and receive statistics for dual interfaces, which respectively counts packet reception, packet transmission, packet loss, and anomaly counts; the second layer is clone-specific statistics, which counts the number of successful clones and the number of failed clones; after detecting that the buffer pool is restored, the message cloning process is automatically resumed; when the clone failure count exceeds the set threshold, a high memory load alarm is reported.
[0034] The above technical solution employs a dual-layer independent quantification and statistical mechanism for memory-constrained scenarios. The first layer utilizes independent send / receive statistics across dual interfaces to independently track packet reception, transmission, loss, and anomaly data across both network segments. The second layer utilizes dedicated cloning statistics to accurately record the number of successful and failed clonings. Once the buffer pool is replenished, the packet cloning process automatically resumes. When the cloning failure count exceeds a set threshold, a high memory load alarm is reported. This achieves comprehensive quantitative monitoring of system operation status, autonomous fault self-healing, and a closed-loop anomaly alarm system, facilitating the identification of abnormal memory loads and network segment communication failures, and improving system maintainability and testing stability.
[0035] As an optional solution in this application, it also includes detailed steps for hardware system initialization and power-on timing calibration: in the initial stage of power-on, the clock of the general-purpose input / output port is first turned on, and the level of the reset pin is pulled high in advance before the pin is configured as output mode; after the media independent interface reference clock is completely stable, the physical layer chip reset signal is released.
[0036] The above technical solution effectively avoids hardware glitches and transient interference caused by pin floating and level jumps during the initial power-on phase by first enabling the general-purpose input / output port clock and pre-pushing the reset pin level before configuring the pins to output mode. After the media-independent interface reference clock is fully stable, the physical layer chip reset signal is released, ensuring that the physical layer chip completes initialization under stable clock conditions. This solves the problems of hardware initialization failure and random link anomalies caused by conventional power-on timing errors and clock instability, providing a stable hardware operating platform for upper-layer dual-protocol stack multi-segment isolation testing.
[0037] The technical solution of this application has achieved the following beneficial effects.
[0038] This application registers independent primary and secondary network interfaces, allowing them to share the same Media Access Control (MAC) address and Ethernet transceiver hardware. Simultaneously, each interface is bound to different Internet Protocol (IP) segments and maintains its own independent Address Resolution Protocol (ARP) and Internet Protocol (IP) states. A single packet-receiving thread performs conditional checks and cloning on each received original packet, delivering the original packet and its clone to the primary and secondary interfaces respectively. Each interface instance then responds to the packets according to its bound segment rules. Based on embedded device hardware equipped with only a single physical Ethernet MAC, independent dual-segment testing can be achieved without adding physical Ethernet hardware, completing logical isolation at the dual-protocol stack level. This effectively solves the drawback of traditional single-port devices that can only perform single-segment testing, requiring additional hardware for multi-segment testing, thus reducing hardware deployment costs and device size. Attached Figure Description
[0039] Figure 1 This is a flowchart illustrating the single-port dual-protocol stack vehicle Ethernet multi-segment isolation testing method in this application embodiment.
[0040] Figure 2 This is a data flow diagram of the single-port dual-protocol stack vehicle Ethernet multi-segment isolation test method in this application embodiment.
[0041] Figure 3 This is a flowchart illustrating the message cloning and distribution process of the single-port dual-protocol stack vehicle Ethernet multi-segment isolation test method in this application embodiment. Detailed Implementation
[0042] The present application will now be further described with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present application and should not be construed as limiting the scope of protection of the present application. It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of the present application.
[0043] like Figure 1 , Figure 2 and Figure 3 As shown, when this system is working, the main network interface connects to the device under test in network segment one for service uplink communication; the auxiliary network interface connects to the device under test in network segment two for diagnostic and configuration communication. Internally, the system uses a packet receiving processing thread to complete packet replication and distribution, and leverages the same physical media access controller to achieve simultaneous testing of two mutually isolated network segments.
[0044] This application discloses a single-port dual-protocol stack vehicle Ethernet multi-segment isolation test system, including...
[0045] Hardware System Initialization and Calibration Module: This module specifically addresses issues such as the lack of an independent reference clock for the Media Access Control (MAC) layer in the STM32 series microcontroller units (MCUs), MAC initialization failure due to improper power-on timing, transient glitches during peripheral power-on, poor adaptability to fixed delays, incomplete Ethernet PHY initialization, and random hardware link anomalies. The module constructs a standardized, fault-tolerant, and highly stable hardware startup process through level pre-constraint, timing offset control, voltage and frequency regulation, PHY timeout fault handling, and a step-by-step hardware initialization mechanism. This provides a zero-error hardware foundation for the operation of upper-layer dual-protocol stacks and dual-interface instances. It includes: a peripheral pin anti-glitch preprocessing unit, an LDO voltage regulation unit, a switching chip clock ready unit, a PHY link initialization and fault handling unit, and a unified MAC and DMA initialization unit.
[0046] Peripheral pin anti-glitch preprocessing unit: During the power-on initialization phase, the GPIOE port clock of group E is enabled first. Before the pins are configured to output mode, the PE0, PE4, and PE5 reset pin levels are pre-pulled high to forcibly lock the switching chip and the two PHY peripherals into the initial reset state. This completely avoids hardware glitches and transient interference caused by pin floating and instantaneous level jumps during the initial power-on period, effectively protecting the onboard Ethernet peripheral hardware and eliminating hardware initialization anomalies caused by power-on transients from the source.
[0047] LDO voltage regulator unit: Enables the onboard low dropout linear regulator (LDO) power supply via the dedicated PE3 control pin. The system employs a fixed 20ms voltage regulation delay while simultaneously acquiring power supply voltage parameters in real time. It automatically adds delay compensation for extreme operating conditions such as alternating high and low temperatures in automotive applications and grid voltage fluctuations, dynamically adapting to power stability requirements in different environments. This ensures power stability throughout the entire process of reset, clock output, and hardware initialization, avoiding clock distortion and hardware initialization errors caused by voltage fluctuations.
[0048] Switching chip clock ready unit: Strictly follows the step-by-step startup logic, prioritizing the release of the RTL8367S gigabit switching chip reset signal. A fixed 100ms frequency stabilization delay is set to complete the switching chip crystal oscillator startup, internal phase-locked loop convergence, and stable reference clock output. Once the frequency stabilization delay ends, the switching chip clock is deemed ready, providing a precise, compliant, and stable reference clock source for subsequent MCU MAC hardware initialization, thus resolving MAC initialization failure issues caused by clock instability.
[0049] The PHY link initialization and fault handling unit waits for the RMII reference clock to stabilize completely before releasing the two RTL9010 Ethernet PHY reset signals sequentially. It utilizes the MDIO configuration bus to read the PHY internal register status bits in real time, employing a closed-loop mechanism of timeout judgment, fault retry, and exception reporting: if a management data input / output MDIO bus communication failure occurs, or the PHY register fails to enter the ready state for an extended period, a timeout retry mechanism is immediately triggered, and a hardware initialization failure is reported. This avoids engineering problems such as incomplete PHY initialization, hidden link anomalies, and program freezes caused by purely fixed delays. Only after verifying that the PHY register initialization is complete and the link self-test passes can the PHY hardware be considered ready.
[0050] Unified MAC and DMA initialization unit: Under the premise that the onboard power supply, switching chip clock, and multi-channel PHY hardware are all stable and ready, the MCU Ethernet MAC core and DMA transceiver hardware are uniformly initialized. The MAC clock configuration, DMA transceiver buffer configuration, Ethernet interrupt priority configuration, and basic link parameter configuration are completed in sequence. The global Ethernet hardware register state and all hardware resources are locked at once, preventing subsequent hardware parameter tampering, duplicate configuration, and resource preemption problems, and completing the stable readiness of the underlying hardware in all dimensions.
[0051] The dual-network interface differentiated registration module supports the system's ability to run dual software interfaces and dual protocol stacks on a single hardware device. Addressing issues such as secondary hardware initialization conflicts, DMA duplicate configuration errors, semaphore duplication, resource preemption, abnormal structure memory copying, and bidirectional crosstalk in traditional lightweight Internet protocol stack (LWIP) multi-interface deployments, it adopts a differentiated registration architecture with full hardware initialization for the main interface and pure software registration (no hardware reuse) for the auxiliary network interface. This completely isolates conflict sources from the driver layer, protocol stack layer, and hardware resource layer, ensuring the long-term stable and independent operation of the dual network interface instances. It includes: a main interface hardware full initialization locking unit, a lightweight, hardware-free initialization registration unit for the auxiliary network interface, a batch inheritance and reuse unit for auxiliary network interface parameters, and a unidirectional linkage isolation link synchronization unit.
[0052] The main interface hardware fully initializes and locks the unit: The main interface uses the lwIP standard ethernetif_init initialization function to call the underlying low_level_init interface, completely executing the HAL_ETH_Init hardware initialization logic and finalizing the configuration of MAC, DMA, interrupts, and link parameters in one go. Simultaneously, it creates a unique packet receiving thread and transmit / receive semaphores, globally and exclusively locking all Ethernet hardware resources, prohibiting secondary hardware initialization, parameter modification, and resource preemption throughout the process, providing a stable hardware operating context for subsequent secondary network interface software reuse. The main interface is configured with static network parameters for the core service network segment, with the link UP state enabled by default, serving as the core communication and hardware bearer interface of the system.
[0053] The secondary network interface features a lightweight, hardware-free initialization registration unit: The lightweight initialization function `ethernetif_init_alias` is used for secondary network interface registration, forcibly skipping the underlying hardware initialization entry point `low_level_init` throughout the process. It avoids executing `HAL_ETH_Init` hardware configuration, repeatedly initializing DMA registers, enabling Ethernet peripheral clocks, and creating independent packet receiving threads and semaphores. It abandons the traditional method of copying the entire `netif` structure into memory, assigning values only to valid member variables of `netif`. This avoids fatal problems such as concurrent resource release anomalies, register corruption, DMA cache overflows, and hardware lock-ups caused by copying hardware handles and semaphore pointers, achieving pure software-level interface instance mounting.
[0054] The secondary network interface parameter batch inheritance and reuse unit performs an independent memory copy only for the MAC address field, completely replicating the physical MAC address of the primary interface. This ensures the consistency of hardware identifiers between the two interfaces and avoids issues such as MAC learning drift, port forwarding errors, and MAC oscillation in the vehicle-mounted switch. Simultaneously, through structure member assignment, it fully reuses all core network parameters of the primary interface, including the maximum transmission unit (MTU), broadcast frame enable flag, Address Resolution Protocol (ARP) enable flag, multicast identifier, and link state attributes, without requiring secondary configuration. This ensures a high degree of consistency in the protocol operation parameters of the two interfaces and avoids problems such as packet fragmentation, ARP resolution failure, and broadcast transmission / reception anomalies caused by parameter inconsistencies.
[0055] Single hardware channel time-division multiplexing transmission unit: The auxiliary network interface only mounts the standard etharp_output layer 3 transmission callback and low_level_output underlying DMA transmission callback at the lwIP protocol stack layer. It does not bind any independent hardware transmission channel, does not request a new DMA descriptor, and does not independently occupy hardware resources. All outgoing packets from both interfaces are uniformly merged into the hardware handle and DMA transmission link exclusively occupied by the main interface, constructing a single hardware channel dual-interface instance packet time-division multiplexing transmission mechanism to solve problems such as DMA queue overflow, packet out-of-order delivery, transmission deadlock, and protocol stack abnormalities caused by concurrent transmission from multiple interfaces.
[0056] Unidirectional Linkage and Isolation Link Synchronization Unit: Establishes a unidirectional state linkage and bidirectional isolation mechanism where the primary and secondary interfaces control each other without interfering with the primary interface. The secondary network interface periodically checks the primary interface link status. When the primary interface link is UP, the secondary network interface synchronously enables the link-ready state. When the primary interface link is DOWN or the hardware link is disconnected, the secondary network interface synchronously sets itself to DOWN and actively clears its own ARP cache table and neighbor state table, eliminating expired protocol states and avoiding communication anomalies caused by residual states. At the same time, the software layer locks all state changes, parameter modifications, and link anomalies of the secondary network interface so that they cannot be written back or interfere with the primary interface hardware driver and operating state, completely avoiding bidirectional state crosstalk.
[0057] Dual-protocol stack independent network segment parameter configuration isolation module: This module breaks through the industry's conventional understanding that traditional single-MAC hardware only supports single network segments and allows for independent testing of multiple hardware components across multiple network segments. It also differs from traditional pseudo-isolation solutions that use multiple Internet protocol addresses (IPs) on a single interface. With zero hardware increments, a single physical MAC address, and a single DMA channel, it achieves true three-layer logical isolation between dual network interface instances and dual network segments. The two protocol states are completely independent and decoupled, simulating the physical testing effect of two independent vehicle terminals accessing different network segments. It includes: a hardware resource binding and reuse unit, a dual-interface differentiated instance creation unit, a dual-network segment static parameter independent configuration unit, and a same-MAC virtual protocol domain isolation unit.
[0058] Hardware resource binding and multiplexing unit: The unique onboard MAC kernel, unique DMA transmit / receive buffer, unique RMII physical serial link, and unique off-chip PHY transmit / receive channel are all bound to a globally fixed driver handle. The system prohibits secondary hardware resource allocation, repeated peripheral initialization, and multiple DMA parameter configurations throughout the entire process, locking resource uniqueness and operational stability from the hardware level. It supports the independent operation of dual software network interface instances with a minimalist hardware base, truly achieving independent deployment of dual network segments with zero hardware increment.
[0059] Dual-interface differentiated instance creation unit: On the same underlying hardware driver layer, two completely independent, data-decoupled, and stateless netif network interface instances are created, with clear functional division and adaptation to dual vehicle testing scenarios: The main interface instance is bound to the vehicle core business communication network segment for regular vehicle business connectivity testing and link stability verification; the auxiliary network interface instance is bound to the vehicle diagnostic configuration network segment for vehicle device parameter configuration, fault diagnosis, and functional verification testing, enabling completely independent testing of the two scenarios.
[0060] Dual-segment static parameter independent configuration unit: Dynamic Host Configuration Protocol (DHCP) dynamic IP allocation is disabled on both interfaces to avoid test environment disruptions, invalid test data, and unreproducible faults caused by dynamic IP jumps and address changes. Each interface is independently configured with its own static IP address, subnet mask, and gateway parameters, forming two completely disjoint network segments. This ensures long-term stability, controllable parameters, and reproducible scenarios in the dual-segment test environment.
[0061] Same MAC Virtual Protocol Domain Isolation Unit: Dual interfaces uniformly reuse the same fixed physical MAC address, perfectly adapting to the single-port single MAC learning mechanism of vehicle switches, eliminating problems such as multiple MAC conflicts, port learning drift, and data forwarding errors. Addressing the inherent architectural characteristics of the standard lwIP protocol stack's global routing table, this system does not split the physical routing table but adopts an interface-level virtual protocol domain isolation mechanism: independent ARP cache tables, neighbor status tables, and private protocol control blocks are created for each of the two interfaces. Network segment routing rules are bound through the interface ID, logically partitioning and isolating the global routing table.
[0062] The two sets of interface protocol state machines operate, update, and age completely independently, without mutual reading, writing, overwriting, or interference. For unicast, broadcast, and multicast frames, network segment matching and isolation rules are uniformly applied. Cross-network segment requests are silently discarded at the network interface instance input callback layer, strictly adhering to the single-response principle of requests and responses within the same network segment. Core business network segment requests are handled only by the primary interface, and diagnostic configuration network segment requests are handled only by the secondary network interface. This fundamentally solves the problems of ARP response conflicts and packet crosstalk between dual network segments with the same MAC address, achieving true three-layer logical isolation.
[0063] Single-threaded packet cloning and distribution independent processing module: The core packet scheduling module of the system, solving the problems of high resource overhead, out-of-order packets, poor real-time performance, and state coupling and inability to independently respond and statistically analyze in traditional multi-interface, multi-threaded scheduling, as well as the pseudo-isolation scheme of single-interface, multi-IP, and the inability to independently respond and analyze. It adopts a global single-receive-thread, DMA-adapted deep copy, single-frame dual-path independent delivery, and dual-stack independent state parsing and scheduling mechanism, achieving absolute isolation of single-frame input at the physical layer, independent processing, independent response, and independent statistics for dual network segments at the protocol layer with extremely low RTOS resource overhead. It includes: a single-threaded exclusive and critical section lock protection unit, an auxiliary network interface state pre-judgment unit, a DMA-adapted deep copy and frame validity verification unit, an independent memory anomaly protection unit, a single-frame differentiated delivery unit, and a dual-protocol-stack independent state machine parsing and response unit.
[0064] Single-threaded exclusive and critical section lock protection unit: The system globally creates only a single Ethernet packet receiving thread, which is bound only to the main interface hardware interrupt and DMA receive entry point. No independent threads, task stacks, or receive queues are configured for secondary network interfaces. Relying on a globally single thread to process packets serially eliminates scenarios where multiple tasks concurrently preempt shared resources, avoiding issues such as buffer overflows, out-of-order packets, memory linked list corruption, and abnormal interface states. This adapts to the operational constraints of resource-constrained MCUs with small memory, low computing power, and high real-time requirements.
[0065] Secondary network interface status pre-judgment unit: After the receiving thread reads the original packet from the DMA buffer, it prioritizes executing the secondary network interface working status and link status detection logic. Subsequent packet cloning and dual-path delivery processes are only executed when the secondary network interface is in a link UP or ready-to-go state; if the secondary network interface is abnormal, offline, or not enabled, the cloning process is skipped directly, avoiding invalid memory allocation and computational overhead, significantly reducing the unnecessary resource overhead of the embedded system.
[0066] DMA-adapted deep copy and frame validity verification unit: Addressing the inherent hardware characteristics of STM32 Ethernet DMA buffer cyclic reuse and real-time data overwriting, this unit abandons the traditional lwIP shallow copy referencing mechanism and adopts a raw frame packet buffer PBUF_RAW raw frame full deep copy mode. The original message and cloned copy have completely independent memory allocation, independent payload data storage, and independent lifecycles, avoiding problems such as dirty data reading, frame truncation, CRC check errors, and message parsing failures caused by shallow copies. Simultaneously, a message validity pre-verification mechanism is employed, automatically detecting frame length, CRC check bits, and Ethernet frame header identifiers. Overly long frames, incomplete frames, and interference error frames are uniformly discarded and anomaly counts are accumulated. Only valid messages participate in clone distribution, ensuring the integrity and accuracy of data received by the dual protocol stack.
[0067] Single-frame differentiated delivery unit: After completing the legality verification and cloning operation, the original physical packet without any modification is delivered to the main interface network interface instance, and the complete bit-level consistent cloned packet copy is accurately delivered to the auxiliary network interface instance, realizing the isolation scheduling effect of the same physical Ethernet frame input being processed by two independent logical instances respectively.
[0068] Dual-protocol stack independent state machine parsing and response unit: The original packet and the cloned copy are respectively sent to the protocol parsing entry points of two independent NetIF instances. The two network interface instances independently start the ARP resolution state machine, IP packet parsing, route matching, and transport layer data processing logic. For the same physical input frame, each interface only responds to the target IP request and ARP broadcast request of its own network segment. Cross-network segment requests are silently discarded, without mutual response or interference, simulating the communication and testing effect of two independent vehicle terminals accessing two network segments respectively.
[0069] Independent memory anomaly protection unit: The packet parsing, memory management, and anomaly handling mechanisms for both interfaces are completely independent. When any interface experiences packet delivery failure, parsing anomaly, or route matching failure, a memory release operation is performed independently, and the PBUF memory resources occupied by the abnormal packet are reclaimed separately. A single interface anomaly will not affect the memory scheduling and task execution of the other interface, avoiding global memory leaks, thread blocking, and task freezes caused by single-segment packet anomalies.
[0070] Memory-Constrained Degradation and Self-Healing Module: This module is the core of the system's fault-tolerant operation and maintenance, specifically addressing issues such as limited SRAM resources in resource-constrained embedded MCUs, limited buffer pool capacity, easy memory exhaustion in high-load testing scenarios, global paralysis of traditional dual-instance solutions, lack of self-healing, and lack of quantitative statistics. It employs a highly reliable mechanism of hierarchical fault tolerance for primary and secondary network segments, on-demand cloning, unidirectional degradation, and restart-free self-healing, balancing lightweight resource overhead with operational stability in extreme scenarios. It includes: a network segment priority fixing guarantee unit, a cloned resource on-demand allocation unit, a memory pool real-time monitoring and main stack priority protection unit, a unidirectional graceful degradation fault tolerance unit, a dual-dimensional independent quantitative statistics unit, and a restart-free automatic self-healing and alarm closed-loop unit.
[0071] Network segment priority solidification guarantee unit: The system solidifies the priority fault tolerance strategy, clearly defining the vehicle core business test network segment corresponding to the main interface as the highest priority and the auxiliary diagnostic test network segment corresponding to the auxiliary network interface as the secondary priority, forming a fixed fault handling logic of prioritizing core business and tolerating and degrading diagnostic business. Under extreme load scenarios, it prioritizes ensuring that the vehicle core test business is not interrupted, degraded, or loses core data.
[0072] Cloning resource on-demand allocation unit: Adopting a precise on-demand resource allocation mechanism, it only requests memory pool resources to perform packet cloning operations when the secondary network interface link is normal and in the UP ready state; when the secondary network interface is offline, abnormal or not enabled, the entire process has zero memory overhead and zero invalid computing power, maximizing the saving of the limited SRAM memory resources of the embedded system, and adapting to the resource-constrained vehicle embedded operation scenario.
[0073] Real-time memory pool monitoring and main stack priority protection unit: Before each packet cloning operation, the system monitors the remaining free capacity of the PBUF_POOL buffer pool in real time to dynamically predict the risk of memory overload. Simultaneously, a core business memory priority preemption mechanism is implemented. When memory resources are scarce, sufficient memory space is reserved to ensure the normal packet reception, parsing, and response process of the main interface, while only restricting the cloning resource request permissions of secondary network interfaces, thus preventing core business paralysis from a hardware resource perspective.
[0074] One-way graceful degradation and fault tolerance unit: Employing a one-way fault tolerance and degradation strategy, when memory pool resources are exhausted or packet cloning fails under high load scenarios, the system only discards the current frame test data and cloning task of the auxiliary diagnostic network segment. The original packets can be delivered normally to the main business network segment for parsing, response, and data statistics. The connectivity test of the main network segment and core business communication remain stable and unaffected throughout. This solves the problems of single-frame anomalies, dual-stack paralysis, and global packet loss in traditional dual-instance architectures. At the same time, when the buffer pool is continuously exhausted, it outputs a high memory load alarm to the upper-layer application.
[0075] Dual-Dimensional Independent Quantitative Statistical Units: A two-layer, fully independent quantitative statistical system is constructed to achieve comprehensive operational condition monitoring and fault tracing. The first layer consists of independent operational condition statistics for both main and auxiliary network interfaces. Each interface is equipped with independent counters for packet reception, packet transmission, packet loss, and anomalies, enabling separate statistics on real-time communication success rate, packet loss rate, and operational status for both network segments. This supports independent fault location and performance evaluation for a single network segment. The second layer is dedicated to cloning statistics, independently tracking the number of successful and failed packet cloning attempts. It quantifies the packet loss frequency and system memory load status of the auxiliary network segment in memory-constrained scenarios, providing traceable data support for system parameter optimization, load assessment, and fault diagnosis.
[0076] Automatic self-healing and alarm closed-loop unit without restart: The system has dynamic and seamless self-healing capabilities, continuously monitoring memory pool balance and packet cloning failure frequency. When test traffic load decreases, memory resources are released, and buffer pool balance recovers to the preset threshold, packet cloning and dual-path distribution logic automatically recovers, and secondary network segment test functions autonomously repair themselves. The entire process requires no device software restart or parameter reset, and the self-healing process does not affect the core business operation of the main interface. If the cloning failure frequency continues to exceed the threshold, the system will continuously report high memory load alarms, providing testers with data to optimize test traffic and adjust test parameters, achieving a complete closed loop of fault monitoring, threshold judgment, alarm prompts, and autonomous self-healing.
[0077] This application discloses a single-port dual-protocol stack vehicle Ethernet multi-segment isolation testing method, including the following steps.
[0078] Step S1: Hardware system initialization and power-on timing calibration: In response to the hardware problem that the STM32 series MCU's built-in MAC has no independent reference clock and that conventional power-on timing errors can easily lead to MAC initialization failure, this application adopts a hierarchical power-on timing mechanism that adapts to the clock supply of the switching chip. It strictly follows the step-by-step startup logic of power supply regulation → clock readiness → Ethernet PHY readiness → MAC initialization. Through level constraints, timing offset constraints, and minimum stable delay constraints, zero abnormalities in hardware initialization are achieved.
[0079] Step S2: Differentiated registration and software resource assembly for dual network interfaces: This application abandons the traditional lwIP unified initialization and IP alias pseudo-configuration scheme, and adopts a differentiated registration architecture with full hardware initialization of the main interface and pure software without hardware reuse of the auxiliary network interface. Two independent netif network interface instances are created under the same lwIP protocol stack kernel to solve the problems of secondary initialization conflict, DMA error, resource preemption, protocol stack crash and link jitter, and realize a single hardware, dual instance, independent operation architecture.
[0080] Step S3: Parameter configuration and state isolation of independent network interface instances: Breaking through the traditional technical understanding of single MAC single network segment and multiple network segments multiple hardware, it achieves true three-layer logical isolation of dual network interface instances and dual network segments with zero hardware increment, which is different from the traditional IP alias pseudo-isolation scheme.
[0081] Step S4: Single-threaded packet cloning and distribution and dual-stack independent processing: This application adopts a global single packet receiving thread, deep copy cloning of packets, and dual-path independent delivery mechanism to solve the problems of high resource overhead of multi-threading and state coupling of pseudo-isolation schemes, and realizes physical single-frame input, independent parsing of protocol dual instances, independent response, and independent statistics.
[0082] Step S5, Graceful Degradation and Data Statistics Self-Healing in Memory-Constrained Scenarios: To address the issues of limited SRAM resources in embedded MCUs and easy memory exhaustion under high load, this application adopts a highly reliable mechanism of primary and secondary hierarchical fault tolerance, on-demand cloning, unidirectional degradation, and self-healing without restart, ensuring the continuous and stable operation of core business network segments.
[0083] Example 1.
[0084] This embodiment 1 discloses a single-port dual-protocol stack vehicle Ethernet multi-segment isolation test system, wherein step S1 includes the following steps.
[0085] S11. Set constraints.
[0086] Define key moments: To enable the onboard LDO power supply, To release the RTL8367S switching chip reset, To ensure the reference clock REF_CLK reaches a stable 50MHz, To release the reset of each PHY, Initialize the MAC.
[0087] Includes the following constraints.
[0088] (1) Initial level constraint for preventing floating glitch: Each reset line must be set to the reset effective level before it is configured as an output.
[0089] .
[0090] In the formula, This indicates that the condition is true for all reset pin variables, and the mathematical logic sign is fixed. 'g' is a reset pin variable, representing all power-on reset control lines of the system. This is the set of reset pins; This is for the reset control line of the RTL8367S switching chip; These are two RTL9010 PHY chip reset control lines; For pin g in The real-time electrical level value at any given moment. The pre-configuration time before pin mode is set is the time before the pin switches from floating input to output mode. This time is obtained by recording the high-precision timer's markings upon system power-on. The reset valid level is a hardware-fixed reference level, defined according to the switching chip and PHY chip hardware manuals, and is the target fixed level for pin pre-configuration.
[0091] (2) Strict temporal partial order constraints.
[0092] .
[0093] In the formula, The power enable timing for the onboard LDO is obtained by reading the hardware register at which the power enable pin level flips, which is then marked by the system's high-precision timer. The reset and release timing of the RTL8367S switching chip is obtained by reading the release operation timing from the reset pin register of the switching chip, and the software records and acquires it in real time. The system marks and determines the moment when the RMII reference clock stabilizes and meets the standard. After continuously sampling the clock frequency and amplitude without jitter and stabilizing at 50MHz, the system marks and determines the time. When the two RTL9010 PHYs are reset and ready for self-test, the PHY ready register status is polled via the MDIO bus, and the status is marked after all self-tests are completed. This is the moment when the MCU Ethernet MAC and DMA are finally initialized, obtained by reading the moment when the underlying Ethernet initialization function is completed and the register configuration is fixed.
[0094] (3) Minimum stable delay constraints for each stage.
[0095] .
[0096] .
[0097] .
[0098] In the formula, Establish a minimum stable delay for the power supply, with a fixed constant of 20ms, and obtain the parameters from the hardware power supply regulation characteristic manual for fixed configuration. Establish a minimum stable delay for the reference clock, with a fixed constant of 100ms, and obtain the solidified configuration of the chip clock start-up stability characteristic parameters. To ensure the minimum latency for PHY hardware stability, a fixed constant of 100ms is used to obtain the PHY chip self-test and link stability characteristic parameters through a fixed configuration.
[0099] The hardware initialization phase of this system employs a scientifically set parameter gradient: Δ1=20ms power supply voltage regulation delay, Δ2=100ms switching chip clock frequency stabilization delay, and Δ3=100ms PHY hardware stabilization delay. These parameters perfectly align with the electrical characteristics of automotive Ethernet hardware and engineering specifications for extreme operating conditions. The 20ms LDO basic voltage regulation delay, matched to the onboard low-dropout regulator chip's power-on voltage convergence characteristics, ensures a smooth power supply voltage rise without overshoot or oscillation, providing a clean power supply base for subsequent peripheral resets and clock startup, and meeting the power-on convergence timing requirements of conventional industrial-grade power supplies. Although the 100ms delay for frequency stabilization of the switching chip and the 100ms delay for PHY self-test stabilization have the same numerical value, their corresponding hardware convergence mechanisms are independent and their timing levels are completely different. There is no parameter redundancy or logic conflict. The 100ms delay on the switching chip side is mainly used for crystal oscillator startup, internal phase-locked loop (PLL) phase locking, and accurate convergence of reference clock frequency and amplitude, avoiding crystal oscillator startup drift and clock jitter problems under high and low temperature environments. The 100ms delay on the PHY side is mainly used for analog circuit bias configuration, register self-test calibration, link hardware initialization and state stabilization, adapting to the slow convergence characteristics under harsh conditions such as vehicle voltage fluctuations and electromagnetic interference. The two 100ms delays serve two independent timing stages: precise clock source establishment and physical link hardware self-test stability. These represent the minimum stability margins for different hardware modules and comply with the power-on timing constraints of the RTL8367S and RTL9010 chip manuals and the AEC-Q level reliability design standards for automotive equipment. Through sufficient engineering margins, hidden anomalies such as clock distortion, incomplete PHY initialization, and random MAC startup failure caused by insufficient stabilization time are completely eliminated. This significantly improves the system's operational stability and test reproducibility under extreme automotive scenarios such as high and low temperature alternation and voltage fluctuations.
[0100] (4) Failure Criterion: If If MAC initialization fails, it will inevitably fail; only if The system hardware initialization is normal.
[0101] S12. Pre-configuration of peripheral pins to prevent glitches: During the initial power-up, the GPIOE port clock is enabled first. Before the pins are configured to output mode, the PE0, PE4, and PE5 reset pin levels are pre-pulled high to maintain the initial reset and locked state of all onboard peripherals. This avoids hardware glitches caused by pin floating and level jumps during power-up, and protects the switching chip and multiple PHY peripherals from power-up transient interference.
[0102] S13. Onboard LDO power supply enable and regulation: Enable the onboard LDO power supply via the PE3 pin, with a fixed regulation delay of 20ms.
[0103] S14. Switching chip reset release and frequency stabilization detection: Prioritize the release of the RTL8367S Gigabit Ethernet switching chip reset, set a basic frequency stabilization duration of 100ms, and wait for the clock parameters to stabilize to the standard 50MHz without jitter before proceeding to the next process, providing an accurate, compliant and stable reference clock source for subsequent MCU MAC initialization.
[0104] S15. Ethernet PHY Reset and Timeout Fault Handling: After the RMII reference clock is fully stable, release the two RTL9010 PHY reset signals sequentially. Read the PHY register status bits in real time via the MDIO bus, employing timeout judgment and fault branch logic: If MDIO communication fails or the PHY register fails to enter the ready state for an extended period, immediately trigger the timeout retry mechanism and report a hardware initialization failure fault to avoid problems such as incomplete PHY initialization, random abnormalities in subsequent links, and program freezes caused by fixed delays; only after detecting that the PHY register initialization is complete and the link self-test is ready is the PHY hardware considered ready.
[0105] S16, MAC and DMA final initialization: After the power supply, clock, and PHY hardware are all stable, the MCU Ethernet MAC and DMA hardware initialization is performed uniformly. This completes the MAC clock configuration, DMA transmit / receive buffer configuration, interrupt priority configuration, and link basic parameter configuration. It also locks the global Ethernet hardware resources and register status, completing the full-dimensional readiness of the underlying hardware.
[0106] In this technical solution, four types of hardware initialization constraints are set: anti-floating glitch initial level constraint, strict timing offset constraint, minimum stable delay constraint at each stage, and failure criterion. At the initial power-on stage, the GPIOE port clock is prioritized. Before configuring the pins to output mode, the PE0, PE4, and PE5 reset pins are pre-pushed high to achieve anti-glitch processing for peripheral pins. The RTL8367S Gigabit Ethernet switch chip reset is released first, and the reset release and frequency stabilization detection of the switch chip are completed by combining a 100ms basic frequency stabilization time and real-time RMII clock detection. After the RMII reference clock is fully stable, the two RTL9010 PHY reset signals are released sequentially. The PHY register status bits are read in real-time via the MDIO bus, and a timeout retry and fault reporting mechanism is configured to complete the Ethernet PHY reset and timeout fault handling. Finally, after the power supply, clock, and PHY hardware are all stable, the MCU Ethernet MAC and DMA final initialization are executed uniformly. This layered power-on timing mechanism is adapted to the hardware characteristics of STM32 series MCUs with built-in MACs that lack independent reference clocks. It conforms to the power-on timing constraints of RTL8367S and RTL9010 chip manuals and the AEC-Q level reliability design standards for automotive equipment. It avoids hardware glitches and transient interference caused by floating level jumps of power-on pins, and is adapted to extreme operating conditions such as alternating high and low temperatures in automotive environments and power grid voltage fluctuations. It solves problems such as clock distortion, incomplete PHY initialization, random MAC initialization failure, and random hardware link anomalies caused by conventional power-on timing errors. It provides a highly stable and fault-tolerant standardized hardware startup base for upper-layer dual-protocol stack multi-segment isolation testing, and improves the operational stability and test reproducibility of the system under extreme automotive scenarios.
[0107] Example 2.
[0108] This embodiment 2 discloses a single-port dual-protocol stack vehicle Ethernet multi-segment isolation test system, wherein step S2 includes the following steps.
[0109] S21. Definition of Dual-Interface Differentiated Initialization Function: Define the standard ethernetif_init initialization function.
[0110] The main interface uses standard initialization operations. Registration, application of unique hardware initialization (H), and creation of a unique packet receiving thread; secondary network interface uses derived initialization operations. Registration fully reuses the main interface hardware resources without performing any hardware initialization operations.
[0111] (1) Main Interface Registration and parameter configuration: Execute hardware initialization H to satisfy Configure network parameters.
[0112] Set it as the system default interface and enable the link UP state.
[0113] In the formula, It is the main network interface, the core business network segment interface, and the first netif network interface object created by the system software layer. It is dynamically created and obtained by the lwIP protocol stack initialization function. Set the main interface to a static IP address, fixed at 192.168.10.250. Obtain the static IP address through system software and disable DHCP. This refers to the number of bits in the main interface subnet mask segment, / 24 segment, corresponding to 255.255.255.0, obtained from system static parameter configuration. The main interface network segment gateway address is fixed at 192.168.10.1, obtained through static configuration in the system software. This is a standard complete hardware initialization registration operator, representing the LWIP standard Ethernet interface initialization process, including the entire process of underlying hardware initialization, DMA configuration, and thread creation. It is obtained by calling the ethernetif_init standard interface. An empty parameter set indicates that the main interface is initialized from scratch with no prior reused resources; this is a mathematical logic identifier. H represents the complete set of underlying hardware initialization operations for Ethernet, including MAC, DMA, peripheral clock, interrupts, and register configuration, which is obtained through the underlying low_level_init execution flag. Mark the number of times the main interface hardware initialization has been executed. =1 indicates that hardware initialization is performed globally and only once, and is obtained by assigning a value to a software global variable. T is the system's Ethernet packet receiving thread set, which carries all Ethernet packet receiving tasks. This is the only Ethernet packet receiving thread in the system, created once during the initialization of the main interface, and is globally unique. The cardinality of the thread set, the number of threads. =1 indicates that there is only one packet receiving thread in the entire system, which is determined by the RTOS thread handle count. up is the interface link ready status indicator. Setting it to UP indicates that the main interface protocol stack and link are enabled, which is obtained by assigning a value to the netif status bit.
[0114] (2) Auxiliary network interface Registration and parameter configuration: Configure network parameters. The secondary network interface uses a lightweight derived registration function to complete software registration.
[0115] Link status unidirectional linkage constraint: .
[0116] In the formula, As a secondary network interface, it diagnoses and configures the network segment interface. The second netif network interface object is dynamically created by a custom lightweight derived initialization function and obtained independently by the software. The secondary network interface has a static IP address, fixed at 192.168.100.250, and the system software has a statically fixed configuration. The subnet segment bit length for the secondary network interface is / 24, corresponding to the subnet mask 255.255.255.0, obtained from the system static parameter configuration. The secondary network interface segment gateway address is fixed at 192.168.100.1, obtained through static configuration by the system software. The auxiliary network interface lightweight derived registration operator is a hardware-free interface initialization operation. It only completes the protocol stack software registration and parameter inheritance, and does not perform underlying hardware initialization. It is obtained by calling the custom ethernetif_init_alias function. The physical link of the main interface is ready. =1 indicates that the physical link of the main interface is normally up, which can be obtained in real time by reading the physical link status variable of the lwIP netif structure. The secondary network interface protocol stack is enabled, indicating that the software protocol layer interface is open and ready. This value is automatically assigned by the system link synchronization logic. The readiness status of the auxiliary network interface logical link is updated unidirectionally in conjunction with the status of the main interface, and is obtained in real time through the netif status register of the auxiliary network interface.
[0117] During the registration phase, a one-way linkage rule is established. When the physical link of the main interface is in normal and ready, the protocol stack of the auxiliary network interface is forcibly enabled and the link is ready, ensuring that the states of the two interfaces are coordinated and consistent, and that the state of the auxiliary network interface does not affect the main interface in the reverse.
[0118] (3) Derivation operation Member-by-member assignment rule: Mapping Φ_alias : N1 N2 is assigned values one by one.
[0119] len(a2) = MAC address length.
[0120] Mount a Layer 3 standard transmission routine. Mount a Layer 2 raw frame transmission routine. Hardware initialization is not performed.
[0121] In the formula, Φ_alias is the lightweight derived registration operator for the secondary network interface. It is an initialization mapping operation that only completes the assignment of protocol stack parameters and callback mounting, without performing any underlying hardware initialization. It is obtained by calling the custom ethernetif_init_alias function. The secondary network interface device name identifier is fixedly assigned the value "st1" and is used by the protocol stack to distinguish it from the primary interface "st0". It is obtained from the static configuration of the software macro definition. The physical MAC address bound to the main interface is fixed as a unique physical address for the hardware and is read and obtained during the underlying hardware initialization. The physical MAC address for secondary network interfaces is a complete replica of the primary interface's MAC parameters, obtained through software memory copying and assignment. len(a2) is the fixed-byte length of the Ethernet MAC address, a 6-byte hardware standard constant, and is obtained through macro definition at the protocol stack level. This is the maximum transmission unit (MTU) parameter for the main interface Ethernet, a fixed configuration for Ethernet standards, obtained during the main interface hardware initialization configuration. The MTU parameter of the secondary network interface is fully inherited from the configuration parameters of the primary interface, and the software directly assigns and reuses the obtained parameters. This is the set of Ethernet protocol flags for the main interface, including broadcast enable and ARP resolution enable attributes, and the configuration of the main interface initialization register. The secondary network interface Ethernet protocol flag bit fully inherits the primary interface flag bit configuration, ensuring consistency of protocol attributes between the two interfaces, and the software can directly assign and reuse the value. The auxiliary network interface uses a Layer 3 IP / ARP protocol send operation handle, mounts the lwIP standard etharp_output send routine, and obtains the protocol stack software interface. As a secondary network interface layer 2 raw frame transmission operation handle, it mounts the lwIP underlying low_level_output hardware transmission routine, reuses the main interface hardware transmission channel, and obtains it through software callback binding. To initialize the secondary network interface hardware, execute the flag. =0 indicates that no hardware initialization operation was performed, and the software global variable assignment flag is obtained.
[0122] (4) System-level conserved invariants: For all K network interface instances of the system, the following conditions are met.
[0123] .
[0124] In the formula, K represents the total number of Ethernet network interface instances actually mounted in the system. In this system, K is fixed at 2 and is obtained from the statically fixed configuration of the software global parameters. k is the network interface instance traversal index, used to traverse all registered netif interfaces in the system, and is a mathematical traversal variable. The hardware initialization execution flag is set for the k-th network interface. =1 indicates that a complete underlying hardware initialization is performed. =0 indicates that only software registration has been performed and hardware initialization has not been executed. This value is obtained from the execution status of the underlying initialization function low_level_init by the software assignment flag. The physical MAC address bound to the k-th network interface is used, and all interfaces reuse the inherent hardware address. The chip's inherent base physical MAC address is fixed at 00:80:E1:00:00:00. It is obtained by reading registers during hardware initialization and is the system's unique physical hardware address. T represents the system's Ethernet packet receiving thread set, accommodating all packet receiving and processing task threads. |T| is the cardinality of the packet receiving thread set, i.e., the total number of packet receiving threads in the system. |T|=1 represents a globally unique packet receiving thread, obtained through RTOS thread handle counting.
[0125] S22. Main Interface Complete Hardware Initialization Lock: The main interface calls the low_level_init underlying interface through the standard ethernetif_init initialization function to fully execute the HAL_ETH_Init hardware initialization, completing the configuration of MAC clock, DMA buffer, interrupt priority, and link parameters in one go. It also creates the system's only packet receiving thread and transmit / receive semaphores, globally locking all Ethernet hardware resources and prohibiting secondary modification and preemption.
[0126] S23. Lightweight secondary network interface with no hardware initialization registration: The secondary network interface uses a custom ethernetif_init_alias function to complete software registration, skipping the low_level_init low-level hardware initialization entry point throughout the process, without executing HAL_ETH_Init configuration, without repeatedly initializing DMA registers, without enabling peripheral clocks, and without creating new threads and semaphores.
[0127] Only assign values to valid members of the netif structure of the network interface, and prohibit the complete memory copying of the netif structure. This avoids concurrent resource release anomalies caused by the secondary network interface copying the hardware handle and semaphore pointer of the primary interface, and completely avoids hardware register disorder, DMA cache overflow and hardware deadlock problems.
[0128] The clone distribution function is as follows: The system relies on a globally unique packet receiving thread to complete the unified reception and differentiated distribution of Ethernet packets. The unique packet receiving thread extracts the original packet p frame by frame from the MAC, and performs conditional cloning-dual delivery operation on each frame to achieve an isolated operation mechanism with single physical frame input and independent processing of dual protocol stacks. A secondary network interface UP status indicator is provided. .
[0129] (1) Cloning operation c, the layer is taken from the original hardware frame layer raw, that is, zero header reservation and offset of 0, for the message satisfy.
[0130] The payload bits are consistent.
[0131] Memory is independent; modification / release of one stack does not affect the other stack.
[0132] .
[0133] In the formula, The raw Ethernet packet frames received by the MAC hardware DMA channel are read from the underlying DMA receive buffer and serve as the raw physical data carrier for a single frame. It is a complete bit-level clone of the original message, generated by RAW zero-offset deep copy, with independent software memory allocation and payload data acquisition copied byte by byte. It is a collection of Ethernet packet payload data, including the complete content of frame header, data segment, and checksum, which is obtained by parsing and reading the packet memory. This is the memory starting address of the PBUF message, obtained by reading the message pointer address through the lwIP memory management interface, and is used to determine the independence of memory space. This is the offset of the cloned message header, fixed at 0. It is a hardware standard constant for RAW mode cloning, obtained from the macro definition of the protocol stack.
[0134] (2) Conditional copy generation.
[0135] .
[0136] (Pool exhausted: Only auxiliary segments discard this frame).
[0137] In the formula, This is a Boolean flag indicating the ready state of the secondary network interface link. This indicates that the secondary network interface is normally up and ready, and can send and receive data normally. This indicates that the secondary network interface is offline or malfunctioning, which can be obtained in real time by reading the netif status register of the lwIP secondary network interface. The number of remaining available memory blocks in the system's PBUF_POOL memory buffer pool is obtained in real time through the lwIP built-in memory management interface and is used to determine whether memory resources are sufficient. To deliver cloned message copies to the secondary network interface, the clone operation generates the copy when the conditions are met, and sets it to an empty set with no copy generated when the conditions are not met. The value is obtained by software condition logic assignment. An empty set identifier indicates that there are no valid message copies or data delivery; it is a mathematical logic identifier.
[0138] (3) Diagnostic count.
[0139] .
[0140] .
[0141] In the formula, The cumulative counter for successful message cloning and secondary network interface delivery automatically increments by 1 after each successful dual-path cloning delivery, and is accumulated and statistically obtained by the system in real time. The cumulative counter for message cloning failures is automatically incremented by 1 when the secondary network interface is ready but the memory pool is exhausted or cloning delivery fails. It is updated in real time by the system fault statistics logic.
[0142] (4) Dual-path delivery operation D.
[0143] Submission main interface: If the return value does not equal success, then release. .
[0144] like Submitting secondary network interface: If the return value does not equal success, then release. .
[0145] In the formula, This is the main interface message protocol stack delivery processing function, responsible for ARP resolution, route matching, and data processing of the original message, and calls the lwIP main interface receive entry function to execute and obtain the data. This is a secondary network interface message protocol stack delivery processing function, responsible for the independent protocol parsing and processing of cloned copy messages, and calls the lwIP secondary network interface customized receiving entry function to execute the acquisition.
[0146] (5) Failure isolation: frame loss in the auxiliary segment does not affect the main segment.
[0147] .
[0148] and and irrelevant Main stack Unaffected.
[0149] In the formula, This is the running instance of the core business protocol stack for the main interface, a globally unique hardware-borne protocol stack, which is created and obtained during system initialization. A protocol stack runtime instance is configured for auxiliary network interface diagnosis, a pure software reuse-generated independent protocol stack instance, and is obtained through dynamic software registration.
[0150] Only assign values to valid members of the netif structure, prohibiting complete memory copying of the netif structure. This avoids concurrent resource release anomalies caused by copying the main interface hardware handle and semaphore pointer from the secondary network interface, and prevents hardware register corruption, DMA cache overflow, and hardware deadlock issues.
[0151] S24. Batch Parameter Inheritance and Reuse for Secondary Network Interfaces: The secondary network interface only performs a memory copy of the MAC address field, replicating the physical MAC address of the primary interface, thus avoiding MAC learning drift and port forwarding anomalies. Simultaneously, through structure member assignment, it fully inherits core parameters such as the primary interface's MTU, broadcast flag, ARP enable flag, multicast identifier, and link status, requiring no secondary configuration and ensuring a high degree of consistency in the protocol operating parameters of both interfaces.
[0152] S25. Send / Receive Callback Mounting and Hardware Channel Multiplexing: The secondary network interface only mounts etharp_output and low_level_output send / receive callbacks at the protocol stack layer, without binding to an independent hardware channel or requesting an independent DMA descriptor. All outgoing packets from both interfaces are uniformly merged into the main interface hardware channel and DMA link, realizing a time-division multiplexing transmission mechanism for dual-instance packets on a single hardware channel, thus solving the problems of queue overflow, packet out-of-order delivery, and transmission deadlock caused by concurrent transmission of multiple instances.
[0153] S26. Dual-interface unidirectional linkage and bidirectional isolated link synchronization: The auxiliary network interface periodically checks the status of the main interface link to achieve unidirectional status synchronization; when the main interface link is UP, the auxiliary network interface is synchronously UP; when the main interface link is DOWN, the auxiliary network interface is synchronously DOWN, and actively clears the ARP cache table and neighbor status table of the auxiliary network interface to eliminate expired protocol status and avoid communication abnormalities caused by state residue.
[0154] Meanwhile, software unidirectional isolation constraints are adopted: changes in the status of the auxiliary network interface, parameter modifications, and link anomalies will not interfere with the hardware driver and link status of the main interface in the reverse direction, achieving the absolute isolation effect of the main control auxiliary and the auxiliary not disturbing the main, and avoiding bidirectional state crosstalk.
[0155] In this technical solution, a differentiated registration architecture is constructed by defining a standard ethernetif_init initialization function and a customized ethernetif_init_alias lightweight derived registration function. The main interface performs full hardware initialization, while the secondary network interface is purely software-based with no hardware reuse. The main interface performs complete HAL_ETH_Init hardware initialization, creates a unique packet receiving thread, and globally locks Ethernet hardware resources. The secondary network interface skips the low_level_init low-level hardware initialization entry point throughout the process, does not perform hardware initialization configuration, does not repeatedly initialize DMA registers, does not enable peripheral clocks, and does not create new threads or semaphores. This approach utilizes a derived operation rule that assigns values to each member of the secondary network interface, assigning values only to valid members of the netif structure, prohibiting complete memory copying of the netif structure, and only performing memory copying of the MAC address field to replicate the physical MAC address of the main interface. It fully inherits core parameters such as the main interface's MTU, broadcast flag, and ARP enable flag. It attaches etharp_output and low_level_output send / receive callbacks without binding to independent hardware channels and DMA descriptors. Relying on a globally unique packet receiving thread, it achieves deep copying of RAW zero-offset packets, conditional cloning, and dual-path independent delivery, and establishes a unidirectional linkage and bidirectional isolation link synchronization mechanism between the main and secondary network interfaces. This effectively solves problems such as secondary hardware initialization conflicts, DMA errors, resource preemption, repeated semaphore creation, abnormal structure memory copying, and bidirectional crosstalk in traditional LWIP multi-interface deployments. It eliminates faults such as hardware register disorder, DMA buffer overflow, hardware lock-up, and protocol stack crashes. Through an independent memory allocation and release mechanism for packets, it ensures that frame loss in the secondary network segment does not affect the operation of the main network segment, guaranteeing long-term stable and independent operation of single hardware and dual software interface instances, and significantly reducing embedded system resource overhead.
[0156] Example 3.
[0157] This embodiment 3 discloses a single-port dual-protocol stack vehicle Ethernet multi-segment isolation test system, wherein step S3 includes the following steps.
[0158] S31. Unified binding and reuse of global hardware resources: The unique onboard MAC kernel, unique DMA buffer, unique RMII physical link, and unique PHY transceiver channel are uniformly bound to the global driver handle, prohibiting secondary hardware allocation, repeated initialization, and multiple DMA configurations, so as to support the operation of dual software network interface instances with a single hardware base.
[0159] S32. Differentiated creation of dual-interface instances: Create two completely independent, data-uncoupled, and stateless netif network interface instances: The main interface is bound to the vehicle core business network segment for routine business connectivity testing; the auxiliary network interface is bound to the vehicle diagnostic configuration network segment for device parameter configuration and fault diagnosis testing, with clear division of labor and adaptability to the independent testing needs of dual scenarios.
[0160] S33. Independent configuration of static network segment parameters: DHCP dynamic allocation is disabled for both interfaces, and static IP, subnet mask, and gateway are configured independently to avoid test disorder and invalid data caused by dynamic IP jumps, ensuring a stable, controllable, and reproducible test environment.
[0161] S34. Unified MAC and Complete State Isolation of Virtual Protocol Domains: Dual interfaces reuse the same fixed physical MAC address, adapting to the single-port single MAC learning mechanism of vehicle-mounted switches, avoiding MAC conflicts and forwarding errors. Addressing the inherent characteristics of lwIP global routing, this application adopts an interface-level virtual protocol domain isolation mechanism. Without splitting the physical routing table, it creates independent ARP cache tables, neighbor state tables, and private protocol control blocks for each interface, binding network segment routing rules through interface IDs, and logically partitioning and isolating the global routing table.
[0162] Cross-network segment packets are silently discarded at the input callback layer of the network interface instance, and the network segment matching response rules are strictly enforced: requests from the 192.168.10.x network segment are only processed by the primary interface response, and requests from the 192.168.100.x network segment are only processed by the secondary network interface response, without interference or overlap.
[0163] Network segment isolation theorem: Two protocol stacks are bound to disjoint network segments. ,and .
[0164] stack For the destination address The criteria for responding to the message.
[0165] .
[0166] Corollary of the Isolation Theorem: For any unicast frame p, the following condition is satisfied: This means that the physical layer receives frames simultaneously with both stacks, while the protocol layer receives responses from at most one stack, achieving absolute three-layer logical isolation on a single physical network interface. In the formula, This is the set of independent network segments corresponding to the i-th network interface, defined by the interface's static IP address and subnet mask. The system software has a statically fixed configuration and disables DHCP, and the parameters are obtained directly from the system configuration. The IP address of the i-th interface is the static host IP address. i=1 corresponds to the core business network segment IP of the main interface, and i=2 corresponds to the diagnostic configuration network segment IP of the auxiliary network interface. Both are obtained from software-fixed static parameter configuration. The number of bits in the subnet mask of the i-th interface is used. Both interfaces use the / 24 standard network segment configuration. This is obtained from the system static parameter configuration and is used to define the network segment address range. The intersection of the primary and secondary network interface segments is an empty set. The address spaces of the two network segments in this system are completely non-overlapping. The intersection is obtained by mathematical determination of the static parameters of the network segments and is a prerequisite constraint for three-layer logical isolation. This is the running instance of the i-th protocol stack. The core business protocol stack for the main interface. The protocol stack for auxiliary network interface diagnostics is created and obtained independently during the system initialization phase. The destination IP address of message p is obtained in real time by parsing the IP field in the Ethernet frame header through the protocol stack message parsing module. This is the set of broadcast addresses corresponding to the i-th network segment, which is calculated in real time by the interface IP and subnet mask according to the network segment operation rules. This serves as a valid identifier for the acknowledgment of message p by the i-th protocol stack. =1 indicates that the current stack matches the network segment rules and processes the message accordingly. =0 indicates a mismatch, and the message is silently discarded. The value is determined and assigned in real time by the routing matching logic of the protocol stack.
[0167] In this technical solution, by uniformly binding the onboard unique MAC kernel, unique DMA buffer, unique RMII physical link, and unique PHY transceiver channel to a global driver handle, secondary hardware allocation and repeated initialization are prohibited. Two completely independent, data-decoupled, and stateless primary and secondary network interfaces are created based on a single hardware base, respectively bound to the core service network segment and the diagnostic configuration network segment. DHCP dynamic allocation is disabled on both interfaces, and static IP addresses, subnet masks, and gateway parameters are configured independently. The same fixed physical MAC address is reused to adapt to the vehicle switch's single-port single-MAC learning mechanism. Simultaneously, a virtual protocol domain isolation mechanism at the interface level is adopted. Without splitting the physical routing table, independent ARP cache tables, neighbor status tables, and private protocol control blocks are created for each interface. The global routing table is logically partitioned and isolated by binding network segment routing rules to the interface ID, strictly adhering to the rule of requesting and responding within the same network segment. Cross-network segment packets are silently discarded at the interface input callback layer. Breaking through the technical limitations of traditional single MAC single network segment and multi-network segment multi-hardware, it achieves true three-layer logical isolation of dual network segments with zero hardware increment. It solves the problems of network segment protocol state coupling, ARP reply conflict and packet crosstalk in traditional IP alias pseudo-isolation schemes. It can accurately simulate test scenarios where two independent vehicle terminals are connected to different network segments respectively, ensuring long-term stability of multi-network segment test environment, controllable parameters and reproducible scenarios.
[0168] Example 4.
[0169] This embodiment 4 discloses a single-port dual-protocol stack vehicle Ethernet multi-segment isolation test system, wherein step S4 includes the following steps.
[0170] S41, Message Conditional Cloning - Dual-Path Delivery Processing.
[0171] Auxiliary network interface UP status indicator The system's single packet receiving thread performs conditional cloning and dual-path delivery on each packet frame.
[0172] (1) Cloning operation c: The payload bits are completely identical; The memory is completely independent; , Zero-offset original frame clone.
[0173] (2) Conditional copy generation.
[0174] .
[0175] (3) Diagnostic count: ; .
[0176] (4) Dual-path delivery: Original message p is delivered to the main interface cloned copy Submission of auxiliary network interface If delivery fails, the memory of the corresponding message will be released independently.
[0177] (5) Failure isolation: The depletion of the buffer pool only causes frame loss on the secondary network interface, while the primary interface’s packet reception, parsing, and response are completely unaffected, thus achieving decoupling of primary and secondary network segment faults.
[0178] S42. Single-threaded exclusivity and critical section lock protection: The system globally creates only one packet receiving thread, which is bound only to the main interface hardware interrupt and DMA entry point. The auxiliary network interface has no independent thread or task stack. RTOS critical section mutex locks are added to the DMA read, PBUF memory allocation, packet cloning, and protocol stack delivery intervals to prevent buffer overflow, packet out-of-order, and abnormal state issues caused by interrupt nesting and task preemption. This is suitable for low-computing-power, small-memory automotive-grade MCUs.
[0179] S43. Pre-judgment of secondary network interface status: After receiving the packet, the link and working status of the secondary network interface are checked first. The cloning operation is only performed when the secondary network interface is normally UP. Otherwise, it is skipped directly to avoid invalid memory allocation and computing power consumption and optimize embedded resource overhead.
[0180] S44, DMA-adapted deep copy and frame validity verification: Addressing the hardware characteristics of STM32 DMA cyclic overlay, this solution abandons the traditional shallow copy approach and adopts a PBUF_RAW raw frame complete deep copy mechanism. The original message and the cloned copy have independent memory and lifecycles, eliminating issues such as dirty data, frame truncation, and verification errors. Simultaneously, it includes pre-frame length checks, CRC checks, and frame header validity checks, ensuring only valid frames participate in clone distribution.
[0181] S45. Differentiated message delivery: The original message is delivered to the main interface instance without modification, and a cloned complete copy is delivered to the auxiliary network interface instance, achieving the isolation effect of single physical frame input and independent processing of dual logical instances.
[0182] S46. Dual-Instance Independent State Machine Resolution and Response: Two network interface instances independently run ARP resolution, IP route matching, and transport layer processing state machines, responding only to their own network segment packet requests and silently discarding cross-network segment requests, simulating the physical test effect of two independent vehicle terminals accessing different network segments.
[0183] S47. Independent memory anomaly protection: The dual-interface memory management is completely independent. If either interface fails to parse a message or fails to deliver it, the memory is released independently without interference, avoiding global memory leaks, thread blocking, and task freezes.
[0184] In this technical solution, a globally unique packet receiving thread is set up, bound only to the main interface hardware interrupt and DMA entry point. RTOS critical section mutexes are added to the DMA read, PBUF memory allocation, packet cloning, and protocol stack delivery intervals. After packet reception, the secondary network interface status is pre-judged first, and packet cloning is only performed when the secondary network interface is in the UP ready state. Considering the STM32 DMA cyclic overlay hardware characteristics, a PBUF_RAW raw frame complete deep copy mechanism is adopted to ensure that the original packet and cloned copy have consistent bit-level payloads, completely independent memory, and no interference in their lifecycles. Pre-frame length, CRC check, and frame header validity detection filter valid packets, delivering unmodified original packets to the main interface and complete cloned copies to the secondary network interface. The two network interface instances run ARP resolution, IP route matching, and transport layer processing state machines independently, independently handling packet memory release and exception handling; an exception on one interface does not affect the operation of the other. It solves the problems of high resource overhead, out-of-order packets, and poor real-time performance of traditional multi-interface and multi-threaded scheduling, avoids dirty data reading, frame truncation, CRC check errors, and packet parsing failures caused by shallow copying, and achieves absolute isolation effect of single frame input at the physical layer and independent parsing, independent response, and independent statistics of dual network segments at the protocol layer. It is suitable for the operation constraints of resource-constrained MCUs with small memory, low computing power, and high real-time performance.
[0185] Example 5.
[0186] This embodiment discloses a single-port dual-protocol stack vehicle Ethernet multi-segment isolation test system, wherein step S5 includes the following steps.
[0187] S51, Network Segment Priority Fixation: The priority fixation strategy is as follows: the main interface is the core business test network segment and is given priority protection; the auxiliary network interface is the diagnostic auxiliary network segment and is fault-tolerant and degraded, prioritizing ensuring that the core vehicle test business is not interrupted.
[0188] S52, On-demand allocation of clone resources: Cloning resources are requested only when the auxiliary network interface is UP and ready, and the operation is carried out with zero overhead in offline / abnormal states, maximizing the saving of embedded memory resources.
[0189] S53, Real-time monitoring of memory pool and priority protection of main stack: Real-time detection of the remaining amount of buffer pool before each cloning, granting priority to the main interface memory preemption, prioritizing the reservation of main business operation resources when memory is tight, and only restricting the application of cloned resources for secondary network interfaces to avoid paralysis of core business.
[0190] S54, One-way graceful degradation fault tolerance: When the memory pool is exhausted or cloning fails, only the current test frame data of the secondary network segment is discarded. The primary network segment's packet sending, receiving, parsing, and response are all normal, solving the problem of single failure and global crash in the traditional dual-instance architecture. At the same time, when the high load continues to exhaust the memory, it reports an alarm of excessive memory load to the upper layer.
[0191] S55, Two-layer independent quantification statistics.
[0192] The first layer provides independent transmit and receive statistics for both interfaces: each interface independently tracks packet reception, transmission, packet loss, and anomaly counts, supporting fault location and performance evaluation by network segment; the second layer provides clone-specific statistics: through... , The system counts the number of successful and failed clones, quantifies system memory load and packet loss conditions on secondary network segments, and ensures that the data is independent and traceable.
[0193] S56. Automatic self-healing and alarm closed loop without restart: When the test load decreases and the buffer pool balance B recovers to greater than 0, the packet cloning logic automatically recovers, and the secondary network segment test function self-heals and recovers. The entire process requires no device restart, and the self-healing process does not affect the main interface service. If the cloning failure count continues to exceed the set threshold, a memory load alarm will be continuously reported, prompting testers to optimize test traffic parameters, thus achieving a complete closed loop of fault monitoring, alarming, and self-healing.
[0194] This technical solution employs a network segment priority strategy that prioritizes the primary interface and degrades the secondary network interface. It utilizes an on-demand allocation mechanism that requests cloning resources only when the secondary network interface is UP and ready. Before each cloning operation, the remaining buffer pool capacity is checked in real-time, and the primary interface is given priority to preempt memory allocation. When cloning fails due to memory pool exhaustion, only the cloned copy corresponding to the secondary network interface is discarded, while the original packets are retained for processing by the primary network interface, achieving one-way graceful degradation and fault tolerance in memory-constrained scenarios. A dual-layer independent quantitative statistical mechanism is constructed, consisting of independent transmit / receive statistics for both interfaces and dedicated cloning statistics. This mechanism tracks transmit / receive data, packet loss, abnormal data, and the number of cloning successes and failures for each network segment. The packet cloning process automatically resumes after the buffer pool capacity is restored, and a high memory load alarm is reported when the cloning failure count exceeds a threshold. It effectively solves the problems of limited SRAM resources in embedded MCUs, easy memory exhaustion in high-load testing scenarios, global paralysis of traditional dual-instance solutions, lack of self-healing, and lack of quantitative statistics. Under extreme load scenarios, it prioritizes ensuring that the core automotive testing business is not interrupted or degraded, and realizes a complete closed loop of fault monitoring, threshold judgment, alarm prompts, and autonomous self-healing without restart, thereby improving the operational reliability and fault traceability of the system under high load conditions.
[0195] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A single-port dual-protocol stack vehicle Ethernet multi-segment isolation test method for an embedded device with a single-path physical Ethernet media access controller, characterized in that, Includes the following steps: Register a primary network interface and a secondary network interface, wherein the primary network interface and the secondary network interface are independent of each other; The main network interface and the auxiliary network interface share the same media access control address; the main network interface and the auxiliary network interface share the same set of Ethernet transceiver hardware; The main network interface and the auxiliary network interface are respectively bound to different Internet Protocol (IP) segments, and the main network interface and the auxiliary network interface each maintain independent Address Resolution Protocol (ARP) status and Internet Protocol (IP) status. The system uses a single packet receiving thread to perform conditional judgment and cloning processing on each received original packet to obtain a cloned copy of the packet. The original message is delivered to the primary network interface, and the cloned copy of the message is delivered to the secondary network interface. The primary network interface and the secondary network interface respectively respond to the packets according to the network segment rules they are bound to.
2. The single-port dual-protocol stack multi-net segment isolation test method for in-vehicle Ethernet of claim 1, wherein The main network interface performs a complete Ethernet hardware initialization, completes the register configuration of the Media Access Controller and Direct Memory Access Controller; enables the peripheral clock, configures Ethernet interrupt enable and priority, and creates a unique packet receiving thread. The auxiliary network interface completes registration using a derived initialization operation, reuses the hardware resources of the main network interface, and does not perform a hardware initialization operation.
3. The single-port dual-protocol-stack multi-net segment isolation test method for in-vehicle Ethernet of claim 2, wherein The auxiliary network interface calls the lightweight derived registration function to complete the software registration, skipping the underlying hardware initialization entry point throughout the process. It does not perform hardware initialization configuration, direct memory access controller register initialization, enable peripheral clock, or create new threads.
4. The single-port dual-protocol-stack multi-net segment isolation test method for in-vehicle Ethernet of claim 3, wherein The secondary network interface performs a memory copy of the media access control address field, replicating the media access control address of the primary network interface; it reuses the maximum transmission unit, broadcast flag, address resolution protocol enable flag, multicast identifier, and link status parameters of the primary network interface; the secondary network interface mounts Internet Protocol output callback and underlying frame transmission callback, but does not bind to an independent hardware channel or request an independent direct memory access controller descriptor.
5. The single-port dual-protocol stack in-vehicle Ethernet multi-net segment isolation test method of claim 1, wherein When the physical link of the main network interface is ready, the protocol stack enable and link ready state of the auxiliary network interface are activated simultaneously. Changes in the link and protocol state of the auxiliary network interface do not affect the working state of the main network interface in the reverse direction. When the primary network interface link is disconnected, the secondary network interface link is simultaneously set to a disconnected state, and the address resolution protocol cache table and neighbor status table of the secondary network interface are cleared.
6. The single-port dual-protocol stack isolation test method for multi-network segment of vehicle Ethernet according to claim 1, characterized in that After receiving a packet, the receiving thread checks the link working status of the secondary network interface. Only when the secondary network interface is in the ready-enabled state is the packet cloning operation performed. The received packets are checked for frame length, cyclic redundancy check, and frame header validity. Only valid frames participate in the cloning and distribution.
7. The single-port dual-protocol-stack multi-net segment isolation test method for in-vehicle Ethernet of claim 6, wherein It also includes the following steps for handling memory-constrained scenarios: before each cloning, the remaining amount of the buffer pool is detected in real time, and the primary network interface is given priority to preempt memory; when the memory pool is exhausted and cloning fails, the cloned copy corresponding to the secondary network interface is discarded, and the original message is retained for processing by the primary network interface.
8. The single-port dual-protocol-stack multi-net segment isolation test method for in-vehicle Ethernet of claim 7, wherein For the memory-constrained scenario, a dual-layer independent quantization and statistical mechanism is adopted: the first layer is the independent send and receive statistics of the two interfaces, which respectively counts the number of received packets, sent packets, lost packets, and anomalies; the second layer is the clone-specific statistics, which counts the number of successful clones and the number of failed clones; after the buffer pool is detected to be restored, the message cloning process is automatically resumed; when the number of failed clones exceeds the set threshold, a high memory load alarm is reported.
9. The single-port dual-protocol stack vehicle Ethernet multi-segment isolation test method according to claim 1, characterized in that... It also includes detailed steps for hardware system initialization and power-on timing calibration: Upon initial power-up, the clock for the general purpose input / output port is enabled, and the reset pin level is pre-pulled high before the pin is configured to output mode. Once the media-independent interface reference clock is fully stable, the physical layer chip reset signal is released.
10. A single-port dual-protocol stack vehicle-mounted Ethernet multi-segment isolation test system, comprising: The module features a dual-network interface differentiated registration module, a dual-protocol stack independent network segment parameter configuration isolation module, and a single-threaded packet cloning and distribution independent processing module; its key features are: The dual network interface differentiated registration module is used to register mutually independent main network interfaces and auxiliary network interfaces, and to control the auxiliary network interface to reuse the hardware resources of the main network interface without repeatedly performing hardware initialization. The dual-protocol stack independent network segment parameter configuration isolation module is used to control the main network interface and the auxiliary network interface to share the same medium access control address and Ethernet transceiver hardware, and to bind different Internet protocol network segments respectively, each maintaining independent address resolution protocol status and Internet protocol status. The single-threaded packet cloning and distribution independent processing module is used to perform condition judgment and cloning processing on the received original packets through the system's only packet receiving thread, and deliver the original packets to the main network interface and the cloned copies to the auxiliary network interface, so that the two network interface instances can complete the packet response processing according to their own network segment rules.
