当前位置:网站首页>P4 learning - p4runtime
P4 learning - p4runtime
2022-07-01 00:40:00 【Sunny_ Fan】
List of articles
Reference resources :https://blog.csdn.net/qq_33681684/article/details/123646883
In this exercise , We will use P4Runtime Send stream entries to the switch , Instead of using switches CLI. We will be based on your basic_tunnel The same used in the exercise P4 Program to build .P4 The program has been renamed to advanced_tunnel.p4 And added two counters (ingressTunnelCounter, egressTunnelCounter) And two new moves (myTunnel_ingress, myTunnel_egress).
You will use starter Program mycontroller.py and p4runtime_lib Directory to create the host 1 And host 2 Table entries required for channel communication between .
Description of the control plane
P4 The program defines a package processing pipeline , But the rules in each table are inserted by the control plane . In this case ,mycontroller.py Realized our control plane , Instead of installing static table entries as we did in the previous exercise .
Important note : One .p4 The file will be compiled to generate a Info The document contains table id Such information is the basis for the control plane to issue specific rules ; Regenerate into a configuration file ( Format according to target And decide ) Send the data plane as a packet processing pipeline. The control plane also passes through p4runtime Data plane management .
Step one : Run incomplete code
- sudo make run ( compile advanced_tunnel.p4, start-up mininet Instance building topology , by hosts Distribute IP)

- h1 ping h2, Normal communication is not available at this time , Because there are no rules on the switch at this time , So I can't receive any reply

- Open another terminal , function mycontroller.py. This will install advanced_tunnel.p4 Program and load on the switch tunnel ingress rules. The program every 2 Print once per second tunnel ingress and egres Count . You should see s1 Of tunnel ingress The counter is increasing :
because s1 and s2 Between transit rules Not yet , So I can only see s1 Enter tunnel count .
- Ctrl-C stop it mycontroller.py, complete switches The flow between is based on the tunnel ID forwarding rules. open mycontroller.py, complete TODO part . At present, every switch is in accordance with the purpose IP Address maps traffic into the tunnel . The goal is to write a tunnel based ID Rules for forwarding traffic between switches .
Step two : Start to realize tunnel forwarding
mycontroller.py Is a basic control plane , It will do the following :
1. by P4Runtime Service establishment to switches Of gRPC Connect ;
2.Pushes the P4 program to each switch. push P4 Program to each switches;
3. by h1 To h2 Write rules for the two tunnels between ,h1 To h2 Tunnel ID 100,h2 To h1 Tunnel ID 200;
4. Every time 2 Read once per second tunnel ingress and egress Count of .
Work will be on writeTunnelRules Function to write tunnel transmission rules , This function will match the tunnel ID And forward the packet to the next hop .
In the experiment , Will use p4runtime_lib Some classes and methods under :
helper.py
Contains for parsing p4info Of documents P4InfoHelper class .
Provide entity name and ID The transformation method of .
structure P4Runtime table Of P4 Relevant parts of the program .
switch.py
contain SwitchConnection class , This class gets gRPC client stub, And establish a connection to the switch .
Provide helper Method , Is used to construct P4Runtime The protocol buffer messages are and processed P4Runtime gRPC The service call
bmv2.py
contain Bmv2SwitchConnection, It expands SwitchConnections, And provide BMv2 Specific equipment loads to load P4 Program .
convert.py
Provide a convenient way , take friendly String and number encoding 、 Byte string required to decode into protocol buffer message .
Helper.py Use
Step three : Run the solution
Open another terminal to execute python file , The control plane will rules Distribute to the data plane . Then you will see the count increase
./my_controller.py
At this time, log in through the command line s1, look down switch The forwarding rules are as follows :
simple_switch_CLI --thrift-port 9090
Purpose IP10.0.2.2/32 Conduct LPM matching , Into the tunnel 100( According to the 64 It's hexadecimal ).
Exactly match the tunnel ID100, To the interface 2.
Tunnel ID yes 200( Show c8 It's hexadecimal ), encapsulation 08–0111 Of h1 Of Mac, To the interface 1.
边栏推荐
- 【2023联发科提前批笔试题】~ 题目及参考答案
- "Experience" my understanding of user growth "new users"
- [designmode] factory pattern
- 写给 5000 粉丝的一封信!
- Random ball size, random motion collision
- C # Generate PPK files in Putty format (passthrough support)
- Stack frame
- P4学习——p4runtime
- Cloud security daily 220630: the IBM data protection platform has found an arbitrary code execution vulnerability, which needs to be upgraded as soon as possible
- Operation record of reinitialization instance of Dameng database
猜你喜欢

Implementation of OSD on Hisilicon platform (1)

Teach you how to use Hal library to get started -- become a lighting master

2022-2028 global retro glass industry research and trend analysis report

Member management applet actual development 07 page Jump

Redis - sentinel mode

P4学习——p4runtime

C#生成putty格式的ppk文件(支持passphrase)

Host FL Studio fruit music production daw20.9

Oracle-表的创建与管理

2022-2028 global herbal diet tea industry research and trend analysis report
随机推荐
C#生成putty格式的ppk文件(支持passphrase)
Longest valid bracket
ArrayList analysis 1-cycle, capacity expansion, version
2022-2028 global carbon fiber room scraper system industry research and trend analysis report
When is it appropriate to replace a virtual machine with a virtual machine?
2022-2028 global weight loss ginger tea industry research and trend analysis report
2022-2028 global herbal diet tea industry research and trend analysis report
20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute
$watch will not trigger data change - $watch not firing on data change
Ditto set global paste only text shortcuts
对libco的一点看法
SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding
问题解决:如何管理线程私有(thread_local)的指针变量
女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
Implementation of OSD on Hisilicon platform (1)
Makefile notes (Yiwen Institute makefile)
left join左连接匹配数据为NULL时显示指定值
Rhai - rust's embedded scripting engine
Basic data structure of redis
2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report