這一次要稍微提一下有關 P4 Switch以及相關的設計。

P4 Switch 這一個 repo 中其實整合了許多不同的元件,如下:

  • Software switch(透過 switch.p4 產生)
  • Resource Mgmt. API(透過 switch.p4 產生)
  • Switch API
  • Switch Abstraction Interface(SAI)
  • Switchlink(Linux netlink listener)

下圖表示了他們的關係(取自官方 GitHub):

    +-----+   +-----+   +-----+   +-----+
    |App a|   |App j|   |App n|   |App z|
    |     |...|     |...|     |...|     |
    +-----+   +-----+   +-----+   +-----+
       |         |         |         |
       |         |    +----|         |
+------------+   |    |
| Switchlink |   |    |
|            |<-----------------------------+
+------------------+  |                     |
|     SAI          |  |                     |
|                  |  |                     |
+-----------------------+                   |
|      Switch API       |                   |
|                       |                   |
+-----------------------+---------+         |
|      Resource Mgmt. API         |         |
| (auto-gen. from switch.p4)      |         | Netlink events
+---------------------------------+         |
|        Soft Switch              |         |
|  (compiled from switch.p4)      |         |
+---------------------------------+         |
                                            |
                                            |
+---------------------------------------------------+
|                     Kernel                        |
|                                                   |
+---------------------------------------------------+

其實 switch.p4 是來自於 DC.p4 這一篇論文,他明定了在 Data center 中的 Switch 該如何用 P4 去定義出來,後來就延伸成為了 switch.p4 這一個 repo。

switch.p4 包含了以下功能(取自官方 GitHub):

  1. Basic L2 Switching: Flooding, learning and STP
  2. L2 Multicast
  3. Basic L3 Routing (unicast): IPv4 and IPv6 and VRF
  4. L3 Multicast
  5. LAG
  6. ECMP
  7. Tunneling: VXLAN and NVGRE (including L2/L3 Gateway), Geneve, and GRE
  8. Basic ACL: MAC and IP ACLs
  9. Unicast RPF check
  10. MPLS: LER, LSR, IPVPN, VPLS, L2VPN
  11. Host interface
  12. Mirroring: Ingress and egress mirroring with ERSPAN
  13. Counters/Statistics
  14. Ingress Policers
  15. Inband Network Telemetry (INT)

接下來幾篇會依序介紹 Switch API、SAI 以及 Switch link 這三個元件

4 thoughts on “簡單介紹 P4 語言(六)- switch.p4

  1. 感谢博主,我刷完了你写的P4相关的文章,写得挺赞!!清晰明了!!看了你的Github也很赞!加油!!

    1. 谢谢您的支持

  2. 我在运行behavioral-model的时候,出现了这个错误,请问是怎么回事啊,
    求指教
    behbmi_port_interface_add(port_mgr, veth_name, n_veth, pcap_filename): ERROR -1 at main.c:430

    1. 您好,請問有其他的log或是你的執行script嗎?

Share Your Thought