Skip to content

Commit c4ec858

Browse files
authored
doc(P4sim): add structured example table with ns-3 and P4 links (#726)
* Update P4sim README examples table Signed-off-by: mingyuma <mingyu.ma@tu-dresden.de> * Remove bold in README.md for queuing_test entry Signed-off-by: jump_forge <mingyu.ma@tu-dresden.de> --------- Signed-off-by: mingyuma <mingyu.ma@tu-dresden.de> Signed-off-by: jump_forge <mingyu.ma@tu-dresden.de>
1 parent 42cae8a commit c4ec858

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

doc/P4sim/README.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,75 @@ In the [paper](https://dl.acm.org/doi/10.1145/3747204.3747210), P4sim is evaluat
116116

117117
More use cases can be found [here](https://github.com/HapCommSys/p4sim/blob/main/doc/examples.md), demonstrating that P4sim can serve both research and educational purposes, enabling exploration of programmable data-plane behaviors in realistic network contexts.
118118

119+
### High-Performance Simulation with P4sim
120+
121+
**Some of the examples have results and plots for analysis in [link](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/examples_test_result), include the `parameters`, `pcaps` for running, please have a look with more detail.**
122+
123+
| Name | Description | ns-3 script | p4 script |
124+
|-----|-------------|--------------|------|
125+
| [p4-basic-example](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/examples_test_result/p4-basic-example) | [basic](https://github.com/p4lang/tutorials/tree/master/exercises/basic) example | [ns-3](https://github.com/HapCommSys/p4sim/blob/main/examples/p4-basic-example.cc) | basic pipeline verification [p4src](https://github.com/HapCommSys/p4sim/tree/main/examples/p4src/p4_basic) |
126+
| [p4-basic-tunnel](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/examples_test_result/p4-basic-tunnel) | [basic tunnel](https://github.com/p4lang/tutorials/tree/master/exercises/basic_tunnel) example | [ns-3](https://github.com/HapCommSys/p4sim/blob/main/examples/p4-basic-tunnel.cc) | encapsulation / decapsulation test [p4src](https://github.com/HapCommSys/p4sim/tree/main/examples/p4src/basic_tunnel) |
127+
| [p4-fat-tree](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/examples_test_result/p4-fat-tree) | fat tree topo testing | [ns-3](https://github.com/HapCommSys/p4sim/blob/main/examples/topo-fattree.cc) | multi-switch forwarding validation [p4src](https://github.com/HapCommSys/p4sim/tree/main/examples/p4src/fat-tree) |
128+
| [p4-firewall](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/examples_test_result/p4-firewall) | [firewall](https://github.com/p4lang/tutorials/tree/master/exercises/firewall) example | [ns-3](https://github.com/HapCommSys/p4sim/blob/main/examples/p4-firewall.cc) | ACL rule verification [p4src](https://github.com/HapCommSys/p4sim/tree/main/examples/p4src/firewall) |
129+
| [p4-psa-ipv4-forwarding](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/examples_test_result/p4-psa-ipv4-forwarding) | ipv4 forwarding in psa arch | [ns-3](https://github.com/HapCommSys/p4sim/blob/main/examples/p4-psa-ipv4-forwarding.cc) | PSA pipeline example [p4src](https://github.com/HapCommSys/p4sim/tree/main/examples/p4src/simple_psa) |
130+
| [p4-spine-leaf-topo](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/examples_test_result/p4-spine-leaf-topo) | Spine leaf topo testing | [ns-3](https://github.com/HapCommSys/p4sim/blob/main/examples/p4-spine-leaf-topo.cc) | datacenter fabric test [p4src](https://github.com/HapCommSys/p4sim/tree/main/examples/p4src/load_balance) |
131+
| [p4-v1model-ipv4-forwarding](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/examples_test_result/p4-v1model-ipv4-forwarding) | ipv4 forwarding in v1model arch | [ns-3](https://github.com/HapCommSys/p4sim/blob/main/examples/p4-v1model-ipv4-forwarding.cc) | v1model pipeline example [p4src](https://github.com/HapCommSys/p4sim/tree/main/examples/p4src/ipv4_forward) |
132+
| [queuing_test](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/queuing_test) | queuing test with qos priority mapping | [ns-3](https://github.com/HapCommSys/p4sim/blob/main/examples/p4-queue-test.cc) | QoS / priority queue experiment [p4src](https://github.com/HapCommSys/p4sim/tree/main/examples/p4src/qos) |
133+
134+
Following we give two simple examples: `IPv4 Forwarding Benchmark` and `Queue and Packet Scheduling Test` show how run the examples.
135+
136+
#### IPv4 Forwarding Benchmark
137+
138+
The following example runs a simple two-host, one-switch topology with IPv4 forwarding at 100 Mbps. The link rate (`--linkRate`), application data rate (`--appDataRate`), and other parameters can be tuned as needed:
139+
140+
```bash
141+
# V1model architecture (recommended)
142+
./ns3 run p4-v1model-ipv4-forwarding -- \
143+
--pktSize=1000 --appDataRate=100Mbps --linkRate=1000Mbps \
144+
--switchRate=100000 --linkDelay=0.01ms --simDuration=20 --pcap=false
145+
146+
# PSA (Portable Switch Architecture)
147+
./ns3 run p4-psa-ipv4-forwarding -- \
148+
--pktSize=1000 --appDataRate=100Mbps --linkRate=1000Mbps \
149+
--switchRate=100000 --linkDelay=0.01ms --simDuration=20 --pcap=false
150+
151+
# PNA (Portable NIC Architecture) — not yet fully implemented
152+
./ns3 run p4-pna-ipv4-forwarding -- \
153+
--pktSize=1000 --appDataRate=100Mbps --linkRate=1000Mbps \
154+
--switchRate=100000 --linkDelay=0.01ms --simDuration=20 --pcap=false
155+
```
156+
157+
#### Queue and Packet Scheduling Test
158+
159+
To evaluate queuing and packet scheduling behavior on the P4 switch, use the [`p4-queue-test.cc`](https://github.com/HapCommSys/p4sim/blob/main/examples/p4-queue-test.cc) example. It accepts three independent traffic flows with configurable data rates:
160+
161+
```bash
162+
./ns3 run p4-queue-test -- \
163+
--pktSize=1000 \
164+
--appDataRate1=3Mbps --appDataRate2=4Mbps --appDataRate3=5Mbps \
165+
--switchRate=1500 --linkRate=1000Mbps --queueSize=1000 --pcap=true
166+
```
167+
168+
Mote details, results, plots please check [Queue Status Monitor](https://github.com/HapCommSys/p4sim-artifact-icns3/tree/main/queuing_test)
169+
170+
> **Note:** Per-port queue parameters cannot currently be set via command-line arguments. Instead, configure them at runtime using the P4 controller command interface:
171+
>
172+
> ```
173+
> set_queue_depth <depth_in_packets> <port_number>
174+
> set_queue_rate <rate_in_pps> <port_number>
175+
> ```
176+
>
177+
> Flow priorities are assigned through match-action table entries that map UDP port numbers to priority levels:
178+
>
179+
> ```
180+
> table_add udp_priority set_priority 2000 => 0x1
181+
> table_add udp_priority set_priority <udp_port_number> => <priority>
182+
> ```
183+
>
184+
> The bottleneck processing rate is controlled by `--switchRate` (in packets per second). In this example it is set to `1500`.
185+
186+
After the simulation completes, inspect the generated PCAP files to observe how packets from the three flows are scheduled and reordered according to their assigned priorities.
187+
119188
## Known Limitations
120189
121190
The packet processing rate `SwitchRate` (in packets per second, pps) must currently be configured manually for each switch. An inappropriate value can cause the switch to enter an idle polling loop, leading to wasted CPU cycles. Automatic rate tuning is planned for a future release.
@@ -129,4 +198,4 @@ The packet processing rate `SwitchRate` (in packets per second, pps) must curren
129198
**Maintainers & Contributors:**
130199
131200
- **Maintainers**: [Mingyu Ma](mailto:mingyu.ma@tu-dresden.de)
132-
- **Contributors**: Thanks to [GSoC 2025](https://summerofcode.withgoogle.com/) with [Davide](mailto:d.scano89@gmail.com) support and contributor [Vineet](https://github.com/Vineet1101).
201+
- **Contributors**: Thanks to [GSoC 2025](https://summerofcode.withgoogle.com/) with [Davide](mailto:d.scano89@gmail.com) support and contributor [Vineet](https://github.com/Vineet1101).

0 commit comments

Comments
 (0)