What is P4 Programming? And why is it important for edge computing?

Jan 6, 2022

What is P4 programming? and why is it so important for Edge computing ?

These questions come up frequently these days. This is because P4 has shown its promise and potential for edge use cases.

So, this article will explain the purpose of P4 and its edge computing use cases in simple to understand manner.

What is P4?

In a nutshell, P4 stands for “Programming Protocol-Independent Packet Processors”. It is a network programming language for network devices that tells switches on how to process packets.

But can we really “program” network devices or in particular the switch ASICs?

After all, we never heard of programmable switch ASICs? As we are used to the fixed functions switch ASICs.

So before we go to the use cases  of the P4 programming language for edge computing, it would make sense to have a word about different types of switch ASICs.

Fixed Function ASICs versus Programmable ASICs

The fixed functions ASICs are designed and optimized for certain functions. Their internal packet processing pipelines are purpose-built that cannot be changed. Therefore, network functions are mapped to this ASIC (Also called bottom-up approach by mapping functions to the available ASIC). To get new functions, the ASIC manufacturer must develop a new model of the ASIC.

So you see the problem we are heading into-We have to wait long, sometimes a year to get a new model of ASIC as it would need a new design and new hardware.

On the other hand, programmable switches (that follow top-down approach) are the newer generation of ASICs and were introduced to solve exactly this problem. Their network ASICs are programmable with any new function the user wants without the need to change the ASICs. Furthermore, it has programmable packet processing pipeline stages that match on packet fields or packet metadata.

Fixed function ASIC vs Programmable ASIC for P4


And the program used for this purpose is P4. With the P4 program, new protocol header formats can be defined beyond the traditional IP, Ethernet, MPLS in new ways the user wants, which can open doors for new and novel use cases. In short, P4 enables programmable data planes.

Just a quick note that the P4 language can also program router, network interface card (NIC) besides switches. To receive an executable file from a P4 program either a compiler or an interpreter is additionally required.

Why is P4 relevant for Edge ?

Edge is an area of high throughput and low latency, where traditional SDN ( Software Defined Networking)  approaches based on open flow combined with fixed function switches may not be efficient.

In the event of a critical event, in the edge network, the switch needs to inform the controller in order to get instructions on how to handle that event. This poses serious scalability issues for the SDN controller. It can also cause issues like latency at the data plane level for critical edge services.

But above all, as the switches are based on fixed function ASICs, the switches cannot be programmed in novel ways for the edge, as we discuss below

P4 programmable switches can open new and innovative use cases at Edge

P4 switches can process packets in new ways based on network state,  on the runtime without the involvement of an SDN controller. Four use cases are described here.


Thanks to the ability to add new packet headers, P4 switches can be programmed to offer in-band telemetry for high priority edge traffic. While traditional QoS offers preferential treatment to high priority packets. This could lead to competition among high priority packets, at times of congestion. With P4 additional INT header (In-band telemetry header) can be added to each high priority packet that can report the time the packet spends in the switch and then switch can do a more dynamic QoS treatment based on the cumulative delay the packet has experienced in the switches it has traversed.

Traffic Engineering

As P4 switches are programmable and stateful, they can be programmed to dynamically route the packets based on a certain state in the network. So without asking the SDN controller for instruction on changing the traffic routes, the switch can decide on its own.

Cyber Security

With the increase in the Edge nodes, the attack surface considerably increases. Instead of a dedicated stateful firewall appliance at the edge, an efficient solution would be to capitalize the inherent capability of P4 switches for deep packet inspection (DPI), that can monitor traffic from transport to application layer effectively screening and blocking the attacks right at the network edge.

5G VNF offloading

An interesting use case is available for 5G. While establishing edge data centers, operators are thinking about virtualizing and integrating multiple services on a single platform. The platform should help in hosting CU/DU from RAN as well as have UPF offload functionality for the 5G core. In that case, some of these workloads can be offloaded to the P4 switch, with no need for spinning up dedicated VMs to host multiple functions, which makes the solution more efficient and less costly.

This was just a brief about a few use cases. There are many more use cases for P4 switch in the edge.

In short, the industry needs to move to programmable ethernet switches compared to traditional switches that have fixed function ASIC  because of the flexibility, scalability and features agility. For enhanced versatility and to have a vendor agnostic platform, P4 programmable switches are available as white boxes fully customizable to the needs of the users.

About Lanner P4 switch

Lanner Electronics is a leading manufacturer of white box platforms. It provides compact white box solutions and UCPEs for different network technologies and a wide variety of applications like Open RAN, MEC, NFV, SDN, network orchestration and S-WAN.

Lanner offers HLM-1100 switch blade, a high performance,  P4 programmable based on intel’s Tofino chipset ( came from acquisition of Barefoot networks) for its all in one feature rich MEC platform HTCA-6600



“Enhancing-5G-SDN-NFV-Edge-with-P4-Data-Plane-Programmability.Pdf.” N.p., n.d. Web.

Latest blogs