Message forwarding method and device, computer device and readable storage medium
By using a packet forwarding method based on parsing and dynamic routing decisions, the problem of inflexible and inefficient traffic processing in VPC gateway scenarios of cloud computing networks by traditional switching devices is solved, achieving efficient, flexible traffic forwarding and scalability.
Patent Information
- Application Number
- CN202411789639.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2044-12-06
AI Technical Summary
Traditional switching devices in cloud computing networks are limited by a single BVI interface in VPC gateway scenarios, resulting in inflexible and inefficient network traffic processing, making it difficult to adapt to the diverse and complex traffic needs of cloud hosts.
By parsing the source MAC address, destination subnet identifier (VNI), and destination IP address in the target traffic packets, a dynamic routing decision mechanism is adopted to achieve fine-grained traffic identification and processing, including Layer 2 and Layer 3 forwarding stages, and packet forwarding is performed using VXLAN encapsulation and a bridge model.
It improves the efficiency and flexibility of traffic forwarding, has better scalability, and can adapt to the increase in the number of cloud hosts and traffic types without the need for large-scale hardware or software upgrades.
Smart Images

Figure CN119583443B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a message forwarding method, apparatus, computer device, and readable storage medium. Background Technology
[0002] In cloud computing network environments, to meet the diverse network communication needs of cloud hosts, Virtual Private Cloud Gateways (VPC Gateways) have emerged as a key forwarding device. VPC Gateways not only act as subnet gateways for cloud hosts but also bear the responsibility of connecting the VPC to external networks. They can efficiently forward traffic between cloud hosts within the same subnet and across subnets, while supporting various traffic types including peering connections, leased line access, Virtual Private Cloud (VPC) connections, and public network access.
[0003] In traditional technologies, the application of switch devices in cloud VPC gateway scenarios is limited by their support for only one BVI (Bridge Virtual Interface) interface, which to some extent restricts the flexible processing and forwarding efficiency of network traffic.
[0004] As cloud servers support an increasing number and more complex types of traffic, how to conceive and design a forwarding mechanism for VPC gateways that is both scalable and high-performance has become a pressing technical challenge. Summary of the Invention
[0005] Therefore, it is necessary to provide a message forwarding method, apparatus, computer device, and readable storage medium that can optimize the message forwarding process to address the aforementioned technical problems.
[0006] Firstly, this application provides a message forwarding method applied to a first Virtual Private Cloud Gateway (VPC) gateway of a virtual machine, the method comprising:
[0007] Obtain the target traffic packet of the target user from the virtual machine; the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address;
[0008] If the destination MAC address is determined to be of subnet address type, the local subnet corresponding to the destination traffic packet and the local subnet routing table corresponding to the local subnet are queried based on the destination subnet identifier (VNI).
[0009] Based on the local subnet routing table and the destination IP address, forward the target traffic packets.
[0010] In one embodiment, forwarding the target traffic packets according to the local subnet routing table and the destination IP address includes:
[0011] If the destination IP address determines that the next hop of the local subnet routing table points to the VPC routing table of the first VPC gateway, then the target traffic packet is forwarded according to the VPC routing table of the first VPC gateway and the destination IP address.
[0012] If the local subnet routing table determines that the next hop points to the virtual machine based on the destination IP address, then the target traffic packets are forwarded within the virtual machine based on the destination MAC address.
[0013] In one embodiment, within the virtual machine, forwarding target traffic packets based on the destination MAC address includes:
[0014] Local encapsulation is performed on the target traffic packets based on the destination MAC address;
[0015] Determine the destination subnet corresponding to the destination MAC address within the virtual machine;
[0016] A bridge model is used to forward locally encapsulated target traffic packets from the local subnet to the subnet interface corresponding to the destination subnet.
[0017] In one embodiment, a bridge model is used to forward locally encapsulated target traffic packets from the local subnet to the subnet interface corresponding to the destination subnet, including:
[0018] Using the bridge model corresponding to the target user, the target traffic packets, which are encapsulated locally, are forwarded from the local subnet to the subnet interface corresponding to the destination subnet.
[0019] In one embodiment, the target traffic packets are forwarded according to the VPC routing table of the first VPC gateway and the destination IP address, including:
[0020] If the next hop of the VPC routing table of the first VPC gateway is determined to point to the default path based on the destination IP address, then the target traffic packet will be forwarded to the public network.
[0021] If, based on the destination IP address, it is determined that the next hop of the VPC routing table of the first VPC gateway points to the external subnet in the second VPC gateway, then the target traffic packet is forwarded according to the external subnet routing table corresponding to the external subnet.
[0022] In one embodiment, the method further includes:
[0023] If the interface type corresponding to the destination MAC address is determined to be a non-subnet address type, the target traffic packet is format-encapsulated according to the non-subnet address type.
[0024] The pre-defined forwarding table corresponding to non-subnet address types is used to forward the target traffic packets after format encapsulation.
[0025] Secondly, this application also provides a message forwarding device configured in a virtual machine's first Virtual Private Cloud Gateway (VPC) gateway, the device comprising:
[0026] The packet acquisition module is used to acquire the target traffic packets of the target user from the virtual machine; the target traffic packets carry the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address.
[0027] The subnet query module is used to query the local subnet corresponding to the target traffic packet and the local subnet routing table corresponding to the local subnet based on the destination subnet identifier (VNI) when the address type of the destination MAC address is determined to be a subnet address type.
[0028] The packet forwarding module is used to forward target traffic packets based on the local subnet routing table and the destination IP address.
[0029] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0030] Obtain the target traffic packet of the target user from the virtual machine; the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address;
[0031] If the destination MAC address is determined to be of subnet address type, the local subnet corresponding to the destination traffic packet and the local subnet routing table corresponding to the local subnet are queried based on the destination subnet identifier (VNI).
[0032] Based on the local subnet routing table and the destination IP address, forward the target traffic packets.
[0033] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0034] Obtain the target traffic packet of the target user from the virtual machine; the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address;
[0035] If the destination MAC address is determined to be of subnet address type, the local subnet corresponding to the destination traffic packet and the local subnet routing table corresponding to the local subnet are queried based on the destination subnet identifier (VNI).
[0036] Based on the local subnet routing table and the destination IP address, forward the target traffic packets.
[0037] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0038] Obtain the target traffic packet of the target user from the virtual machine; the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address;
[0039] If the destination MAC address is determined to be of subnet address type, the local subnet corresponding to the destination traffic packet and the local subnet routing table corresponding to the local subnet are queried based on the destination subnet identifier (VNI).
[0040] Based on the local subnet routing table and the destination IP address, forward the target traffic packets.
[0041] The aforementioned message forwarding method, apparatus, computer equipment, and readable storage medium, through parsing the source MAC address, destination subnet identifier (VNI), and destination IP address in the target traffic message, enable this solution to intelligently classify and route traffic based on this information. This fine-grained traffic identification and processing method significantly improves the efficiency and flexibility of traffic forwarding compared to traditional methods that rely solely on the BVI interface.
[0042] Because this application does not rely on a single BVI interface, but instead makes dynamic routing decisions based on information in traffic packets, it has better scalability. As the number of cloud hosts and traffic types increase, the VPC gateway can easily adapt to changes in network scale without requiring large-scale hardware or software upgrades. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 This is a flowchart illustrating a message forwarding method in one embodiment;
[0045] Figure 2 This is a flowchart illustrating the steps of forwarding target traffic packets in one embodiment;
[0046] Figure 3This is a flowchart illustrating the steps of forwarding target traffic packets in another embodiment;
[0047] Figure 4 This is a flowchart illustrating the steps of forwarding target traffic packets in another embodiment;
[0048] Figure 5 This is a flowchart illustrating the steps of format encapsulating target traffic packets in one embodiment;
[0049] Figure 6 This is a structural block diagram of a message forwarding device in one embodiment;
[0050] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0052] To facilitate understanding of the technical solution in this embodiment, the relevant terms are introduced below:
[0053] A Virtual Private Cloud (VPC) is an isolated virtual network environment provided by a cloud computing service provider. It allows users to create and manage their own private network space on top of public cloud infrastructure. This space is logically isolated and provides similar security and control as a private data center. A VPC typically includes components such as subnets, routing tables, network access control lists (ACLs), and security groups, allowing users to customize network topology and security policies as needed.
[0054] A VPC gateway is a key component of a Virtual Private Cloud (VPC). As a subnet gateway for cloud hosts within a VPC, it is responsible for forwarding traffic between cloud hosts. This gateway not only supports communication within the same subnet but also handles cross-subnet traffic, enabling peering connections between VPCs, dedicated line access to physical data centers, VPN connections, and providing external IPs (EIPs) to cloud hosts. The VPC gateway is a crucial bridge connecting the internal and external networks of a VPC.
[0055] VXLAN (Virtual eXtensible Local Area Network): VXLAN is a network virtualization technology that enables communication between virtual machines (VMs) across physical networks by building a virtual Layer 2 (Ethernet) network on top of an existing Layer 3 (IP) network. VXLAN technology allows VMs to communicate as if they were on the same physical local area network, without being limited by physical location or underlying network architecture. This is crucial for cloud computing and data centers, as they typically need to migrate and scale VMs across multiple physical servers and data centers.
[0056] VNI (VXLAN Network Identifier): A core concept in VXLAN technology. It uniquely identifies a virtual network or virtual subnet within a VXLAN network. Each VNI corresponds to a specific VXLAN virtual network. Through the VNI, network devices can identify and distinguish traffic from different VXLAN virtual networks, thereby ensuring correct traffic forwarding and isolation. The introduction of VNI enables VXLAN networks to support large-scale virtual machine deployments and flexible network topologies.
[0057] A Bridge Virtual Interface (BVI) is a virtual interface on a network switch used for Virtual Local Area Networks (VLANs). It allows communication between different VLANs on the switch, or between a VLAN and other parts of the network (such as routers, other switches, etc.). A BVI can be viewed as a logical interface that enables interconnection between VLANs by bridging traffic from different VLANs, without changing the physical network structure.
[0058] Traditional switching devices have certain shortcomings in their Layer 2 and Layer 3 forwarding strategies, mainly including:
[0059] (1) One-to-one correspondence between Layer 2 broadcast domains and subnets: In the traditional model, a Layer 2 broadcast domain is tightly bound to a subnet, and within this subnet (often abstracted as a Layer 2 bridging structure), although it can accommodate multiple ports, only one BVI (Bridge Virtual Interface) is allowed to exist, becoming the only channel for Layer 2 traffic to reach Layer 3 forwarding. This design is inadequate in the flexibility and multi-tenant environment of cloud computing.
[0060] (2) Fixed binding of BVI interface and VLAN: Traditional switches regard BVI interface as a virtualization of VLAN. However, in the scenario of cloud computing VPC, VNI (Virtual Network Interface) is the key to identifying and isolating the service traffic of different tenants. Under a VPC network, tenants may plan multiple subnets, which means that multiple different subnet interfaces need to be supported on the same Layer 2 bridge, that is, the coexistence of multiple BVI interfaces. However, traditional switch devices and their forwarding models have failed to meet this urgent need.
[0061] To address the aforementioned technical problems, in an exemplary embodiment, such as Figure 1 As shown, a message forwarding method is provided. Taking the application of this method to the first Virtual Private Cloud Gateway (VPC) gateway of a virtual machine as an example, the method includes:
[0062] S101: Obtain the target traffic packets of the target user from the virtual machine.
[0063] The destination traffic packet carries the source Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address.
[0064] Understandably, in an IP network, data packets are routed based on their destination IP address. However, when a data packet reaches the subnet gateway, its destination MAC address needs to be set to the subnet gateway's MAC address so that the packet can be correctly received and processed by the gateway. When a virtual machine needs to send a data packet to an external network, it first queries its default routing table. This routing table contains routing information within the subnet where the virtual machine resides, as well as the default route pointing to the subnet gateway. Based on the routing table, the virtual machine determines that the destination MAC address of the data packet should be set to the subnet gateway's MAC address, because the subnet gateway is the exit point for the virtual machine to access the external network.
[0065] Furthermore, the vSwitch on the virtual machine host encapsulates the data packets sent by the virtual machine into VXLAN according to preset flow table rules. VXLAN encapsulation allows data packets to be transmitted transparently over the underlying underlay network (such as an IP network) while maintaining the isolation of the Layer 2 network. The encapsulated VXLAN packet contains the original Ethernet frame, the destination VNI (VXLAN Network Identifier), and the UDP / IP header for transmission. That is, in VXLAN technology, the destination VNI is encapsulated in the header of the VXLAN packet and transmitted along with the data packet on the physical network. When the data packet arrives at the VPC gateway, the VPC gateway parses the destination VNI in the VXLAN packet header and makes a routing decision based on the destination VNI.
[0066] Furthermore, when the subnet gateway (router interface) receives a data packet, it first parses the network layer header of the data packet to obtain the destination IP address.
[0067] S102, if the address type of the destination MAC address is determined to be a subnet address type, query the local subnet corresponding to the destination traffic packet and the local subnet routing table corresponding to the local subnet based on the destination subnet identifier VNI.
[0068] Specifically, the VPC gateway first checks the destination MAC address in the target traffic packet to determine its type. If the destination MAC address is a subnet address (also known as a subnet gateway address or subnet broadcast address), it indicates that the packet is intended to be sent to a device outside the subnet.
[0069] Once the destination MAC address is determined to be a subnet address type, the VPC gateway needs to determine the local subnet corresponding to this subnet address based on the destination VNI. This typically involves looking up internal data structures (such as subnet tables or VPC configurations) that map MAC addresses (or subnet addresses) to specific local subnets. After obtaining the local subnet information, the VPC gateway then retrieves the corresponding local subnet routing table. The routing table contains information on how to forward packets within or outside the subnet. For packets within the local subnet, the routing table may contain information about interfaces directly connected to the subnet gateway; for packets that need to be forwarded across subnets or VPCs, the routing table may contain routing information pointing to other gateways or routers.
[0070] S103 forwards the target traffic packets based on the local subnet routing table and the destination IP address.
[0071] Optionally, once a matching entry for the destination IP address is found in the local subnet routing table, the VPC gateway will make a forwarding decision based on that entry. This decision includes determining the next-hop address and the outgoing interface. The next-hop address could be the interface address of another VPC gateway or the gateway address of the network where the target device resides. The outgoing interface is the physical interface through which the data packet leaves the current VPC gateway and enters the next network segment.
[0072] After making a forwarding decision, the VPC gateway re-encapsulates the data packet for transmission over the physical network. During encapsulation, the VPC gateway updates the packet's destination MAC address. Since the packet is about to be sent to the next intermediate device (such as another VPC gateway) or target device in the next network segment or subnet, the destination MAC address needs to be updated to the MAC address of the next device. Updating the destination MAC address typically involves using ARP (Address Resolution Protocol) to look up the MAC address of the next device. If the VPC gateway has already cached the MAC address, it can use the cached value directly; otherwise, the VPC gateway sends an ARP request to look up the MAC address. Once the destination MAC address is updated, the packet is sent to the next network segment or subnet through the specified outgoing interface.
[0073] In subsequent subnets, the subnet routing table is checked to see if there is an entry matching the destination IP address, and a forwarding decision is made to forward the target traffic packets.
[0074] The aforementioned packet forwarding method, by parsing the source MAC address, destination subnet identifier (VNI), and destination IP address in the target traffic packet, enables intelligent classification and routing of traffic based on this information. This fine-grained traffic identification and processing approach significantly improves the efficiency and flexibility of traffic forwarding compared to traditional methods that rely solely on the BVI interface. Because this application does not depend on a single BVI interface but instead makes dynamic routing decisions based on information within the traffic packet, it offers better scalability. As the number of cloud hosts and the types of traffic increase, the VPC gateway can easily adapt to changes in network scale without requiring large-scale hardware or software upgrades.
[0075] In one exemplary embodiment, such as Figure 2 As shown, based on the local subnet routing table and the destination IP address, the target traffic packets are forwarded, including:
[0076] S201. If the next hop of the local subnet routing table is determined to point to the VPC routing table of the first VPC gateway based on the destination IP address, then the target traffic packet is forwarded according to the VPC routing table of the first VPC gateway and the destination IP address.
[0077] Understandably, the VPC gateway uses the resolved destination IP address as the lookup key to search for a matching route entry in the local subnet routing table. The local subnet routing table is a data structure that stores how packets are forwarded based on their destination IP address. The table contains multiple route entries, each associated with one or more destination IP address ranges and their corresponding next-hop information. The VPC gateway iterates through these route entries until it finds one that matches the destination IP address. Once a matching route entry is found, the VPC gateway determines how to forward the packet based on the next-hop information within that entry.
[0078] If the next-hop information points to the VPC routing table of the first VPC gateway, the following two scenarios may occur:
[0079] Scenario 1) The destination IP address of the target traffic packet does not belong to a subnet directly managed by the current VPC gateway, but to another subnet or VPC managed by the first VPC gateway. Therefore, the current VPC gateway needs to forward the packet to the first VPC gateway so that the latter can further forward the packet to the destination location according to its VPC routing table. 2) The destination IP address cannot be identified, and the target traffic packet is forwarded to an external network. The following explains these two scenarios:
[0080] Specifically, such as Figure 3 As shown, based on the VPC routing table and destination IP address of the first VPC gateway, the target traffic packets are forwarded, including:
[0081] S301: If the next hop of the VPC routing table of the first VPC gateway is determined to point to the default path based on the destination IP address, then the target traffic packet is forwarded to the public network.
[0082] Understandably, the default path is usually a special route set in the routing table to match destination IP addresses that do not have a more specific route entry to match.
[0083] In a VPC environment, the default path typically points to a public gateway or internet egress to forward packets that are unrecognized or cannot be processed internally to the external network. If the VPC routing table of the first VPC gateway indicates that the next hop is the default path, then the VPC gateway will encapsulate the destination traffic packet (if necessary) and forward it to the public gateway. The public gateway will further process the packet, potentially including performing NAT (Network Address Translation) to hide the internal network structure, before sending the packet to its destination address on the internet.
[0084] S302, if the next hop of the VPC routing table of the first VPC gateway is determined to point to the external subnet in the second VPC gateway based on the destination IP address, then the target traffic packet is forwarded according to the external subnet routing table corresponding to the external subnet.
[0085] Understandably, if an entry in the first VPC routing table matches the destination IP address of a packet, and the next hop of that entry points to an external subnet within the second VPC gateway, the first VPC gateway needs to communicate with the second VPC gateway to obtain routing information for that external subnet. This is typically achieved through internal network protocols (such as BGP, OSPF, etc.), which allow VPC gateways to exchange routing information. The second VPC gateway will then provide the first VPC gateway with the routing tables (or related routing information) of the external subnets it manages.
[0086] The first VPC gateway now has routing information for the external subnet and can use this information to forward target traffic packets. The packets are encapsulated (with a VXLAN header added if necessary) and sent to the second VPC gateway. Upon receiving the packets, the second VPC gateway further processes them according to its managed external subnet routing table. It looks up a routing entry matching the packet's destination IP address and forwards the packet to the target device or subnet gateway within the external subnet based on that entry.
[0087] S202 If the next hop of the local subnet routing table is determined to point to the virtual machine based on the destination IP address, then the target traffic packets are forwarded within the virtual machine based on the destination MAC address.
[0088] Understandably, a destination MAC address pointing to a virtual machine indicates that the traffic is local communication between the virtual machine and other virtual machines or devices within the same subnet or vSwitch. In this case, the traffic does not need to be forwarded through the VPC gateway or external network, but is processed directly within the vSwitch or virtual machine network stack on the virtual machine host. This implements a cross-subnet transmission process, as follows:
[0089] Specifically, such as Figure 4 As shown, within the virtual machine, target traffic packets are forwarded based on the destination MAC address, including:
[0090] S401 performs local encapsulation of target traffic packets based on the destination MAC address.
[0091] Specifically, inside the virtual machine, when the destination MAC address is determined to be the local virtual machine, the packet is encapsulated into a format suitable for transmission in the virtual machine network environment (possibly an Ethernet frame) and forwarded directly to the destination virtual machine through the virtual machine's network interface card (vNIC) or vSwitch.
[0092] S402, determine the destination subnet corresponding to the destination MAC address within the virtual machine.
[0093] Understandably, in a virtualization environment, virtual machines (VMs) are typically configured to connect to one or more virtual networks (such as VLANs or VXLANs). These virtual networks provide isolated communication channels for VMs, enabling them to communicate on the network like physical machines, while maintaining a high degree of flexibility and scalability.
[0094] When a virtual machine (VM) sends traffic, it first needs to determine the destination MAC address based on the destination IP address. Inside the VM, this is typically done by querying the local ARP cache or sending an ARP request. Once the destination MAC address is obtained, the VM needs to determine its location within the internal network, i.e., the corresponding destination subnet. The virtual switch (vSwitch) on the VM host is a key component in handling internal network traffic. The vSwitch maintains flow tables containing forwarding rules based on information such as the destination MAC address, source MAC address, and VLAN ID. When a VM sends traffic, the vSwitch uses the rules in the flow tables to decide how to forward the packet to the destination subnet or the VM.
[0095] While VPC routing tables and subnet routing tables play a crucial role in virtual machines accessing external networks (such as the public network), they may not be directly involved in communication between local virtual machines. Local communication primarily relies on vSwitch flow tables, the virtual machine's network configuration, and any existing local routing tables (if the virtual machine's operating system requires further routing decisions). Local routing tables may contain specific routing rules for handling network traffic within the virtual machine.
[0096] By querying the vSwitch flow table, the virtual machine's network configuration, and the local routing table (if it exists), the virtual machine can determine the destination subnet corresponding to the destination MAC address. Once the destination subnet is determined, the virtual machine can encapsulate the traffic into a format suitable for transmission within the virtual network and forward the packets to the destination subnet via the vSwitch or other network components.
[0097] S403 uses a bridge model to forward locally encapsulated target traffic packets from the local subnet to the subnet interface corresponding to the destination subnet.
[0098] As is understandable, the Bridge model, also known as the network bridge model, is a forwarding mechanism at the data link layer (Layer 2). It determines how to forward a data frame from one network segment (or subnet) to another based on the destination MAC address in the data frame. The bridge is not concerned with the IP address or other network layer (Layer 3) information in the data frame; it only focuses on data link layer information. Virtual switches (vSwitch) or similar network components on a virtual machine host machine act as bridges.
[0099] vSwitch maintains a flow table or forwarding database that records the mapping between MAC addresses and subnet interfaces. When an encapsulated destination traffic packet arrives at vSwitch, vSwitch queries this table to find the subnet interface corresponding to the destination MAC address. Then, vSwitch forwards the packet from the source subnet interface to the destination subnet interface. A subnet interface is the connection point between a virtual machine and a virtual network. Each subnet interface corresponds to a specific virtual network segment (or subnet). Through subnet interfaces, virtual machines can communicate with other virtual machines or devices within the same subnet.
[0100] Specifically, a bridge model is used to forward locally encapsulated target traffic packets from the local subnet to the subnet interface corresponding to the destination subnet. This includes: using a bridge model corresponding to the target user to forward locally encapsulated target traffic packets from the local subnet to the subnet interface corresponding to the destination subnet.
[0101] When a VPC gateway receives a traffic packet, it first parses the packet to identify its destination user. This is typically done by examining the packet's destination MAC address, IP address, or other identifying information.
[0102] Once the target user is identified, the VPC gateway needs to determine which bridge model should be used to forward the packet. This depends on several factors, including the network segment to which the target user belongs, the tenant, and security isolation requirements. For example, different tenants may use different VNIs to isolate their network traffic, and each VNI may correspond to an independent bridge model. After determining the bridge model, the VPC gateway encapsulates the received traffic packets as needed. This may include adding Ethernet frame headers, VLAN tags, VXLAN encapsulation, etc., to ensure that the packet can be transmitted on the correct network path. The VPC gateway maintains one or more forwarding tables, which contain mappings from destination addresses (such as MAC addresses, IP addresses) to ports or interfaces. Finally, the VPC gateway forwards the encapsulated packet through the found subnet interface or VXLAN tunnel interface. If the packet is sent to a user within the same subnet, it may be forwarded directly through the VXLAN tunnel or internal network. If the packet is sent to a user in a different subnet, it may first enter a Layer 3 forwarding process through the subnet gateway interface and then be sent to the destination subnet through appropriate routing.
[0103] In one exemplary embodiment, such as Figure 5 As shown, the method also includes:
[0104] S501: If it is determined that the interface type corresponding to the destination MAC address is a non-subnet address type, the target traffic packet is format-encapsulated according to the non-subnet address type.
[0105] Optionally, the VPC gateway or corresponding network component needs to resolve the destination MAC address of the target traffic packet and query its corresponding interface type. If the interface type is not a subnet address type (i.e., not an interface directly connected to a subnet), special handling is required. Non-subnet address types may include, but are not limited to, VXLAN tunnel interfaces, leased line interfaces, VPN interfaces, etc. These interface types are typically used for communication across subnets, data centers, or networks. Based on the determined non-subnet address type, the VPC gateway will encapsulate the target traffic packet in the appropriate format. This may include adding additional header information (such as VXLAN headers, IP headers, etc.), and possible encryption or compression operations to ensure that the packet can be correctly transmitted in the specific network environment.
[0106] S502 uses a preset forwarding table corresponding to non-subnet address types to forward target traffic packets after format encapsulation.
[0107] Understandably, for each non-subnet address type, the VPC gateway maintains a corresponding default forwarding table. These forwarding tables contain mappings from destination addresses (such as MAC addresses and IP addresses) to specific interfaces or next-hop addresses. For example, the underlay routing table.
[0108] After the formatting is complete, the VPC gateway queries the preset forwarding table corresponding to the non-subnet address type to find the interface or next-hop address to which the target traffic packet should be forwarded. Finally, the VPC gateway forwards the formatted target traffic packet to the corresponding interface or next-hop address based on the query results. This may involve transmission via VXLAN tunnels, leased networks, VPN connections, etc.
[0109] In one exemplary embodiment, based on the above-described packet forwarding method, a VPC forwarding model is proposed. This forwarding model mainly consists of two stages: Layer 2 forwarding and Layer 3 forwarding. These two stages together ensure efficient and accurate traffic transmission.
[0110] Phase 1: Layer 2 Forwarding (Bridge Model), involving VPC MAC entries: This is the core data structure of the Layer 2 forwarding phase. It records the host location information of the cloud host (virtual machine), which is abstracted into VXLAN tunnel interfaces. Simultaneously, it also stores the VPC subnet interfaces, i.e., the subnet gateways of the cloud hosts. VPC MAC entries are also used for broadcast domain control, achieving broadcast traffic isolation by abstracting different bridges.
[0111] Specifically, the VPC gateway receives traffic packets from cloud hosts or other network devices. If the traffic packets are encapsulated using the VXLAN protocol, the VPC gateway will first perform a VXLAN decapsulation operation to obtain the original data frame. Based on the destination MAC address in the decapsulated data frame, the VPC gateway queries the VPC MAC table to obtain the corresponding port information.
[0112] Communication within the same subnet: If the query results show that the port is of type VXLAN, it means that the destination address and the source address are in the same subnet. The VPC gateway will re-encapsulate the data frame into a VXLAN packet and forward it to the destination cloud host through the corresponding VXLAN tunnel interface.
[0113] Cross-subnet communication: If the query result shows that the port is a subnet gateway interface, it means that the destination address and the source address are not in the same subnet. At this time, the traffic packet will enter the second stage of the Layer 3 forwarding process.
[0114] Broadcast domain control: For traffic that needs to be transmitted across broadcast domains, the VPC gateway will abstract different bridges as needed to isolate broadcast traffic and ensure the correct transmission of traffic.
[0115] Phase Two: Layer 3 Forwarding (Route Forwarding), involving: Subnet Routing Table: Records routing information within the subnet, used to guide traffic forwarding within the subnet. VPC Routing Table: Records routing information within the VPC network, including default routes and other custom routes. Other Routing Tables: Such as leased line routing tables, used to implement custom traffic redirection policies for specific traffic.
[0116] Specifically, cross-subnet traffic packets received from the Layer 2 forwarding stage will enter the Layer 3 forwarding process. The VPC gateway first queries the subnet routing table to determine if there is a direct route to the destination address.
[0117] Intra-subnet forwarding: If a matching route entry exists in the subnet routing table, the VPC gateway will forward the traffic packets to the subnet gateway interface corresponding to the destination subnet based on that entry. Subsequently, the traffic packets will undergo Layer 2 forwarding within the destination subnet, eventually reaching the destination cloud host.
[0118] Querying the VPC routing table: If no matching route entry is found in the subnet routing table, the VPC gateway will query the VPC routing table. The VPC routing table may contain default routes or other custom routes to guide traffic packets on how to traverse the VPC network or communicate with other networks.
[0119] External network communication: If there is a route entry in the VPC routing table that points to an external network, the VPC gateway will forward traffic packets to the external network interface or the corresponding gateway device according to the entry.
[0120] Custom traffic redirection: For traffic packets that require specific redirection strategies, the VPC gateway will query other routing tables (such as dedicated line routing tables) and forward them according to the rules therein.
[0121] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0122] Based on the same inventive concept, this application also provides a packet forwarding apparatus for implementing the packet forwarding method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more packet forwarding apparatus embodiments provided below can be found in the limitations of the packet forwarding method described above, and will not be repeated here.
[0123] In one exemplary embodiment, such as Figure 6 As shown, a message forwarding device is provided, configured in the first Virtual Private Cloud Gateway (VPC) gateway of a virtual machine. The device includes:
[0124] The packet acquisition module 11 is used to acquire the target traffic packet of the target user from the virtual machine; wherein, the target traffic packet carries the active media access control MAC address, the destination subnet identifier VNI and the destination IP address;
[0125] Subnet query module 12 is used to query the local subnet corresponding to the target traffic packet and the local subnet routing table corresponding to the local subnet based on the destination subnet identifier VNI when the address type of the destination MAC address is determined to be a subnet address type.
[0126] The packet forwarding module 13 is used to forward target traffic packets according to the local subnet routing table and the destination IP address.
[0127] In one embodiment, the packet forwarding module 12 is further configured to: if it is determined that the next hop of the local subnet routing table points to the VPC routing table of the first VPC gateway based on the destination IP address, then forward the target traffic packet based on the VPC routing table of the first VPC gateway and the destination IP address;
[0128] If the local subnet routing table determines that the next hop points to the virtual machine based on the destination IP address, then the target traffic packets are forwarded within the virtual machine based on the destination MAC address.
[0129] In one embodiment, the packet forwarding module 12 is further configured to: locally encapsulate the target traffic packet according to the destination MAC address;
[0130] Determine the destination subnet corresponding to the destination MAC address within the virtual machine;
[0131] A bridge model is used to forward locally encapsulated target traffic packets from the local subnet to the subnet interface corresponding to the destination subnet.
[0132] In one embodiment, the packet forwarding module 12 is further configured to: use the bridge model corresponding to the target user to forward the locally encapsulated target traffic packet from the local subnet to the subnet interface corresponding to the destination subnet.
[0133] In one embodiment, the packet forwarding module 12 is further configured to: if, based on the destination IP address, it is determined that the next hop of the VPC routing table of the first VPC gateway points to the default path, then forward the target traffic packet to the public network;
[0134] If, based on the destination IP address, it is determined that the next hop of the VPC routing table of the first VPC gateway points to the external subnet in the second VPC gateway, then the target traffic packet is forwarded according to the external subnet routing table corresponding to the external subnet.
[0135] In one embodiment, the device further includes a non-subnet forwarding module, configured to: when it is determined that the interface type corresponding to the destination MAC address is a non-subnet address type, encapsulate the target traffic packet according to the non-subnet address type;
[0136] The pre-defined forwarding table corresponding to non-subnet address types is used to forward the target traffic packets after format encapsulation.
[0137] Each module in the aforementioned message forwarding device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0138] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data for message forwarding methods. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a message forwarding method.
[0139] Those skilled in the art will understand that Figure 7The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0140] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0141] Obtain the target traffic packet of the target user from the virtual machine; the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address;
[0142] If the destination MAC address is determined to be of subnet address type, the local subnet corresponding to the destination traffic packet and the local subnet routing table corresponding to the local subnet are queried based on the destination subnet identifier (VNI).
[0143] Based on the local subnet routing table and the destination IP address, forward the target traffic packets.
[0144] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0145] Obtain the target traffic packet of the target user from the virtual machine; the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address;
[0146] If the destination MAC address is determined to be of subnet address type, the local subnet corresponding to the destination traffic packet and the local subnet routing table corresponding to the local subnet are queried based on the destination subnet identifier (VNI).
[0147] Based on the local subnet routing table and the destination IP address, forward the target traffic packets.
[0148] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0149] Obtain the target traffic packet of the target user from the virtual machine; the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address;
[0150] If the destination MAC address is determined to be of subnet address type, the local subnet corresponding to the destination traffic packet and the local subnet routing table corresponding to the local subnet are queried based on the destination subnet identifier (VNI).
[0151] Based on the local subnet routing table and the destination IP address, forward the target traffic packets.
[0152] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0153] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0154] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A message forwarding method, characterized in that, The method for applying a first Virtual Private Cloud Gateway (VPC) gateway to a virtual machine includes: Obtain the target traffic packet of the target user from the virtual machine; wherein the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address; If the destination MAC address is determined to be of subnet address type, the local subnet corresponding to the target traffic packet and the local subnet routing table corresponding to the local subnet are queried according to the destination subnet identifier (VNI). The target traffic packets are forwarded according to the local subnet routing table and the destination IP address; The method further includes: If it is determined that the interface type corresponding to the destination MAC address is a non-subnet address type, the target traffic packet is format-encapsulated according to the non-subnet address type. The target traffic packets, after being encapsulated, are forwarded using a preset forwarding table corresponding to the non-subnet address type.
2. The method according to claim 1, characterized in that, The forwarding of the target traffic packet based on the local subnet routing table and the destination IP address includes: If, based on the destination IP address, it is determined that the next hop of the local subnet routing table points to the VPC routing table of the first VPC gateway, then the target traffic packet is forwarded based on the VPC routing table of the first VPC gateway and the destination IP address. If the next hop of the local subnet routing table is determined to point to the virtual machine based on the destination IP address, then the target traffic packet is forwarded within the virtual machine based on the destination MAC address.
3. The method according to claim 2, characterized in that, The step of forwarding the target traffic packet based on the destination MAC address within the virtual machine includes: The target traffic packet is locally encapsulated based on the destination MAC address; Determine the destination subnet corresponding to the destination MAC address within the virtual machine; A bridge model is used to forward locally encapsulated target traffic packets from the local subnet to the subnet interface corresponding to the destination subnet.
4. The method according to claim 3, characterized in that, The method of using a bridge model to forward locally encapsulated target traffic packets from the local subnet to the subnet interface corresponding to the destination subnet includes: Using the bridge model corresponding to the target user, the locally encapsulated target traffic packets are forwarded from the local subnet to the subnet interface corresponding to the destination subnet.
5. The method according to claim 2, characterized in that, The step of forwarding the target traffic packet according to the VPC routing table of the first VPC gateway and the destination IP address includes: If, based on the destination IP address, it is determined that the next hop of the VPC routing table of the first VPC gateway points to the default path, then the target traffic packet is forwarded to the public network. If, based on the destination IP address, it is determined that the next hop of the VPC routing table of the first VPC gateway points to an external subnet in the second VPC gateway, then the target traffic packet is forwarded according to the external subnet routing table corresponding to the external subnet.
6. The method according to claim 1, characterized in that, The non-subnet address types include Virtual Scalable Local Area Network (VXLAN) tunnel interfaces, leased line interfaces, or Virtual Private Network (VPN) interfaces, and the preset forwarding table includes the underlying underlay routing table.
7. A message forwarding device, characterized in that, The first Virtual Private Cloud (VPC) gateway configured in a virtual machine, the device includes: The packet acquisition module is used to acquire the target traffic packet of the target user from the virtual machine; wherein the target traffic packet carries the active Media Access Control (MAC) address, the destination subnet identifier (VNI), and the destination IP address; The subnet query module is used to query the local subnet corresponding to the target traffic packet and the local subnet routing table corresponding to the local subnet based on the destination subnet identifier (VNI) when the address type of the destination MAC address is determined to be a subnet address type. The packet forwarding module is used to forward the target traffic packet according to the local subnet routing table and the destination IP address; The packet forwarding module is also used to encapsulate the target traffic packet according to the non-subnet address type when it is determined that the interface type corresponding to the destination MAC address is a non-subnet address type; and to forward the encapsulated target traffic packet using a preset forwarding table corresponding to the non-subnet address type.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Packet forwarding method and VxLAN gateway
CN104350714A
Flow data control method and device and medium
CN115242788A