A switch and switching method based on CAN network multicast technology

Through the switch based on CAN network multicast technology, the forwarding table and data cache modules are used to optimize data transmission, and the problems of communication conflicts and low bandwidth utilization in traditional CAN bus direct connection solutions are solved, achieving efficient data transmission and system real-time improvement.

CN120128559BActive Publication Date: 2025-08-12ANHUI ZHONGKE ZHONGHUAN INTELLIGENT EQUIP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510615117.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2025-08-12
Estimated Expiration
2045-05-14

AI Technical Summary

Technical Problem

The traditional CAN bus direct connection solution leads to increased communication conflicts and reduced bandwidth utilization when the network scale is expanded, and cannot solve the problem of multiple devices communicating simultaneously, affecting the real-time nature of the system.

Method used

Switches based on CAN network multicast technology are adopted to record the mapping relationship between the identifier of each target device and the CAN port through forwarding tables, ensuring accurate forwarding of data frames, avoid broadcasting data, reduce unnecessary bus usage, and optimize data transmission through data caching, priority scheduling and aging mechanisms.

Benefits of technology

It effectively avoids broadcast data, reduces bus usage, improves network flexibility and adaptability, ensures that critical data transmission is not delayed or lost, and improves the real-time and bandwidth utilization of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120128559B_ABST
    Figure CN120128559B_ABST
Patent Text Reader

Abstract

The present invention discloses a switch and a switching method based on CAN network multicast technology, relating to the field of switches, comprising: a port module and a processor; wherein the port module includes multiple independent CAN ports, and the multiple independent CAN ports are electrically connected to the processor respectively; the processor is pre-set with a forwarding table, and the forwarding table records the identifiers of the CAN ports and corresponding target devices; when a CAN port receives a data frame, the processor is used to parse the data frame to obtain the identifier of the target device of the data frame, and find the corresponding CAN port in the forwarding table according to the identifier of the target device, and forward the data frame to the corresponding CAN port. By maintaining the mapping relationship between the identifier of each target device and the corresponding CAN port, the present invention can avoid broadcasting data and reduce unnecessary bus occupancy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of switches, and in particular to a switch and a switching method based on CAN network multicast technology. Background Art

[0002] In the fields of modern industrial automation, intelligent transportation, automotive electronics and intelligent manufacturing, CAN (Controller Area Network) bus is widely used in distributed control systems due to its high reliability, real-time performance and anti-interference ability. However, traditional CAN bus direct connection solutions, such as Figure 1 and Figure 2 As shown in the figure, the broadcast communication mode is adopted, and all nodes share the same bus. As the network scale expands, communication conflicts will increase and bandwidth utilization will decrease. It cannot solve the problem of multiple devices communicating at the same time, affecting the real-time performance of the system. Summary of the Invention

[0003] In order to solve the technical problems existing in the background technology, the present invention proposes a switch and a switching method based on CAN network multicast technology.

[0004] In a first aspect, the present invention provides a switch based on CAN network multicast technology, comprising: a port module and a processor; wherein the port module comprises a plurality of independent CAN ports, each of which is electrically connected to the processor; and the processor is pre-set with a forwarding table, wherein the forwarding table records identifiers of the CAN ports and corresponding target devices.

[0005] When a CAN port receives a data frame, the processor is used to parse the data frame to obtain the identifier of the target device of the data frame, and find the corresponding CAN port in the forwarding table according to the identifier of the target device, and forward the data frame to the corresponding CAN port.

[0006] Preferably, when the corresponding CAN port cannot be found in the forwarding table according to the identifier of the target device, the processor broadcasts the data frame to all CAN ports until the target device responds; when the target device responds and sends the data frame through a certain CAN port, the processor updates the forwarding table according to the CAN port and the identifier that is not recorded in the forwarding table.

[0007] Preferably, it also includes a data cache module, multiple independent CAN ports are electrically connected to the data cache module respectively, the data cache module is electrically connected to the processor through a high-speed bus, and the data cache module is used to temporarily store the received CAN data frames.

[0008] Preferably, a priority scheduling strategy and arbitration rules are preset in the processor; the processor is also used to determine the priority of each data frame according to the arbitration rules when multiple CAN ports simultaneously receive or send multiple data frames, and forward each data frame according to its priority from high to low according to the priority scheduling strategy.

