CN115632985B - Multipath load balancing NAT gateway forwarding method and system based on P4 - Google Patents
Multipath load balancing NAT gateway forwarding method and system based on P4 Download PDFInfo
- Publication number
- CN115632985B CN115632985B CN202211065787.0A CN202211065787A CN115632985B CN 115632985 B CN115632985 B CN 115632985B CN 202211065787 A CN202211065787 A CN 202211065787A CN 115632985 B CN115632985 B CN 115632985B
- Authority
- CN
- China
- Prior art keywords
- load balancing
- link
- programmable switch
- flow table
- bandwidth
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000001514 detection method Methods 0.000 claims abstract description 22
- 230000015654 memory Effects 0.000 claims description 30
- 238000012545 processing Methods 0.000 claims description 10
- 238000006243 chemical reaction Methods 0.000 claims description 8
- 239000000523 sample Substances 0.000 claims description 3
- 230000006854 communication Effects 0.000 abstract description 12
- 238000004891 communication Methods 0.000 abstract description 10
- 230000006870 function Effects 0.000 description 13
- 230000005540 biological transmission Effects 0.000 description 11
- 230000002776 aggregation Effects 0.000 description 10
- 238000004220 aggregation Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 5
- 101000933296 Homo sapiens Transcription factor TFIIIB component B'' homolog Proteins 0.000 description 4
- 101001087412 Homo sapiens Tyrosine-protein phosphatase non-receptor type 18 Proteins 0.000 description 4
- 102100026002 Transcription factor TFIIIB component B'' homolog Human genes 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 4
- 238000013519 translation Methods 0.000 description 4
- 101100435070 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) APN2 gene Proteins 0.000 description 3
- 101100268779 Solanum lycopersicum ACO1 gene Proteins 0.000 description 3
- 238000004590 computer program Methods 0.000 description 3
- 238000013461 design Methods 0.000 description 3
- 101000827703 Homo sapiens Polyphosphoinositide phosphatase Proteins 0.000 description 2
- 102100023591 Polyphosphoinositide phosphatase Human genes 0.000 description 2
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 2
- 101100401199 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) SAM2 gene Proteins 0.000 description 2
- 230000006399 behavior Effects 0.000 description 2
- 230000009977 dual effect Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000000737 periodic effect Effects 0.000 description 2
- 238000011158 quantitative evaluation Methods 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 1
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/12—Avoiding congestion; Recovering from congestion
- H04L47/125—Avoiding congestion; Recovering from congestion by balancing the load, e.g. traffic engineering
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/24—Multipath
- H04L45/245—Link aggregation, e.g. trunking
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/38—Flow based routing
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明公开了一种基于P4的多路径负载均衡NAT网关转发方法和系统,所述方法包括:SDN控制器根据带宽时延积,得到权重哈希负载均衡策略流表,并将权重哈希负载均衡策略流表下发给P4可编程交换机;P4可编程交换机根据权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发。本发明可基于P4语言编写实现,通过主动探测的方式获取路径质量做加权,并通过权重哈希策略进行选路通信,提升网络可靠性的同时又具备了一定的灵活性与可拓展性。
The present invention discloses a multi-path load balancing NAT gateway forwarding method and system based on P4, the method comprising: an SDN controller obtains a weighted hash load balancing strategy flow table according to a bandwidth-delay product, and sends the weighted hash load balancing strategy flow table to a P4 programmable switch; the P4 programmable switch selects a forwarding link according to the weighted hash load balancing strategy flow table and performs load balancing NAT gateway forwarding. The present invention can be implemented based on the P4 language, obtains path quality by active detection for weighting, and performs route selection communication by weighted hash strategy, thereby improving network reliability while having certain flexibility and scalability.
Description
技术领域Technical Field
本发明涉及网络通信技术领域,具体涉及一种基于P4的多路径负载均衡NAT网关转发方法和系统。The present invention relates to the technical field of network communication, and in particular to a multi-path load balancing NAT gateway forwarding method and system based on P4.
背景技术Background technique
在多链路网络环境中,对端主机在通信过程中往往选择其中一条链路进行传输,为了不浪费多个空闲链路以及提升网络带宽和稳定性等因素,现有方案提出了多链路聚合和多路径传输协议等技术。In a multi-link network environment, the peer host often selects one of the links for transmission during the communication process. In order not to waste multiple idle links and to improve network bandwidth and stability, existing solutions have proposed technologies such as multi-link aggregation and multi-path transmission protocols.
然而当前的多链路聚合交换机以厂商定制为主同时采用多链路聚合协议控制,不具备控制面加可编程数据面的灵活性。多路径传输协议MPTCP从协议层面融合了异构网络提升了稳定性,然而MPTCP协议目前存在不普及性,以及多链路如果存在带宽时延差距较大时性能有所降低。However, the current multi-link aggregation switches are mainly customized by manufacturers and are controlled by multi-link aggregation protocols, which do not have the flexibility of a control plane and a programmable data plane. The multi-path transmission protocol MPTCP integrates heterogeneous networks at the protocol level to improve stability. However, the MPTCP protocol is not popular at present, and the performance is reduced if there is a large difference in bandwidth and delay between multiple links.
因此,现有技术还有待于改进和发展。Therefore, the prior art still needs to be improved and developed.
发明内容Summary of the invention
本发明要解决的技术问题在于,针对现有技术的上述缺陷,提供一种基于P4的多路径负载均衡NAT网关转发方法和系统,旨在解决现有技术不具备控制面加可编程数据面的灵活性以及多链路如果存在带宽时延差距较大时性能有所降低的问题。The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a multi-path load balancing NAT gateway forwarding method and system based on P4 is provided, aiming to solve the problem that the prior art does not have the flexibility of a control plane plus a programmable data plane and the performance is reduced when there is a large bandwidth delay difference between multiple links.
本发明解决技术问题所采用的技术方案如下:The technical solution adopted by the present invention to solve the technical problem is as follows:
第一方面,本发明提供一种基于P4的多路径负载均衡NAT网关转发方法,其中,所述方法包括:In a first aspect, the present invention provides a multi-path load balancing NAT gateway forwarding method based on P4, wherein the method comprises:
SDN控制器根据带宽时延积,得到权重哈希负载均衡策略流表,并将所述权重哈希负载均衡策略流表下发给P4可编程交换机;The SDN controller obtains a weighted hash load balancing strategy flow table according to the bandwidth-delay product, and sends the weighted hash load balancing strategy flow table to the P4 programmable switch;
所述P4可编程交换机根据所述权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发。The P4 programmable switch selects a forwarding link according to the weighted hash load balancing policy flow table and performs load balancing NAT gateway forwarding.
在一种实现方式中,所述SDN控制器根据带宽时延积,得到权重哈希负载均衡策略流表,并将所述权重哈希负载均衡策略流表下发给P4可编程交换机之前,还包括:In one implementation, the SDN controller obtains a weighted hash load balancing strategy flow table according to the bandwidth-delay product, and before sending the weighted hash load balancing strategy flow table to the P4 programmable switch, it also includes:
所述SDN控制器使能,并下发初始化流表给所述P4可编程交换机,以实现接入所述P4可编程交换机的LAN侧同网段IP地址间互通,以及所述P4可编程交换机的NAT网关IP地址与对端外网IP地址间互通。The SDN controller is enabled and sends an initialization flow table to the P4 programmable switch to achieve intercommunication between IP addresses in the same network segment on the LAN side accessing the P4 programmable switch, and intercommunication between the NAT gateway IP address of the P4 programmable switch and the external network IP address of the peer end.
在一种实现方式中,所述SDN控制器根据带宽时延积,得到权重哈希负载均衡策略流表,并将所述权重哈希负载均衡策略流表下发给P4可编程交换机,包括:In one implementation, the SDN controller obtains a weighted hash load balancing strategy flow table according to the bandwidth-delay product, and sends the weighted hash load balancing strategy flow table to the P4 programmable switch, including:
所述SDN控制器周期性地向每个链路发送探测包,以得到回包;The SDN controller periodically sends a detection packet to each link to obtain a reply packet;
根据所述回包,得到每个链路的带宽Bandwidth和时延Delay;According to the returned packet, the bandwidth Bandwidth and delay Delay of each link are obtained;
根据所述每个链路的带宽Bandwidth和时延Delay,得到每个链路的带宽时延积BDP=Bandwidth×Delay;According to the bandwidth Bandwidth and delay Delay of each link, a bandwidth-delay product BDP=Bandwidth×Delay of each link is obtained;
根据所述带宽时延积BDP的占比,得到每个链路的哈希负载均衡权重;According to the proportion of the bandwidth delay product BDP, a hash load balancing weight of each link is obtained;
根据所述每个链路的哈希负载均衡权重,得到所述权重哈希负载均衡策略流表;According to the hash load balancing weight of each link, the weighted hash load balancing strategy flow table is obtained;
将所述权重哈希负载均衡策略流表下发给所述P4可编程交换机。The weighted hash load balancing strategy flow table is sent to the P4 programmable switch.
在一种实现方式中,所述所述P4可编程交换机根据所述权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发,包括:In one implementation, the P4 programmable switch selects a forwarding link and performs load balancing NAT gateway forwarding according to the weighted hash load balancing policy flow table, including:
所述P4可编程交换机收到来自接入主机的数据包,根据所述权重哈希负载均衡策略流表选择转发链路;The P4 programmable switch receives a data packet from an access host and selects a forwarding link according to the weighted hash load balancing strategy flow table;
根据所述转发链路将所述数据包送达对应的所述P4可编程交换机的NAT网关出口;Delivering the data packet to the corresponding NAT gateway exit of the P4 programmable switch according to the forwarding link;
所述P4可编程交换机的NAT网关出口对所述数据包做源IP网络地址转换,并通过所述转发链路将所述数据包发往对端服务器。The NAT gateway egress of the P4 programmable switch performs source IP network address conversion on the data packet and sends the data packet to the peer server through the forwarding link.
在一种实现方式中,所述所述P4可编程交换机收到来自接入主机的数据包,基于所述权重哈希负载均衡策略流表选择转发链路之前,还包括:In one implementation, the P4 programmable switch receives a data packet from an access host, and before selecting a forwarding link based on the weighted hash load balancing policy flow table, further includes:
所述接入主机接入到所述P4可编程交换机的LAN口后,由所述SDN控制器通过DHCP动态主机配置协议为所述接入主机自动分配IP地址。After the access host is connected to the LAN port of the P4 programmable switch, the SDN controller automatically allocates an IP address to the access host through the DHCP dynamic host configuration protocol.
在一种实现方式中,所述所述P4可编程交换机的NAT网关出口对所述数据包做源IP网络地址转换,并通过所述转发链路将所述数据包发往对端服务器之后,还包括:In one implementation, after the NAT gateway egress of the P4 programmable switch performs source IP network address conversion on the data packet and sends the data packet to the peer server through the forwarding link, it also includes:
所述P4可编程交换机的NAT网关出口收到所述对端服务器的回包后,对所述回包做目的IP网络地址转换并发往所述接入主机。After receiving the reply packet from the peer server, the NAT gateway exit of the P4 programmable switch converts the destination IP network address of the reply packet and sends it to the access host.
在一种实现方式中,所述方法还包括:In one implementation, the method further includes:
所述SDN控制器在每个发送探测包的周期,均重新生成并下发所述权重哈希负载均衡策略流表给所述P4可编程交换机。The SDN controller regenerates and sends the weighted hash load balancing strategy flow table to the P4 programmable switch in each cycle of sending a detection packet.
第二方面,本发明实施例还提供一种基于P4的多路径负载均衡NAT网关转发系统,其中,所述系统包括:SDN控制器与P4可编程交换机;In a second aspect, an embodiment of the present invention further provides a multi-path load balancing NAT gateway forwarding system based on P4, wherein the system comprises: an SDN controller and a P4 programmable switch;
所述SDN控制器用于根据带宽时延积,得到权重哈希负载均衡策略流表,并将所述权重哈希负载均衡策略流表下发给P4可编程交换机;The SDN controller is used to obtain a weighted hash load balancing strategy flow table according to the bandwidth-delay product, and send the weighted hash load balancing strategy flow table to the P4 programmable switch;
所述P4可编程交换机用于根据所述权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发。The P4 programmable switch is used to select a forwarding link according to the weighted hash load balancing policy flow table and perform load balancing NAT gateway forwarding.
在一种实现方式中,所述SDN控制器具体用于:In one implementation, the SDN controller is specifically used to:
周期性地向每个链路发送探测包,以得到回包;Periodically send a probe packet to each link to get a reply packet;
根据所述回包,得到每个链路的带宽Bandwidth和时延Delay;According to the returned packet, the bandwidth Bandwidth and delay Delay of each link are obtained;
根据所述每个链路的带宽Bandwidth和时延Delay,得到每个链路的带宽时延积BDP=Bandwidth×Delay;According to the bandwidth Bandwidth and delay Delay of each link, a bandwidth-delay product BDP=Bandwidth×Delay of each link is obtained;
根据所述带宽时延积BDP的占比,得到每个链路的哈希负载均衡权重;According to the proportion of the bandwidth delay product BDP, a hash load balancing weight of each link is obtained;
根据所述每个链路的哈希负载均衡权重,得到所述权重哈希负载均衡策略流表;According to the hash load balancing weight of each link, the weighted hash load balancing strategy flow table is obtained;
将所述权重哈希负载均衡策略流表下发给所述P4可编程交换机。The weighted hash load balancing strategy flow table is sent to the P4 programmable switch.
在一种实现方式中,所述P4可编程交换机具体用于:In one implementation, the P4 programmable switch is specifically used for:
接收来自接入主机的数据包,根据所述权重哈希负载均衡策略流表选择转发链路;Receive a data packet from an access host and select a forwarding link according to the weighted hash load balancing strategy flow table;
根据所述转发链路将所述数据包送达对应的所述P4可编程交换机的NAT网关出口;Delivering the data packet to the corresponding NAT gateway exit of the P4 programmable switch according to the forwarding link;
所述P4可编程交换机的NAT网关出口对所述数据包做源IP网络地址转换,并通过所述转发链路将所述数据包发往对端服务器。The NAT gateway egress of the P4 programmable switch performs source IP network address conversion on the data packet and sends the data packet to the peer server through the forwarding link.
在一种实现方式中,所述SDN控制器还用于:In one implementation, the SDN controller is further configured to:
在每个发送探测包的周期,均重新生成并下发所述权重哈希负载均衡策略流表给所述P4可编程交换机。In each cycle of sending a detection packet, the weighted hash load balancing strategy flow table is regenerated and sent to the P4 programmable switch.
第三方面,本发明实施例还提供一种处理设备,其中,所述处理设备包括存储器、处理器及存储在所述存储器中并可在所述处理器上运行的基于P4的多路径负载均衡NAT网关转发程序,所述处理器执行所述基于P4的多路径负载均衡NAT网关转发程序时,实现如以上任一项所述的基于P4的多路径负载均衡NAT网关转发方法的步骤。In a third aspect, an embodiment of the present invention further provides a processing device, wherein the processing device includes a memory, a processor, and a P4-based multi-path load balancing NAT gateway forwarding program stored in the memory and executable on the processor, and when the processor executes the P4-based multi-path load balancing NAT gateway forwarding program, the steps of the P4-based multi-path load balancing NAT gateway forwarding method as described in any one of the above items are implemented.
第四方面,本发明实施例还提供一种存储介质,其中,所述存储介质存储有一个或者多个程序,所述一个或者多个程序可被一个或者多个处理器执行,以实现如以上任一项所述的一种基于P4的多路径负载均衡NAT网关转发方法的步骤。In a fourth aspect, an embodiment of the present invention also provides a storage medium, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of a multi-path load balancing NAT gateway forwarding method based on P4 as described in any of the above items.
有益效果:与现有技术相比,本发明提供了一种基于P4的多路径负载均衡NAT网关转发方法。本发明首先通过SDN控制器获取链路的带宽时延积,并根据带宽时延积得到权重哈希负载均衡策略流表,以实现对各链路质量的量化评估,再将权重哈希负载均衡策略流表下发给P4可编程交换机,P4可编程交换机就可以根据权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发,从而通过P4语言的编写实现,使交换机在链路选取时具备更好的灵活性与可拓展性。Beneficial effect: Compared with the prior art, the present invention provides a multi-path load-balancing NAT gateway forwarding method based on P4. The present invention first obtains the bandwidth-delay product of the link through the SDN controller, and obtains the weighted hash load-balancing strategy flow table according to the bandwidth-delay product to achieve quantitative evaluation of the quality of each link, and then sends the weighted hash load-balancing strategy flow table to the P4 programmable switch. The P4 programmable switch can select the forwarding link according to the weighted hash load-balancing strategy flow table and perform load-balancing NAT gateway forwarding, thereby realizing the writing of the P4 language, so that the switch has better flexibility and scalability when selecting links.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
图1是本发明实施例提供的基于P4的多路径负载均衡NAT网关转发方法的流程示意图。FIG1 is a schematic flow chart of a multi-path load balancing NAT gateway forwarding method based on P4 according to an embodiment of the present invention.
图2是本发明实施例提供的链路探测流程示意图。FIG. 2 is a schematic diagram of a link detection process provided by an embodiment of the present invention.
图3是本发明实施例提供的双链路网络聚合场景下负载均衡NAT网关转发流程示意图。FIG3 is a schematic diagram of a load balancing NAT gateway forwarding process in a dual-link network aggregation scenario provided by an embodiment of the present invention.
图4是本发明实施例提供的基于P4的多路径负载均衡NAT网关转发系统的原理框图。FIG4 is a principle block diagram of a multi-path load balancing NAT gateway forwarding system based on P4 provided in an embodiment of the present invention.
图5是本发明实施例提供的处理设备的结构示意图。FIG. 5 is a schematic diagram of the structure of a processing device provided in an embodiment of the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案及效果更加清楚、明确,以下参照附图并举实施例对本发明进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
在多链路网络环境中,对端主机在通信过程中往往选择其中一条链路进行传输,为了不浪费多个空闲链路以及提升网络带宽和稳定性等因素,现有的解决方案提出了多链路聚合和多路径传输协议等技术。然而当前的多链路聚合交换机以厂商定制为主同时采用多链路聚合协议控制,不具备控制面加可编程数据面的灵活性。新兴的多路径传输协议MPTCP从协议层面融合了异构网络提升了稳定性,然而MPTCP协议目前存在不普及性,以及多链路如果存在带宽时延差距较大的情况就会表现出性能方面的不尽人意。In a multi-link network environment, the peer host often selects one of the links for transmission during the communication process. In order to avoid wasting multiple idle links and improve network bandwidth and stability, existing solutions have proposed technologies such as multi-link aggregation and multi-path transmission protocols. However, current multi-link aggregation switches are mainly customized by manufacturers and are controlled by multi-link aggregation protocols, which do not have the flexibility of control plane plus programmable data plane. The emerging multi-path transmission protocol MPTCP integrates heterogeneous networks at the protocol level to improve stability. However, the MPTCP protocol is currently not popular, and if there is a large gap in bandwidth and delay between multiple links, the performance will be unsatisfactory.
因此,为了解决上述问题,本发明公开了一种基于P4的多路径负载均衡NAT网关转发方法和系统,首先通过SDN控制器获取链路的带宽时延积,并根据带宽时延积得到权重哈希负载均衡策略流表,以实现对各链路质量的量化评估,再将权重哈希负载均衡策略流表下发给P4可编程交换机,P4可编程交换机就可以根据权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发,从而通过P4语言的编写实现,使交换机在链路选取时具备更好的灵活性与可拓展性。Therefore, in order to solve the above problems, the present invention discloses a multi-path load balancing NAT gateway forwarding method and system based on P4. First, the bandwidth-delay product of the link is obtained through the SDN controller, and the weighted hash load balancing strategy flow table is obtained according to the bandwidth-delay product to achieve quantitative evaluation of the quality of each link. Then, the weighted hash load balancing strategy flow table is sent to the P4 programmable switch. The P4 programmable switch can select the forwarding link according to the weighted hash load balancing strategy flow table and perform load balancing NAT gateway forwarding, thereby realizing it through the writing of P4 language, so that the switch has better flexibility and scalability in link selection.
示例性方法Exemplary Methods
本实施例提供一种基于P4的多路径负载均衡NAT网关转发方法。如图1所示,所述方法包括如下步骤:This embodiment provides a multi-path load balancing NAT gateway forwarding method based on P4. As shown in Figure 1, the method includes the following steps:
步骤S100、SDN控制器根据带宽时延积,得到权重哈希负载均衡策略流表,并将所述权重哈希负载均衡策略流表下发给P4可编程交换机。Step S100: The SDN controller obtains a weighted hash load balancing strategy flow table according to the bandwidth-delay product, and sends the weighted hash load balancing strategy flow table to the P4 programmable switch.
网络层能够被分解为两个相互作用的部分,即数据平面和控制平面,传统上控制平面路由选择协议和数据平面转发功能已被实现成一个整体,位于一台路由器中。其中,数据平面:即网络层中每台路由器的转发的功能,该数据平面功能决定到达路由器输入链路之一的数据报如何转发到该路由器的输出链路之一。控制平面:作为一种网络范围的逻辑,不仅控制沿着从源主机到目的主机的端到端路径间的路由器如何转发数据报,而且控制网络层组件和服务如何配置和管理。The network layer can be decomposed into two interacting parts, namely the data plane and the control plane. Traditionally, the control plane routing protocol and the data plane forwarding function have been implemented as a whole and located in a router. Among them, the data plane: that is, the forwarding function of each router in the network layer, which determines how the datagram arriving at one of the input links of the router is forwarded to one of the output links of the router. The control plane: as a network-wide logic, it not only controls how the routers along the end-to-end path from the source host to the destination host forward datagrams, but also controls how the network layer components and services are configured and managed.
SDN控制器在控制平面,而P4可编程交换机在数据平面。The SDN controller is in the control plane, while the P4 programmable switch is in the data plane.
其中,SDN(Software-defined Network,软件定义网络)控制器,是软件定义网络中的应用程序,负责流量控制以确保智能网络。其中,SDN控制器是基于如OpenFlow等协议的,允许服务器告诉交换机向哪里发送数据包。Among them, the SDN (Software-defined Network) controller is an application in the software-defined network that is responsible for traffic control to ensure an intelligent network. Among them, the SDN controller is based on protocols such as OpenFlow, which allows the server to tell the switch where to send data packets.
P4(Programming Protocol-Independent Packet Processors,协议无关的包处理器)网络编程语言,主要用在网卡、交换机、路由器等网络设备上,允许用户编程来控制报文在数据平面转发行为。基于P4网络编程语言的P4可编程交换机,减少了网络层级,降低网络复杂度,节约建设成本。相较于传统交换机,P4可编程交换机的数据平面功能未提前固定,但由P4程序确定,数据在初始化时配置平面以实现P4程序描述的功能,并且没有现有网络协议的内置知识。控制平面使用与特定功能交换机一样的通道与数据平面通信,但数据平面中的表集合和其他对象不再固定,因为它们由P4可编程交换机定义且利用P4编译器生成控制平面使用的API与数据平面通信。因此,P4可编程交换机可以说是独立于协议的,它使程序员能够自由实现一组协议和其他数据平面行为。P4 (Programming Protocol-Independent Packet Processors) network programming language is mainly used in network devices such as network cards, switches, and routers, allowing users to program to control the forwarding behavior of packets in the data plane. P4 programmable switches based on the P4 network programming language reduce network layers, reduce network complexity, and save construction costs. Compared with traditional switches, the data plane functions of P4 programmable switches are not fixed in advance, but are determined by the P4 program. The data configures the plane at initialization to implement the functions described by the P4 program, and there is no built-in knowledge of existing network protocols. The control plane communicates with the data plane using the same channels as function-specific switches, but the table collection and other objects in the data plane are no longer fixed because they are defined by the P4 programmable switch and the API used by the control plane to communicate with the data plane is generated by the P4 compiler. Therefore, the P4 programmable switch can be said to be protocol-independent, which enables programmers to freely implement a set of protocols and other data plane behaviors.
本实施例适用于多链路的网络聚合场景,基于SDN控制面加可编程交换机P4对多链路网络进行配置管理,SDN控制器通过将权重哈希负载均衡策略流表下发负载均衡策略给可编程交换机P4,以实现P4可编程交换机在负载均衡选路同时充当NAT网关。This embodiment is applicable to multi-link network aggregation scenarios. The multi-link network is configured and managed based on the SDN control plane plus the programmable switch P4. The SDN controller sends the load balancing policy to the programmable switch P4 through the weighted hash load balancing policy flow table, so that the P4 programmable switch can act as a NAT gateway while performing load balancing routing.
在一种实现方式中,本实施例所述步骤S100之前包括如下步骤:In one implementation, the following steps are included before step S100 in this embodiment:
步骤S10、所述SDN控制器使能,并下发初始化流表给所述P4可编程交换机,以实现接入所述P4可编程交换机的LAN侧同网段IP地址间互通,以及所述P4可编程交换机的NAT网关IP地址与对端外网IP地址间互通。Step S10, the SDN controller is enabled and sends an initialization flow table to the P4 programmable switch to achieve intercommunication between the IP addresses on the same network segment of the LAN side accessing the P4 programmable switch, and intercommunication between the NAT gateway IP address of the P4 programmable switch and the external network IP address of the peer end.
具体地,SDN控制器使能并下发初始化流表,如ARP,LLDP二层链路流表,L3三层转发流表,多链路通道能够正常工作。P4可编程交换机启动,二层链路转发表t_mac_lpm,三层网络转发表t_ipv4_lpm,三层探测表t_probe_lpm,NAT转发表t_nat_lpm工作生效。Specifically, the SDN controller enables and sends down the initialization flow table, such as ARP, LLDP layer 2 link flow table, L3 layer 3 forwarding flow table, and the multi-link channel can work normally. The P4 programmable switch starts, and the layer 2 link forwarding table t_mac_lpm, layer 3 network forwarding table t_ipv4_lpm, layer 3 detection table t_probe_lpm, and NAT forwarding table t_nat_lpm work effectively.
在一种实现方式中,本实施例所述步骤S100包括如下步骤:In one implementation, step S100 in this embodiment includes the following steps:
步骤S101、所述SDN控制器周期性地向每个链路发送探测包,以得到回包。Step S101: The SDN controller periodically sends a detection packet to each link to obtain a reply packet.
具体地,以双链路场景为例,如图2所示,SDN控制器下发初始化流表后可以正常监控到可用链路,紧接着创建一个周期任务,主动向各个链路发送探测包,所述探测包可为ICMP包,设定好间隔与次数,如间隔0.2s,探测10次,通过各个链路的物理口向下一跳的对端IP发送探测包。其中,图2所示的场景分别是3.3.3.11和4.4.4.11,P4网关的逻辑口IP地址为2.2.2.11,SNAT后(源IP网络地址转换)(1.1.1.11→2.2.2.11)目的MAC被改为下一跳的ETH1和ETH2地址,ETH1和ETH2收到探测包后进行回复,回包通过各自的链路到达P4后再被DNAT(2.2.2.11→1.1.1.11)转换为控制器CONTROLLER的地址,目的MAC同样改为控制器的MAC,由此完成一次对各个链路的探测,主要实现功能的表项为t_probe_lpm。Specifically, taking the dual-link scenario as an example, as shown in Figure 2, after the SDN controller sends the initialization flow table, it can monitor the available links normally, and then create a periodic task to actively send detection packets to each link. The detection packet can be an ICMP packet, and the interval and number of times are set, such as an interval of 0.2s, 10 detections, and the detection packet is sent to the next hop peer IP through the physical port of each link. Among them, the scenarios shown in Figure 2 are 3.3.3.11 and 4.4.4.11 respectively. The logical port IP address of the P4 gateway is 2.2.2.11. After SNAT (source IP network address translation) (1.1.1.11→2.2.2.11), the destination MAC is changed to the next hop ETH1 and ETH2 addresses. ETH1 and ETH2 reply after receiving the detection packet. After the reply packet reaches P4 through their respective links, it is converted by DNAT (2.2.2.11→1.1.1.11) to the address of the controller CONTROLLER. The destination MAC is also changed to the MAC of the controller, thereby completing a detection of each link. The table entry that mainly implements the function is t_probe_lpm.
步骤S102、根据所述回包,得到每个链路的带宽Bandwidth和时延Delay;Step S102: Obtain the bandwidth and delay of each link according to the returned packet;
步骤S103、根据所述每个链路的带宽Bandwidth和时延Delay,得到每个链路的带宽时延积BDP=Bandwidth×Delay;Step S103: According to the bandwidth Bandwidth and delay Delay of each link, obtain the bandwidth delay product BDP of each link = Bandwidth × Delay;
步骤S104、根据所述带宽时延积BDP的占比,得到每个链路的哈希负载均衡权重;Step S104: Obtain a hash load balancing weight for each link according to the proportion of the bandwidth delay product BDP;
步骤S105、根据所述每个链路的哈希负载均衡权重,得到所述权重哈希负载均衡策略流表;Step S105, obtaining the weighted hash load balancing strategy flow table according to the hash load balancing weight of each link;
步骤S106、将所述权重哈希负载均衡策略流表下发给所述P4可编程交换机。Step S106: Send the weighted hash load balancing strategy flow table to the P4 programmable switch.
具体地,SDN控制器的UI界面上能够监测到多链路的工作状态,包括后续主动探测后各个链路传递回来的带宽时延积BDP,即链路质量。SDN控制器发起定时周期性任务,通过每条链路向对端路由发送探测包,根据回包由计算出各个链路的带宽Bandwidth和时延Delay,然后计算出链路的带宽时延积BDP=Bandwidth×Delay,并显示在控制器界面。再根据每条链路的带宽时延积在所有链路中的占比多少作为哈希负载均衡算法的权重,控制器将新的权重哈希负载均衡策略流表下发给P4数据面。Specifically, the working status of multiple links can be monitored on the UI interface of the SDN controller, including the bandwidth-delay product BDP transmitted back by each link after subsequent active detection, that is, the link quality. The SDN controller initiates a scheduled periodic task, sends a detection packet to the opposite router through each link, calculates the bandwidth Bandwidth and delay Delay of each link based on the return packet, and then calculates the link bandwidth-delay product BDP = Bandwidth × Delay, and displays it on the controller interface. Then, based on the proportion of each link's bandwidth-delay product in all links as the weight of the hash load balancing algorithm, the controller sends the new weighted hash load balancing strategy flow table to the P4 data plane.
如图2所示,双链路分别命名为L1与L2,哈希负载均衡的权重和算子则如表1所示。与普通的哈希负载均衡策略不同,普通哈希负载均衡策略在通信的时候,例如HOST1访问HOST2,选路是随机的,即从L1与L2中随机选择一条发送出去。本实施例中权重的哈希负载均衡策略则是根据带宽时延积作为权重因子进行选路发送,即按照权重哈希算法,权重约高的路径被选中的几率就越大,对应本发明中链路质量越好、带宽时延积高的链路被选中发送的几率就越高。As shown in Figure 2, the dual links are named L1 and L2 respectively, and the weights and operators of hash load balancing are shown in Table 1. Different from the ordinary hash load balancing strategy, the ordinary hash load balancing strategy is random when communicating, for example, when HOST1 accesses HOST2, that is, a random path is selected from L1 and L2 for transmission. The weighted hash load balancing strategy in this embodiment selects the path for transmission based on the bandwidth-delay product as the weight factor, that is, according to the weighted hash algorithm, the higher the weight, the greater the probability of being selected, and the higher the link quality and the higher the bandwidth-delay product in the present invention, the higher the probability of being selected for transmission.
表1.权重计算表Table 1. Weight calculation table
需要注意的是,所述每个链路的哈希负载均衡权重还可通过目的IP哈希、源IP哈希、加权源IP哈希、源IP端口哈希、ISP算法、最小带宽、加权最小带宽、最小连接数、轮询、加权轮询、动态就近等均衡算法得到。It should be noted that the hash load balancing weight of each link can also be obtained through balancing algorithms such as destination IP hash, source IP hash, weighted source IP hash, source IP port hash, ISP algorithm, minimum bandwidth, weighted minimum bandwidth, minimum number of connections, polling, weighted polling, and dynamic proximity.
步骤S200、所述P4可编程交换机根据所述权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发。Step S200: The P4 programmable switch selects a forwarding link according to the weighted hash load balancing policy flow table and performs load balancing NAT gateway forwarding.
具体地,P4可编程交换机在数据面转发主要实现的功能包括链路层与网络层转发互通,控制器作为接入终端进行全链路的主动探测,匹配接入主机的地址并进行负载均衡NAT转发,因此P4的Pipeline流水线需要针对以上的需求进行关表表项设计,如表2所示:Specifically, the main functions of the P4 programmable switch in data plane forwarding include link layer and network layer forwarding intercommunication. The controller acts as an access terminal to actively detect the entire link, match the address of the access host and perform load balancing NAT forwarding. Therefore, the P4 Pipeline pipeline needs to design the table entries according to the above requirements, as shown in Table 2:
表2.P4可编程交换机的表项设计Table 2. Table entry design of P4 programmable switch
在一种实现方式中,本实施例所述步骤S200包括如下步骤:In one implementation, step S200 in this embodiment includes the following steps:
步骤S201、所述P4可编程交换机收到来自接入主机的数据包,根据所述权重哈希负载均衡策略流表选择转发链路;Step S201, the P4 programmable switch receives a data packet from an access host and selects a forwarding link according to the weighted hash load balancing strategy flow table;
步骤S202、根据所述转发链路将所述数据包送达对应的所述P4可编程交换机的NAT网关出口;Step S202: delivering the data packet to the corresponding NAT gateway exit of the P4 programmable switch according to the forwarding link;
步骤S203、所述P4可编程交换机的NAT网关出口对所述数据包做源IP网络地址转换,并通过所述转发链路将所述数据包发往对端服务器。Step S203: The NAT gateway egress of the P4 programmable switch performs source IP network address conversion on the data packet, and sends the data packet to the peer server through the forwarding link.
具体地,当主机接入P4可编程交换机的LAN口,并与外部通信时,基于权重哈希负载均衡策略流表选择转发链路,发包经过转发链路,到达P4可编程交换机的NAT网关出口,然后P4可编程交换机对发包做源IP网络地址转换SNAT,将源地址转换成下一跳对端服务器可路由的IP地址被发往对端服务器。Specifically, when the host is connected to the LAN port of the P4 programmable switch and communicates with the outside world, the forwarding link is selected based on the weighted hash load balancing policy flow table. The packet passes through the forwarding link and reaches the NAT gateway exit of the P4 programmable switch. Then the P4 programmable switch performs source IP network address translation SNAT on the packet, converting the source address into an IP address that can be routed to the next-hop peer server and sent to the peer server.
举例说明,按照如图3所示的双链路网络聚合场景为例,本发明适用于链路大于等于2的场景,当HOST1访问外部IP地址5.5.5.12的主机HOST2时,以一次收发包为例,第一步需要通过ARP请求由控制器提供出口网关的MAC(00:00:03),经过权重哈希负载均衡策略流表的负载均衡选路后选择了物理口port3作为出口。假设P4网关的逻辑口IP地址为2.2.2.12,源IP网络地址转换SNAT(1.1.1.12→2.2.2.12)后,目的MAC被改为下一跳的ETH1地址,再经过对端服务路由转发后被送达给正确的目的地HOST2。如果是同网段内部通信,如HOST1访问控制器CONTROLLER(1.1.1.12→1.1.1.11),则控制器做完ARP代答后通过t_mac_lpm转发表做二层转发,与访问外网不同的是,不再做权重哈希策略以及NAT网关转发,但对于接入主机HOST1来说无论是访问内网还是外网,这一个过程不被感知。For example, taking the dual-link network aggregation scenario shown in FIG3 as an example, the present invention is applicable to the scenario where the link is greater than or equal to 2. When HOST1 accesses the host HOST2 with the external IP address 5.5.5.12, taking a packet transmission and reception as an example, the first step is to provide the MAC (00:00:03) of the egress gateway through the ARP request from the controller, and after the load balancing routing of the weighted hash load balancing strategy flow table, the physical port port3 is selected as the egress. Assuming that the logical port IP address of the P4 gateway is 2.2.2.12, after the source IP network address is converted to SNAT (1.1.1.12→2.2.2.12), the destination MAC is changed to the ETH1 address of the next hop, and then forwarded by the peer service routing, it is delivered to the correct destination HOST2. If the communication is within the same network segment, such as HOST1 accessing the controller CONTROLLER (1.1.1.12→1.1.1.11), the controller performs Layer 2 forwarding through the t_mac_lpm forwarding table after completing the ARP proxy reply. Unlike accessing the external network, the weighted hash strategy and NAT gateway forwarding are no longer performed. However, for the access host HOST1, whether accessing the internal network or the external network, this process is not perceived.
在一种实现方式中,本实施例所述步骤S200之前包括如下步骤:In one implementation, the following steps are included before step S200 in this embodiment:
步骤S20、所述接入主机接入到所述P4可编程交换机的LAN口后,由所述SDN控制器通过DHCP动态主机配置协议为所述接入主机自动分配IP地址。Step S20: After the access host is connected to the LAN port of the P4 programmable switch, the SDN controller automatically allocates an IP address to the access host through the DHCP dynamic host configuration protocol.
举例说明,本实施例以图3的双链路为例,HOST1接入到所述P4可编程交换机的LAN口后,由SDN控制器通过DHCP动态主机配置协议为为HOST1分配IP地址1.1.1.12。For example, this embodiment takes the dual link of FIG. 3 as an example. After HOST1 is connected to the LAN port of the P4 programmable switch, the SDN controller allocates an IP address 1.1.1.12 to HOST1 through the DHCP dynamic host configuration protocol.
在一种实现方式中,本实施例所述步骤S203之后包括如下步骤:In one implementation, the following steps are included after step S203 in this embodiment:
步骤S204、所述P4可编程交换机的NAT网关出口收到所述对端服务器的回包后,对所述回包做目的IP网络地址转换并发往所述接入主机。Step S204: After receiving the reply packet from the peer server, the NAT gateway egress of the P4 programmable switch converts the destination IP network address of the reply packet and sends it to the access host.
具体地,从外部的回包经过对端服务器路由到P4可编程交换机的NAT网关口后,P4可编程交换机对回包做目的IP网络地址转换DNAT,地址转换成发包的主机IP地址,即完成一轮通信。Specifically, after the return packet from the outside is routed through the peer server to the NAT gateway port of the P4 programmable switch, the P4 programmable switch performs destination IP network address translation DNAT on the return packet, converting the address into the IP address of the host sending the packet, thus completing a round of communication.
举例说明,按照如图3所示的双链路网络聚合场景为例,HOST2的回包经过对端服务路由转发到P4的port3之后,再被目的IP网络地址转换DNAT(2.2.2.12→1.1.1.12)转换为正确的HOST1地址,目的MAC也同时改为HOST1的MAC,由此完成外部通信,主要实现功能的表项为t_hash_nat。For example, taking the dual-link network aggregation scenario shown in Figure 3 as an example, the reply packet of HOST2 is forwarded to port 3 of P4 through the peer service routing, and then converted to the correct HOST1 address by the destination IP network address translation DNAT (2.2.2.12→1.1.1.12), and the destination MAC is also changed to the MAC of HOST1, thereby completing the external communication. The table entry that mainly implements the function is t_hash_nat.
在一种实现方式中,本实施例所述方法还包括:In one implementation, the method described in this embodiment further includes:
步骤M100、所述SDN控制器在每个发送探测包的周期,均重新生成并下发所述权重哈希负载均衡策略流表给所述P4可编程交换机。Step M100: The SDN controller regenerates and sends the weighted hash load balancing policy flow table to the P4 programmable switch in each cycle of sending a detection packet.
具体地,SDN控制器周期性的主动探测各个链路,在每个周期更新并下发权重哈希负载均衡策略流表给P4可编程交换机,然后开始新一轮的探测任务。Specifically, the SDN controller actively detects each link periodically, updates and sends the weighted hash load balancing policy flow table to the P4 programmable switch in each cycle, and then starts a new round of detection tasks.
示例性系统Exemplary Systems
进一步地,本发明还相应提供了一种基于P4的多路径负载均衡NAT网关转发系统,如图4所示,所述系统包括:SDN控制器与P4可编程交换机;Furthermore, the present invention also provides a P4-based multi-path load balancing NAT gateway forwarding system, as shown in FIG4 , the system includes: an SDN controller and a P4 programmable switch;
所述SDN控制器用于根据带宽时延积,得到权重哈希负载均衡策略流表,并将所述权重哈希负载均衡策略流表下发给P4可编程交换机;The SDN controller is used to obtain a weighted hash load balancing strategy flow table according to the bandwidth-delay product, and send the weighted hash load balancing strategy flow table to the P4 programmable switch;
所述P4可编程交换机用于根据所述权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发。The P4 programmable switch is used to select a forwarding link according to the weighted hash load balancing policy flow table and perform load balancing NAT gateway forwarding.
在一种实现方式中,本实施例所述SDN控制器具体用于:In one implementation, the SDN controller described in this embodiment is specifically used for:
周期性地向每个链路发送探测包,以得到回包;Periodically send a probe packet to each link to get a reply packet;
根据所述回包,得到每个链路的带宽Bandwidth和时延Delay;According to the returned packet, the bandwidth Bandwidth and delay Delay of each link are obtained;
根据所述每个链路的带宽Bandwidth和时延Delay,得到每个链路的带宽时延积BDP=Bandwidth×Delay;According to the bandwidth Bandwidth and delay Delay of each link, a bandwidth-delay product BDP=Bandwidth×Delay of each link is obtained;
根据所述带宽时延积BDP的占比,得到每个链路的哈希负载均衡权重;According to the proportion of the bandwidth delay product BDP, a hash load balancing weight of each link is obtained;
根据所述每个链路的哈希负载均衡权重,得到所述权重哈希负载均衡策略流表;According to the hash load balancing weight of each link, the weighted hash load balancing strategy flow table is obtained;
将所述权重哈希负载均衡策略流表下发给所述P4可编程交换机。The weighted hash load balancing strategy flow table is sent to the P4 programmable switch.
在一种实现方式中,本实施例所述P4可编程交换机具体用于:In one implementation, the P4 programmable switch in this embodiment is specifically used for:
接收来自接入主机的数据包,根据所述权重哈希负载均衡策略流表选择转发链路;Receive a data packet from an access host and select a forwarding link according to the weighted hash load balancing strategy flow table;
根据所述转发链路将所述数据包送达对应的所述P4可编程交换机的NAT网关出口;Delivering the data packet to the corresponding NAT gateway exit of the P4 programmable switch according to the forwarding link;
所述P4可编程交换机的NAT网关出口对所述数据包做源IP网络地址转换,并通过所述转发链路将所述数据包发往对端服务器。The NAT gateway egress of the P4 programmable switch performs source IP network address conversion on the data packet and sends the data packet to the peer server through the forwarding link.
在一种实现方式中,本实施例所述SDN控制器还用于:In one implementation, the SDN controller described in this embodiment is further used for:
在每个发送探测包的周期,均重新生成并下发所述权重哈希负载均衡策略流表给所述P4可编程交换机。In each cycle of sending a detection packet, the weighted hash load balancing strategy flow table is regenerated and sent to the P4 programmable switch.
参见图5,是本发明实施例提供的一种基于P4的多路径负载均衡NAT网关转发处理设备的结构示意图。如图5所示的处理设备1300包括一个或多个处理器1301、通信接口1302和存储器1303,处理器1301、通信接口1302和存储器1303可通过总线方式连接,也可通过无线传输等其他手段实现通信。本发明实施例以通过总线1304连接为例其中,该存储器1303用于存储指令,用于执行该存储器1303存储的指令。该存储器1303存储程序代码,且处理器1301可以调用存储器1303中存储的程序代码实现如基于P4的多路径负载均衡NAT网关转发处理设备1300的相关功能。Referring to FIG. 5 , it is a schematic diagram of the structure of a multi-path load balancing NAT gateway forwarding processing device based on P4 provided in an embodiment of the present invention. The processing device 1300 shown in FIG. 5 includes one or more processors 1301, a communication interface 1302, and a memory 1303. The processor 1301, the communication interface 1302, and the memory 1303 can be connected via a bus, or can communicate via other means such as wireless transmission. The embodiment of the present invention takes the connection via bus 1304 as an example, wherein the memory 1303 is used to store instructions for executing instructions stored in the memory 1303. The memory 1303 stores program code, and the processor 1301 can call the program code stored in the memory 1303 to implement the relevant functions of the multi-path load balancing NAT gateway forwarding processing device 1300 based on P4.
应当理解,在本发明实施例中,所称处理器1301可以是中央处理单元(CentralProcessing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(DigitalSignal Processor,DSP)、专用集成电路(Application Specific IntegratedCircuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that in the embodiment of the present invention, the processor 1301 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
通信接口1302可以为有线接口(例如以太网接口)或无线接口(例如蜂窝网络接口或使用无线局域网接口),用于与其他模块或装置设备进行通信。例如,本申请实施例中通信接口1302具体可用于接收用户输入的输入数据;或者接收外部设备的数据等。The communication interface 1302 may be a wired interface (e.g., an Ethernet interface) or a wireless interface (e.g., a cellular network interface or a wireless local area network interface) for communicating with other modules or devices. For example, in the embodiment of the present application, the communication interface 1302 may be specifically used to receive input data input by a user; or receive data from an external device, etc.
存储器1303可以包括易失性存储器(Volatile Memory),例如随机存取存储器(Random Access Memory,RAM);存储器也可以包括非易失性存储器(Non-VolatileMemory),例如只读存储器(Read-Only Memory,ROM)、快闪存储器(Flash Memory)、硬盘(Hard Disk Drive,HDD)或固态硬盘(Solid-State Drive,SSD);存储器还可以包括上述种类的存储器的组合。存储器可用于存储一组程序代码,以便于处理器调用存储器中存储的程序代码以实现如上乘加器10的相关功能。The memory 1303 may include a volatile memory, such as a random access memory (RAM); the memory may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory may also include a combination of the above types of memories. The memory may be used to store a set of program codes so that the processor can call the program codes stored in the memory to implement the related functions of the multiplier 10 as above.
需要说明的,图5仅仅是本发明实施例的一种可能的实现方式,实际应用中,处理设备还可以包括更多或更少的部件,这里不作限制。关于本发明实施例中未示出或未描述的内容,可参见前述方法实施例中的相关阐述,这里不再赘述。It should be noted that FIG5 is only a possible implementation of the embodiment of the present invention. In practical applications, the processing device may also include more or fewer components, which is not limited here. For the contents not shown or described in the embodiment of the present invention, please refer to the relevant description in the aforementioned method embodiment, which will not be repeated here.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及实施步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Those of ordinary skill in the art will appreciate that the units and implementation steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本发明所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
综上,本发明公开了一种基于P4的多路径负载均衡NAT网关转发方法和系统,所述方法包括:SDN控制器根据带宽时延积,得到权重哈希负载均衡策略流表,并将权重哈希负载均衡策略流表下发给P4可编程交换机;P4可编程交换机根据权重哈希负载均衡策略流表选择转发链路并进行负载均衡NAT网关转发。本发明可基于P4语言编写实现,通过主动探测的方式获取路径质量做加权,并通过权重哈希策略进行选路通信,提升网络可靠性的同时又具备了一定的灵活性与可拓展性。In summary, the present invention discloses a multi-path load balancing NAT gateway forwarding method and system based on P4, the method comprising: the SDN controller obtains a weighted hash load balancing strategy flow table according to the bandwidth delay product, and sends the weighted hash load balancing strategy flow table to the P4 programmable switch; the P4 programmable switch selects a forwarding link according to the weighted hash load balancing strategy flow table and performs load balancing NAT gateway forwarding. The present invention can be implemented based on the P4 language, obtains the path quality by active detection for weighting, and performs routing communication by weighted hash strategy, which improves the network reliability while having certain flexibility and scalability.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (11)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211065787.0A CN115632985B (en) | 2022-09-01 | 2022-09-01 | Multipath load balancing NAT gateway forwarding method and system based on P4 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211065787.0A CN115632985B (en) | 2022-09-01 | 2022-09-01 | Multipath load balancing NAT gateway forwarding method and system based on P4 |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115632985A CN115632985A (en) | 2023-01-20 |
CN115632985B true CN115632985B (en) | 2024-05-14 |
Family
ID=84901937
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211065787.0A Active CN115632985B (en) | 2022-09-01 | 2022-09-01 | Multipath load balancing NAT gateway forwarding method and system based on P4 |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115632985B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117118895B (en) * | 2023-08-30 | 2025-08-15 | 中电信数智科技有限公司 | Flow data packet distribution method, storage medium and device based on BGP dual-activity architecture |
CN117240787B (en) * | 2023-11-14 | 2024-03-01 | 鹏城实验室 | Switch load balancing method, device, electronic equipment and readable storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009224947A (en) * | 2008-03-14 | 2009-10-01 | Fujitsu Ltd | Network control system, network control device, traffic control method, and program |
CN113992569A (en) * | 2021-09-29 | 2022-01-28 | 新华三大数据技术有限公司 | Multi-path service convergence method and device in SDN network and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2015187946A1 (en) * | 2014-06-05 | 2015-12-10 | KEMP Technologies Inc. | Adaptive load balancer and methods for intelligent data traffic steering |
-
2022
- 2022-09-01 CN CN202211065787.0A patent/CN115632985B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009224947A (en) * | 2008-03-14 | 2009-10-01 | Fujitsu Ltd | Network control system, network control device, traffic control method, and program |
CN113992569A (en) * | 2021-09-29 | 2022-01-28 | 新华三大数据技术有限公司 | Multi-path service convergence method and device in SDN network and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115632985A (en) | 2023-01-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11770309B2 (en) | On-demand probing for quality of experience metrics | |
CN111770028B (en) | Method and network device for computer network | |
US9807016B1 (en) | Reducing service disruption using multiple virtual IP addresses for a service load balancer | |
US11277341B2 (en) | Resilient segment routing service hunting with TCP session stickiness | |
US9060323B2 (en) | Aggregating multiple wireless channels | |
US9571382B2 (en) | Method, controller, and system for processing data packet | |
CN115632985B (en) | Multipath load balancing NAT gateway forwarding method and system based on P4 | |
EP3122004A1 (en) | Traffic switching method, device, and system | |
US9008084B2 (en) | Method of IPv6 at data center network with VM mobility using graceful address migration | |
US20160226742A1 (en) | Monitoring network performance characteristics | |
US20170063699A1 (en) | Method and apparatus for configuring multi-paths using segment list | |
CN104081749B (en) | DAD-NS triggered address resolution for DOS attack protection | |
US11223597B2 (en) | Network and network management method | |
US20220070736A1 (en) | Traffic steering device | |
US10374944B2 (en) | Quality of service for data transmission | |
US11870683B2 (en) | 3GPP network function set adaptation for pre-5G network elements | |
WO2022112851A1 (en) | Smart local mesh networks | |
CN105812272B (en) | Processing method, device and the system of business chain | |
JP6801075B2 (en) | How to get path information for data packets and devices | |
US11876680B2 (en) | Method and apparatus for determining link for forwarding service flow | |
CN118488512A (en) | A method and system for processing data by multiple gateways in a local area network | |
JP2019146065A (en) | Radio communication apparatus and method |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |