CN117336234A - Data transmission method and device, electronic equipment and storage medium - Google Patents

Data transmission method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117336234A
CN117336234A CN202311458372.4A CN202311458372A CN117336234A CN 117336234 A CN117336234 A CN 117336234A CN 202311458372 A CN202311458372 A CN 202311458372A CN 117336234 A CN117336234 A CN 117336234A
Authority
CN
China
Prior art keywords
interface
mac address
virtual sub
virtual
data transmission
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311458372.4A
Other languages
Chinese (zh)
Inventor
雷永成
吴方
陈玲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Aloha Technology Co ltd
CHENGDU SKSPRUCE TECHNOLOGY Inc
Original Assignee
Suzhou Aloha Technology Co ltd
CHENGDU SKSPRUCE TECHNOLOGY Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Aloha Technology Co ltd, CHENGDU SKSPRUCE TECHNOLOGY Inc filed Critical Suzhou Aloha Technology Co ltd
Priority to CN202311458372.4A priority Critical patent/CN117336234A/en
Publication of CN117336234A publication Critical patent/CN117336234A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/58Association of routers
    • H04L45/586Association of routers of virtual routers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/618Details of network addresses
    • H04L2101/622Layer-2 addresses, e.g. medium access control [MAC] addresses

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a data transmission method, a device, electronic equipment and a storage medium, and relates to the field of VRF, wherein the method comprises the following steps: creating a plurality of virtual sub-interfaces based on the physical interfaces, and establishing a one-to-one correspondence between a plurality of VRF instances and the plurality of virtual sub-interfaces; configuring independent MAC addresses for each virtual sub-interface; data transmission is carried out between the VRF instance and the external equipment by utilizing the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface, and/or data transmission is carried out between the VRF instance by utilizing the virtual sub-interface and the MAC address of the virtual sub-interface; the virtual sub-interfaces can be established for each VRF instance based on the physical interfaces, and independent MAC addresses can be configured for each virtual sub-interface, so that each virtual sub-interface can be logically used as the physical interface, and each VRF instance can be directly communicated with external equipment and other VRF instances through the corresponding virtual sub-interfaces, thereby effectively improving the processing efficiency.

Description