[0009] Preferably, the processor is preset with an aging mechanism, and the processor is also used to age the forwarding table according to the aging mechanism; wherein the aging mechanism means that the mapping relationship between the identifier of the target device and the CAN port in the forwarding table will automatically become invalid after a preset cumulative time of non-use.

[0010] Preferably, it also includes a remote management module, which is electrically connected to the processor and supports remote debugging and configuration via a serial port, Ethernet or USB to improve operation and maintenance efficiency.

[0011] In a second aspect, the present invention further proposes a switching method based on CAN network multicast technology, comprising:

[0012] Get the data frame;

[0013] Parsing the data frame to obtain an identifier of a target device of the data frame;

[0014] According to the identifier of the target device, the corresponding CAN port is found in the preset forwarding table, and the data frame is forwarded to the corresponding CAN port; wherein the forwarding table records the identifier of the CAN port and the corresponding target device.

[0015] Preferably, when the corresponding CAN port cannot be found in the forwarding table according to the identifier of the target device, the data frame is broadcast to all CAN ports until the target device responds; when the target device responds and sends the data frame through a certain CAN port, the forwarding table is updated according to the CAN port and the identifier not recorded in the forwarding table.

[0016] Preferably, after acquiring the data frame, the method further includes: temporarily storing the CAN data frame.

[0017] Preferably, in the process of forwarding the data frame to the corresponding CAN port, when multiple CAN ports receive or send multiple data frames at the same time, the priority of each data frame is determined according to the preset arbitration rules, and each data frame is forwarded according to its priority from high to low according to the preset priority scheduling strategy.

[0018] Preferably, the forwarding table has an aging mechanism; wherein the aging mechanism means that the mapping relationship between the identifier of the target device and the CAN port in the forwarding table will automatically become invalid after being unused for a preset cumulative time.

[0019] The switch and switching method proposed in this invention, based on CAN network multicast technology, uses a forwarding table to record the mapping between each target device identifier (CAN ID) and its corresponding CAN port. When the switch receives a data frame, it searches the forwarding table based on the target device identifier (CAN ID) in the data frame to determine the CAN port to which the data frame should be forwarded. By maintaining the mapping between each target device identifier (CAN ID) and its corresponding CAN port, the present invention avoids broadcasting data and reduces unnecessary bus usage. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 Schematic diagram of the traditional CAN bus direct connection solution.

[0021] Figure 2 Schematic diagram of communication conflicts caused by traditional CAN bus direct connection solution.

[0022] Figure 3 This is a schematic diagram of the connection between a switch based on CAN network multicast technology and an external target device in an embodiment of the present invention.

[0023] Figure 4 This is a schematic diagram of communication between a switch and an external target device based on CAN network multicast technology in an embodiment of the present invention.

[0024] Figure 5 This is a schematic diagram of the structure of a switch based on CAN network multicast technology in one embodiment of the present invention.

[0025] Figure 6 The figure is a flow chart of an exchange method based on CAN network multicast technology in one embodiment of the present invention. DETAILED DESCRIPTION

[0026] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments of the present invention can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0027] First, refer to Figure 3-Figure 5 The present invention proposes a switch based on CAN network multicast technology, comprising: a port module and a processor; wherein the port module comprises a plurality of independent CAN ports, each CAN port being used to receive a data frame or forward a data frame to a target device; the plurality of independent CAN ports are respectively electrically connected to the processor;

[0028] The processor is pre-set with a forwarding table, which records the identifiers of the CAN ports and the corresponding target devices;

[0029] When a CAN port receives a data frame, the processor is used to parse the data frame, obtain the identifier of the target device of the data frame, and find the corresponding CAN port in the forwarding table according to the identifier of the target device, and forward the data frame to the corresponding CAN port, thereby forwarding it to the target device.

[0030] Each CAN interface in this embodiment is used to connect to a CAN network or target device, and each port can receive data frames from other CAN networks or target devices and send data to other networks or target devices.

