当前位置:网站首页>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.
边栏推荐
- Two-stage RO: part 1
- From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
- 1009 product of polynomials (25 points) [PTA class A]
- HDU 2488 A Knight's Journey(DFS)
- MySQL index test
- New trend of embedded software development: Devops
- $watch will not trigger data change - $watch not firing on data change
- C # generates PPK files in putty format (supports passphrase)
- leetcode 474. Ones and zeroes (medium)
- Multi graph explanation of resource preemption in yarn capacity scheduling
猜你喜欢

Member management applet actual development 07 page Jump

To tell you the truth, ThreadLocal is really not an advanced thing

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

2022-2028 global carbon fiber room scraper system industry research and trend analysis report

2022-2028 global plant peptone industry research and trend analysis report

IFLYTEK active competition summary! (12)

Ditto set global paste only text shortcuts

20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract

Redis - how to understand publishing and subscribing

【日常记录】——对BigDecimal除法运算时遇到的Bug
随机推荐
最长的可整合子数组的长度
Search rotation sort array
ABAQUS 2022 latest edition - perfect realistic simulation solution
1009 product of polynomials (25 points) [PTA class A]
Exercise and health
Solving the weird problem that the query conditions affect the value of query fields in MySQL query
left join左连接匹配数据为NULL时显示指定值
Longest valid bracket
什么是产品思维
The programmer's girlfriend gave me a fatigue driving test
20220215 CTF misc buuctf Xiaoming's safe binwalk analysis DD command separate rar file archpr brute force password cracking
2022-2028 global weight loss ginger tea industry research and trend analysis report
Explain kubernetes backup and recovery tools velero | learn more about carina series phase III
ArrayList分析1-循环、扩容、版本
2022-2028 global ICT test probe 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
Design e-commerce seckill system
获取屏幕高度
C#生成putty格式的ppk文件(支持passphrase)
Deployment of mini version message queue based on redis6.0