CN-116436875-B - Message forwarding method and device
Abstract
The application provides a message forwarding method and device. The method comprises the steps of determining and executing three layers of forwarding according to the fact that a destination MAC address of an Ethernet message is a gateway MAC address, searching a link layer address mapping table according to a destination IP address of an inner IP message of the Ethernet message, acquiring a new destination MAC address from a matched link layer address mapping table when the link layer address mapping table item matched with the destination IP address is searched, searching an MAC address table according to the new destination MAC address, acquiring an output port and an output VLAN from the MAC address table item when the matched MAC address table item of the new destination MAC address is searched, respectively modifying the destination MAC address, the source MAC address and the input VLAN of the Ethernet message into the new MAC address, the gateway MAC address and the output VLAN, and transmitting the modified Ethernet message through the output port.
Inventors
- ZHANG JIANBO
Assignees
- 新华三技术有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20230322
Claims (12)
- 1. A method for forwarding a message, the method comprising: determining to execute three layers of forwarding according to the destination MAC address of the Ethernet message is a gateway MAC address; Searching a link layer address mapping table according to a destination IP address of an inner layer IP message of the Ethernet message; when a first link layer address mapping table item matched with the destination IP address is found, acquiring a new destination MAC address from the matched first link layer address mapping table item; Searching an MAC address table according to the new destination MAC address; when a first MAC address table item matched with the new destination MAC address is found, acquiring a port and a VLAN from the first MAC address table item; Modifying the destination MAC address, the source MAC address and the ingress VLAN of the Ethernet message into the new destination MAC address, the gateway MAC address and the egress VLAN respectively; And sending the modified Ethernet message through the output port.
- 2. The method of claim 1, wherein prior to looking up a MAC address table from the new destination MAC address, the method further comprises; Searching an MAC address table according to the source MAC address; And learning a second MAC address table entry without finding the MAC address table entry matched with the source MAC address, wherein the source MAC address of the Ethernet message of the second MAC address table entry is related to the VLAN identifier and the port of the Ethernet message.
- 3. The method according to claim 1, wherein the method further comprises: When the link layer address mapping table item matched with the destination IP address is not found, generating a link layer address mapping request message for the destination IP address; And sending the generated link layer address mapping request message through a port of each main ring connected with the VSI in the virtual forwarding instance, wherein each main ring is associated with different sub-rings and the different sub-rings are configured with different VLANs.
- 4. A method according to claim 3, characterized in that the method further comprises: receiving a first link layer address mapping response message with the IP address of the transmitting end as the destination IP address; generating the first link layer address mapping table item, wherein the IP address of the transmitting end of the first link layer address mapping response message corresponds to the MAC address of the transmitting end of the link layer address mapping response message; and generating the first MAC address table entry, wherein the source MAC address of the link layer address mapping response message is recorded to correspond to the VLAN and the port of the first link layer address mapping response message.
- 5. A method according to claim 1 or 3, characterized in that, The ingress VLAN and the egress VLAN belong to the same VLAN, or the ingress VLAN and the egress VLAN belong to different VLANs.
- 6. The method according to claim 1, wherein the method further comprises: receiving a second link layer address mapping request message with a target end IP address being a gateway IP address; Generating a second link layer address mapping table item, wherein the second link layer address mapping table item records that the IP address of the transmitting end of the second link layer address mapping request message corresponds to the MAC address of the transmitting end of the second link layer address mapping request message; Generating a third MAC address table item, wherein the source MAC address of the second link layer address mapping request message in the third MAC address table item is related to the VLAN and the port of the second link layer address mapping request message; Generating a second link layer address mapping response message, searching the third MAC address table item according to the destination MAC address of the second link layer address mapping response message, acquiring the output port and the output VLAN of the second link layer address mapping response message, adding the output VLAN for the second link layer address mapping response message, and transmitting the second link layer address mapping response message through the output port of the second link layer address mapping response message.
- 7. A message forwarding device, the device comprising: The receiving module is used for receiving the Ethernet message; the preprocessing module is used for determining to execute three layers of forwarding according to a gateway MAC address serving as a destination MAC address of the Ethernet message; The forwarding module searches a link layer address mapping table according to a destination IP address of an inner layer IP message of the Ethernet message, acquires a new destination MAC address from a first link layer address mapping table item matched with the destination IP address when the first link layer address mapping table item matched with the destination IP address is searched, searches an MAC address table according to the new destination MAC address, acquires an output port and an output VLAN from the first MAC address table item when the first MAC address table item matched with the new destination MAC address is searched, and respectively modifies a destination MAC address, a source MAC address and an input VLAN of the Ethernet message into the new destination MAC address, the gateway MAC address and the output VLAN; and the sending module is used for sending the modified Ethernet message through the output port.
- 8. The apparatus of claim 7, wherein the device comprises a plurality of sensors, The forwarding module is further configured to search an MAC address table according to the source MAC address, and learn a second MAC address table entry if no MAC address table entry matching the source MAC address is found, where the source MAC address of the ethernet packet is associated with an ingress VLAN identifier and an ingress port of the ethernet packet.
- 9. The apparatus of claim 7, wherein the apparatus further comprises a link layer address mapping module; the forwarding module informs the link layer address mapping module when the link layer address mapping table item matched with the destination IP address is not found; the link layer address mapping module generates a link layer address mapping request message for the destination IP address; The sending module sends the link layer address mapping request message through a port of each main ring connected with the VSI in the virtual forwarding instance, wherein each main ring is associated with different sub-rings and the different sub-rings are configured with different VLANs.
- 10. The apparatus of claim 9, wherein the device comprises a plurality of sensors, The receiving module is further configured to receive a first link layer address mapping response packet with the sender IP address being the destination IP address; The link layer address mapping module generates the first link layer address mapping table item and synchronizes to the link layer address mapping table of the forwarding module; And the forwarding module generates the first MAC address table entry, wherein the source MAC address of the link layer address mapping response message is recorded to correspond to the VLAN and the port of the first link layer address mapping response message.
- 11. The apparatus according to claim 7 or 9, wherein, The ingress VLAN and the egress VLAN belong to the same VLAN, or the ingress VLAN and the egress VLAN belong to different VLANs.
- 12. The apparatus of claim 7, wherein the device comprises a plurality of sensors, The receiving module is further configured to receive a second link layer address mapping request packet with the target IP address being the gateway IP address; The link layer address mapping module generates a second link layer address mapping table item and synchronizes to the link layer address mapping table of the forwarding module to generate a second link layer address mapping response message, wherein the second link layer address mapping table item records that the IP address of the sending end of the second link layer address mapping request message corresponds to the MAC address of the sending end of the link layer address mapping request message; The forwarding module generates a third MAC address table item; wherein, the source MAC address of the second link layer address mapping request packet in the third MAC address table entry is associated with an ingress VLAN and an ingress port of the second link layer address mapping request packet; the third MAC address table item is searched according to the destination MAC address of the second link layer address mapping response message, the output port and the VLAN of the second link layer address mapping response message are obtained, and the VLAN is added for the second link layer address mapping response message; and the sending module is used for sending the response message through the output port of the second link layer address mapping.
Description
Message forwarding method and device Technical Field The application relates to a communication technology, in particular to a vehicle networking communication technology, and specifically relates to a message forwarding method and device. Background The internet of vehicles is an omnibearing network connection of the inside of the vehicle, the vehicle and the road, the vehicle and the person, and the vehicle and the service platform by means of new generation information and communication technology. In the Internet of vehicles, the roadside network comprises a wireless network and a wired network, a plurality of subrings are arranged in the wired network, and different VLANs are configured by switches in different subrings in order to prevent the influence of two-layer broadcast data messages on the wired network, wherein the data messages sent by the vehicles and the data messages sent to the vehicles need to be forwarded through gateway switches. When a vehicle communicating with other terminals (such as other vehicles and external terminals) runs from one intersection to another, when the vehicle roams from one base station to another base station in a wireless network, the sub-ring changes, VLAN and port of a data message of the running vehicle are changed by a gateway switch, the gateway switch needs to refresh a link layer address mapping table item (such as an ARP table item of an IPv4 network or an ND table item of an IPv6 network) to correctly reflect the port and VLAN of the data message of the running vehicle, and guide a return data message to be sent to the vehicle through the correct port and VLAN of a sub-network. However, the learning requirement of the link layer address mapping table item occupies CPU resources of the gateway switch, and the refreshing of the link layer address mapping table item from time to time of vehicles running in the Internet of vehicles occupies software computing resources, so that the refreshing efficiency of the table item is reduced, and the data forwarding among the vehicles is affected. Disclosure of Invention The application aims to provide a message forwarding method and equipment, which avoid the influence of refreshing efficiency of a link layer address mapping table item on data forwarding of a driving vehicle. In order to achieve the above purpose, the present application provides a message forwarding method, in which three layers of forwarding are determined to be executed according to the fact that the destination MAC address of an ethernet message is a gateway MAC address, a link layer address mapping table is searched according to the destination IP address of an inner layer IP message of the ethernet message, when a link layer address mapping table item matched with the destination IP address is searched, a new destination MAC address is obtained from the matched link layer address mapping table item, a MAC address table is searched according to the new destination MAC address, when the matched MAC address table item of the new destination MAC address is searched, an output port and an output VLAN are obtained from the MAC address table item, the destination MAC address, the source MAC address and the input VLAN of the ethernet message are respectively modified to be a new MAC address, a gateway MAC address and an output VLAN, and the modified ethernet message is sent through the output port. The application further provides message forwarding equipment which is not used for achieving the purposes, and comprises a receiving module, a preprocessing module, a forwarding module, a sending module and a sending module, wherein the receiving module is used for receiving an Ethernet message, the preprocessing module is used for determining to execute three-layer forwarding according to a gateway MAC address serving as a destination MAC address of the Ethernet message, the forwarding module is used for searching a link layer address mapping table according to a destination IP address of an inner layer IP message of the Ethernet message, acquiring a new destination MAC address from the matched link layer address mapping table when the link layer address mapping table item matched with the destination IP address is searched, searching the MAC address table according to the new destination MAC address, acquiring an output port and an output VLAN from the first MAC address table item when the matched MAC address item of the new destination MAC address is searched, respectively modifying the destination MAC address, a source MAC address and an input VLAN of the Ethernet message into the new MAC address, the gateway MAC address and the output VLAN, and the sending module is used for sending the modified Ethernet message through the output port. The application has the advantages that the mode of the traditional forwarding mechanism is changed, the information of the VLAN and the outlet of the three-layer forwarding flow between vehicles is not acquired through