[0031] The present invention uses a forwarding table to record the mapping between each target device's identifier (CAN ID) and its corresponding CAN port. When the switch receives a data frame, it searches the forwarding table based on the target device's identifier (CAN ID) in the data frame to determine the CAN port to which the data frame should be forwarded. By maintaining the mapping between each target device's identifier (CAN ID) and its corresponding CAN port, the present invention avoids broadcast data and reduces unnecessary bus usage.

[0032] It is important to know that each target device has a unique identifier (CAN ID).

[0033] In this embodiment, when the identifier of the target device is not recorded in the forwarding table, the processor broadcasts the data frame to all CAN ports until the target device responds; when the target device responds and sends the data frame through a certain CAN port, the processor updates the forwarding table based on the CAN port and the identifier that is not recorded in the forwarding table.

[0034] In practice, when a target ID is not recorded in the forwarding table, meaning a data frame is received from a new device, the switch broadcasts the message, waits for a response from the target device, and updates the forwarding table based on the response, storing the device ID and receiving port. If data is received from the same device in the future, the switch can directly search the forwarding table and send the frame to the corresponding port.

[0035] This configuration in this embodiment ensures that even if the target device's identifier (CAN ID) has not yet been learned into the forwarding table, data can still be delivered to all possible devices, effectively preventing data loss. Furthermore, once the target device responds and sends a data frame to the switch, the processor updates the forwarding table, preventing further broadcast (i.e., flooding). This embodiment enables the switch to dynamically adapt to changes in network topology, effectively improving its flexibility and adaptability.

[0036] Each CAN port supports CAN 2.0A and CAN 2.0B, and can be expanded to CAN FD to increase data transmission rate.

[0037] In this embodiment, a data cache module is also included. Multiple independent CAN ports are electrically connected to the data cache modules respectively. The data cache module is electrically connected to the processor through a high-speed bus. The data cache module is used to temporarily store received CAN data frames to prevent frame loss caused by data arriving too fast or processing delays.

[0038] In this embodiment, by caching received frames, the switch can achieve more efficient scheduling in data processing. Caching can prevent network congestion caused by excessive instantaneous traffic and ensure that all data frames can be effectively received, processed, and correctly forwarded.

[0039] In one specific embodiment, the data cache module adopts DMA (direct memory access).

[0040] In this embodiment, a priority scheduling strategy and arbitration rules are preset in the processor; the processor is also used to determine the priority of each data frame according to the arbitration rules when multiple CAN ports simultaneously receive or send multiple data frames, and forward each data frame according to its priority from high to low according to the priority scheduling strategy.

[0041] This embodiment can ensure that high-priority data frames are transmitted first according to the priority scheduling strategy and arbitration rules when the CAN port is highly loaded, so as to ensure that the data transmission of the system's critical tasks is not delayed or lost, and avoid transmission conflicts.

[0042] In this embodiment, the processor is preset with an aging mechanism, and the processor is also used to age the forwarding table according to the aging mechanism; wherein the aging mechanism means that the mapping relationship between the identifier (CAN ID) of the target device and the CAN port in the forwarding table will automatically become invalid after a preset cumulative time of non-use.

[0043] This embodiment uses an aging mechanism to periodically remove identifiers of target devices that have not been used for a long time, ensuring that the forwarding table is up-to-date, preventing outdated information from being stored in the forwarding table, and reducing unnecessary network overhead. The aging mechanism can effectively prevent data forwarding errors caused by outdated information, especially in situations where the network topology frequently changes.

[0044] In this embodiment, a remote management module is also included. The remote management module is electrically connected to the processor and supports remote debugging and configuration via a serial port, Ethernet or USB to improve operation and maintenance efficiency.

[0045] In one specific embodiment, the processor is an ARM Cortex-M embedded processor.

[0046] Among them, the port module in this embodiment adopts the S32K358 module, which supports 8 CAN port communications.

[0047] Second, as Figure 6 As shown, the present invention also proposes a switching method based on CAN network multicast technology, comprising:

[0048] Get the data frame;

[0049] Parsing the data frame to obtain an identifier of a target device of the data frame;

[0050] According to the identifier of the target device, the corresponding CAN port is found in the preset forwarding table, and the data frame is forwarded to the corresponding CAN port; wherein the forwarding table records the identifier of the CAN port and the corresponding target device.

