Floodlight - Bhargavi Goswami



Programming Protocol-Independent Packet ProcessorsAgenda Introduction InstallationGetting the P4 source program folder in UbuntuRunning the first program1. IntroductionP4 compiler and behavioral model are two sub-repositories of p4lang github repository. The behavioral model is a C++ software switch that will behave according to P4 program. The P4 compiler that we are going to use today is a compiler for behavioral model. It takes P4 program as input and generates a JSON file as output, which can be loaded into the behavioral model. There is one more compiler that comes under the parent repository of p4lang, known as p4c. It provides a standard frontend and midend which can be combined with a target-specific backend to create a complete P4 compiler.2. InstallationP4 can be installed in your system by the following waysUsing P4 Virtual Machine or Virtual BoxUsing P4 GIT repositoryIn this tutorial we will be installing the controller on UBUNTU operating by using the second method. Using P4 Virtual Box (On Windows)STEP 1: Install VirtualBox 2: Download virtual machine imageP4 Tutorial 2018-06-01.ovaSTEP 3: Importing virtual machine into VirtualBoxi. Open VirtualBox,ii. Select “File > Import Appliance”iii. Navigate to the downloaded fileSTEP 4: Boot Virtual MachineSelect “P4 Tutorial 2018-06-01”, and click “Start”NOTE: It is preferable you go with the above way because this vm will contain all the required components needed for a P4 compiler environment. Without much to worry about installing different packages.Using P4 Git Repository (On Ubuntu)NOTE:Before you install make sure you have python installed with the latest version.Mininet installed.STEP 1: Open a new TerminalCtrl + Alt + t(above command will open a new terminal)STEP 2: Install GITsudo apt-get install git(above command will install git version control in your machine)STEP 3: Goto desktop via terminalcd Desktop(above command will change directory path to desktop)Step 4: Install GIT sudo apt-get install git(above command will install git version control in your machine)STEP 5: Go to Desktop via terminalCd Desktop(above command will change directory path to desktop)STEP 6: Clone behavioral model source code from githubgit clone bmv2(above command will download the floodlight source code from github)STEP 7: Install dependencies of behavioral modelcd bmv2sudo ./install_deps.sh(above command will install all the dependencies related to compile the behavioral mode)STEP 8: Configure the behavioral model source code./autogen.sh./configure(After configuring you should get Makefile (with no extension) in the same directory)STEP 9: Build and install the behavioural modelmake -j 6sudo make install -j 6 (will take 5 minutes)(Above commands will compile and generate the binaries for bmv2)STEP 10: Come out of bmv2 directoryCd ..(above command will come out of the current directory)STEP 11: Clone p4c-bmv2 compiler source code from githubgit clone p4c-bmv2(Above command clone the p4 compiler for bmv2)STEP 12: Go inside p4c-bmv2 directorycd p4c-bmv2(above command will change directory path to p4c-bmv2)STEP 13: Installing the dependencies of p4c-bmv2sudo pip install -r requirements.txtsudo pip install -r requirements_v1_1.txt(above command will install the dependencies)STEP 14: Build and install the p4c-bmv2sudo python setup.py installNOTE: Here you might get a error of Tenjin package not installed. So if you face the issue then execute this command: sudo easy_install TenjinSTEP 15: Check p4c-bmv2 is installed or notp4c-bmv2 -h(Above command will display the help page of the p4c-bmv2)STEP 16: Come out of p4c-bmv2 directory.Cd ..(above command will come out of the current directory)/**Yay! You have successfully installed the P4 compiler and behavioral model on your Ubuntu Operating System.**/If you still face any issues follow these links: the P4 source programs folderSTEP 1: Clone the sample program from tutorial section of p4lang:git clone (Above command will get the sample p4 program from github.)Inside the tutorials Folder:Before using P4, refer the following tutorial-slides for understanding its programming aspects:P4_tutorial_labs.pdfGo-to:exercises folder(Inside this folder you can find all the programs stored inside different folders)Running the first P4 program STEP 1: Goto basic via terminalCd /home/p4/tutorials/exercises/basic(above command will change directory path to basic)The objective of this exercise is to write a P4 program thatimplements basic forwarding. Here we are just implementing forwarding for IPv4.With IPv4 forwarding, the switch must perform the following actionsfor every packet: (i) update the source and destination MAC addresses,(ii) decrement the time-to-live (TTL) in the IP header, and (iii)forward the packet out the appropriate port.Your switch will have a single table, which the control plane willpopulate with static rules. Each rule will map an IP address to theMAC address and output port for the next hop. We have already definedthe control plane rules, so you only need to implement the data planelogic of your P4 program.STEP 2: The P4 ScriptBasic.p4(Is the p4 script that is used to implement the above objectives )STEP 3: Open the new terminalCtrl + Alt + t(above command will open a new terminal)STEP 4: Goto basic via terminalCd /home/p4/tutorials/exercises/basic(above command will change directory path to basic)STEP 5: Run the scriptmake run(above command will do the following):compile basic.p4start a Mininet instance with three switches (`s1`, `s2`, `s3`) configured in a triangle, each connected to one host (`h1`, `h2`, and `h3`).The hosts are assigned IPs of `10.0.1.1`, `10.0.2.2`, and `10.0.3.3`.STEP 6: Opening the Server and Client terminalsMininet> xterm h1 h2(above command will open two xterm terminals for h1 and h2 hosts)Each host includes a small Python-based messaging client and server.STEP 7: In h2’s xterm, start the server./receive.py(above command will run h2 terminal which is waiting for clients message)STEP 8: In h1’s xterm, send a message to h2./send.py 10.0.2.2 “<any message>”(above command will send the message to server i.e. h2 whose IP address is 10.0.2.2)**But this message will not be received.**STEP 9: Type ‘exit’ to leave each xterm and the mininet command lineSTEP 10: To stop the mininet and delete all pcaps, build files and logsCd /home/p4/tutorials/exercises/basic > make stopCd /home/p4/tutorials/exercises/basic > make clean(above command will stop the mininet and clean the basic folder to its original form)** The `basic.p4` file contains a skeleton P4 program with key pieces oflogic replaced by `TODO` comments. Your implementation should followthe structure given in this file---replace each `TODO` with logicimplementing the missing piece.**To execute the actual file which will be able to send packets to server form client. Follow these stepsSTEP 1: Goto solution directory in the same folderCd /home/p4/tutorials/exercises/basic/solutionBasic.p4(is the actual file which will execute the basic forwarding of the packets)STEP 2: Copy the file(basic.p4) to basic folderAnd continue the steps from STEP 5(this time you will be able to see the message being received at h2’s terminal)NOTE:If you still want to know what is the program all about and how to run the program, then you can refer the file README.md in each folder that is present. Learn more!Why P4?: P4: P4 source code: installation: tutorials: tutorial at SIGCOMM-16: based Applications:1. PISCES: . NetPaxos: . In-band Network Telemetry: (INT).pdf ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches