Virtualization method and device of can equipment and medium
By using scheduler and CAN proxy modules in Kubernetes environment, the virtualization scheduling process of CAN devices is simplified, disaster recovery capabilities are improved, and QOS problems are solved, and the problems of high complexity and poor disaster recovery in CAN devices in the existing technology are solved.
Patent Information
- Application Number
- CN202411544685.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-03-04
AI Technical Summary
In Kubernetes environment, the virtualization of CAN devices has problems with complex non-peer topology management, high scheduling complexity, poor disaster recovery, and QOS of shared CAN devices.
The scheduler schedules physical nodes according to the CAN application deployment request, creates a container group and allocates virtual CAN devices, and the virtual CAN device encapsulates CAN protocol messages, and performs route selection and forwarding control through the CAN proxy module.
The scheduling process of CAN equipment is simplified, disaster recovery capabilities are improved, and multi-tasks are isolated and guaranteed through the QOS control unit, solving the QOS problem of shared CAN equipment.
Smart Images

Figure CN119557046A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of device virtualization, and in particular relates to a virtualization method, device and medium for CAN devices. Background Art
[0002] Currently, the virtualization of CAN (Controller Area Network) devices in the Kubernetes environment mainly relies on two methods: device passthrough and virtualization technology. Device passthrough allows physical CAN devices to be assigned directly to containers, ensuring that containers can directly access the functions of physical CAN devices. This method mounts the file descriptor of the CAN device (such as / dev / can0) into the container, allowing the container to access the CAN device as if it were a local device. In addition, vxcan (virtual CAN) technology is also used to virtualize CAN devices, which enables multiple containers to communicate on a virtual CAN bus by creating a virtual CAN network interface.
[0003] Although the existing technology has solved the problem of CAN device virtualization to some extent, it still has the following major defects:
[0004] 1. Complex management of non-peer topology: In many environments, the configuration of CAN devices is not equal. Some CAN devices are on node A, and some CAN devices are on node B. It is very complicated to globally maintain the topology of CAN devices.
[0005] 2. High scheduling complexity: In the Kubernetes environment, users need to sense and specify the node where the target CAN device exists, otherwise the target node will be incorrectly scheduled without the required CAN device. Even if scheduling is performed through the Deviceplugin technology, it is necessary to combine complex topologies for scheduling, and the scheduling complexity is very high, and scheduling often fails. Especially for applications that need to mount multiple CAN devices at the same time, only a few nodes meet their scheduling requirements.
[0006] 3. Poor disaster tolerance: When the node where the container is located goes down, the target node that triggers the migration may not have the required CAN devices or insufficient containers. Due to the strong binding between containers and CAN devices, the downtime migration function is limited, affecting business operations.
[0007] 4. QOS issues of shared CAN devices: The CAN device sharing function is implemented through vxcan. Since vxcan does not support QOS control, it cannot respond to QOS issues under multi-task sharing, resulting in mutual impact between multiple tasks. Summary of the invention
[0008] In view of the above problems, the present invention is proposed to provide a method for virtualizing a CAN device and a corresponding apparatus for virtualizing a CAN device and a computer-readable medium that overcome the above problems or at least partially solve the above problems.
[0009] The present invention discloses a virtualization method for a CAN device, comprising:
[0010] The scheduler schedules physical nodes according to the CAN application deployment request;
[0011] The scheduled physical node creates a container group based on the CAN application deployment request and allocates a virtual CAN device;
[0012] The virtual CAN device encapsulates the CAN protocol message to obtain the VCAN protocol message;
[0013] The can proxy module performs routing operations and forwarding control based on the vcan protocol messages.
[0014] As a further improvement of the present invention, before the step of the scheduler scheduling the physical node according to the CAN application deployment request, the step further includes:
[0015] The CAN agent module collects the local physical CAN device topology and reports it to the scheduler.
[0016] As a further improvement of the present invention, the step of scheduling the physical node according to the CAN application deployment request by the scheduler includes:
[0017] Select the physical node that meets the CAN application deployment request for scheduling;
[0018] If all physical nodes do not meet the CAN application deployment request, the physical node with the least CAN devices will be selected for scheduling.
[0019] As a further improvement of the present invention, the CAN application deployment request includes: the number of CAN devices, and the step of allocating virtual CAN devices includes:
[0020] According to the number of CAN devices, a corresponding number of virtual CAN devices are allocated.
[0021] As a further improvement of the present invention, the step of obtaining a vcan protocol message after the virtual can device encapsulates the can protocol message includes:
[0022] The container group application on the physical node initiates a request to the virtual CAN device specified in the container group;
[0023] After receiving the CAN protocol message, the virtual CAN device encapsulates the physical CAN device and QoS information into the message header and converts it into a vCAN protocol message;
[0024] The virtual CAN device is forwarded to the CAN proxy module on the physical node through the TCP protocol.
[0025] As a further improvement of the present invention, when the CAN proxy module performs routing operations and forwarding control according to the VCAN protocol message, the CAN proxy module decapsulates the VCAN protocol message to obtain the target physical CAN device, Qos information, and CAN message.
[0026] As a further improvement of the present invention, the steps of the CAN proxy module performing routing operations and forwarding control according to the VCAN protocol message include:
[0027] The routing module in the CAN proxy module selects the route according to the target physical CAN device;
[0028] The QoS control unit in the can proxy module controls the forwarding rate and bandwidth of the message.
[0029] As a further improvement of the present invention, the step of the routing module in the CAN proxy module performing routing according to the target physical CAN device includes:
[0030] If the local machine has a target physical CAN device, the message will be forwarded to the target physical CAN device;
[0031] If the target physical CAN device does not exist on the local machine, the physical node with the target physical CAN device is found according to the global topology relationship, and the original message is forwarded to the CAN proxy module of the target physical node;
[0032] The CAN proxy module of the target physical node performs secondary decapsulation, routing and forwarding on the original message.
[0033] The present invention also provides a virtualization device for a CAN device, characterized in that it is used to implement the above-mentioned virtualization method, and the virtualization device comprises:
[0034] Scheduler, used to schedule physical nodes according to CAN application deployment requests;
[0035] The CAN proxy module is set in each CAN device to allocate virtual CAN devices to container groups and forward messages according to the requests of virtual CAN devices.
[0036] Virtual CAN devices are mounted into containers based on CAN application deployment requests;
[0037] The vcan protocol message module is used to encapsulate and convert can protocol messages.
[0038] As a further improvement of the present invention, the can proxy module includes:
[0039] Decapsulation module, used to decapsulate vcan protocol messages;
[0040] The routing module is used to select the route according to the target physical CAN device;
[0041] The QoS control unit is used to control the forwarding rate and bandwidth of message forwarding.
[0042] The present invention also provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is loaded and executed by a processor to implement the above virtualization method.
[0043] Compared with the prior art, the present invention has the following beneficial effects: the present invention encapsulates the CAN protocol through a virtual CAN device, shields the coupling relationship between the user application and the physical CAN device through a CAN proxy module, avoids the complexity of scheduling, and realizes the forwarding control of communication requests of different CAN applications through the CAN proxy module. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The specific embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings, wherein:
[0045] Figure 1 This is a flow chart of the virtualization method described in Example 1;
[0046] Figure 2 This is a flowchart of steps S100 to S102 described in Example 1;
[0047] Figure 3 This is a flowchart of steps S1030 to S104 described in Example 1. DETAILED DESCRIPTION
[0048] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0049] Example 1
[0050] This embodiment provides a virtualization method for a CAN device, such as Figures 1 to 3 As shown, the steps include:
[0051] S100, the CAN proxy module collects the local physical CAN device topology and reports it to the scheduler to obtain the global topology;
[0052] S101, the scheduler schedules the physical nodes according to the CAN application deployment request;
[0053] The user initiates a CAN application deployment request. The scheduler first selects the physical node that meets the CAN application deployment request for scheduling based on the CAN application deployment request. If all physical nodes do not meet the CAN application deployment request, the physical node with the least CAN devices is selected as the suboptimal scheduling. Based on this, resources available for optimal scheduling can be reserved.
[0054] S102, the scheduled physical node creates a container group based on the CAN application deployment request and allocates a virtual CAN device;
[0055] In actual applications, the scheduling physical node allocates a corresponding number of virtual CAN devices according to the number of CAN devices, such as virtual CAN1, virtual CAN2, and the virtual CAN device includes the mapping of physical CAN device numbers and QoS control.
[0056] S103, after the virtual CAN device processes the CAN protocol message, a VCAN protocol message is obtained:
[0057] First, the container group application on the physical node initiates a request to the virtual CAN device specified inside the container group. The internally specified virtual CAN device refers to the CAN device that the user application believes needs to be used for communication. After receiving the CAN protocol message, the virtual CAN device encapsulates the physical CAN device and QoS information into the message header and converts it into a vCAN protocol message. Subsequently, the virtual CAN device forwards it to the CAN proxy module on the physical node through the TCP protocol.
[0058] S104, the can proxy module performs routing operations and forwarding control according to the vcan protocol message:
[0059] After the CAN proxy module receives the VCAN protocol message, the CAN proxy module decapsulates the VCAN protocol message to obtain the target physical CAN device, Qos information, and CAN message.
[0060] The routing module in the CAN proxy module selects the route according to the target physical CAN device; if the target physical CAN device exists on the local machine (i.e. the physical machine where the CAN proxy module is located), the message is forwarded to the target physical CAN device; if the target physical CAN device does not exist on the local machine, the physical node with the target physical CAN device is found according to the global topology relationship, and the original message is forwarded to the CAN proxy module of the target physical node. The CAN proxy module of the target physical node performs secondary decapsulation, routing and forwarding on the original message; for example, CAN0, communication is directly carried out through it. If it does not exist, it is forwarded to other hosts with CAN0 devices.
[0061] At the same time, the QoS control unit in the CAN proxy module controls the forwarding rate and bandwidth of the message.
[0062] The virtualization method of this embodiment mainly includes two processes: the scheduling process of the CAN device and the request process of the CAN protocol. Through the global CAN topology and CAN protocol encapsulation agent method, the decoupling of the CAN virtual device and the underlying physical CAN device is realized, so that the scheduling no longer needs to be strongly bound to the underlying topology, thereby improving the availability and disaster recovery capability of the CAN virtualization method; and combined with the QoS control capability, multiple tasks are isolated and guaranteed.
[0063] This embodiment encapsulates the CAN protocol through a virtual CAN device, and shields the coupling relationship between the user application and the physical CAN device through the CAN proxy module. It only needs to mount the vCAN device to the user application. The user application does not need to pay attention to whether the physical machine has the target CAN device, such as whether there is a CAN0 device or a CAN1 device. The message can be forwarded to the host with the corresponding CAN device through vCAN protocol encapsulation and CAN proxy. The complexity of scheduling is avoided, and the forwarding control of communication requests of different CAN applications is realized through the CAN proxy module.
[0064] Example 2
[0065] This embodiment provides a virtualization device for a CAN device, which is used to implement the virtualization method in Embodiment 1. Figure 2 and Figure 3 As shown, the virtualization device includes: a scheduler, a CAN proxy module, a virtual CAN device, and a VCAN protocol message module; wherein the scheduler is used to schedule physical nodes according to CAN application deployment requests; the CAN proxy module is set in each CAN device, and is used to allocate virtual CAN devices to container groups, and is also used to forward messages according to requests of virtual CAN devices;
[0066] The virtual CAN device is mounted into the container according to the CAN application deployment request; the vCAN protocol message module is used to encapsulate and convert the CAN protocol messages.
[0067] Specifically, the CAN proxy module includes: a decapsulation module, a routing module, and a QoS control unit. The decapsulation module is used to decapsulate the VCAN protocol message to obtain the target physical CAN device, QoS information, and CAN message; the routing module is used to perform routing according to the target physical CAN device. If the target physical CAN device exists on the local machine, the message is forwarded to the target physical CAN device; if the target physical CAN device does not exist on the local machine, the physical node with the target physical CAN device is found according to the global topology relationship, and the original message is forwarded to the CAN proxy module of the target physical node. The CAN proxy module of the target physical node performs secondary decapsulation, routing, and forwarding on the original message; the QoS control unit is used to control the forwarding rate and bandwidth of message forwarding.
[0068] For the specific implementation process and beneficial effects of this embodiment, please refer to Embodiment 1, which will not be described in detail here.
[0069] Example 3
[0070] This embodiment provides a computer-readable storage medium, in which at least one instruction is stored. The at least one instruction is loaded and executed by a processor to implement the virtualization method in Embodiment 1.
[0071] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer-readable storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0072] As is known to those of ordinary skill in the art, the term computer-readable storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer-readable storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0073] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Therefore, any modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention shall still fall within the scope of the technical solution of the present invention.
Claims
1. A virtualization method for a CAN device, characterized in that: include: The scheduler schedules physical nodes according to the CAN application deployment request; The scheduled physical node creates a container group based on the CAN application deployment request and allocates a virtual CAN device; The virtual CAN device encapsulates the CAN protocol message to obtain the VCAN protocol message; The can proxy module performs routing operations and forwarding control based on the vcan protocol messages.
2. The virtualization method according to claim 1, characterized in that: Before the step of the scheduler scheduling the physical node according to the CAN application deployment request, the step further includes: The CAN agent module collects the local physical CAN device topology and reports it to the scheduler.
3. The virtualization method according to claim 1, characterized in that: The step of scheduling the physical node according to the CAN application deployment request by the scheduler includes: Select the physical node that meets the CAN application deployment request for scheduling; If all physical nodes do not meet the CAN application deployment request, the physical node with the least CAN devices will be selected for scheduling.
4. The virtualization method according to claim 1, characterized in that: The CAN application deployment request includes: the number of CAN devices, and the step of allocating virtual CAN devices includes: According to the number of CAN devices, a corresponding number of virtual CAN devices are allocated.
5. The virtualization method according to claim 1, characterized in that: The step of obtaining a vcan protocol message after the virtual can device encapsulates the can protocol message comprises: The container group application on the physical node initiates a request to the virtual CAN device specified in the container group; After receiving the CAN protocol message, the virtual CAN device encapsulates the physical CAN device and QoS information into the message header and converts it into a vCAN protocol message; The virtual CAN device is forwarded to the CAN proxy module on the physical node through the TCP protocol.
6. The virtualization method according to claim 1, characterized in that: When the CAN proxy module performs routing operations and forwarding control according to the VCAN protocol message, the CAN proxy module decapsulates the VCAN protocol message to obtain the target physical CAN device, QoS information, and CAN message.
7. The virtualization method according to claim 6, characterized in that: The steps of the CAN proxy module performing routing operations and forwarding control according to the VCAN protocol message include: The routing module in the CAN proxy module selects the route according to the target physical CAN device; The QoS control unit in the can proxy module controls the forwarding rate and bandwidth of the message.
8. The virtualization method according to claim 7, characterized in that: The step of the routing module in the CAN proxy module performing routing according to the target physical CAN device includes: If the local machine has a target physical CAN device, the message will be forwarded to the target physical CAN device; If the target physical CAN device does not exist on the local machine, the physical node with the target physical CAN device is found according to the global topology relationship, and the original message is forwarded to the CAN proxy module of the target physical node; The CAN proxy module of the target physical node performs secondary decapsulation, routing and forwarding on the original message.
9. A virtualization device for a CAN device, characterized in that: Used to implement the virtualization method according to any one of claims 1 to 8, the virtualization device comprises: Scheduler, used to schedule physical nodes according to CAN application deployment requests; The CAN proxy module is set in each CAN device to allocate virtual CAN devices to container groups and forward messages according to the requests of virtual CAN devices. Virtual CAN devices are mounted into containers based on CAN application deployment requests; The Vcan protocol message module is used to encapsulate and convert CAN protocol messages.
10. A computer-readable storage medium, characterized in that: The readable storage medium stores at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the virtualization method according to any one of claims 1 to 8.