[0051] In this embodiment, when the corresponding CAN port cannot be found in the forwarding table according to the identifier of the target device, the data frame is broadcast to all CAN ports until the target device responds; when the target device responds and sends a data frame through a certain CAN port, the forwarding table is updated according to the CAN port and the identifier that is not recorded in the forwarding table.

[0052] In this embodiment, after acquiring the data frame, the method further includes:

[0053] Temporarily store the CAN data frame.

[0054] In this embodiment, in the process of forwarding the data frame to the corresponding CAN port, when multiple CAN ports receive or send multiple data frames at the same time, the priority of each data frame is determined according to the preset arbitration rules, and each data frame is forwarded according to its priority from high to low according to the preset priority scheduling strategy.

[0055] The forwarding table in this embodiment has an aging mechanism; wherein the aging mechanism means that the mapping relationship between the identifier (CAN ID) of the target device and the CAN port in the forwarding table will automatically become invalid after a preset cumulative time of non-use.

[0056] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.

Claims

1. A switch based on CAN network multicast technology, characterized in that: include: A port module, a direct memory access (DMA) and a processor; wherein the port module includes multiple independent CAN ports, each of which is electrically connected to the DMA, and the DMA is electrically connected to the processor via a high-speed bus; a forwarding table is preset in the processor, and the forwarding table records the identifiers of the CAN ports and the corresponding target devices; the DMA is used to temporarily store received CAN data frames; When a CAN port receives a data frame, the processor is used to parse the data frame to obtain the identifier of the target device of the data frame, and find the corresponding CAN port in the forwarding table according to the identifier of the target device, and forward the data frame to the corresponding CAN port; When the corresponding CAN port cannot be found in the forwarding table according to the identifier of the target device, the processor broadcasts the data frame to all CAN ports until the target device responds; when the target device responds and sends a data frame through a certain CAN port, the processor updates the forwarding table according to the CAN port and the identifier that is not recorded in the forwarding table.

2. The switch based on CAN network multicast technology according to claim 1, characterized in that: The processor is preset with priority scheduling strategies and arbitration rules; the processor is also used to determine the priority of each data frame according to the arbitration rules when multiple CAN ports receive or send multiple data frames at the same time, and forward each data frame according to its priority from high to low according to the priority scheduling strategy.

3. The switch based on CAN network multicast technology according to claim 1, characterized in that: The processor is preset with an aging mechanism, and the processor is also used to age the forwarding table according to the aging mechanism; wherein the aging mechanism means that the mapping relationship between the identifier of the target device and the CAN port in the forwarding table will automatically become invalid after a preset cumulative time of non-use.

4. A switching method based on CAN network multicast technology, applied to the switch based on CAN network multicast technology according to any one of claims 1 to 3, characterized in that: include: Get the data frame and temporarily store the CAN data frame in direct storage access; Parsing the data frame to obtain an identifier of a target device of the data frame; According to the identifier of the target device, a corresponding CAN port is found in a preset forwarding table, and the data frame is forwarded to the corresponding CAN port; wherein the forwarding table records the identifier of the CAN port and the corresponding target device; When the corresponding CAN port cannot be found in the forwarding table according to the identifier of the target device, the data frame is broadcast to all CAN ports until the target device responds; when the target device responds and sends a data frame through a certain CAN port, the forwarding table is updated according to the CAN port and the identifier that is not recorded in the forwarding table.

5. The switching method based on CAN network multicast technology according to claim 4 is characterized in that: In the process of forwarding the data frame to the corresponding CAN port, when multiple CAN ports receive or send multiple data frames at the same time, the priority of each data frame is determined according to the preset arbitration rules, and each data frame is forwarded according to its priority from high to low according to the preset priority scheduling strategy.

6. The switching method based on CAN network multicast technology according to claim 4, characterized in that: The forwarding table has an aging mechanism; the aging mechanism means that the mapping relationship between the identifier of the target device and the CAN port in the forwarding table will automatically become invalid after a preset cumulative time of non-use.

Citation Information

Patent Citations

  • CAN frame sending method, device and system, computing equipment and storage medium

    CN117692408A