You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,9 @@ you get started with P4 programming, organized into several modules:
34
34
-[P4Runtime](./exercises/p4runtime)<br>
35
35
<small>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.</small>
36
36
37
+
-[Flowcache](./exercises/flowcache)<br>
38
+
<small> This exercise implements a program named flowcache.p4, which handles the PacketIn and PacketOut mechanisms, along with an idle timeout mechanism for table entries. In the data plane, packets are sent to the P4Runtime controller using the PacketIn. Upon receiving these packets, the controller adds an entry to the flow table. While the controller computes and installs the flow rule, PacketOut are sent to forward the packets to its destination. Once a flow entry is installed and no packets match it, the idle timeout start. Once a flow entry is installed and no packets match it, the idle timeout starts. When the timer expires, an IdleTimeoutNotification message is sent to the controller, which is responsible for reinstalling the expired flow entry.</small>
<small>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.</small>
Copy file name to clipboardExpand all lines: exercises/flowcache/README.md
+22-46Lines changed: 22 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,41 +1,36 @@
1
1
2
2
[comment]: #(SPDX-License-Identifier: Apache-2.0)
3
3
4
-
# WORK IN PROGRESS
5
-
6
4
## Introduction
7
5
8
-
In this exercise, we will be using P4Runtime to send flow entries to the
9
-
switch instead of using the switch's CLI. We will be building on the same P4
10
-
program that you used in the [basic_tunnel](../basic_tunnel) exercise. The
11
-
P4 program has been renamed to `advanced_tunnel.p4` and has been augmented
12
-
with two counters (`ingressTunnelCounter`, `egressTunnelCounter`) and
13
-
two new actions (`myTunnel_ingress`, `myTunnel_egress`).
6
+
The goal of this exercise is to write a P4 program that implements the `PacketIn` and `PacketOut` mechanisms, along with an idle timeout mechanism for table entries. The control plane uses P4Runtime to configure and manage the data plane. The P4 program `flowcache.p4` contains one ingress table (`flow_cache`) and two counters (`ingressPktOutCounter`, `egressPktInCounter`).
7
+
8
+
The action `flow_unknown` in the `flow_cache` table triggers the generation of a PacketIn when no flow rules match the packet. The PacketIn is then forwarded to the controller via P4Runtime. Upon receiving these packets, the controller adds an entry to the flow table with action `cached_action`. While the controller computes and installs the flow rule, PacketOut messages are sent via P4Runtime to the data plane in order to forward the packets to their destination.
9
+
10
+
Once a flow entry is installed and no packets match it, the idle timeout start. Once a flow entry is installed and no packets match it, the idle timeout starts. When the timer expires, an IdleTimeoutNotification message is sent to the controller.
11
+
12
+
The Counters `ingressPktOutCounter` and `egressPktInCounter` are used to verify whether `PacketIn` and `PacketOut` messages are sent or received.
14
13
15
14
You will use the starter program, `mycontroller.py`, and a few helper
16
15
libraries in the `p4runtime_lib` directory to create the table entries
17
-
necessary to tunnel traffic between host 1 and 2.
16
+
necessary to forward traffic between hosts.
18
17
19
18
> **Spoiler alert:** There is a reference solution in the `solution`
20
19
> sub-directory. Feel free to compare your implementation to the
21
20
> reference.
22
21
23
22
## Step 1: Run the (incomplete) starter code
24
23
25
-
The starter code for this assignment is in a file called `mycontroller.py`,
26
-
and it will install only some of the rules that you need to tunnel traffic between
27
-
two hosts.
24
+
The starter code for this assignment is in files called `flowcache.p4` and `mycontroller.py`. Your job will be to finalize the P4 program to properly implement the `PacketIn` and `PacketOut` idle timeout mechanismes.
28
25
29
-
Let's first compile the new P4 program, start the network, use `mycontroller.py`
30
-
to install a few rules, and look at the `ingressTunnelCounter` to see that things
31
-
are working as expected.
26
+
Let's first compile the new P4 program, start the network, and use `mycontroller.py` to install the flowcache pipeline in the data plane.
32
27
33
28
1. In your shell, run:
34
29
```bash
35
30
make
36
31
```
37
32
This will:
38
-
* compile `advanced_tunnel.p4`,
33
+
* compile `flowcache.p4`,
39
34
* start a Mininet instance with three switches (`s1`, `s2`, `s3`)
40
35
configured in a triangle, each connected to one host (`h1`, `h2`, `h3`), and
41
36
* assign IPs of `10.0.1.1`, `10.0.2.2`, `10.0.3.3` to the respective hosts.
@@ -49,31 +44,21 @@ are working as expected.
49
44
50
45
3. Open another shell and run the starter code:
51
46
```bash
52
-
cd~/tutorials/exercises/p4runtime
47
+
cd~/tutorials/exercises/flowcache
53
48
./mycontroller.py
54
49
```
55
-
This will install the `advanced_tunnel.p4` program on the switches and push the
56
-
tunnel ingress rules.
57
-
The program prints the tunnel ingress and egress counters every 2 seconds.
58
-
You should see the ingress tunnel counter for s1 increasing:
59
-
```
60
-
s1 ingressTunnelCounter 100: 2 packets
61
-
```
62
-
The other counters should remain at zero.
63
-
50
+
This will install the `flowcache.p4` program on the switches, and it will wait for notifications from the data plane.
64
51
4. Press `Ctrl-C` to the second shell to stop `mycontroller.py`
65
52
66
-
Each switch is currently mapping traffic into tunnels based on the destination IP
67
-
address. Your job is to write the rules that forward the traffic between the switches
68
-
based on the tunnel ID.
53
+
Each switch currently has no flow rules. So, as soon as a packet is received, it will be sent to the control plane within a PacketIn. Your job is to write the functions that handle PacketIn, PacketOut, and idle timeout mechanisms. Then, you can verify that PacketIn and PacketOut are working by reading the counters.
69
54
70
55
### Potential Issues
71
56
72
57
If you see the following error message when running `mycontroller.py`, then
73
58
the gRPC server is not running on one or more switches.
@@ -208,13 +186,11 @@ To run the reference solution, you should run the following command from the
208
186
solution/mycontroller.py
209
187
```
210
188
211
-
212
189
## Next Steps
213
190
214
191
Congratulations, your implementation works! Move onto the next assignment
215
192
[Explicit Congestion Notification](../ecn)
216
193
217
-
218
194
## Relevant Documentation
219
195
220
196
Documentation on the Usage of Gateway (gw) and ARP Commands in topology.json is [here](https://github.com/p4lang/tutorials/tree/master/exercises/basic#the-use-of-gateway-gw-and-arp-commands-in-topologyjson)
0 commit comments