Data transmission method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of VRF (Virtual Routing and Forwarding, virtual routing forwarding), and in particular, to a data transmission method, apparatus, electronic device, and storage medium.
Background
VRFs are a common computer network technology for creating multiple virtual routing tables (i.e., VRF instances) on one physical router or switch, each of which can independently run routing protocols and forward data packets as if they were different physical devices. VRF technology is widely used in virtualized networks and multi-tenant environments.
In the related art, because the VRF instances are isolated from each other, in order to ensure that each VRF instance can communicate with an external device through a physical interface, a special VRF instance is required to aggregate all the VRF instances, and traffic forwarding is performed between the physical interface and each VRF instance by the special VRF instance. Clearly, the advent of this special VRF instance reduced processing efficiency and increased processor overhead and message transmission latency.
Disclosure of Invention
The invention aims to provide a data transmission method, a device, electronic equipment and a storage medium, which can create a corresponding virtual sub-interface for each VRF instance based on a physical interface, so that each VRF instance can directly communicate with external equipment and other VRF instances through the corresponding virtual sub-interface, thereby effectively improving the processing efficiency and reducing the CPU overhead and message transmission delay.
In order to solve the above technical problems, the present invention provides a data transmission method, including:
creating a plurality of virtual sub-interfaces based on a physical interface, and establishing a one-to-one correspondence between a plurality of VRF instances and the plurality of virtual sub-interfaces;
configuring an independent MAC address for each virtual sub-interface;
and carrying out data transmission between the VRF instance and external equipment by utilizing the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface, and/or carrying out data transmission between the VRF instance by utilizing the virtual sub-interface and the MAC address of the virtual sub-interface.
Optionally, the data transmission between the VRF instance and the external device using the virtual subinterface, the MAC address of the virtual subinterface, and the physical interface includes:
receiving an IP data packet sent by a corresponding VRF instance by utilizing the virtual sub-interface;
encapsulating the IP data packet by using the virtual sub-interface and taking the MAC address of the virtual sub-interface as a source MAC address to obtain a data frame;
and sending the data frame to the external equipment through the physical interface.
Optionally, the data transmission between the VRF instance and the external device using the virtual subinterface, the MAC address of the virtual subinterface, and the physical interface includes:
receiving a data frame sent by the external equipment by utilizing the physical interface;
when the destination MAC address of the data frame is determined to correspond to the virtual sub-interface, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address;
and extracting an IP data packet from the data frame by using the target virtual sub-interface, and sending the IP data packet to a VRF instance corresponding to the target virtual sub-interface by using the target virtual sub-interface.
Optionally, after configuring an independent MAC address for each virtual subinterface, the method further includes:
writing the MAC address of each virtual sub-interface into an MAC address table;
correspondingly, when determining that the destination MAC address of the data frame corresponds to the virtual sub-interface, sending the data frame to a target virtual sub-interface corresponding to the destination MAC address, including:
and when the destination MAC address of the data frame is determined to be recorded in the MAC address table, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address.
Optionally, after writing the MAC address of each virtual subinterface into the MAC address table, the method further includes:
adding a local mark for the MAC address of each virtual sub-interface in the MAC address table;
correspondingly, when determining that the destination MAC address of the data frame is recorded in the MAC address table, sending the data frame to a target virtual sub-interface corresponding to the destination MAC address, including:
and when the destination MAC address of the data frame is determined to be recorded in the MAC address table and provided with the local mark, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address.
Optionally, the data transmission between the VRF instances using the virtual subinterface and the MAC address of the virtual subinterface includes:
receiving an IP data packet sent by a corresponding VRF instance by using a first virtual sub-interface;
encapsulating the IP data packet by using the first virtual sub-interface and using an MAC address of the first virtual sub-interface as a source MAC address and an MAC address corresponding to a destination IP address of the IP data packet as a destination MAC address to obtain a data frame;
transmitting the data frame to a second virtual sub-interface corresponding to the destination MAC address;
and extracting an IP data packet from the data frame by using the second virtual sub-interface, and sending the IP data packet to a VRF instance corresponding to the second virtual sub-interface by using the second virtual sub-interface.
Optionally, the user device maps with the VRF instance based on VLAN, and the user device communicates with the external device through the VRF instance.
The invention also provides a data transmission device, comprising:
the virtual sub-interface creation module is used for creating a plurality of virtual sub-interfaces based on the physical interfaces and establishing a one-to-one correspondence between a plurality of VRF instances and the virtual sub-interfaces;
the MAC address allocation module is used for configuring independent MAC addresses for the virtual sub-interfaces;
and the data transmission module is used for carrying out data transmission between the VRF instance and external equipment by utilizing the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface, and/or carrying out data transmission between the VRF instance by utilizing the virtual sub-interface and the MAC address of the virtual sub-interface.
The present invention also provides an electronic device including:
a memory for storing a computer program;
a processor for implementing the data transmission method as described above when executing the computer program;
and the physical interface is used for carrying out network data transmission with external equipment.
The present invention also provides a computer-readable storage medium having stored therein computer-executable instructions that, when loaded and executed by a processor, implement a data transmission method as described above.
The invention provides a data transmission method, which comprises the following steps: creating a plurality of virtual sub-interfaces based on a physical interface, and establishing a one-to-one correspondence between a plurality of VRF instances and the plurality of virtual sub-interfaces; configuring an independent MAC address for each virtual sub-interface; and carrying out data transmission between the VRF instance and external equipment by utilizing the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface, and/or carrying out data transmission between the VRF instance by utilizing the virtual sub-interface and the MAC address of the virtual sub-interface.
Therefore, the invention can firstly create a plurality of virtual sub-interfaces based on the physical interface, and establish a one-to-one correspondence between a plurality of VRF instances and the plurality of virtual sub-interfaces, namely each VRF instance can use the corresponding virtual sub-interface for communication; then, the invention can configure independent MAC addresses for the virtual sub-interfaces, namely each virtual sub-interface can be used as a physical interface to communicate with external equipment logically; furthermore, the invention uses the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface to carry out data transmission between the VRF instance and the external device, and/or uses the virtual sub-interface and the MAC address of the virtual sub-interface to carry out data transmission between the VRF instance, which is logically equivalent to that each VRF instance can adopt independent and exclusive physical interface to communicate with the external device and other VRF instances, thereby effectively improving the processing efficiency and reducing the CPU cost and the message transmission delay. The invention also provides a data transmission device, electronic equipment and a computer readable storage medium, which have the beneficial effects.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a conventional multi-VRF example communication system according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a new multi-VRF example communication system according to an embodiment of the present invention;
fig. 3 is a flowchart of a data transmission method according to an embodiment of the present invention;
FIG. 4 is a logical schematic diagram of another novel multi-VRF instance communication system provided by an embodiment of the present invention;
FIG. 5 is a schematic diagram of a first data flow according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating a second data flow according to an embodiment of the present invention;
FIG. 7 is a diagram illustrating a third data flow according to an embodiment of the present invention;
FIG. 8 is a diagram illustrating relationships between data structures according to an embodiment of the present invention;
fig. 9 is a block diagram of a data transmission device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
VRFs (Virtual Routing and Forwarding, virtual routing forwarding) are a common computer network technology for creating multiple virtual routing tables (i.e., VRF instances) on one physical router or switch, each of which can independently run routing protocols and forward data packets as if they were different physical devices. In the related art, because the VRF instances are isolated from each other, in order to ensure that each VRF instance can communicate with an external device through a physical interface, a special VRF instance is required to aggregate all the VRF instances, and traffic forwarding is performed between the physical interface and each VRF instance by the special VRF instance. Referring to fig. 1, fig. 1 is a logic diagram of a conventional multi-VRF instance communication system according to an embodiment of the present invention. Wherein VRF1 through VRFn represent multiple VRF instances that are isolated from each other and work independently; the physical interface is a network port. To ensure that these VRF instances can communicate with the outside world, a further VRF0 is provided for data aggregation of VRFs 1 through VRFn and traffic distribution between the multiple VRF instances and the external device. Obviously, the appearance of VRF0 brings additional processing flow, which not only reduces the processing efficiency, but also increases the CPU overhead and the message transmission delay. In view of this, the present invention may provide a data transmission method, which may create a corresponding virtual sub-interface for each VRF instance based on a physical interface, and allocate an independent MAC address for each virtual sub-interface, so that each VRF instance may directly communicate with an external device and other VRF instances through the corresponding virtual sub-interface, thereby effectively improving processing efficiency and reducing processor overhead and message transmission delay.
For ease of understanding, please refer to fig. 2, fig. 2 is a logic diagram of a new multi-VRF instance communication system according to an embodiment of the present invention. Where VRF1 through VRFn represent multiple VRF instances, the physical interface is also a portal. Unlike existing systems, embodiments of the present invention may create virtual subinterfaces (i.e., subinterface 1 through subinterface n) that correspond one-to-one to each VRF instance based on the physical interfaces, and may assign independent MAC addresses (i.e., MAC1 through MACn, each MAC address being different) to each virtual subinterface. Thus, each virtual sub-interface can be logically regarded as a physical interface; the actual physical interface can be abstracted into a switch, and the received data frames can be forwarded only in the form of the switch. On the basis, in the actual communication process, after each VRF instance generates an IP data packet, each VRF instance can be directly sent to a corresponding virtual sub-interface, so that the virtual sub-interface takes the MAC address of the virtual sub-interface as a source MAC address to package the IP data packet into a data frame, and the virtual sub-interface directly sends the data frame to external equipment through a physical interface. Similarly, when the physical interface receives a data frame sent by the external device, the physical interface can simply forward the data frame to a corresponding virtual sub-interface in the form of a switch according to a destination MAC address in the data frame, so that the virtual sub-interface analyzes the data frame, and the virtual sub-interface sends the obtained IP data packet to a corresponding VRF instance. It is further worth noting that by creating virtual subinterfaces for each VRF instance, it is also convenient for each VRF instance to communicate between VRF instances directly through the virtual subinterfaces. In short, by creating a virtual sub-interface for each VRF instance, the capability of each VRF instance for two-layer communication is given, so that the communication flexibility between the VRF instance and external equipment and between the VRF instance and other VRF instances can be further improved, and the influence of the special VRF instance for data summarization on processor overhead and message transmission delay can be avoided.
It should be noted that, the embodiment of the present invention is not limited to the hardware device for setting the VRF instance, the virtual sub-interface and the physical interface, and the hardware device may be a network device, or may be an electronic device (such as a personal computer, a server, etc.) with a network communication function, and may be set according to actual application requirements.
Referring to fig. 3 for describing the system structure, fig. 3 is a flowchart of a data transmission method according to an embodiment of the present invention, where the method may include:
s301, creating a plurality of virtual sub-interfaces based on the physical interfaces, and establishing a one-to-one correspondence between a plurality of VRF instances and the plurality of virtual sub-interfaces.
In the embodiment of the invention, the virtual sub-interfaces corresponding to all the VRF instances can be created based on the physical interfaces, and the virtual sub-interfaces and the corresponding VRF instances can be established in a binding relation, so that the VRF instances send the IP data packets to the corresponding virtual sub-interfaces for data frame encapsulation, and the VRF instances receive the IP data packets returned by the corresponding virtual sub-interfaces.
It should be noted that, the embodiment of the present invention is not limited to the implementation manner of the virtual sub-interface, and may be implemented according to the actual application requirement, and only needs to ensure that the virtual sub-interface has the function of the physical interface.
S302, configuring independent MAC addresses for each virtual sub-interface.
The embodiment of the invention can further configure an independent MAC address for each virtual sub-interface, so that each virtual sub-interface has the capability of independently receiving and transmitting data frames. It will be appreciated that a MAC address generation algorithm may be employed to set a corresponding MAC address for each virtual subinterface. It should be noted that, the embodiment of the present invention is not limited to a specific MAC address generation algorithm, and may be set according to actual application requirements.
S303, data transmission is carried out between the VRF instance and the external equipment by utilizing the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface, and/or data transmission is carried out between the VRF instance by utilizing the virtual sub-interface and the MAC address of the virtual sub-interface.
It should be noted that, the virtual sub-interface in the embodiment of the present invention may be logically regarded as a physical interface, and has all functions of the physical interface, such as a data frame encapsulation and parsing function, and also has a function of maintaining a MAC table and an ARP table (Address Resolution Protocol ). Therefore, in the actual communication process, when receiving the IP data packet sent by the VRF instance, the virtual sub-interface can take the self MAC address as the source MAC address, and the IP data packet is packaged into a data frame; then, if the data frame needs to be sent to the external device, the virtual sub-interface may send the data frame to the physical interface, so that the physical interface forwards the data frame to the external device; if it is determined that the data frame needs to be sent to another virtual sub-interface, the virtual sub-interface can directly send the data frame to the corresponding virtual sub-interface, so that the virtual sub-interface receiving the data frame performs subsequent analysis processing. In addition, the physical interface in the embodiment of the invention can be regarded as a switch in logic, so that the physical interface only needs to forward the received data frame based on the identity of the switch, for example, after receiving the data frame sent by the external device, the physical interface can forward the data frame to the corresponding virtual sub-interface according to the destination MAC address in the data frame. Of course, if the physical interface determines that the destination MAC address in the data frame sent by the external device does not correspond to any virtual subinterface, the physical interface may discard or otherwise process the data frame.
Further, the VRF instance in the embodiment of the present invention may establish a mapping with the user equipment through a VLAN (Virtual Local Area Network ), so that the user equipment may communicate with the external device through the VRF instance. Moreover, the relationship between the VRF instance and the user equipment may be a one-to-many relationship, i.e., multiple user equipments may all communicate with the external device through one VRF instance. Referring to fig. 4, fig. 4 is a logic diagram of another new multi-VRF instance communication system according to an embodiment of the present invention. It can be seen that the mapping relationship is established between the user equipment 1 and the VRF1 through VLAN1, the mapping relationship is established between the user equipment 2 and the VRF2 through VLAN2, and the mapping relationship is established between the user equipment n and the VRFn through VLAN n. In other words, the user device may establish a virtual local area network with the corresponding VRF instance. Because VRF is a virtualization technology, the embodiments of the present invention can create a large number of VRF instances in a small number of physical devices, and utilize these VRF instances and VLAN technology to provide intranet management functionality for a large number of user devices. When the VRF instance is deployed in the edge cloud and the edge cloud resource is accessed through the VRF instance, the embodiment of the invention can extend the range of the user local area network into the edge cloud, and the VRF instance provides the intranet management function and the cloud resource access function for the user side, thereby improving the convenience of accessing and using the edge cloud by the user equipment.
Based on the above embodiment, the present invention may first create a plurality of virtual subinterfaces based on a physical interface, and establish a one-to-one correspondence between a plurality of VRF instances and a plurality of virtual subinterfaces, that is, each VRF instance may use a corresponding virtual subinterface for communication; then, the invention can configure independent MAC addresses for the virtual sub-interfaces, namely each virtual sub-interface can be used as a physical interface to communicate with external equipment logically; furthermore, the invention uses the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface to carry out data transmission between the VRF instance and the external device, and/or uses the virtual sub-interface and the MAC address of the virtual sub-interface to carry out data transmission between the VRF instance, which is logically equivalent to that each VRF instance can adopt independent and exclusive physical interface to communicate with the external device and other VRF instances, thereby effectively improving the processing efficiency and reducing the processor cost and the message transmission delay.
Based on the above embodiments, a data transmission procedure between the VRF instance and the external device will be described in detail. In one possible scenario, data transfer between the VRF instance and the external device using the virtual subinterface, the MAC address of the virtual subinterface, and the physical interface may include:
step 11: and receiving the IP data packet sent by the corresponding VRF instance by utilizing the virtual sub-interface.
Step 12: and encapsulating the IP data packet by using the virtual sub-interface and taking the MAC address of the virtual sub-interface as a source MAC address to obtain a data frame.
Step 13: and sending the data frame to an external device through a physical interface.
Referring to fig. 5, fig. 5 is a schematic diagram of a first data flow according to an embodiment of the invention. When receiving an IP packet sent by VRF1, subinterface 1 may use its own MAC address (i.e. MAC 1) as a source MAC address (i.e. smac=mac1) to encapsulate the IP packet into a data frame; the sub-interface may then send the data frame to the physical interface for forwarding by the physical interface to the corresponding external device.
In one possible scenario, data transfer between a VRF instance and an external device using a virtual subinterface, a MAC address of the virtual subinterface, and a physical interface, includes:
step 21: receiving a data frame sent by external equipment by using a physical interface;
step 22: when the destination MAC address of the data frame is determined to correspond to the virtual sub-interface, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address;
step 23: and extracting the IP data packet from the data frame by using the target virtual sub-interface, and sending the IP data packet to the VRF instance corresponding to the target virtual sub-interface by using the target virtual sub-interface.
Referring to fig. 6, fig. 6 is a schematic diagram of a second data flow according to an embodiment of the invention. When the physical interface receives a data frame sent by the external device, it can first determine to which sub-interface the Destination MAC Address (DMAC) in the data frame corresponds. Since the destination MAC address of the data frame shown in fig. 6 is MAC2 (dmac=mac2), and MAC2 is the MAC address of the subinterface 2, the physical interface may forward the data frame to the subinterface 2, so that the subinterface 2 parses the data frame and sends the resulting IP packet to its corresponding VRF2.
Further, in order to achieve the above forwarding effect, when each virtual sub-interface is created, the MAC address of each virtual sub-interface may be written into the MAC address table, and then both the physical interface and each virtual sub-interface may perform internal forwarding of the data frame by querying the MAC address table.
Based on this, after configuring an independent MAC address for each virtual subinterface, it may further include:
step 31: writing the MAC address of each virtual sub-interface into an MAC address table;
correspondingly, when the destination MAC of the data frame is determined to correspond to the virtual sub-interface, the data frame is sent to the target virtual sub-interface corresponding to the destination MAC address, which comprises the following steps:
step 32: when the destination MAC address of the data frame is determined to be recorded in the MAC address table, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address.
It should be noted that, the embodiment of the present invention is not limited to the implementation form of the MAC address table, and may be set according to the actual application requirement. The MAC address of each virtual sub-interface may also be recorded using an existing MAC address table, for example, an FDB database (Forwarding Data Base ) may be used to record the MAC address of each virtual sub-interface. Of course, since the MAC address of each virtual sub-interface belongs to a special MAC address and should be distinguished from the existing MAC address type in the FDB database, the embodiment of the present invention may also set a special tag (e.g., a local tag) for the MAC address of the virtual sub-interface, so as to separately manage and query the MAC address of the virtual sub-interface.
Based on this, after the MAC address of each virtual subinterface is written into the MAC address table, it may further include:
step 41: adding a local mark for the MAC address of each virtual sub-interface in the MAC address table;
correspondingly, when determining that the destination MAC address of the data frame is recorded in the MAC address table, sending the data frame to the target virtual sub-interface corresponding to the destination MAC address includes:
step 42: and when the destination MAC address of the data frame is determined to be recorded in the MAC address table and provided with the local mark, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address.
Based on the above embodiments, the data transmission procedure between VRF instances will be described in detail below. In one possible scenario, data transfer between VRF instances using virtual subinterfaces and MAC addresses of the virtual subinterfaces may include:
step 51: receiving an IP data packet sent by a corresponding VRF instance by using a first virtual sub-interface;
step 52: encapsulating the IP data packet by using the first virtual sub-interface and using the MAC address of the first virtual sub-interface as a source MAC address and the MAC address corresponding to the destination IP address of the IP data packet as a destination MAC address to obtain a data frame;
step 53: transmitting the data frame to a second virtual sub-interface corresponding to the destination MAC address;
step 54: and extracting the IP data packet from the data frame by using the second virtual sub-interface, and sending the IP data packet to the VRF instance corresponding to the second virtual sub-interface by using the second virtual sub-interface.
Referring to fig. 7, fig. 7 is a schematic diagram of a third data flow according to an embodiment of the invention. When receiving an IP packet sent by VRF1, subinterface 1 may package an IP packet into a data frame with its own MAC address (i.e., MAC 1) as a source MAC address (i.e., smac=mac1) and a MAC address corresponding to a destination IP in the IP packet as a destination MAC address; then, when determining that the destination MAC address in the data frame is the MAC address of the subinterface 2 (i.e. MAC 2), the subinterface 1 may directly forward the data frame to the subinterface 2, so that the subinterface 2 parses the data frame, and sends the obtained IP data packet to its corresponding VRF2.
The data transmission method and the data structure according to the present invention will be described below. The invention relates to three data structures, which are respectively:
1. macvrf_port, the data structure is attributed to the physical interface, defined as:
the maximum number of# define MACRSF_MAX_NUM 512// VRF subinterfaces belongs to the macro definition.
The HASH SIZE of the # definition MACRSF_HASH_SIZE (1 < < 8)// MAC address table belongs to the macro definition.
The parameters related to the # definition MACREF_HASH_MASK (MACREF_HASH_SIZE-1)// MAC address table belong to the macro definition.
struct MACVRF_port{
structnet_device; dev data structure corresponding to the/(physical interface).
int count; the virtual subinterface counter takes on values from 0 to MACRFF_MAX_NUM.
unsigned long bitmap [ bits_to_length (macvrf_max_num) ]; and// bitmap for marking the virtual subinterface.
spin_t MACRFF_mac_lock; a/write lock.
int mac_num; a// MAC address counter.
struct hlist_head mac_hash [ MACRFF_HASH_SIZE ]; a// MAC address table.
…/…
}
2. The macvrf_dev, the data structure belongs to a virtual subinterface, is an extension of the subinterface dev data structure, and is defined as:
struct MACVRF_dev{
structnet_device; the/(v) point to the dev data structure corresponding to the subinterface.
struct macvrf_port; the// points to the data structure above, the parent interface.
unsigned short MACVRF _id; the// subinterface identity is allocated by the bitmap in MACRFF_port.
…/…
}
The relationship of the macvrf_port and the macvrf_dev structures can be referred to in fig. 8.
3. Macvrf_ fdb _entry, which is used to record the MAC address of the virtual subinterface, defined as:
struct MACVRF_fdb_entry{
structhlist_node hash_link; hash pointers in the/(MAC address table).
struct macvrf_dev macdev; the// direction MACRFF_dev;
unsigned char mac _addr [ eth_all ]; /(MAC address)
unsigned char mac _type; type of/(MAC)
unsigned long last _used; use of the tag
…/…
}
It should be noted that the macvrf_ fdb _entry may perform operations of inserting, searching, and deleting through a hash index in the physical interface macvrf_port data structure. It is also worth noting that mac_type corresponds to three types of local, static, dynamic, wherein the local type corresponds to the MAC address of the virtual subinterface; the static type and dynamic type are native types in the FDB database, where static represents a manually configured static MAC address and dynamic represents a dynamic MAC address learned from other messages.
The message related processing flow in this embodiment is as follows:
a) Creating a corresponding sub-interface for each VRF/VLAN and binding the sub-interface to a physical interface;
b) The three data structures described above may be updated at the time of creation of the subinterface: updating Macvrf_port information, creating Macvrf_dev, and creating and adding Macvrf_ fdb _entry nodes (randomly generating subinterfaces mac, mac_type is local);
c) The VRF/VLAN sends message to outside, through sub interface, encapsulates MAC address corresponding to sub interface; the information is sent out through a physical interface without modifying the replacement SMAC information;
d) The physical interface driving process can judge whether the message is a message to the sub-interface by inquiring the Macvrf_ fdb _entry, and forward the message to the sub-interface for processing when determining the corresponding sub-interface.
The data transmission device, the electronic device, and the computer readable storage medium provided in the embodiments of the present invention are described below, and the data transmission device, the electronic device, and the computer readable storage medium described below and the data transmission method described above may be referred to correspondingly.
Referring to fig. 9, fig. 9 is a block diagram of a data transmission device according to an embodiment of the present invention, where the device may include:
the virtual sub-interface creation module 901 is configured to create a plurality of virtual sub-interfaces based on a physical interface, and create a one-to-one correspondence between a plurality of VRF instances and the plurality of virtual sub-interfaces;
a MAC address allocation module 902, configured to configure an independent MAC address for each virtual subinterface;
the data transmission module 903 is configured to perform data transmission between the VRF instance and the external device by using the virtual sub-interface, the MAC address of the virtual sub-interface, and the physical interface, and/or perform data transmission between the VRF instance by using the virtual sub-interface and the MAC address of the virtual sub-interface.
Optionally, the data transmission module 903 may include:
the virtual sub-interface receiving sub-module is used for receiving the IP data packet sent by the corresponding VRF instance by utilizing the virtual sub-interface;
the virtual sub-interface encapsulation sub-module is used for encapsulating the IP data packet by using the virtual sub-interface and taking the MAC address of the virtual sub-interface as a source MAC address to obtain a data frame;
and the physical interface transmitting sub-module is used for transmitting the data frame to the external equipment through the physical interface.
Optionally, the data transmission module 903 includes:
the physical interface receiving sub-module is used for receiving a data frame sent by the external equipment by utilizing the physical interface;
the physical interface forwarding sub-module is used for sending the data frame to a target virtual sub-interface corresponding to the target MAC address when the target MAC address of the data frame is determined to correspond to the virtual sub-interface;
and the virtual sub-interface analysis sub-module is used for extracting the IP data packet from the data frame by utilizing the target virtual sub-interface and sending the IP data packet to the VRF instance corresponding to the target virtual sub-interface by utilizing the target virtual sub-interface.
Optionally, the apparatus may further include:
the MAC address table management module is used for writing the MAC address of each virtual sub-interface into the MAC address table;
accordingly, the physical interface forwarding sub-module may be configured to:
when the destination MAC address of the data frame is determined to be recorded in the MAC address table, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address.
Optionally, the MAC address table management module may further include:
the marking sub-module is used for adding a local mark for the MAC address of each virtual sub-interface in the MAC address table;
accordingly, the physical interface forwarding sub-module may be configured to:
and when the destination MAC address of the data frame is determined to be recorded in the MAC address table and provided with the local mark, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address.
Optionally, the data transmission module 903 includes:
the first virtual sub-interface receiving sub-module is used for receiving the IP data packet sent by the corresponding VRF instance by utilizing the first virtual sub-interface;
the first virtual sub-interface encapsulation sub-module is used for encapsulating the IP data packet by using the first virtual sub-interface and taking the MAC address of the first virtual sub-interface as a source MAC address and the MAC address corresponding to the destination IP address of the IP data packet as a destination MAC address to obtain a data frame;
the first virtual sub-interface forwarding sub-module is used for transmitting the data frame to a second virtual sub-interface corresponding to the destination MAC address;
and the second virtual sub-interface analysis sub-module is used for extracting the IP data packet from the data frame by using the second virtual sub-interface and sending the IP data packet to the VRF instance corresponding to the second virtual sub-interface by using the second virtual sub-interface.
Optionally, the user device is mapped with the VRF instance based on the VLAN, and the user device communicates with the external device through the VRF instance.
The embodiment of the invention also provides electronic equipment, which can comprise:
a memory for storing a computer program;
a processor for implementing the data transmission method as described above when executing the computer program.
And the physical interface is used for carrying out network data transmission with external equipment.
Since the embodiments of the electronic device portion correspond to the embodiments of the data transmission method portion, the embodiments of the electronic device portion refer to the description of the embodiments of the data transmission method portion, and are not repeated herein.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and the computer program realizes the data transmission method when being executed by a processor.
Since the embodiments of the computer readable storage medium portion and the embodiments of the data transmission method portion correspond to each other, the embodiments of the storage medium portion are referred to the description of the embodiments of the data transmission method portion, and are not repeated herein.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The data transmission method, the data transmission device, the electronic equipment and the storage medium provided by the invention are described in detail. The principles and embodiments of the present invention have been described herein with reference to specific examples, the description of which is intended only to facilitate an understanding of the method of the present invention and its core ideas. It should be noted that it will be apparent to those skilled in the art that various modifications and adaptations of the invention can be made without departing from the principles of the invention and these modifications and adaptations are intended to be within the scope of the invention as defined in the following claims.

