Skip to main content

An Introduction to Networking and where P4 fits in

·3 mins

NOTE: This is a draft post. It’s been uploaded here for a review by RH.

Networking is an age-old subject. One that people just assume works, and that’s not an incorrect take to have. This is because networking has a standard protocol to follow that does not change and has been battle-tested over the generations. From ARPANET to the current day 5G networks. It’s been quite the number of innovations, one on top of the other.

However, despite all the progress, the fundamentals of networking have seldom changed and still do (in most parts) follow the OSI Model. The OSI reference model consists of 7 layers of protocols and was made to ensure that the computers developed have a common basis for communication.

 OSI Networking Model

The seven layers of the OSI model are as follows,

  • Layer 1: Physical layer
  • Layer 2: Data link layer
  • Layer 3: Network layer
  • Layer 4: Transport layer
  • Layer 5: Session layer
  • Layer 6: Presentation layer
  • Layer 7: Application layer

It’s good to be aware of some networking terminology. Such as if one says “L2/L3”. They are referring to the layers of the OSI model and at which networking layer an individual works on. In the case of L2/L3, we’re pointing at Layer 2, the Data Link Layer and Layer 3, the Network Layer.

The UNIX implementation of the OSI model system is widely adopted and utilized across the computers of today. In it, we club some of the layers together to make a layered model with the following layers:

  1. Application Layer (ftp, http, etc protocols)
  2. Host-to-host Transport Layer (udp, tcp)
  3. Internet Layer (IP and routing)
  4. Network Access Layer (Ethernet, wifi, etc)

Finally, when we get around to the actual encapsulation of the data across these layers, we have a structure that looks like this.

 Data Encapsulation

It may look complex, but it’s exactly what we’ve discussed so far. Let’s compare the both.

 UNIX Data Encapsulation for Networking

And such is the basics of networking. Each layer has been constructed in such a way that when the data is wrapped in one layer in computer A, it can only be unwrapped by the same layer in computer B. Furthermore, each layer has its own methods and functions which we won’t be covering here.

However, if you are interested, it helps to take a look at UNIX Network Programming by W. Richard Stevens, if you wish to have a more comprehensive view of the layers.

Now, where does P4 fit in? #

P4 is a technology that deals with the L2 to L4 layer in the OSI Model.

The layers targeted by P4

In a traditional networking switch, the switch is built and exposes limited APIs to the control plane to work with. Suppose that the only functionality that a switch has been for is routing, then it will only perform routing and we cannot alter it at any later given date. This is a bottom-up approach and the layer on top of the switch is forced to work with the limited functionality and output generated by the switch.

P4, on the other hand, pushes the logic in a top-down approach. By first setting up the forwarding rules in a high level, we define the API that needs to be populate the switch. This puts the network architect/developer in charge rather than the chip vendor itself. P4 attempts to standardize the approach to populate the forwarding tables so that it doesn’t have to be vendor-specific anymore.

Over the next few chapters of the course, we’ll delve into how P4 is architected and how we can leverage it to implement solutions to common networking requirements.