<commit_before><!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [P4 SIGCOMM 2015 Tutorial](#p4-sigcomm-2015-tutorial)
  - [Introduction](#introduction)
  - [Obtaining required software](#obtaining-required-software)
  - [Before starting the exercises](#before-starting-the-exercises)
  - [Exercise 1: Source Routing](#exercise-1-source-routing)
    - [Description of the EasyRoute protocol](#description-of-the-easyroute-protocol)
    - [A few hints](#a-few-hints)
    - [Populating the tables](#populating-the-tables)
    - [Testing your code](#testing-your-code)
    - [Debugging your code](#debugging-your-code)
  - [Exercise 2: Implementing TCP flowlet switching](#exercise-2-implementing-tcp-flowlet-switching)
    - [What is flowlet switching?](#what-is-flowlet-switching)
    - [Running the starter code](#running-the-starter-code)
    - [What you need to do](#what-you-need-to-do)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# P4 SIGCOMM 2015 Tutorial

The original webpage for the tutorial can be found 
[here](http://conferences.sigcomm.org/sigcomm/2015/tutorial-p4.php)

## Introduction

This repository include 2 exercises we presented at SIGCOMM: *Source Routing*
and *Flowlet Switching*. Both exercises assume that you possess basic networking
knowledge and some familiarity with the P4 language. Please take a look at the
[P4 language spec] (http://p4.org/spec/) and at the example `simple_router`
target [on p4lang]
(https://github.com/p4lang/p4factory/tree/master/targets/simple_router/p4src).
*Source Routing* asks you to write a P4 program from scratch to implement a
custom source routing protocol. *Flowlet Switching* is more difficult: you will
start from a simple P4 routing program (with ECMP) and implement a version of
flowlet switching, which yields better load balancing for bursty TCP flows.

For both exercises, you will find a .tar.gz archive which contains the solution
files.

## Obtaining required software

To complete the exercises, you will need to clone 2 p4lang Github repositories
and install their dependencies. To clonde the repositories:

- `git clone https://github.com/p4lang/behavioral-model.git bmv2`
- `git clone https://github.com/p4lang/p4c-bm.git p4c-bmv2`

The first repository ([bmv2](https://github.com/p4lang/behavioral-model)) is the
second version of the behavioral model. It is a C++ software switch that will
behave according to your P4 program. The second repository
([p4c-bmv2](https://github.com/p4lang/p4c-bm)) is the compiler for the
behavioral model: it takes P4 program and output a JSON file which can be loaded
by the behavioral model.

Each of these repositories come with dependencies. `p4c-bmv2` is a Python
repository and installing the required Python dependencies is very easy to do
using `pip`: `sudo pip install -r requirements.txt`.

`bmv2` is a C++ repository and has more external dependencies. They are listed
in the
[README](https://github.com/p4lang/behavioral-model/blob/master/README.md). If
you are running Ubuntu 14.04+, the dependencies should be easy to install (you
can use the `install_deps.sh` script that comes with `bmv2`). Do not forget to
build the code once all the dependencies have been installed:

- `./autogen.sh`
- `./configure`
- `make`

## Before starting the exercises

You need to tell us where you cloned the `bmv2` and `p4c-bm` repositories
:). Please update the values of the shell variables `BMV2_PATH` and
`P4C_BM_PATH` in the `env.sh` file - located in this directory. Note that if you
cloned both repositories in the same directory as this one (`tutorials`), you
will not need to change the value of the variables.

That's all :)

## Exercise 1: Source Routing<commit_msg>updated SIGCOMM README with more dependencies<commit_after><!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [P4 SIGCOMM 2015 Tutorial](#p4-sigcomm-2015-tutorial)
  - [Introduction](#introduction)
  - [Obtaining required software](#obtaining-required-software)
  - [Before starting the exercises](#before-starting-the-exercises)
  - [Exercise 1: Source Routing](#exercise-1-source-routing)
    - [Description of the EasyRoute protocol](#description-of-the-easyroute-protocol)
    - [A few hints](#a-few-hints)
    - [Populating the tables](#populating-the-tables)
    - [Testing your code](#testing-your-code)
    - [Debugging your code](#debugging-your-code)
  - [Exercise 2: Implementing TCP flowlet switching](#exercise-2-implementing-tcp-flowlet-switching)
    - [What is flowlet switching?](#what-is-flowlet-switching)
    - [Running the starter code](#running-the-starter-code)
    - [What you need to do](#what-you-need-to-do)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# P4 SIGCOMM 2015 Tutorial

The original webpage for the tutorial can be found 
[here](http://conferences.sigcomm.org/sigcomm/2015/tutorial-p4.php)

## Introduction

This repository include 2 exercises we presented at SIGCOMM: *Source Routing*
and *Flowlet Switching*. Both exercises assume that you possess basic networking
knowledge and some familiarity with the P4 language. Please take a look at the
[P4 language spec] (http://p4.org/spec/) and at the example `simple_router`
target [on p4lang]
(https://github.com/p4lang/p4factory/tree/master/targets/simple_router/p4src).
*Source Routing* asks you to write a P4 program from scratch to implement a
custom source routing protocol. *Flowlet Switching* is more difficult: you will
start from a simple P4 routing program (with ECMP) and implement a version of
flowlet switching, which yields better load balancing for bursty TCP flows.

For both exercises, you will find a .tar.gz archive which contains the solution
files.

## Obtaining required software

To complete the exercises, you will need to clone 2 p4lang Github repositories
and install their dependencies. To clonde the repositories:

- `git clone https://github.com/p4lang/behavioral-model.git bmv2`
- `git clone https://github.com/p4lang/p4c-bm.git p4c-bmv2`

The first repository ([bmv2](https://github.com/p4lang/behavioral-model)) is the
second version of the behavioral model. It is a C++ software switch that will
behave according to your P4 program. The second repository
([p4c-bmv2](https://github.com/p4lang/p4c-bm)) is the compiler for the
behavioral model: it takes P4 program and output a JSON file which can be loaded
by the behavioral model.

Each of these repositories come with dependencies. `p4c-bmv2` is a Python
repository and installing the required Python dependencies is very easy to do
using `pip`: `sudo pip install -r requirements.txt`.

`bmv2` is a C++ repository and has more external dependencies. They are listed
in the
[README](https://github.com/p4lang/behavioral-model/blob/master/README.md). If
you are running Ubuntu 14.04+, the dependencies should be easy to install (you
can use the `install_deps.sh` script that comes with `bmv2`). Do not forget to
build the code once all the dependencies have been installed:

- `./autogen.sh`
- `./configure`
- `make`

You will also need to install `mininet`, as well as the following Python
packages: `scapy`, `thrift` (>= 0.9.2) and `networkx`. On Ubuntu, it would look
like this:
- `sudo apt-get install mininet`
- `sudo pip install scapy thrift networkx`

## Before starting the exercises

You need to tell us where you cloned the `bmv2` and `p4c-bm` repositories
:). Please update the values of the shell variables `BMV2_PATH` and
`P4C_BM_PATH` in the `env.sh` file - located in this directory. Note that if you
cloned both repositories in the same directory as this one (`tutorials`), you
will not need to change the value of the variables.

That's all :)

## Exercise 1: Source Routing
{'fraction_non_alphanumeric': 0.09850451118526758, 'fraction_numerical': 0.016190829316524533, 'mean_word_length': 4.401869158878505, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2093200', 'n_tokens_mistral': 2535, 'n_tokens_neox': 2347, 'n_words': 960}