Claims (10)

1. A data transmission method, comprising:
creating a plurality of virtual sub-interfaces based on a physical interface, and establishing a one-to-one correspondence between a plurality of VRF instances and the plurality of virtual sub-interfaces;
configuring an independent MAC address for each virtual sub-interface;
and carrying out data transmission between the VRF instance and external equipment by utilizing the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface, and/or carrying out data transmission between the VRF instance by utilizing the virtual sub-interface and the MAC address of the virtual sub-interface.
2. The method of data transmission according to claim 1, wherein said using the virtual subinterface, the MAC address of the virtual subinterface, and the physical interface for data transmission between the VRF instance and the external device comprises:
receiving an IP data packet sent by a corresponding VRF instance by utilizing the virtual sub-interface;
encapsulating the IP data packet by using the virtual sub-interface and taking the MAC address of the virtual sub-interface as a source MAC address to obtain a data frame;
and sending the data frame to the external equipment through the physical interface.
3. The method of data transmission according to claim 1, wherein said using the virtual subinterface, the MAC address of the virtual subinterface, and the physical interface for data transmission between the VRF instance and the external device comprises:
receiving a data frame sent by the external equipment by utilizing the physical interface;
when the destination MAC address of the data frame is determined to correspond to the virtual sub-interface, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address;
and extracting an IP data packet from the data frame by using the target virtual sub-interface, and sending the IP data packet to a VRF instance corresponding to the target virtual sub-interface by using the target virtual sub-interface.
4. A data transmission method according to claim 3, further comprising, after configuring an independent MAC address for each of the virtual subinterfaces:
writing the MAC address of each virtual sub-interface into an MAC address table;
correspondingly, when determining that the destination MAC address of the data frame corresponds to the virtual sub-interface, sending the data frame to a target virtual sub-interface corresponding to the destination MAC address, including:
and when the destination MAC address of the data frame is determined to be recorded in the MAC address table, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address.
5. The data transmission method according to claim 4, further comprising, after writing the MAC address of each of the virtual subinterfaces into the MAC address table:
adding a local mark for the MAC address of each virtual sub-interface in the MAC address table;
correspondingly, when determining that the destination MAC address of the data frame is recorded in the MAC address table, sending the data frame to a target virtual sub-interface corresponding to the destination MAC address, including:
and when the destination MAC address of the data frame is determined to be recorded in the MAC address table and provided with the local mark, the data frame is sent to a target virtual sub-interface corresponding to the destination MAC address.
6. The method of claim 1, wherein the data transmission between the VRF instances using the virtual subinterfaces and the MAC addresses of the virtual subinterfaces comprises:
receiving an IP data packet sent by a corresponding VRF instance by using a first virtual sub-interface;
encapsulating the IP data packet by using the first virtual sub-interface and using an MAC address of the first virtual sub-interface as a source MAC address and an MAC address corresponding to a destination IP address of the IP data packet as a destination MAC address to obtain a data frame;
transmitting the data frame to a second virtual sub-interface corresponding to the destination MAC address;
and extracting an IP data packet from the data frame by using the second virtual sub-interface, and sending the IP data packet to a VRF instance corresponding to the second virtual sub-interface by using the second virtual sub-interface.
7. A data transmission method according to any one of claims 1 to 6, characterized in that user equipment is mapped with the VRF instance based on VLAN and the user equipment communicates with the external device through the VRF instance.
8. A data transmission apparatus, comprising:
the virtual sub-interface creation module is used for creating a plurality of virtual sub-interfaces based on the physical interfaces and establishing a one-to-one correspondence between a plurality of VRF instances and the virtual sub-interfaces;
the MAC address allocation module is used for configuring independent MAC addresses for the virtual sub-interfaces;
and the data transmission module is used for carrying out data transmission between the VRF instance and external equipment by utilizing the virtual sub-interface, the MAC address of the virtual sub-interface and the physical interface, and/or carrying out data transmission between the VRF instance by utilizing the virtual sub-interface and the MAC address of the virtual sub-interface.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the data transmission method according to any one of claims 1 to 7 when executing the computer program;
and the physical interface is used for carrying out network data transmission with external equipment.
10. A computer readable storage medium having stored therein computer executable instructions which when loaded and executed by a processor implement a data transmission method as claimed in any one of claims 1 to 7.
CN202311458372.4A 2023-11-02 2023-11-02 Data transmission method and device, electronic equipment and storage medium Pending CN117336234A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311458372.4A CN117336234A (en) 2023-11-02 2023-11-02 Data transmission method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311458372.4A CN117336234A (en) 2023-11-02 2023-11-02 Data transmission method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117336234A true CN117336234A (en) 2024-01-02

