GithubHelp home page GithubHelp logo

msbaz2013 / p4runtime-nanoswitch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yyasuda/p4runtime-nanoswitch

0.0 0.0 0.0 1.07 MB

A tutorial of Multicast, Packet-In/Out on P4Runtime

P4 7.10% Python 92.50% C 0.40%

p4runtime-nanoswitch's Introduction

P4Runtime-nanoswitch

A Simple L2 lerning switch development tutorial on P4Runtime

see Japanese version

Introduction

This tutorial uses P4Runtime's Packet-In / Out function to build a simple switch which is based on the P4Runtime Shell. It also provides an easy to use environment for you to continue to expand the capabilities of your own switch.

This tutorial does…

In this tutorial, you will try four things as follows:

  1. Multicast Group settings and the Flooding process using them
  2. Processing request to the controller using Packet-In
  3. Using Packet-Out to Add Entries to the Switch Table
  4. Adding functionalities to the P4Runtime Shell to execute such experiments

The final result is a very simple MAC learning switch.

These experiments are performed in the following environments:

  • Use P4 Runtime Shell as controller
  • Use Mininet corresponding to P4 Runtime as switch
  • Use open source p4c for P4 compilation

If you skip the tutorial, try shortcut.

Step by Step

All set. Here are the steps. I recommend that you try them in order.

Start Mininet and start the P4 Runtime Shell, which is the controller replacement. Then connect them.

Tutorial 1: NanoSwitch01

Repeat all incoming packets to all ports.

  • Set a Multicast Group and output to

Tutorial 2: NanoSwitch02

Prevent repeat back to the input port.

  • Drop Multicast packets if they have the same port number as Ingress port

Tutorial 3: NanoSwitch03

Create a flow table on the switch side to accommodate unknown hosts.

  • Unknown is processed as Packet-In
  • Packets received as Packet-In will send back as Packet-Out to repeat to all ports

Tutorial 4: NanoSwitch04

Create a host table on the controller side to correspond to known hosts.

  • Add round-trip entries to the flow table for communication with known host pairs
  • From now on, the switch will forward the round-trip packet without the controller

Tutorial 5: NanoSwitch05

Add the broadcast process, which has been ignored in nanosw04

  • When the broadcast comes out, add the corresponding entry to the flow table
  • By supporting ARP, it will behave more like a normal switch

Tutorial 6: NanoSwitch06

Corresponds to the error when the entry could not be added to the flow table in time

  • Ignore the error if double registration occurs

Next Step

The Switch I designed has priority on making the P4 Runtime easy to understand and try out. So it's pretty imperfect in terms of functionality, and there are several issues that come to mind. Why don't you add them yourself?

  • In actual switch operation, it is common to replace host X from port 1 to port 2 on the same switch. However, this switch does not handle this and packets cannot go back and forth.

  • There is a limit to the number of entries that can be registered, so you should remove any flow entries for which there has been no packet flow for some time.

  • In the first place, a normal L2 Learning Switch only remembers the port on which the destination host resides, and does not need to remember an entry for each flow. However, in order to do this in P4, you need two tables: one for source MAC and one for destination MAC + port. How about making a switch to match two tables in this way?

Appendix

Modified P4Runtime Shell

This tutorial was arranged by adding features to the P4 Runtime Shell. I have released the [Modified P4Runtime Shell] (https://github.com/yyasuda/p4runtime-shell) which I used to design this switch. If you compare Dockerfile.dev to the original version, you'll see where it's been modified. Docker Image which was created by the method shown in Tutorial 0: Preparing the Environment is also available.

It includes all the features that I used in this tutorial, as well as some features that I didn't cover here. Hit the link below to read more.

Send RAW Packets

Mininet provides tools such as ping, which makes it easy to send packets without ARP, etc. However, in experiments with real devices such as the Wedge Switch, you may want to send arbitrary packets from Wedge itself (OpenNetworkLinux) or a Windows/Mac connected to the Wedge port. Here are the tools for that.

CPU port changes

CPU port information is at the beginning of nanoswXX.p4. If necessary, update it and recompile.

#define CPU_PORT 255

If you don't know the CPU port number of the switch you are testing, P4Runtime-CPUport-finder may help.

p4runtime-nanoswitch's People

Contributors

yyasuda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.