This application relates to the field of communications technologies, and in particular, to an in-vehicle gateway communication method, an in-vehicle gateway, and an intelligent vehicle.
A Controller Area Network (CAN) protocol is a serial communication protocol included in the International Organization for Standardization (ISO) international standardization, and is widely applied to the field of automotive technologies, to implement communication between in-vehicle devices inside a vehicle. All in-vehicle devices in the vehicle are connected to a CAN bus to form an in-vehicle network of the vehicle, and communication data is received and sent between the in-vehicle devices based on the CAN protocol using the CAN bus.
In other approaches, with continuous development of communications technologies and automotive technologies, an increasing quantity of in-vehicle devices provide a function of connecting to the Internet such that the vehicle obtains more applications such as navigation and remote system upgrade from the Internet. However, because the in-vehicle device that can be connected to the Internet supports an Ethernet protocol, a gateway used for communication protocol conversion needs to be disposed in the vehicle. Therefore, after communication data of the in-vehicle device that supports the Ethernet protocol is converted into communication data of the in-vehicle device that supports a CAN protocol through the gateway, the converted communication data of the CAN protocol is sent to the CAN bus. Alternatively, after communication data of a CAN protocol is converted, through the gateway, into communication data of the in-vehicle device that supports the Ethernet protocol, the converted communication data of the Ethernet protocol is sent to the in-vehicle device that supports the Ethernet protocol.
However, for an existing vehicle, malicious data from the Internet may enter a CAN bus through an in-vehicle device that can be connected to the Internet. This brings a security threat to an in-vehicle network of a vehicle, and causes relatively poor security performance of the in-vehicle network.
This application provides an in-vehicle device gateway communication method, an in-vehicle device gateway, and an intelligent vehicle, to improve security performance of an in-vehicle device network.
According to a first aspect, an in-vehicle device gateway communication method is provided. The method includes receiving a first message from a first in-vehicle device, where the first message meets a first communications protocol supported by the first in-vehicle device, is used to indicate a second in-vehicle device to perform a target operation, and includes identification information, identifying the identification information in the first message, matching the identification information in the first message with preset identification information stored in the in-vehicle gateway, and if the matching succeeds, sending a second message, where the second message is used to indicate the second in-vehicle device to perform a target operation, is generated based on the first message, and meets a second communications protocol supported by the second in-vehicle device, and the first communications protocol is different from the second communications protocol.
In the in-vehicle gateway communication method provided in this embodiment, only when the identification information of the first message successfully matches the preset identification information using the preset identification information set in the in-vehicle gateway of the vehicle, the in-vehicle gateway sends the second message, to indicate, using the second message, the second in-vehicle device to perform the target operation. However, when the identification information in the first message cannot match the preset identification information stored in the gateway, the in-vehicle gateway does not send the second information to control the second in-vehicle device to perform the target operation. This reduces a security threat to the in-vehicle network, and improves security performance of the in-vehicle network of the vehicle.
In a possible implementation of the first aspect of this application, if the first in-vehicle device is an in-vehicle device that supports an Ethernet protocol and the second in-vehicle device is an in-vehicle device that supports a CAN protocol, the first message is an Ethernet packet and the second message is a CAN packet.
According to the in-vehicle gateway communication method in this embodiment, when identification information in the Ethernet packet received by the in-vehicle gateway does not match the preset identification information, it indicates that the Ethernet packet may be malicious data from the Internet such that the in-vehicle gateway does not convert the Ethernet packet that fails to match the identification information into the CAN packet, and does not send the CAN packet to a CAN bus. In this way, the in-vehicle gateway matches the Ethernet packet. This reduces a risk of the Internet from outside the in-vehicle network such that the malicious data cannot enter the CAN bus through the in-vehicle gateway, and further improves security performance of the in-vehicle network.
In a possible implementation of the first aspect of this application, if the first in-vehicle device is an in-vehicle device that supports a CAN protocol and the second in-vehicle device is an in-vehicle device that supports an Ethernet protocol, the first message is a CAN packet and the second message is an Ethernet packet.
According to the in-vehicle gateway communication method provided in this embodiment, similarly, when identification information in the CAN packet received by the in-vehicle gateway does not match the preset identification information, it indicates that the CAN packet may have a security risk such that the in-vehicle gateway does not convert the CAN packet that fails to match the identification information into the Ethernet packet. In this way, the in-vehicle gateway matches the CAN packet. This reduces a security threat from the CAN packet to the in-vehicle device of the Ethernet protocol, and improves security performance of the in-vehicle network of the vehicle.
In a possible implementation of the first aspect of this application, the matching the identification information in the first message with preset identification information stored in the in-vehicle gateway includes matching, by searching whether the preset identification information stored in the in-vehicle gateway includes the identification information of the first message, the identification information of the first message with the preset identification information stored in the in-vehicle gateway, where the in-vehicle gateway stores at least one piece of the preset identification information.
In a possible implementation of the first aspect of this application, the first message is an Ethernet packet, and the identification information of the first message includes one or more of the following a predefined flag bit in a source MAC address, a predefined flag bit in a destination media access control (MAC) address, and a predefined flag bit in a protocol type, which are in the Ethernet packet.
In a possible implementation of the first aspect of this application, the first message is a CAN packet, and the identification information of the first message includes a CAN identifier (ID) in the CAN packet.
In a possible implementation of the first aspect of this application, if the matching succeeds, the sending a second message further includes the in-vehicle gateway stores a mapping relationship, and the mapping relationship is a mapping relationship between the preset identification information and message construction information, if the matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway succeeds, corresponding message construction information is obtained based on the successfully matched preset identification information, and the second message is generated using the message construction information and the first message.
According to the in-vehicle gateway communication method provided in this embodiment, when determining the second message after successfully matching the identification information of the first message with the preset identification information, the in-vehicle gateway can obtain the second message by querying a pre-stored mapping relationship, instead of obtaining the second message after performing protocol conversion based on the first message. In this way, the in-vehicle gateway can directly obtain the second message by searching a second mapping relationship based on the preset identification information. A calculation amount of searching for the mapping relationship is small. This increases a speed of performing protocol conversion by the in-vehicle gateway, and further improves protocol conversion efficiency of the in-vehicle gateway.
In a possible implementation of the first aspect of this application, the second message is a CAN packet, and the message construction information includes a CAN ID in the CAN packet.
In a possible implementation of the first aspect of this application, the second message is an Ethernet packet, and the message construction information includes one or more of the following a protocol type of the Ethernet packet, a predefined flag in a source MAC address and/or a destination MAC address in the Ethernet packet.
According to a second aspect of this application, an in-vehicle gateway is provided. The in-vehicle gateway includes a transceiver module configured to receive a first message from a first in-vehicle device, where the first message meets a first communications protocol supported by the first in-vehicle device, is used to indicate a second in-vehicle device to perform a target operation, and includes identification information, an identification module configured to identify the identification information in the first message, a determining module configured to match the identification information in the first message and preset identification information stored in the in-vehicle gateway, and determine whether preset identification information that matches the identification information in the first message exists in the preset identification information stored in the in-vehicle gateway, and if the matching succeeds, send a matching result to a message construction module, and the message construction module configured to generate a second message based on the matching result sent by the determining module, where the second message meets a second communications protocol supported by the second in-vehicle device, and the first communications protocol is different from the second communications protocol, where the transceiver module is further configured to send the second message, where the second message is used to indicate the second in-vehicle device to perform a target operation.
In a possible implementation of the second aspect of this application, if the first in-vehicle device is an in-vehicle device that supports a CAN protocol and the second in-vehicle device is an in-vehicle device that supports an Ethernet protocol, the first message is a CAN packet and the second message is an Ethernet packet.
In a possible implementation of the second aspect of this application, if the first in-vehicle device is an in-vehicle device that supports an Ethernet protocol and the second in-vehicle device is an in-vehicle device that supports a CAN protocol, the first message is an Ethernet packet and the second message is a CAN packet.
In a possible implementation of the second aspect of this application, the determining module is further configured to match, by searching whether the preset identification information stored in the in-vehicle gateway includes the identification information of the first message, the identification information of the first message with the preset identification information stored in the in-vehicle gateway, where the in-vehicle gateway stores at least one piece of the preset identification information.
In a possible implementation of the second aspect of this application, the first message is an Ethernet packet, and the identification information of the first message includes one or more of the following a predefined flag bit in a source MAC address, a predefined flag bit in a destination MAC address, and a predefined flag bit in a protocol type, which are in the Ethernet packet.
In a possible implementation of the second aspect of this application, the first message is a CAN packet, and the identification information of the first message includes a CAN ID in the CAN packet.
In a possible implementation of the second aspect of this application, the in-vehicle gateway stores a first mapping relationship, and the first mapping relationship is a mapping relationship between the preset identification information and message construction information. The message construction module is further configured to, if the matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway succeeds, obtain corresponding message construction information based on the successfully matched preset identification information, and generate the second message using the message construction information.
In a possible implementation of the second aspect of this application, the second message is a CAN packet, and the message construction information includes a CAN ID in the CAN packet.
In a possible implementation of the second aspect of this application, the second message is an Ethernet packet, and the message construction information includes one or more of the following a predefined flag in a protocol type of the Ethernet packet, and a predefined flag in a source MAC address and a predefined flag in a destination MAC address in the Ethernet packet.
According to a third aspect of this application, an in-vehicle gateway is provided. The in-vehicle gateway includes a first communications interface, a second communications interface, a processor, and a memory. The first communications interface is configured to receive a first message from a first in-vehicle device, and send the first message to the processor, where the first message meets a first communications protocol supported by the first in-vehicle device, is used to indicate a second in-vehicle device to perform a target operation, and includes identification information. The memory stores an instruction, and when the processor invokes and executes the instruction, the processor is enabled to, after receiving the first message, identify identification information in the first message, and match the identification information in the first message with preset identification information stored in the in-vehicle gateway. The processor is further configured to, if the matching succeeds, send a second message to the second communications interface, where the second communications interface is further configured to send the second message, the second message is used to indicate the second in-vehicle device to perform a target operation, is generated based on the first message, and meets a second communications protocol supported by the second in-vehicle device, and the first communications protocol is different from the second communications protocol.
In a possible implementation of the third aspect of this application, if the first in-vehicle device is an in-vehicle device that supports a CAN protocol and the second in-vehicle device is an in-vehicle device that supports an Ethernet protocol, the first message is a CAN packet and the second message is an Ethernet packet.
In a possible implementation of the third aspect of this application, if the first in-vehicle device is an in-vehicle device that supports an Ethernet protocol and the second in-vehicle device is an in-vehicle device that supports a CAN protocol, the first message is an Ethernet packet and the second message is a CAN packet.
In a possible implementation of the third aspect of this application, the processor is further configured to match, by searching whether the preset identification information stored in the in-vehicle gateway includes the identification information of the first message, the identification information of the first message with the preset identification information stored in the in-vehicle gateway, where the in-vehicle gateway stores at least one piece of the preset identification information.
In a possible implementation of the third aspect of this application, if the first message is an Ethernet packet, and the identification information of the first message includes one or more of the following a predefined flag bit in a source MAC address, a predefined flag bit in a destination MAC address, and a predefined flag bit in a protocol type, which are in the Ethernet packet.
In a possible implementation of the third aspect of this application, if the first message is a CAN packet, and the identification information of the first message includes a CAN ID in the CAN packet.
In a possible implementation of the third aspect of this application, the in-vehicle gateway stores a first mapping relationship, and the first mapping relationship is a mapping relationship between the preset identification information and message construction information. The processor is further configured to, if the matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway succeeds, obtain corresponding message construction information based on the successfully matched preset identification information, and generate the second message using the message construction information.
In a possible implementation of the third aspect of this application, if the second message is a CAN packet, and the message construction information includes a CAN ID in the CAN packet.
In a possible implementation of the third aspect of this application, if the second message is an Ethernet packet, and the message construction information includes one or more of the following a protocol type of the Ethernet packet, a predefined flag in a source MAC address and a destination MAC address in the Ethernet packet.
According to a fourth aspect of this application, an intelligent vehicle is provided. The intelligent vehicle includes a first in-vehicle device, a second in-vehicle device, and an in-vehicle gateway. The first in-vehicle device is configured to send a first message to the in-vehicle gateway, where the first message meets a first communications protocol supported by the first in-vehicle device, is used to indicate a second in-vehicle device to perform a target operation, and includes identification information. The in-vehicle gateway is configured to receive the first message from the first in-vehicle device, and identify the identification information in the first message. The in-vehicle gateway is further configured to match the identification information in the first message with preset identification information stored in the in-vehicle gateway. If the matching succeeds, the in-vehicle gateway sends a second message, where the second message is used to indicate the second in-vehicle device to perform a target operation, is generated based on the first message, and meets a second communications protocol supported by the second in-vehicle device, and the first communications protocol is different from the second communications protocol.
In a possible implementation of the fourth aspect of this application, if the first in-vehicle device is an in-vehicle device that supports a CAN protocol and the second in-vehicle device is an in-vehicle device that supports an Ethernet protocol, the first message is a CAN packet and the second message is an Ethernet packet.
In a possible implementation of the fourth aspect of this application, if the first in-vehicle device is an in-vehicle device that supports an Ethernet protocol and the second in-vehicle device is an in-vehicle device that supports a CAN protocol, the first message is an Ethernet packet and the second message is a CAN packet.
In a possible implementation of the fourth aspect of this application, the in-vehicle gateway is further configured to match, by searching whether the preset identification information stored in the gateway includes the identification information of the first message, the identification information of the first message with the preset identification information stored in the gateway, where the gateway stores at least one piece of the preset identification information.
In a possible implementation of the fourth aspect of this application, if the first message is an Ethernet packet, and the identification information of the first message includes one or more of the following a predefined flag bit in a source MAC address, a predefined flag bit in a destination MAC address, and a predefined flag bit in a protocol type, which are in the Ethernet packet.
In a possible implementation of the fourth aspect of this application, if the first message is a CAN packet, and the identification information of the first message includes a CAN ID in the CAN packet.
In a possible implementation of the fourth aspect of this application, the in-vehicle gateway stores a first mapping relationship, and the first mapping relationship is a mapping relationship between the preset identification information and message construction information, and the in-vehicle gateway is further configured to, if the matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway succeeds, obtain corresponding message construction information based on the successfully matched preset identification information, and generate the second message using the message construction information and the first message.
In a possible implementation of the fourth aspect of this application, the second message is a CAN packet, and the message construction information includes a CAN ID in the CAN packet.
In a possible implementation of the fourth aspect of this application, the second message is an Ethernet packet, and the message construction information includes one or more of the following a predefined flag in a protocol type of the Ethernet packet, a predefined flag in a source MAC address and a predefined flag in a destination MAC address in the Ethernet packet.
In conclusion, this application provides an in-vehicle gateway communication method, an in-vehicle gateway, and an intelligent vehicle. The in-vehicle gateway communication method includes receiving a first message from a first in-vehicle device, identifying identification information in the first message, matching the identification information with preset identification information stored in the in-vehicle gateway, and if the matching succeeds, sending a second message, to indicate, using the second message, a second in-vehicle device to perform a target operation. However, when the identification information in the first message cannot match the preset identification information stored in the gateway, the in-vehicle gateway does not send the second information to control the second in-vehicle device to perform the target operation. This application provides the in-vehicle gateway communication method, the in-vehicle gateway, and the intelligent vehicle. This reduces a security threat to the in-vehicle network, and improves security performance of the in-vehicle network of the vehicle.
In addition, with continuous development of communications technologies and automotive technologies, an increasing quantity of in-vehicle devices 11 that can be connected to the Internet are connected to an in-vehicle network inside the vehicle 10 by a manufacturer of the vehicle 10 or a user of the vehicle 10 such that the in-vehicle device connected to the Internet provides more functions for the vehicle and the user of the vehicle, for example, navigation, remote system upgrade, and automatic driving. The in-vehicle device 11 that can be connected to the Internet needs to support an Ethernet protocol to access the Internet. If the in-vehicle device 11 that supports the Ethernet protocol is directly connected to the CAN bus inside the vehicle, the in-vehicle device 11 that supports the Ethernet protocol cannot communicate with another in-vehicle device that supports a CAN protocol. Therefore, a switch 12 and a gateway 13 are introduced inside the vehicle 10, to implement communication between the in-vehicle device 11 that supports the Ethernet protocol and the in-vehicle device 11 that supports the CAN protocol. For example, in an example shown in
However, in the vehicle 10 shown in
Therefore, in order to further ensure security of the in-vehicle network after the in-vehicle device that supports the Ethernet protocol is introduced, this application provides the in-vehicle gateway communication method, the in-vehicle gateway, and the intelligent vehicle. On a basis that a protocol conversion function of the in-vehicle gateway can be satisfied, the in-vehicle gateway is further used to reduce a security threat to the in-vehicle network, and further to improve security performance of the in-vehicle network of the vehicle.
The following describes, with reference to the accompanying drawings, the gateway communication method provided in this application.
Further, the in-vehicle gateway communication method provided in the embodiments of this application may be performed by a gateway switch shown in
Alternatively,
Specific embodiments are used below to describe in detail the technical solutions of this application. The following several specific embodiments may be combined with each other, and a same or similar concept or process may not be described repeatedly in some embodiments.
S101. The in-vehicle gateway receives a first message from a first in-vehicle device. The first message meets a first communications protocol supported by the first in-vehicle device, is used to indicate a second in-vehicle device to perform a target operation, and includes identification information.
Further, the in-vehicle gateway in this embodiment is disposed between the first in-vehicle device and the second in-vehicle device, and is configured to, when the first in-vehicle device and the second in-vehicle device support different communications protocols, perform protocol conversion on the first message that is sent by the first in-vehicle device to the second in-vehicle device through the in-vehicle gateway. The first message meets an Ethernet communications protocol, the first message may be further an Ethernet packet, and the Ethernet packet is used to indicate the second in-vehicle device to perform a target operation. In S101, when the first in-vehicle device needs to indicate, through the in-vehicle gateway, the second in-vehicle device to perform the target operation, the first in-vehicle device sends an Ethernet packet to the in-vehicle gateway, and the in-vehicle gateway receives the Ethernet packet from the first in-vehicle device. Herein, when the in-vehicle gateway is the gateway switch in
In this embodiment, the first message further includes identification information. The identification information is used by the in-vehicle gateway to determine the target operation performed by the second in-vehicle device indicated by the first message, and the identification information may be information included in the first message sent by the first in-vehicle device. The in-vehicle gateway can determine, using the information in the first message, the target operation performed by the second in-vehicle device indicated by the first message. For example, if the first message is an Ethernet packet, the identification information of the first message may be one or more of the following in the Ethernet packet a predefined identifier in a source MAC address, a predefined identifier in a destination MAC address, and a predefined identifier in a protocol type. The in-vehicle gateway may determine, when the destination MAC address of the Ethernet packet is 1, that the Ethernet packet is used to indicate the second in-vehicle device to perform a target operation of turning on an air conditioner. Alternatively, the identification information may be information specially added by the first in-vehicle device to the first message used to indicate the second in-vehicle device to perform a target operation such that the in-vehicle gateway can determine, using the information added to the first message, the target operation performed by the second in-vehicle device indicated by the first message. For example, when the first message is an Ethernet packet, the first in-vehicle device may add “1” to a specific location in the Ethernet packet such that the in-vehicle gateway may determine, based on the specific location “1” in the Ethernet packet, that the Ethernet packet is used to indicate the second in-vehicle device to perform a target operation of turning on an air conditioner.
Optionally, the in-vehicle device that supports the Ethernet protocol in this embodiment may support a Time-Sensitive Networking (TSN) Ethernet, an Audio Video Bridging (AVB) Ethernet, and a conventional Ethernet. The in-vehicle device that supports the CAN protocol may support CAN2.0A, CAN2.0B, and CAN-flexible data rate (CAN-FD) protocols.
Optionally, the device that supports the Ethernet protocol in this embodiment includes a human-machine interface device, a diagnosis interface device, a telematics box (TBox) device, an advanced driver assistance system (ADAS) controller device, and the like. The device that supports the CAN protocol includes a power controller, a body controller, a power management controller, a power controller, and the like.
S102. The in-vehicle gateway identifies the identification information in the first message based on the first message obtained in S101.
Then, in S102, the in-vehicle gateway identifies the identification information included in the first message obtained in S101. In a possible implementation, after receiving the first message, the in-vehicle gateway may parse the first message, to determine the identification information in the first message. For example, if the first message is an Ethernet packet and the identification information is a source MAC address and a destination MAC address of the CAN packet, the in-vehicle gateway may determine the source MAC address and the destination MAC address of the Ethernet packet by parsing data of data bits in which the source MAD address and the destination MAC address in the Ethernet packet are located.
S103. The in-vehicle gateway matches the identification information, in the first message, identified in S102 with preset identification information stored in the in-vehicle gateway.
Subsequently, in S103, the in-vehicle gateway matches the identification information, of the first message, identified in S102 with the preset identification information stored in the in-vehicle gateway. The in-vehicle gateway stores at least one piece of preset identification information, and each piece of preset identification information is used to indicate a target operation performed by a second device indicated by the first message sent by the first in-vehicle device to the in-vehicle gateway. The matching includes determining whether the identification information of the first message is the same as the preset identification information stored in the in-vehicle gateway, that is, determining whether the preset identification information includes the determined identification information of the first message.
For example, the preset identification information stored in the in-vehicle gateway includes “1” and “2”, where “1” is used to indicate that the target operation performed by the second device indicated by the first message is “turning on an air conditioner”, and “2” is used to indicate that the target operation performed by the second device indicated by the first message is “turning on a radio”. Therefore, if the in-vehicle gateway identifies that the identification information of the first message is “1”, because the preset identification information stored in the in-vehicle gateway includes “1”, it is determined that the identification information of the first message is successfully matched. However, if the in-vehicle gateway identifies that the identification information of the first message is “0”, because the preset identification information stored in the in-vehicle gateway does not include “0”, it is determined that the identification information of the first message is not successfully matched.
S104. If the matching succeeds, the in-vehicle gateway sends a second message, where the second message is used to indicate the second in-vehicle device to perform the target operation.
Finally, when the in-vehicle gateway successfully matches the identification information of the first message with the stored preset identification information in S103, the in-vehicle gateway sends the second message in S104, to indicate, using the second message, the second in-vehicle device to perform the target operation. However, if the in-vehicle gateway fails to match the identification information of the first message with the preset identification information in S103, the in-vehicle gateway does not send the second message in S104, that is, does not indicate, using the second message, the second in-vehicle device to perform the target operation. The second message is generated by the in-vehicle gateway based on the first message, the second message meets a second communications protocol supported by the second in-vehicle device, and the first communications protocol supported by the first in-vehicle device is different from the second communications protocol supported by the second in-vehicle device.
Further, in this embodiment, the first in-vehicle device is an in-vehicle device that supports an Ethernet protocol, and the second in-vehicle device is an in-vehicle device that supports a CAN protocol. In this case, the first message supports the Ethernet protocol, the second message supports the CAN network communication protocol, and the first message may be an Ethernet packet, and the second message may be a CAN packet. In S104, after receiving the Ethernet packet and determining the CAN packet according to the foregoing steps, the in-vehicle gateway may send the CAN packet to a CAN bus. After the second in-vehicle device obtains the CAN packet from the CAN bus, the second in-vehicle device performs the target operation based on the obtained CAN packet. Herein, the in-vehicle gateway sends the second message. When the in-vehicle gateway is the gateway switch in
Therefore, in the in-vehicle gateway communication method provided in this embodiment, when receiving the first message from the first in-vehicle device, the in-vehicle gateway identifies the identification information in the first message, and matches the identification information with the preset identification information stored in the in-vehicle gateway. When the matching succeeds, the in-vehicle gateway sends the second message, to indicate, using the second message, the second in-vehicle device to perform the target operation. Therefore, the in-vehicle gateway may filter, based on whether the identification information of the first message is stored, whether the first message can be used by the in-vehicle gateway to control the second in-vehicle device to perform the target operation. When the in-vehicle gateway allows the first message to control, through the in-vehicle gateway, the second in-vehicle device to perform the target operation, the identification information of the first message may be stored as the preset identification information such that after the first message successfully matches the preset identification information, the in-vehicle gateway sends the second message to control the second in-vehicle device to perform the target operation. When the in-vehicle gateway does not allow the first message to control, through the in-vehicle gateway, the second in-vehicle device to perform the target operation, the identification information of the first message is not stored in the in-vehicle gateway. Therefore, when the identification information in the first message cannot match the preset identification information stored in the gateway, the in-vehicle gateway does not send the second information to control the second in-vehicle device to perform the target operation.
In this case, this embodiment is applied to an in-vehicle network scenario shown in
Further, based on the foregoing embodiment, in a possible specific implementation of S104 in this embodiment, the in-vehicle gateway obtains the second message in a manner of performing protocol conversion on the first message. The gateway converts the first message that uses the first communications protocol into the second message that uses the second communications protocol. For a specific method and a principle of performing protocol conversion by the in-vehicle gateway, refer to other approaches. A protocol conversion manner of the in-vehicle gateway is not limited in this embodiment. It is emphasized that the in-vehicle gateway performs protocol conversion only when the identification information of the first message is successfully matched in S103, and then the in-vehicle gateway performs protocol conversion from the first message to the second message, and sends the second message obtained after the protocol conversion.
Alternatively, in another possible implementation of S104 in this embodiment, to improve a protocol conversion speed of the in-vehicle gateway and to improve protocol conversion efficiency of the in-vehicle gateway, the in-vehicle gateway further stores a mapping relationship used by the in-vehicle gateway to determine the second message, and the mapping relationship includes a mapping relationship between the preset identification information and message construction information. In this case, after successfully matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway in S103, the in-vehicle gateway obtains, from the mapping relationship based on the successfully matched preset identification information, the message construction information corresponding to the preset identification information, and can generate the second message based on the message construction information and the first message. Optionally, the in-vehicle network stores the mapping relationship in a form of a table.
The message construction information includes the second message that can be determined by the in-vehicle gateway using the first message. In this case, the in-vehicle gateway provided in this embodiment may store, in advance using the mapping relationship, message construction messages corresponding to different preset identification information. After the gateway successfully matches the preset identification information with the identification information of the first message, the in-vehicle gateway may directly use, as the second message, message construction information that is obtained by searching the mapping relationship based on the successfully matched identification information. In addition, in this embodiment, when the in-vehicle gateway may determine, using the mapping relationship, the second message obtained after protocol conversion is performed on the first message, and the in-vehicle gateway may no longer perform protocol conversion on the first message. This improves efficiency of determining the second message by the in-vehicle gateway based on the first message.
Alternatively, the message construction information includes a part of information in the second message, and after the in-vehicle gateway in this embodiment successfully matches the identification information of the first message with the preset identification information, the in-vehicle gateway searches the mapping relationship based on the successfully matched identification information of the performance, to obtain the part of message construction information of the second message. Then, the second message is jointly obtained based on the first message and the message construction information such that a speed and efficiency of performing protocol conversion on the entire first message by the in-vehicle gateway to obtain the second message are also increased to some extent.
With reference to the accompanying drawings, the following describes a manner in which the in-vehicle gateway determines the second message based on the mapping relationship in this embodiment.
In this embodiment, the identification information of the first message is one or more of the following information in the Ethernet packet a predefined flag bit in a source MAC address, a predefined flag bit in a destination MAC address, and a predefined flag bit in a protocol type, where the predefined flag bit refers to a specific bit in the MAC address in the Ethernet packet. Further,
As shown in
Optionally, in the example shown in
Alternatively, in the example shown in
Further, in the embodiment shown in
It should be noted that, in the example shown in
In conclusion, in the in-vehicle gateway communication method provided in this embodiment, when determining the CAN packet after successfully matching the identification information of the Ethernet packet with the preset identification information, the in-vehicle gateway can obtain the CAN packet by querying the pre-stored mapping relationship, instead of obtaining the CAN packet only after protocol conversion is performed based on the Ethernet packet. In this way, the in-vehicle gateway can directly obtain the CAN packet by searching a second mapping relationship based on the preset identification information. Because a calculation amount of searching for the mapping relationship is far less than that of data processing performed on the Ethernet packet during protocol conversion, compared with an existing in-vehicle gateway, this greatly improves a speed of the in-vehicle gateway in protocol conversion from the Ethernet packet to the CAN packet, and further improves protocol conversion efficiency of the in-vehicle gateway.
S101. The in-vehicle gateway receives a first message from a first in-vehicle device. The first message meets a first communications protocol supported by the first in-vehicle device, is used to indicate a second in-vehicle device to perform a target operation, and includes identification information.
Further, the in-vehicle gateway in this embodiment is disposed between the first in-vehicle device and the second in-vehicle device, and is configured to, when the first in-vehicle device and the second in-vehicle device support different communications protocols, perform protocol conversion on the first message that is sent by the first in-vehicle device to the second in-vehicle device through the in-vehicle gateway. The first message meets a CAN communications protocol, the first message may be further a CAN packet, and the CAN packet is used to indicate the second in-vehicle device to perform a target operation. In S101, when the first in-vehicle device needs to indicate, through the in-vehicle gateway, the second in-vehicle device to perform the target operation, the first in-vehicle device sends a CAN packet to the in-vehicle gateway, and the in-vehicle gateway receives the CAN packet from the first in-vehicle device. Herein, when the in-vehicle gateway is the gateway switch in
In this embodiment, the first message further includes identification information. The identification information is used by the in-vehicle gateway to determine the target operation performed by the second in-vehicle device indicated by the first message, and the identification information may be information included in the first message sent by the first in-vehicle device. The in-vehicle gateway can determine, using the information in the first message, the target operation performed by the second in-vehicle device indicated by the first message. For example, if the first message is communication data that supports the CAN protocol, namely, a CAN packet, the identification information may be a CAN ID in the CAN packet. The in-vehicle gateway may determine, when the CAN ID in the CAN packet is 1, that the CAN packet is used to indicate the second in-vehicle device to perform a target operation of turning on an air conditioner. Alternatively, the identification information may be information specially added by the first in-vehicle device to the first message used to indicate the second in-vehicle device to perform a target operation such that the in-vehicle gateway can determine, using the information added to the first message, the target operation performed by the second in-vehicle device indicated by the first message. For example, when the first message is a CAN packet, the first in-vehicle device may add “1” to a specific location in the CAN packet such that the in-vehicle gateway may determine, based on the specific location “1” in the CAN packet, that the CAN packet is used to indicate the second in-vehicle device to perform a target operation of turning on an air conditioner.
Optionally, the in-vehicle device that supports the Ethernet protocol in this embodiment may support a TSN Ethernet, an AVB Ethernet, and a conventional Ethernet. The in-vehicle device that supports the CAN protocol may support CAN2.0A, CAN2.0B, and CAN-FD protocols.
Optionally, the device that supports the Ethernet protocol in this embodiment includes a human-machine interface device, a diagnosis interface device, a TBox device, an ADAS controller device, and the like. The device that supports the CAN protocol includes a power controller, a body controller, a power management controller, a power controller, and the like.
S102. The in-vehicle gateway identifies the identification information in the first message based on the first message obtained in S101.
Then, in S102, the in-vehicle gateway identifies the identification information included in the first message obtained in S101. In a possible implementation, after receiving the first message, the in-vehicle gateway may parse the first message, to determine the identification information in the first message. For example, if the first message is a CAN packet and the identification information is a CAN ID of the CAN packet, the in-vehicle gateway may determine the CAN ID of the CAN packet by parsing data of data bits in which the CAN ID in the CAN packet is located.
S103. The in-vehicle gateway matches the identification information, in the first message, identified in S102 with preset identification information stored in the in-vehicle gateway.
Subsequently, in S103, the in-vehicle gateway matches the identification information, of the first message, identified in S102 with the preset identification information stored in the in-vehicle gateway. The in-vehicle gateway stores at least one piece of preset identification information, and each piece of preset identification information is used to indicate a target operation performed by a second device indicated by the first message sent by the first in-vehicle device to the in-vehicle gateway. The matching includes determining whether the identification information of the first message is the same as the preset identification information stored in the in-vehicle gateway, that is, determining whether the preset identification information includes the determined identification information of the first message.
For example, the preset identification information stored in the in-vehicle gateway includes “1” and “2”, where “1” is used to indicate that the target operation performed by the second device indicated by the first message is “turning on an air conditioner”, and “2” is used to indicate that the target operation performed by the second device indicated by the first message is “turning on a radio”. Therefore, if the in-vehicle gateway identifies that the identification information of the first message is “1”, because the preset identification information stored in the in-vehicle gateway includes “1”, it is determined that the identification information of the first message is successfully matched. However, if the in-vehicle gateway identifies that the identification information of the first message is “0”, because the preset identification information stored in the in-vehicle gateway does not include “0”, it is determined that the identification information of the first message is not successfully matched.
S104. If the matching succeeds, the in-vehicle gateway sends a second message, where the second message is used to indicate the second in-vehicle device to perform the target operation.
Finally, when the in-vehicle gateway successfully matches the identification information of the first message with the stored preset identification information in S103, the in-vehicle gateway sends the second message in S104, to indicate, using the second message, the second in-vehicle device to perform the target operation. However, if the in-vehicle gateway fails to match the identification information of the first message with the preset identification information in S103, the in-vehicle gateway does not send the second message in S104, that is, does not indicate, using the second message, the second in-vehicle device to perform the target operation. The second message is generated by the in-vehicle gateway based on the first message, the second message meets a second communications protocol supported by the second in-vehicle device, and the first communications protocol supported by the first in-vehicle device is different from the second communications protocol supported by the second in-vehicle device.
Further, in this embodiment, if the first in-vehicle device is an in-vehicle device that supports a CAN protocol, and the second in-vehicle device is an in-vehicle device that supports an Ethernet protocol, the first message supports the CAN protocol, the second message supports the Ethernet network communication protocol, and the first message may be a CAN packet, and the second message may be an Ethernet packet. In S104, after receiving the CAN packet and determining the Ethernet packet according to the foregoing steps, the in-vehicle gateway may send the Ethernet packet to the switch. The switch sends the Ethernet packet to a corresponding second in-vehicle device based on a destination MAC address of the Ethernet packet, and finally, the second in-vehicle device performs the target operation based on the received Ethernet packet. Herein, the in-vehicle gateway sends the second message. When the in-vehicle gateway is the gateway switch in
Therefore, in the in-vehicle gateway communication method in this embodiment, when receiving the first message from the first in-vehicle device, the in-vehicle gateway identifies the identification information in the first message, and matches the identification information with the preset identification information stored in the in-vehicle gateway. When the matching succeeds, the in-vehicle gateway sends the second message, to indicate, using the second message, the second in-vehicle device to perform the target operation. Therefore, the in-vehicle gateway may filter, based on whether the identification information of the first message is stored, whether the first message can be used by the in-vehicle gateway to control the second in-vehicle device to perform the target operation. When the in-vehicle gateway allows the first message to control, through the in-vehicle gateway, the second in-vehicle device to perform the target operation, the identification information of the first message may be stored as the preset identification information such that after the first message successfully matches the preset identification information, the in-vehicle gateway sends the second message to control the second in-vehicle device to perform the target operation. When the in-vehicle gateway does not allow the first message to control, through the in-vehicle gateway, the second in-vehicle device to perform the target operation, the identification information of the first message is not stored in the in-vehicle gateway. Therefore, when the identification information in the first message cannot match the preset identification information stored in the gateway, the in-vehicle gateway does not send the second information to control the second in-vehicle device to perform the target operation.
In this case, this embodiment is applied to an in-vehicle network scenario shown in
Further, based on the foregoing embodiment, in a possible specific implementation of S104 in this embodiment, the in-vehicle gateway obtains the second message in a manner of performing protocol conversion on the first message. The gateway converts the first message that uses the first communications protocol into the second message that uses the second communications protocol. For a specific method and a principle of performing protocol conversion by the in-vehicle gateway, refer to other approaches. A protocol conversion manner of the in-vehicle gateway is not limited in this embodiment. It is emphasized that the in-vehicle gateway performs protocol conversion only when the identification information of the first message is successfully matched in S103, and then the in-vehicle gateway performs protocol conversion from the first message to the second message, and sends the second message obtained after the protocol conversion.
Alternatively, in another possible implementation of S104 in this embodiment, to improve a protocol conversion speed of the in-vehicle gateway and to improve protocol conversion efficiency of the in-vehicle gateway, the in-vehicle gateway further stores a mapping relationship used by the in-vehicle gateway to determine the second message, and the mapping relationship includes a mapping relationship between the preset identification information and message construction information. In this case, after successfully matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway in S103, the in-vehicle gateway obtains, from the mapping relationship based on the successfully matched preset identification information, the message construction information corresponding to the preset identification information, and can generate the second message based on the message construction information and the first message. Optionally, the in-vehicle network stores the mapping relationship in a form of a table.
The message construction information includes the second message that can be determined by the in-vehicle gateway using the first message. In this case, the in-vehicle gateway provided in this embodiment may store, in advance using the mapping relationship, message construction messages corresponding to different preset identification information. After the gateway successfully matches the preset identification information with the identification information of the first message, the in-vehicle gateway may directly use, as the second message, message construction information that is obtained by searching the mapping relationship based on the successfully matched identification information. In addition, in this embodiment, when the in-vehicle gateway may determine, using the mapping relationship, the second message obtained after protocol conversion is performed on the first message, and the in-vehicle gateway may no longer perform protocol conversion on the first message. This improves efficiency of determining the second message by the in-vehicle gateway based on the first message.
Alternatively, the message construction information includes a part of information in the second message, and after the in-vehicle gateway in this embodiment successfully matches the identification information of the first message with the preset identification information, the in-vehicle gateway searches the mapping relationship based on the successfully matched identification information of the performance, to obtain the part of message construction information of the second message. Then, the second message is jointly obtained based on the first message and the message construction information such that a speed and efficiency of performing protocol conversion on the entire first message by the in-vehicle gateway to obtain the second message are also increased to some extent.
With reference to the accompanying drawings, the following describes a manner in which the in-vehicle gateway determines the second message based on the mapping relationship in this embodiment.
In this embodiment, identification information of the first message is a CAN ID in the CAN packet, where the CAN ID is used to identify a CAN packet on a CAN bus. Further, referring to a packet structure of the CAN packet shown in
As shown in
Optionally, in the example shown in
Alternatively, in the example shown in
Further, in the embodiment shown in
Optionally, because a length of the Ethernet packet is greater than a length of the CAN packet, in the example shown in
Similarly, in the example shown in
In conclusion, in the in-vehicle gateway communication method provided in this embodiment, when determining the Ethernet packet after successfully matching the identification information of the CAN packet with the preset identification information, the in-vehicle gateway can obtain the Ethernet packet by querying the pre-stored mapping relationship, instead of obtaining the Ethernet packet only after protocol conversion is performed based on the CAN packet. In this way, the in-vehicle gateway can directly obtain the Ethernet packet by searching a second mapping relationship based on the preset identification information. Because a calculation amount of searching for the mapping relationship is far less than that of data processing performed on the CAN packet during protocol conversion, compared with an existing in-vehicle gateway, this greatly improves a speed of the in-vehicle gateway in protocol conversion from the CAN packet to the Ethernet packet, and further improves protocol conversion efficiency of the in-vehicle gateway.
It may be understood that for in-vehicle networks inside different vehicles, representation modes of the CAN packet are the same. Therefore, corresponding representation modes of the Ethernet packet outside vehicles are also the same. When the in-vehicle device that supports the CAN protocol sends an Ethernet packet to the in-vehicle device that supports the Ethernet protocol through the in-vehicle gateway, an external attacker may reversely determine a data representation mode on the CAN bus inside the vehicle using the Ethernet packet. Consequently, security performance of the in-vehicle network is relatively low. However, in the embodiment shown in
It should be noted that, the procedure shown in
In the embodiments provided in the foregoing embodiments of this application, the methods provided in this application are described and explained from a perspective of the in-vehicle gateway. To implement functions in the methods provided in the embodiments of this application, the in-vehicle gateway may include a hardware structure and/or a software module, and implement the functions in a form of the hardware structure, the software module, or a combination of the hardware structure and the software module. Whether a function in the foregoing functions is performed in a manner of the hardware structure, the software module, or the combination of the hardware structure and the software module depends on particular applications and design constraint of the technical solution.
The transceiver module 901 is configured to receive a first message from a first in-vehicle device, where the first message meets a first communications protocol supported by the first in-vehicle device, is used to indicate a second in-vehicle device to perform a target operation, and includes identification information. The identification module 902 is configured to identify the identification information in the first message. The determining module 903 is configured to match the identification information in the first message and preset identification information stored in the in-vehicle gateway, and determine whether preset identification information that matches the identification information in the first message exists in the preset identification information stored in the in-vehicle gateway, and if the matching succeeds, send a matching result to a message construction module 904. The message construction module 904 is configured to generate a second message based on the matching result sent by the determining module 903, where the second message meets a second communications protocol supported by the second in-vehicle device, and the first communications protocol is different from the second communications protocol. The transceiver module 901 is further configured to send the second message, where the second message is used to indicate the second in-vehicle device to perform a target operation.
The in-vehicle gateway provided in this embodiment may be configured to perform the in-vehicle gateway communication method in the embodiment shown in
When the first in-vehicle device is an in-vehicle device that supports an Ethernet protocol and the second in-vehicle device is an in-vehicle device that supports a CAN protocol, the first message is an Ethernet packet and the second message is a CAN packet.
A transceiver module 901 is configured to receive an Ethernet packet from a first in-vehicle device.
An identification module 902 is configured to determine identification information of the Ethernet protocol. The identification information of the Ethernet protocol includes one or more of the following a predefined flag bit in a source MAC address, a predefined flag bit in a destination MAC address, and/or a predefined flag bit in a protocol type, which are in the Ethernet packet.
A determining module 903 is configured to match the identification information in the Ethernet packet and preset identification information stored in the in-vehicle gateway, and if the matching succeeds, send a matching result to a message construction module 904.
The message construction module 904 is further configured to generate a CAN packet based on the matching result sent by the determining module, and send the CAN packet to a CAN bus on which the second in-vehicle device is located such that the second in-vehicle device performs a target operation after receiving the CAN packet using the CAN bus.
Optionally, when the matching succeeds, the determining module 903 may send a matching result indicating that the matching succeeds to the message construction module 904 such that the message construction module 904 generates the CAN packet based on the matching result. When the matching fails, the determining module 903 may also send a matching result indicating that the matching fails to the message construction module 904, and the message construction module 904 does not perform an operation of generating the CAN packet based on the matching result indicating that the matching fails.
Optionally, in the foregoing embodiment, the determining module 903 is further configured to match, by searching whether the preset identification information stored in the in-vehicle gateway includes the identification information of the first message, the identification information of the first message with the preset identification information stored in the in-vehicle gateway, where the in-vehicle gateway stores at least one piece of the preset identification information.
Optionally, in the foregoing embodiment, the in-vehicle gateway stores a first mapping relationship, and the first mapping relationship is a mapping relationship between the preset identification information and message construction information. The message construction module 904 is further configured to, if the matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway succeeds, obtain corresponding message construction information based on the successfully matched preset identification information, and generate the second message using the message construction information.
Optionally, in the foregoing embodiment, if the first in-vehicle device is an in-vehicle device that supports an Ethernet protocol and the second in-vehicle device is an in-vehicle device that supports a CAN protocol, the message construction information includes a CAN ID of the CAN packet. In other words, the message construction module 904 further generates the CAN packet based on the CAN ID in the message construction information.
When the first in-vehicle device is an in-vehicle device that supports a CAN protocol and the second in-vehicle device is an in-vehicle device that supports an Ethernet protocol, the first message is a CAN packet and the second message is an Ethernet packet.
A transceiver module 901 is configured to receive a CAN packet from a first in-vehicle device.
An identification module 902 determines identification information of the CAN protocol. The identification information of the CAN protocol includes a CAN ID of the CAN packet.
A determining module 903 is configured to match the identification information in the CAN packet and preset identification information stored in the in-vehicle gateway, and if the matching succeeds, send a matching result to a message construction module 904.
The message construction module 904 is further configured to generate an Ethernet packet based on the matching result sent by the determining module, and send the Ethernet packet to the second in-vehicle device or send the Ethernet packet to the second in-vehicle device using a switch such that the second in-vehicle device performs a target operation using the received Ethernet packet.
Optionally, when the matching succeeds, the determining module 903 may send a matching result indicating that the matching succeeds to the message construction module 904 such that the message construction module 904 generates the Ethernet packet based on the matching result. When the matching fails, the determining module 903 may also send a matching result indicating that the matching fails to the message construction module 904, and the message construction module 904 does not perform an operation of generating the Ethernet packet based on the matching result indicating that the matching fails.
Optionally, in the foregoing embodiment, the determining module 903 is further configured to match, by searching whether the preset identification information stored in the in-vehicle gateway includes the identification information of the first message, the identification information of the first message with the preset identification information stored in the in-vehicle gateway, where the in-vehicle gateway stores at least one piece of the preset identification information.
Optionally, in the foregoing embodiment, the in-vehicle gateway stores a first mapping relationship, and the first mapping relationship is a mapping relationship between the preset identification information and message construction information. The message construction module 904 is further configured to, if the matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway succeeds, obtain corresponding message construction information based on the successfully matched preset identification information, and generate the second message using the message construction information.
Optionally, in the foregoing embodiment, the message construction information includes one or more of the following a protocol type of the Ethernet packet, a predefined flag in a source MAC address and a destination MAC address in the Ethernet packet.
The in-vehicle gateway provided in the foregoing embodiments may be configured to perform the in-vehicle gateway communication method in the foregoing embodiments of this application. An implementation and a principle of the in-vehicle gateway communication method are the same as those of the in-vehicle gateway communication method in the foregoing embodiments of this application. Details are not described again.
Division into modules in this embodiment of this application is an example, is merely logical function division, and may be other division in an embodiment. In addition, functional modules in embodiments of this application may be integrated into one processor, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module may be implemented in a form of hardware, or may be implemented in a form of a software functional module.
A specific connection medium between the first communications interface 1010, the second communications interface 1011, the processor 1020, and the memory 1030 is not limited in this embodiment of this application. In this embodiment of this application, in
For example, in the in-vehicle gateway shown in
Optionally, in the embodiment shown in
For example, if the first in-vehicle device is an in-vehicle device that supports a CAN protocol and the second in-vehicle device is an in-vehicle device that supports an Ethernet protocol, the first message is a CAN packet and the second message is an Ethernet packet. In the in-vehicle gateway shown in
For another example, if the first in-vehicle device is an in-vehicle device that supports an Ethernet protocol and the second in-vehicle device is an in-vehicle device that supports a CAN protocol, the first message is an Ethernet packet and the second message is a CAN packet. In the in-vehicle gateway shown in
For specific content of the first message and the second message, refer to detailed descriptions in the method example. Details are not described herein again. Alternatively, for example, the processor 1020 may further be configured to obtain corresponding message construction information based on the successfully matched preset identification information, and generate the second message using the message construction information. For details, refer to detailed descriptions in the method example. Details are not described herein again.
In the embodiments of this application, the processor may be a general processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or another programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logical block diagrams disclosed in the embodiments of this application. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed with reference to the embodiments of this application may be directly performed by a hardware processor, or may be performed using a combination of hardware in the processor and a software module.
In this embodiment of this application, the memory may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD), or may be a volatile memory, such as a random-access memory (RAM). The memory is any other medium that can be configured to carry or store expected program code in a form of an instruction or a data structure and that can be accessed by a computer. However, the memory is not limited thereto. The memory in the embodiments of this application may alternatively be a circuit or any other apparatus that can implement a storage function, and is configured to store a program instruction and/or data.
Optionally, in the foregoing embodiment, if the first in-vehicle device 1101 is an in-vehicle device that supports a CAN protocol and the second in-vehicle device 1103 is an in-vehicle device that supports an Ethernet protocol, the first message is a CAN packet and the second message is an Ethernet packet.
The first in-vehicle device 1101 sends the Ethernet packet to the in-vehicle gateway 1102. The first in-vehicle device 1101 may directly send the Ethernet packet to the in-vehicle gateway 1102, or send the Ethernet packet to the in-vehicle gateway 1102 using a switch. After receiving the Ethernet packet sent by the first in-vehicle device 1101, the in-vehicle gateway 1102 matches identification information in the Ethernet packet, and generates the CAN packet when the matching succeeds. The in-vehicle gateway 1102 sends the generated CAN packet to a CAN bus on which the second in-vehicle device 1103 is located such that after receiving, from the CAN bus, the CAN packet sent by the in-vehicle gateway 1102, the second in-vehicle device 1103 performs a target operation based on the CAN packet.
Optionally, in the foregoing embodiment, the in-vehicle gateway 1102 is further configured to match, by searching whether the preset identification information stored in the gateway includes the identification information of the first message, the identification information of the first message with the preset identification information stored in the gateway, where the in-vehicle gateway stores at least one piece of the preset identification information. The identification information includes one or more of the following a predefined flag bit in a source MAC address, a predefined flag bit in a destination MAC address, and/or a predefined flag bit in a protocol type, which are in the Ethernet packet.
Optionally, in the foregoing embodiment, the in-vehicle gateway 1102 stores a first mapping relationship, and the first mapping relationship is a mapping relationship between the preset identification information and message construction information. The in-vehicle gateway 1102 is further configured to, if the matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway 1102 succeeds, obtain corresponding message construction information based on the successfully matched preset identification information, and generate the second message using the message construction information and the first message. The message construction information includes a CAN ID of the CAN packet.
Alternatively, if the first in-vehicle device 1101 is an in-vehicle device that supports an Ethernet protocol and the second in-vehicle device 1103 is an in-vehicle device that supports a CAN protocol, the first message is an Ethernet packet and the second message is a CAN packet.
In this case, the first in-vehicle device 1101 sends the CAN packet to the CAN bus. After receiving the CAN packet sent by the first in-vehicle device 1101 using the CAN bus, the in-vehicle gateway 1102 matches identification information in the CAN packet, and generates the Ethernet packet when the matching succeeds. The in-vehicle gateway 1102 sends the Ethernet packet to the second in-vehicle device 1103. The in-vehicle gateway may directly send the Ethernet packet to the second in-vehicle device 1103, or send the Ethernet packet to the in-vehicle gateway 1103 using a switch such that the second in-vehicle device 1103 performs a target operation based on the received Ethernet packet.
Optionally, in the foregoing embodiment, the in-vehicle gateway 1102 is further configured to match, by searching whether the preset identification information stored in the gateway includes the identification information of the first message, the identification information of the first message with the preset identification information stored in the gateway, where the in-vehicle gateway stores at least one piece of the preset identification information. The identification information includes a CAN ID of the CAN packet.
Optionally, in the foregoing embodiment, the in-vehicle gateway 1102 stores a first mapping relationship, and the first mapping relationship is a mapping relationship between the preset identification information and message construction information. The in-vehicle gateway 1102 is further configured to, if the matching the identification information in the first message with the preset identification information stored in the in-vehicle gateway 1102 succeeds, obtain corresponding message construction information based on the successfully matched preset identification information, and generate the second message using the message construction information and the first message. The message construction information includes one or more of the following a protocol type of the Ethernet packet, a predefined flag in a source MAC address and a destination MAC address in the Ethernet packet.
All or some of the foregoing methods in the embodiments of this application may be implemented by means of software, hardware, firmware, or any combination thereof. When software is used to implement the embodiments, the embodiments may be implemented completely or partially in a form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the procedure or functions according to the embodiments of the present disclosure are all or partially generated. The computer may be a general-purpose computer, a dedicated computer, a computer network, a network device, a user device, or other programmable apparatuses. The computer instructions may be stored in a computer-readable storage medium or may be transmitted from a computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another web site, computer, server, or data center in a wired (for example, a coaxial cable, an optical fiber, or a digital subscriber line (DSL)) or wireless (for example, infrared, radio, or microwave) manner. The computer-readable storage medium may be any usable medium accessible by a computer, or a data storage device, such as a server or a data center, integrating one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a digital video disc (DVD), a semiconductor medium (for example, an SSD), or the like.
Obviously, a person skilled in the art can make various modifications and variations to this application without departing from the scope of this application. This application is intended to cover these modifications and variations of this application provided that they fall within the scope of protection defined by the following claims and their equivalent technologies.
Number | Date | Country | Kind |
---|---|---|---|
201910328524.6 | Apr 2019 | CN | national |
This application is a continuation application of International Patent Application No. PCT/CN2020/086058, filed on Apr. 22, 2020, which claims priority to Chinese Patent Application No. 201910328524.6, filed on Apr. 23, 2019. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2020/086058 | Apr 2020 | US |
Child | 17139133 | US |