Family

ID=89279356

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311458372.4A Pending CN117336234A (en) 2023-11-02 2023-11-02 Data transmission method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117336234A (en)

Similar Documents

Publication Publication Date Title
US10193707B2 (en) Packet transmission method and apparatus
US11374857B2 (en) Network device management method and apparatus, and system for indicating a network device to perform management operation
US20160294769A1 (en) Communication Method, Apparatus, and System of Virtual Extensible Local Area Network
WO2024067336A1 (en) Packet processing method, programmable network card device, physical server, and storage medium
CN106712988B (en) A kind of virtual network management method and device
CN113132202B (en) Message transmission method and related equipment
CN108429680A (en) A kind of method for configuring route, system, medium and equipment based on virtual private cloud
EP3313031A1 (en) Sdn-based arp realization method and apparatus
EP4156626A1 (en) Ipv6 network communication method, apparatus and system
CN110932890A (en) Data transmission method, server and computer readable storage medium
EP4366264A1 (en) Communication method based on segment routing over internet protocol version 6 (srv6)
CN106992918B (en) Message forwarding method and device
WO2022237291A1 (en) Message transmission method and apparatus, related device, and storage medium
US12003417B2 (en) Communication method and apparatus
Yan et al. Open vSwitch Vxlan performance acceleration in cloud computing data center
WO2017036384A1 (en) Provider edge device and data forwarding method
CN112565053B (en) Method, device, service system and storage medium for identifying private network user
EP3503484B1 (en) Message transmission methods and devices
CN115412492B (en) Policy enforcement by a top-of-rack switch for bare metal servers
CN117336234A (en) Data transmission method and device, electronic equipment and storage medium
WO2018214947A1 (en) Communication method and device
US11962673B2 (en) Packet tunneling and decapsulation with split-horizon attributes
CN107689881B (en) Message processing method and device
CN110768916B (en) Port statistical parameter notification method and device
WO2021164546A1 (en) Message processing method, forwarding device, and message processing system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination