Giter VIP home page Giter VIP logo

tutorials's Introduction

P4 Tutorial

If you are reading this while not attending a live P4 tutorial class, see below for links to information about recently given live classes.

Introduction

Welcome to the P4 Tutorial! We've prepared a set of exercises to help you get started with P4 programming, organized into several modules:

  1. Introduction and Language Basics

    • Basic Forwarding
      In this exercise, you'll learn to implement basic IPv4 packet forwarding using P4. By extending the provided basic.p4 skeleton, you'll develop logic for updating MAC addresses, decrementing TTL values, and forwarding packets based on predefined rules. Through practical implementation and testing on a fat-tree topology in Mininet, you'll gain insights into designing and deploying data plane logic for network switches.

    • Basic Tunneling
      In this exercise, you enhance an IP router implemented in P4 by adding basic tunneling support, enabling encapsulation of IP packets for customized forwarding. By introducing a new tunnel header type, you modify the switch code to handle encapsulated packets and define forwarding rules based on destination IDs. Through static control plane entries, the switch routes encapsulated packets, showcasing P4's versatility in customizing packet processing and network functionality.

  2. P4Runtime and the Control Plane

    • P4Runtime
      This exercise involves implementing a control plane using P4Runtime to send flow entries to switches for tunneling traffic between hosts. Students modify the provided P4 program and controller script to establish connections, push P4 programs, install tunnel ingress rules, and read tunnel counters, enhancing their understanding of P4Runtime and network forwarding logic.
  3. Monitoring and Debugging

    • Explicit Congestion Notification
      In this tutorial, you'll enhance a basic L3 forwarding P4 program with Explicit Congestion Notification (ECN) support, enabling end-to-end notification of network congestion without packet drops. By modifying the ecn.p4 file, you'll implement ECN logic such as updating the ECN flag based on queue length thresholds and configuring static rules for proper ECN handling, followed by testing the solution in Mininet to verify packet forwarding and ECN flag manipulation.

    • Multi-Hop Route Inspection
      This tutorial aims to augment basic L3 forwarding with a simplified version of In-Band Network Telemetry (INT) called Multi-Hop Route Inspection (MRI). It guides users through extending a skeleton P4 program, mri.p4, to append an ID and queue length to the header stack of every packet, enabling tracking of the packet's path and queue lengths.

  4. Advanced Behavior

    • Source Routing
      This exercise aims to implement source routing, where the source host specifies the route for each packet through a stack of output ports. After configuring the P4 program, source_routing.p4, packets should be routed according to the specified port numbers in the stack, enabling end-to-end delivery based on the predetermined path.

    • Calculator
      This tutorial guides you through implementing a basic calculator using a custom protocol header in P4. The P4 program, calc.p4, parses incoming calculator packets, performs the specified operation on the operands, and returns the result to the sender, enabling basic arithmetic calculations in a network switch.

    • Load Balancing
      This exercise guides you in implementing load balancing using Equal-Cost Multipath Forwarding in a P4 program named load_balance.p4. It utilizes a hash function to distribute packets between two destination hosts based on a 5-tuple hash, enabling efficient traffic distribution across the network.

    • Quality of Service
      This tutorial focuses on implementing Quality of Service (QoS) using Differentiated Services (Diffserv) in a P4 program named qos.p4. It extends basic L3 forwarding to classify and manage network traffic, providing QoS on modern IP networks by setting DiffServ flags based on traffic classes and priority.

    • Multicasting
      This exercise involves writing a P4 program to enable a network switch to multicast packets to multiple output ports based on the destination MAC address. It requires the implementation of logic to handle multicast packets, including defining actions for packet forwarding and configuring the control plane to manage packet processing rules. Through practical implementation and testing in a Mininet environment, participants learn to enhance network traffic management and efficiency through multicast communication.

  5. Stateful Packet Processing

    • Firewall
      This exercise focuses on implementing a basic stateful firewall using a P4 program named firewall.p4. The firewall is designed to allow communication between internal and external hosts based on predefined rules, utilizing a bloom filter for stateful packet inspection and filtering.

    • Link Monitoring
      This exercise focuses on implementing link monitoring within a network using P4 programming. By extending the basic IPv4 forwarding exercise, the program enables the measurement of link utilization by processing source-routed probe packets. Through the manipulation of probe packet headers and the maintenance of register arrays, the solution facilitates accurate monitoring of link utilization, which can be invaluable for network management and optimization.

Presentation

The slides are available online and in the P4_tutorial.pdf in the tutorial directory.

A P4 Cheat Sheet is also available online which contains various examples that you can refer to.

P4 Documentation

The documentation for P4_16 and P4Runtime is available here

All excercises in this repository use the v1model architecture, the documentation for which is available at:

  1. The BMv2 Simple Switch target document accessible here talks mainly about the v1model architecture.
  2. The include file v1model.p4 has extensive comments and can be accessed here.

Obtaining required software

If you are starting this tutorial at one of the proctored tutorial events, then we've already provided you with a virtual machine that has all of the required software installed. Ask an instructor for a USB stick with the VM image.

Otherwise, to complete the exercises, you will need to either build a virtual machine or install several dependencies.

To build the virtual machine

Requirements

  • Vagrant
  • VirtualBox
  • At least 12 GB of free disk space, otherwise the installation can fail in unpredictable ways.

Installation Steps

  1. Install Vagrant and VirtualBox on your system.

  2. Clone the repository

    git clone https://github.com/p4lang/tutorials.git
    
  3. Navigate to the cloned directory :

    cd vm-ubuntu-20.04
    
  4. Start the virtual machine using Vagrant:

    vagrant up
    

    Note : The time for this step depends on your computer and Internet speed. On a 2015 MacBook Pro with a 50 Mbps download speed, it took approximately 20 minutes. Ensure a stable Internet connection throughout the process.

Accessing the VM

  • There are two user accounts:
    • Username: vagrant | Password: vagrant (This is the default account)
    • Username: p4 | Password: p4 (Usage of this account is expected)

Note: Before running the vagrant up command, make sure you have enabled virtualization in your environment; otherwise you may get a "VT-x is disabled in the BIOS for both all CPU modes" error. Check this for enabling it in virtualbox and/or BIOS for different system configurations.

You will need the script to execute to completion before you can see the p4 login on your virtual machine's GUI. In some cases, the vagrant up command brings up only the default vagrant login with the password vagrant. Dependencies may or may not have been installed for you to proceed with running P4 programs. Please refer the existing issues to help fix your problem or create a new one if your specific problem isn't addressed there.

To install P4 development tools on an existing system

There are instructions and scripts in another Github repository that can, starting from a freshly installed Ubuntu 20.04 or 22.04 Linux system with enough RAM and free disk space, install all of the necessary P4 development tools to run the exercises in this repository. You can find those instructions and scripts here (note that you must clone a copy of that entire repository in order for its install scripts to work).

How to Contribute

We value and welcome new contributions. To get started, kindly look at our Contribution Guidelines.

Older tutorials

Multiple live tutorial classes have been given using the example code in this repository for hands-on exercises. For example, there is one each April or May at the P4 workshop at Stanford University in California, and there have been several at networking conferences such as ACM SIGCOMM.

Please create an issue for this tutorials repository if you know a public link for classroom video recordings and/or pre-built VM images that currently do not have such a link.

ACM SIGCOMM August 2019 Tutorial on Programming the Network Data Plane

You can find more information about the ACM SIGCOMM August 2019 Tutorial on Programming the Network Data Plane here

The page linked above has a link to download a pre-built VM image used for this class, as well as instructions to build one yourself from a particular branch of this repository.

P4 Developer Day, April 2019

You can find more information about the P4 Developer Day held in April 2019 here

Both a beginner and advanced class were taught at this event. The page linked above contains instructions to download and install a pre-built Linux VM that was used during the classes.

P4 Developer Day, November 2017

This link plays the first welcome video of a series of 6 videos of tutorials given at this event.

tutorials's People

Contributors

abhinavcode13 avatar adarshrawat1 avatar alex1230608 avatar antoninbas avatar bocon13 avatar ccascone avatar irevoire avatar jafingerhut avatar jfingerh avatar jklr avatar jnfoster avatar khooi8913 avatar liujed avatar matt-telstra avatar minmit avatar prvnkumar avatar riftadi avatar robertmacdavid avatar robertsoule avatar robertsoule-barefoot avatar robh2 avatar rst0git avatar sanket-0510 avatar seanschoi avatar sibanez12 avatar snapdgn avatar stano45 avatar theojepsen avatar tudang avatar umakantkulkarni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tutorials's Issues

Question about bytes representation of packet at xterm

Hi, I want to know how to print the byte representation of the packet at xterm. I can read that through the pcap file, just like this: 00 00 00 00 00 00 00 00 68 65 6c 6c 6f ........hello. I try to read middle bytes(bold) by doing this in the receive.py:
pkt = str(pkt) // pkt is the packet from network
number = struct.unpack("<L", pkt[4:8])[0] // get the middle bytes
print('number: %s' %number)

I can get a really large integer, like 10063296, but when I check the pcap file, I see this:
00 00 00 00 00 00 00 06 68 65 6c 6c 6f ........hello.
So I don't get the same number as in pcap file, can't figure out why.

You requested P4 v1.1 but the corresponding p4-hlir package does not seem to be installed

When I run run_demo.sh in p4v1_1 simple router folder, it gives me "You requested P4 v1.1 but the corresponding p4-hlir package does not seem to be installed". I am pretty sure I have installed p4-hlir because I have successfully setup.py in p4-hlir folder. Can someone help me with that?

Here is the full output error message when I run run_demo.sh:

You requested P4 v1.1 but the corresponding p4-hlir package does not seem to be installed
*** Creating network
*** Adding hosts:
h1 h2
*** Adding switches:
Invalid JSON file.

Broadcast, Queue Size and Global Data

As I understand, the features like broadcast, obtaining buffer queue size and registers for storing global data are architecture specific.
Right now I am still learning how to make p4 work with mininet and bmv2 simple switch as given in the tutorials.

Do we have any way to do broadcast, obtain buffer queue size (individual for each port or combined, whatever way is the implementation) and store global variables (do not change with packet) in the simple switch?

It might be out of scope here because it is related to mininet, let me know if its possible to run separate p4 file in each mininet switch. The way it is set right now /tutorials/P4D2_2017/utils/mininet/* is to pass P4switch object to mininet.

More comments wanted for basic.p4

Since basic.p4 is a first look at a P4 program, I think more comments would be nice. For example, it would be helpful to have a comment on ipv4_forward() saying that the dstAddr and port arguments (1) are provided as action data when the control plane fills out the ipv4_lpm table, and (2) indicate the Ethernet destination and port number on which the packet should be forwarded.

Issues About SIGCOMM_2015 Source Routing

I have set up the necessary software and environment for Exercise 1 : Source Routing, but I face some problems when I want to run it:

The shell reports:
Command '['/home/jy/tutorials/./bmv2/tools/runtime_CLI.py', '--json', 'source_routing.json', '--thrift-port', '22222']' returned non-zero exit status 1
Could not connect to thrift client on port 22222
Make sure the switch is running and that you have the right port

And when one host sends a packet, the other cannot receive.

./run_demo.sh ERROR env.sh, ...

Hello,

I m woking in heavy_hitter project (example 1) I download the project then I try to compile the p4 code and run the switch and the mininet instance, while running ./run_demo.sh and I get

error run_demo sh

I try to make that manually

  1. compile the p4 code [ p4c-bmv2 --json heavy_hitter.json heavy_hitter.p4]
  2. run the switch and the mininet instance
    before I move
  • topo.py and topo.txt in p4_mininet
  • heavy_hitter.json heavy_hitter.p4 and includes (p4src directory) in simple_switch target
  • commands.txt in /tools
    in /mininet I perform [ sudo python topo.py --behavioral-exe ../targets/simple_switch/simple_switch --json ../targets/simple_switch/heavy_hitter.json --cli ../tools/runtime_CLI.py]
    It work good the network created with P4 switch and all the flow rules has been added correctly (commands.txt)
    mininet network p4

But the ping don't pass

ping don t work

Please how can I resolve the problem

Bug in apptopo.py in P4D2_2017_Spring

Hi,

I think there is a small copy-paste bug at line 57 in P4D2_2017_Spring/utils/mininet/apptopo.py

delay_key = ''.join(sorted([host_name, sw]))

should be

delay_key = ''.join(sorted([sw1, sw2]))

Hope it helps!

MRI swid table gets removed on compilation

...
Reading package manifest.
> p4c-bm2-ss --p4v 16 "mri.p4" -o "mri.p4.json"
mri.p4(115): warning: parse_ipv4_option: implicit transition to `reject'
    state parse_ipv4_option {
          ^^^^^^^^^^^^^^^^^
mri.p4(124): warning: parse_mri: implicit transition to `reject'
    state parse_mri {
          ^^^^^^^^^
mri.p4(135): warning: parse_swid: implicit transition to `reject'
    state parse_swid {
          ^^^^^^^^^^
mri.p4(201): warning: Table swid is not used; removing       <--- table gets removed
    table swid {
          ^^^^
...

Due to this, later when the swid table gets programmed, it's not available and addition of entry fails.

....
Control utility for runtime P4 table manipulation
RuntimeCmd: Setting default action of ipv4_lpm
action:              drop
runtime data:        
RuntimeCmd: Error: Invalid table name (swid)        <---- failure here
RuntimeCmd: Adding entry to lpm match table ipv4_lpm
...

Solution for ipv4_forward doesn't run => other problems?

Hi,

VM was copied from USB during P4 Developer Day 2017, so it should be good.
My problem is the solution doesn't run. After examining the logs, the LPM lookup
resulted in a miss (used the correct ipv4.dstAddr). The table for S1 was populated
during runtime. However, for all the switches, there were errors similar to:

No handlers could be found for logger "thrift.transport.TSlocket"
Could not connect to thrift client on port 909x (x = 0-2)

right after all the table_adds. Search for similar problems only pointed to
a previous deprecation issue, but this should all be the latest. Could there
be some other problems (setup) with VirtualBox I'm using?

Thanks for any pointers. BTW, solution for other exercises don't run
either, so it's probably my setup instead of the code itself. Sorry for
the submission here, if this is the wrong place.

James

Which tutorial to follow exactly?

I see that every SIGCOMM repo has a tutorial, and there are some overlapping examples. Trying to figure out where to start exactly, thanks very much.

Error in tutorial text

In the arp example.
https://github.com/p4lang/tutorials/tree/master/P4D2_2017/exercises/arp

The description says:

An action (named ipv4_forward) to store information in the metadata structure, rather than immediately writing to the packet header.

A table (named ipv4_lpm) that will match on the destination IP address and invoke the ipv4_forward action.

But actually the action for ipv4_lpm should be set_dst_infoin simple_router.config:

table_add ipv4_lpm set_dst_info 10.0.1.10/24 => 00:00:01:00:00:01 00:00:02:00:00:02 1

problem in installing thrift and nanomsg to install BMv2

Hi,
I followed the officiel tutorial '' https://github.com/p4lang/behavioral-model '' for installing P4/BMv2 on Ubuntu 14.04.5 LTS (desktop )
1, I installed the dependecies needed using the install_deps.sh script.
2, I try to install the thrift and nanomsg from the /travis source
./install-nanomsg.sh
./install-thrift.sh
./install-nnpy.sh
Then I get this message
permission denied

When I try with sudo it give me " commande not found "

PLease your help

question about multicast

Want to know how to implement multicast in P4 switch. I have read the p4-spec, and it seems that clone_egress_pkt_to_egress can be used, but not recommended. However there's no use case for that action, and I'm confused about the two arguments(clone_spec, field_list) it takes. How to determine the egress specification with clone_spec ?

./run_demo.sh ERROR

Hello,

I try to perform heavy_hitter project for that

  1. I download "Tutorials" directory and sub-directories and docs

  2. I cloned bmv2 and p4c-bmv2 in the "tutorials" directory
    git clone https://github.com/p4lang/behavioral-model.git bmv2
    git clone https://github.com/p4lang/p4c-bm.git p4c-bmv2

  3. this is env.sh that I use
    env.sh.txt

  4. In SIGCOM_2016/heavy_hitter project I try to compile the p4src/heavy_hitter.p4 code and run the switch and the mininet instance, while running ./run_demo.sh and I get

run_demo sh error

It can't open file 'topo.py': [Errno 2] No such file or directory
Even though the path of topo.py is alredy defined in run_demo.sh as bellow

 sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
--behavioral-exe $SWITCH_PATH \
--json heavy_hitter.json \
--cli $CLI_PATH

Thank you for your interest and help

One action declaration missed in "mri.p4"

Hello,

I'm tring the demo named mri in the branch P4D2, and noticed that the table swid missed the declaration of NoAction. See mri.p4/#L184. It will raise the error like this:

Entering build directory.
Extracting package.
Reading package manifest.
> p4c-bm2-ss --p4v 16 "mri.p4" -o "mri.p4.json"
mri.p4(188): error: NoAction not present in action list
        default_action = NoAction();
                         ^^^^^^^^
Compile failed.

It should be like this:

    table swid {
        actions        = { add_swid; NoAction; }
        default_action =  NoAction();      
    }

By the way, I noticed that you are still working on the p4v1.2 specification and p4c compiler. Thank you for this great work!

Best regards,
Chen.

p4 register

Just want to know if p4 register is working well for now.

MRI solution; is it correct?!

It seems that the solution provided for the MRI exercise doesn't cover all the details. For example, it's necessary to update totalLen in the IP header anytime the size of packet changes.

hdr.ipv4.ihl = hdr.ipv4.ihl + 1;

Thus, the add_mri_option() action should be something like:

@name("add_mri_option") action add_mri_option() {
   hdr.ipv4_option.setValid();
   hdr.ipv4_option.copyFlag = 1;
   hdr.ipv4_option.optClass = 2;
   hdr.ipv4_option.option = IPV4_OPTION_MRI;
   hdr.ipv4_option.optionLength = 4;

   hdr.mri.setValid();
   hdr.mri.count = 0;
   hdr.ipv4.ihl = hdr.ipv4.ihl + 1;
   hdr.ipv4.totalLen = hdr.ipv4.totalLen + 4;
}

socket.error: [Errno 19] No such device

Hi,

I'm trying to run copy_to_cpu example. However, I get the following error while running either 'udo python send.py' or 'udo python receive.py' commands:
socket.error: [Errno 19] No such device

Any idea?

having trouble running 2017 tutorials

I'm trying to run the l3 forwarding p4 app and when i launch ./run.sh i get:

Entering build directory.
Extracting package.
Reading package manifest.

p4c-bm2-ss --p4v 16 "ipv4_forward.p4" -o "ipv4_forward.p4.json"
sh: 1: p4c-bm2-ss: not found
Compile failed.

I can't seem to figure out how to fix this, I found p4c-bm2-ss in the p4c compiler as a backend tool, but I'm not using it, should i be? In other words i'm using the bmv2 and the p4c-bmv2 and getting this message

Error Running Sigcomm 2017 Tutorials

I just set up a VM for these tutorials. While executing run.sh for the "basic" exercise, I get the following error:

basic.p4(160): error: main: Cannot unify parameter hdr with hdr because they have different directions
) main;
^^^^

basic.p4(65)
control MyVerifyChecksum(in headers hdr, input metadata mets) {
^^^

/usr/local/share/p4c/p4include/v1model.p4(197)
control VerifyChecksum<H, M>(inout H hdr,
^^^

Compile failed.

Upon a web search, I did see that this issue was raised ~3 weeks back, and was supposedly fixed. However, I still get this error on a fresh install. Any thoughts on how to fix it?

Thanks,

Shyam

SIGCOMM_2016: P4 switch s1 did not start correctly

Hello,

I have a problem with the heavy_hitter example. When I run ./run_demo.sh the switch s1 can not be setup correctly with the following message:

*** Starting 1 switches s1 Starting P4 switch s1. /home/simon/Documents/p4/tutorials/../bmv2/targets/simple_switch/simple_switch -i 1@s1-eth1 -i 2@s1-eth2 -i 3@s1-eth3 --pcap --thrift-port 22222 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 heavy_hitter.json P4 switch s1 did not start correctly.

Everything should be setup right, because it already worked last week with the 2015 tutorial "source routing"

Thanks for your help.

h3 receives nothing

I have filled in command.txt by using the example of flowlet_switching/commands.txt and h3 will show nothing when I send message "Hello" from h1. I have typed "./receive.py" in h3 and "./send.py h1 h3" in h1. Can someone help me about that?

By the way, when I typed ".receive.py" in h3 it said "No route found for IPv6 destination ::(no default route?)", does this matter with my problem?

Kind Regards

There's a possibility to execute the heavy_hitter project on simple_router

Hi,
I try to perform manually the project heavy_hitter and exactly ''counter_example''
https://github.com/p4lang/tutorials/tree/master/SIGCOMM_2016/heavy_hitter/counter_example
on simple router.

  1.   I compile heavy_hitter.P4 to have json file : **OK**
    
  2.   When I type the following commande:
    

sudo python 1sw_demo.py --behavioral-exe ../targets/simple_router/simple_router --json ../targets/simple_router/heavy_hitter.json

It gives me an error '' p4 switch s1 did not started correctly "

Please What is the problem exactly

A ping problem in SIGCOMM2015/source_routing

Hi. Recently, I am trying the example named source_routing in tutorial/SIGCOMM2015/.

I just followed README. And installed some tools like thrift. I list some version INFO below:

java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Python 2.7.6

Thrift version 1.0.0-dev

And the directory:

bmv2:/home/wasdns/bmv2

p4c-bm:/home/wasdns/p4c-bmv2

tutorial:/home/wasdns/tutorials

Then I used the solution provided.

I copyed the env.sh to the directory /tutorial/SIGCOMM2015/source_routing

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# ---------------- EDIT THIS ------------------
BMV2_PATH=/home/wasdns/bmv2
# e.g. BMV2_PATH=$THIS_DIR/../bmv2
P4C_BM_PATH=/home/wasdns/p4c-bmv2
# e.g P4C_BM_PATH=$THIS_DIR/../p4c-bm
# ---------------- END ------------------

The run_demo.sh I used:

#!/bin/bash

# Copyright 2013-present Barefoot Networks, Inc. 
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

SWITCH_PATH=$BMV2_PATH/targets/simple_switch/simple_switch

CLI_PATH=$BMV2_PATH/tools/runtime_CLI.py

$P4C_BM_SCRIPT p4src/source_routing.p4 --json source_routing.json
# This gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
    --behavioral-exe $SWITCH_PATH \
    --json source_routing.json \
--cli $CLI_PATH

The commands.txt:

table_set_default ecmp_group _drop
table_set_default ecmp_nhop _drop
table_set_default forward _drop
table_set_default send_frame _drop
table_add ecmp_group set_ecmp_select 10.0.0.1/32 => 0 2
table_add ecmp_nhop set_nhop 0 => 10.0.1.1 1
table_add ecmp_nhop set_nhop 1 => 10.0.2.1 2
table_add forward set_dmac 10.0.1.1 => 00:04:00:00:00:00
table_add forward set_dmac 10.0.2.1 => 00:04:00:00:00:01
table_add send_frame rewrite_mac 1 => 00:aa:bb:00:00:00
table_add send_frame rewrite_mac 2 => 00:aa:bb:00:00:01

The I run ./run_demo.py, and it started:

root@ubuntu:/home/wasdns/tutorials/SIGCOMM_2015/source_routing# ./run_demo.sh 
parsing successful
semantic checking successful
Header type standard_metadata_t not byte-aligned, adding padding
Generating json output to /home/wasdns/tutorials/SIGCOMM_2015/source_routing/source_routing.json
*** Creating network
*** Adding hosts:
h1 h2 h3 
*** Adding switches:
s1 s2 s3 
*** Adding links:
(h1, s1) (h2, s2) (h3, s3) (s1, s2) (s1, s3) (s2, s3) 
*** Configuring hosts
h1 h2 h3 
*** Starting controller

*** Starting 3 switches
s1 Starting P4 switch s1
/home/wasdns/bmv2/targets/simple_switch/simple_switch -i 1@s1-eth1 -i 2@s1-eth2 -i 3@s1-eth3 --pcap --thrift-port 22222 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 source_routing.json
switch has been started
s2 Starting P4 switch s2
/home/wasdns/bmv2/targets/simple_switch/simple_switch -i 1@s2-eth1 -i 2@s2-eth2 -i 3@s2-eth3 --pcap --thrift-port 22223 --nanolog ipc:///tmp/bm-1-log.ipc --device-id 1 source_routing.json
switch has been started
s3 Starting P4 switch s3
/home/wasdns/bmv2/targets/simple_switch/simple_switch -i 1@s3-eth1 -i 2@s3-eth2 -i 3@s3-eth3 --pcap --thrift-port 22224 --nanolog ipc:///tmp/bm-2-log.ipc --device-id 2 source_routing.json
switch has been started

/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/home/wasdns/bmv2/tools/runtime_CLI.py --json source_routing.json --thrift-port 22222
Control utility for runtime P4 table manipulation
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: 

/home/wasdns/bmv2/tools/runtime_CLI.py --json source_routing.json --thrift-port 22223
Control utility for runtime P4 table manipulation
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: 

/home/wasdns/bmv2/tools/runtime_CLI.py --json source_routing.json --thrift-port 22224
Control utility for runtime P4 table manipulation
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: 

Ready !
*** Starting CLI:
mininet>

Then I tried h1 ping h3, it failed.

I'm puzzled...How can I solved this problem?

Thank you very much!

Chen.

mri - OSError: [Errno 2] No such file or directory

Hi, all.

Happy to see that the P4D2_2017 have been published today. But I found a problem(or a bug?) which makes me puzzled as I tried the exercise named mri.

My Environment

  • Ubuntu 14.04, 64bit

  • Already install the bmv2, p4c-bm, p4c, mininet etc.

My Steps

1.First fullfill the env.sh with my environment settings.

2.Fllow the steps below:

$ cd P4D2_2017/exercises/mri

// I use the solution in my first attempt:
$ mv mri.p4 oldmri.p4 
$ cp -r solution/mri.p4 ./

$ ./run.sh

Error Details

The step ./run.sh raised the error OSError: [Errno 2] No such file or directory:

Entering build directory.
Extracting package.
Reading package manifest.
> p4c-bm2-ss --p4v 16 "mri.p4" -o "mri.p4.json"
*** Log directory /home/wasdns/tutorials/P4D2_2017/exercises/mri/build/logs
*** Pcap directory /home/wasdns/tutorials/P4D2_2017/exercises/mri/build
> python2 "/home/wasdns/tutorials/P4D2_2017/utils/mininet/multi_switch_mininet.py" --log-dir "/home/wasdns/tutorials/P4D2_2017/exercises/mri/build/logs" --manifest "./p4app.json" --target "multiswitch" --auto-control-plane --behavioral-exe "simple_switch" --json "mri.p4.json" --cli-message "mininet_message.txt"
*** Creating network
*** Adding hosts:
h1 h2 h3 
*** Adding switches:
s1 s2 s3 
*** Adding links:
Traceback (most recent call last):
  File "/home/wasdns/tutorials/P4D2_2017/utils/mininet/multi_switch_mininet.py", line 242, in <module>
    main()
  File "/home/wasdns/tutorials/P4D2_2017/utils/mininet/multi_switch_mininet.py", line 145, in main
    controller = None)
  File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 164, in __init__
    self.build()
  File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 357, in build
    self.buildFromTopo( self.topo )
  File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 344, in buildFromTopo
    self.addLink( src, dst, srcPort, dstPort, **params )
  File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 287, in addLink
    return cls( node1, node2, **defaults )
  File "/usr/lib/python2.7/dist-packages/mininet/link.py", line 400, in __init__
    params2=params)
  File "/usr/lib/python2.7/dist-packages/mininet/link.py", line 350, in __init__
    self.makeIntfPair( intfName1, intfName2 )
  File "/usr/lib/python2.7/dist-packages/mininet/link.py", line 381, in makeIntfPair
    makeIntfPair( intf1, intf2  )
  File "/usr/lib/python2.7/dist-packages/mininet/util.py", line 154, in makeIntfPair
    quietRun( 'ip link del ' + intf1 )
  File "/usr/lib/python2.7/dist-packages/mininet/util.py", line 117, in quietRun
    return errRun( cmd, stderr=STDOUT, **kwargs )[ 0 ]
  File "/usr/lib/python2.7/dist-packages/mininet/util.py", line 77, in errRun
    popen = Popen( cmd, stdout=PIPE, stderr=stderr, shell=shell )
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Related Questions

After the attempt to fix this problem, I found a question that is most similar to my situation:

But the solution is useless to me. The problem is still remained.

Could you give me some instructions on how to deal with it? Thanks a lot!

need calrification

Hi Antonin,
file register.p4
line 68, 69
modify_field_rng_uniform(meta.register_tmp, 100, 200);
register_write(my_register, register_idx, meta.register_tmp);

Could you please refer to some doc where I find what these functions are doing. Intuitively I can understand , but which parameter is getting written where is somewhat obscure to me.

Also I have seen these command used through cli at runtime to update the switch tables:

table_set_default m_table m_action
table_add m_table m_action aa:bb:cc:dd:ee:ff => 0

what does that do exactly. Again if there is any quick readme on that please share.

Thrift issue running SIGCOMM_2015/source_routing - could not connect to thrift client

I'm stuck while trying to run source_routing tutorial from SIGCOMM_2015. All examples are running on Mininet-VM based on Ubuntu 14.04 LTS.

First, i cloned and installed bmv2 and p4c-bmv2 with all dependencies. env.sh file looks like this:

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# ---------------- EDIT THIS ------------------
BMV2_PATH=/home/mininet/mgr/bmv2
# e.g. BMV2_PATH=$THIS_DIR/../bmv2
P4C_BM_PATH=/home/mininet/mgr/p4c-bm
# e.g P4C_BM_PATH=$THIS_DIR/../p4c-bm
# ---------------- END ------------------

and placed in source_routing directory.
I'm using Barefoot provided solution (source_routing.p4 and commands.txt) from solution.tar.gz file.

Then, with veth_setup.sh from /bmv2/tools/ i create virtual ports.

#!/bin/bash
for idx in 0 1 2 3 4 5 6 7 8; do
    intf0="veth$(($idx*2))"
    intf1="veth$(($idx*2+1))"
    if ! ip link show $intf0 &> /dev/null; then
        ip link add name $intf0 type veth peer name $intf1
        ip link set dev $intf0 up
        ip link set dev $intf1 up
    fi
done

Next, I run the script run_demo.sh which looks :

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/env.sh

P4C_BM_SCRIPT=/home/mininet/mgr/p4c-bm/p4c_bm/__main__.py

SWITCH_PATH=$BMV2_PATH/targets/simple_switch/simple_switch

CLI_PATH=$BMV2_PATH/targets/simple_switch/simple_switch_CLI

$P4C_BM_SCRIPT p4src/source_routing.p4 --json source_routing.json
# This gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
    --behavioral-exe $SWITCH_PATH \
    --json source_routing.json \
    --cli $CLI_PATH

I also tried runtime_CLI.py from /bmv2/tools and /p4factory/submodules/bm/tools - same effect.

Script creates topology succesfully but it cant connect to any port.

parsing successful
semantic checking successful
Header type standard_metadata_t not byte-aligned, adding padding
Generating json output to /home/mininet/mgr/tutorials/SIGCOMM_2015/source_routing/source_routing.json
*** Creating network
*** Adding hosts:
h1 h2 h3 
*** Adding switches:
s1 s2 s3 
*** Adding links:
(h1, s1) (h2, s2) (h3, s3) (s1, s2) (s1, s3) (s2, s3) 
*** Configuring hosts
h1 h2 h3 
*** Starting controller

*** Starting 3 switches
s1 Starting P4 switch s1
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch --name s1 --dpid 0000000000000001 -i s1-eth1 -i s1-eth2 -i s1-eth3 --listener 127.0.0.1:11111 --pd-server 127.0.0.1:22222 
switch has been started
s2 Starting P4 switch s2
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch --name s2 --dpid 0000000000000002 -i s2-eth1 -i s2-eth2 -i s2-eth3 --listener 127.0.0.1:11111 --pd-server 127.0.0.1:22223 
switch has been started
s3 Starting P4 switch s3
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch --name s3 --dpid 0000000000000003 -i s3-eth1 -i s3-eth2 -i s3-eth3 --listener 127.0.0.1:11111 --pd-server 127.0.0.1:22224 
switch has been started

/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI --json source_routing.json --thrift-port 22222
No handlers could be found for logger "thrift.transport.TSocket"
Command '['/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI', '--json', 'source_routing.json', '--thrift-port', '22222']' returned non-zero exit status 1
Could not connect to thrift client on port 22222
Make sure the switch is running and that you have the right port

/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI --json source_routing.json --thrift-port 22223
No handlers could be found for logger "thrift.transport.TSocket"
Command '['/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI', '--json', 'source_routing.json', '--thrift-port', '22223']' returned non-zero exit status 1
Could not connect to thrift client on port 22223
Make sure the switch is running and that you have the right port

/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI --json source_routing.json --thrift-port 22224
No handlers could be found for logger "thrift.transport.TSocket"
Command '['/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI', '--json', 'source_routing.json', '--thrift-port', '22224']' returned non-zero exit status 1
Could not connect to thrift client on port 22224
Make sure the switch is running and that you have the right port

Ready !
*** Starting CLI:
mininet> 

My Thrift version is 0.9.2.

I realize, it gives same outcome with:
https://github.com/p4lang/behavioral-model#integrating-with-mininet

and flowlet_switching example

No handlers could be found for logger "thrift.transport.TSocket"
Could not connect to thrift client on port 9090
Make sure the switch is running and that you have the right port

even, they both work fine before.

How can I solve this problem? Thanks for commitment!

condition hd4.ipv4.isValid() is false

I am trying to run the solution of mri. hosts fail to ping each other. switch log says condition hd4.ipv4.isValid() is false. What could be the issue?

Solution of flowlet switching tutorial

In the proposed solution for the flowlet switching tutorial
(simple_router.p4 in https://github.com/p4lang/tutorials/blob/master/SIGCOMM_2015/flowlet_switching/solution.tar.gz)

  • The timestamp is defined as 32 bits in the metadata ingress_metadata_t (fields flowlet_lasttime and flow_ipg) and in the register flowlet_lasttime, but I think should be 48 bits. In fact in the intrinsic.p4 file the timestamp is defined as 48 bits (correct according to https://github.com/p4lang/tutorials/blob/master/SIGCOMM_2016/p4-tutorial-slides.pdf).

  • In the action lookup_flowlet_map() the call to
    modify_field_with_hash_based_offset()
    has FLOWLET_MAP_SIZE (=13) as size value, but I think it should be 2^13=8192.

The P4_14 document says:

modify_field_with_hash_based_offset(dest, base, field_list_calc, size)
...
size (VAL) The size of the hash value range. Must be larger than 0.
...
The hash value is used to generate a value between base and (base + size - 1) by calculating (base + (hash_value % size)).

so size should be the max value that the result can have +1, not the number of bits.

Seeing Help for Parse TCP Option

For some reason I want to parse TCP Options using p4 , but it seems that there is no such a helpful code to reference in this repository and P4 spc.
Could you please give me some advise how to parse TCP Options using p4?

Thanks. John.

calc.p4 exception at extract

screenshot from 2017-10-03 11 47 04

Hello, I tried executing the calc.p4 example and I am getting exception at the extract of hdr.ethernet (if I am not wrong). Can any one please try this example and confirm this.

Error when requesting config md5 sum from switch

In the meter , while running the command " ./run_switch.sh " it shows up the error " Error when requesting config md5 sum from switch" the thirft server is running properly and displays the message READY. While I am running my python file using command " sudo python send_and_receive.py 1", I am not getting the desired output. Instead of sending two packet it is sending just one packets. Moreover when I change the veth pairs the output the output changes to two receive packets and one send packets. Can any one help in figuring out where the problem lies.
screenshot from 2017-02-10 00-58-44
screenshot from 2017-02-10 01-00-28

p4c-bm2-ss in P4D2_2017/utils/p4apprunner.py not found

Logs below:

~/p4/tutorials/P4D2_2017/exercises/ipv4_forward$ ./run.sh 
tar: build: file changed as we read it
Entering build directory.
Extracting package.
Reading package manifest.
> p4c-bm2-ss --p4v 16 "ipv4_forward.p4" -o "ipv4_forward.p4.json"
sh: 1: p4c-bm2-ss: not found
Compile failed.

Count TCP_SYN packets for each host : Issue

Hi everybody,
Please I want count number of SYN request sending by each host on network for this end I create a counter as bellow:

counter ip_src_counter {
type: packets;
static: count_table;
instance_count: 1024;
}
//with action
action count_action(idx) {
count(ip_src_counter, idx);
}
// Here I specify (IPsrc and IPdst, srcPort, TCP_SYNfalgs
//Please I want to know if it s the correct way to specify TCP_SYN_flag field (as bellow tcp.tcpFlags1 : exact;)on p4 and how can I also specify TCP_ACK_flag field sending by source if I want to do
table count_table {
reads {
ipv4.srcAddr : ternary;
ipv4.dstAddr : exact;
tcp.srcPort : ternary;
tcp.tcpFlags1 : exact;
}
actions {
count_action;
_drop;
}
size : 1024;
}
I generate traffic between hosts then I try to read counter for each host It gives 0 packets
display counter

please find attached p4 program
Counter_SYN_paquet.txt

Properly setting up P4D2_2017 with native installation of required software

Since P4D2_2017 seemed to provide an environment to run P4-16 programs, I've been trying the examples in P4D2_2017 with native installation of the required software, but I can't get the solutions to run.

P4 switch s1 did not start correctly.Check the switch log file.

The log file reads:

Unknown primitive action: assign

My own code ran well (sort of, see below) until I modified a (previously empty) TopIngress like this:

control TopIngress(inout Parsed_packet p, inout Metadata m,
    inout standard_metadata_t standard_metadata) {

 apply {
   standard_metadata.egress_spec = 3 - standard_metadata.ingress_port;
 }

}

I previously encountered problems running my program when using varbits (see the end of this message) and subparsers (in this case, it complained about unknown primitive assign_header).

I've tried replacing the code with a table that matches on the ingress_port and sets the egress_port since that approach is closer to P4-14, but it still yields the same error.

The error logged with varbits was:

simple_switch: P4Objects.cpp:449: int bm::P4Objects::init_objects(std::istream*, bm::LookupStructureFactory*, int, size_t, std::shared_ptrbm::TransportIface, const std::set<std::pair<std::__cxx11::basic_string, std::__cxx11::basic_string > >&, const bm::P4Objects::ForceArith&): Assertion `cfg_header_type.isMember("length_exp")' failed.
Calling target program-options parser

load_balancing: more guidance needed for use of hash()

  • Slide 78 of P4D2_2017_Fall/P4_tutorial_labs.pdf has information on the signature of hash() that should be copied into load_balancing.p4.
  • Comments for ecmp_base and ecmp_count are needed in load_balancing p4. (Otherwise, I wouldn't know to use them for baseand max in the call to hash().)
  • Hash algorithm is unspecified. (Need to say CRC16 somewhere.)
  • Attempts based on example usage in PSA spec didn't work. My attempt:
Hash<bit<14>>(HashAlgorithm_t.CRC16) h;
meta.ecmp_select =
  h.get_hash({hdr.ipv4.srcAddr, hdr.ipv4.dstAddr,
    hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort});

Resulting error:

syntax error, unexpected IDENTIFIER, expecting ;
        Hash<bit<14>>(HashAlgorithm_t.CRC16) h
                                             ^

question about mininet

I have created a very simple topo(h1-s1-h2) based on source_routing, and changed the related files. It passed the compiler, but when I tried the command: h1 ping -c4 h2 in the mininet CLI, there were 100% paket loss. I have checked the s1-eth1.pcap and I can see the packet, while nothing in the s1-eth2.pcap. Maybe there's something wrong in the soft switch, but I can't figure it out. So please help me. The p4 code is below:
p4src

header_type sequencer_head_t {
fields {
preamble: 64;
serial_number: 32;
}
}

header sequencer_head_t sequencer_head;

header_type ingress_metadata_t {
fields {
serial_number : 32;
}
}

metadata ingress_metadata_t ingress_data;

register serial_number {
width : 32;
instance_count : 1;
}

parser start {
return select(current(0, 64)) {
0: parse_head;
default: ingress;
}
}

parser parse_head {
extract(sequencer_head);
return ingress;
}

action route() {
register_read(ingress_data.serial_number, serial_number, 0);
modify_field(sequencer_head.serial_number, ingress_data.serial_number);
add_to_field(ingress_data.serial_number, 1);
register_write(serial_number, 0, ingress_data.serial_number);
}

table route_pkt {
actions {
route;
}
}

control ingress {
apply(route_pkt);
}

control egress {
// leave empty
}

commands.txt
table_set_default route_pkt route

run_demo.sh
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/../../env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/main.py

SWITCH_PATH=$BMV2_PATH/targets/simple_switch/simple_switch

CLI_PATH=$BMV2_PATH/tools/runtime_CLI.py

$P4C_BM_SCRIPT p4src/sequencer.p4 --json sequencer.json

This gives libtool the opportunity to "warm-up"

sudo $SWITCH_PATH >/dev/null 2>&1
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py
--behavioral-exe $SWITCH_PATH
--json sequencer.json
--cli $CLI_PATH

Register cannot be declared at the top-level

I use v1model (v1model.p4) to build the program. When I tried to instantiate extern registers at the top-level of my program and read register values at one of actions, I got error:

P4 switch s1 did not start correctly.Check the switch log file.

S1 log:
terminate called after throwing an instance of 'std::out_of_range'
what(): _Map_base::at
Calling target program-options parser

After I changed to declare registers in the ingress control block, I can run my program.
I don't find in P4_16 spec that forbids us to declare extern objects in the top-level.

A bug in example RESUBMIT

The script "sudo $SWITCH_PATH resubmit.json
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8
--nanolog ipc:///tmp/bm-0-log.ipc --log-console
--pcap &" in run_switch.sh add 5 interfaces into the P4 switch.
But the test script in send_and_receive.py uses the veth1 and veth7 to send and receive packets respectively...It does work, and the P4 consle echos right information. But, in fact veth1 and veth7 are not added to the p4 switch...

I have try to use other virtual ethernet interfaces to send packets which is not added to the P4 switch...It still works.

Is there some problem?

aaa

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.