# P4 04
## 龍帆軒
**v1model** 架構
> P4常使用到一個架構叫v1model
而v1model standard metadata大概為這幾項
ingress_port : 封包抵達的port
egress_spec : 封包要被送往的port
egress_port : 封包要從哪個port被送出去
clone_spec , instance_type, drop, recirculate_port, packet_length, enq_timestamp, enq_qdepth, deq_timedelta, deq_qdepth, ingress_global_timesptamp, lf_field_list, mcast_grp, resubmit_flag, egress_field, checksum_error
P4教學裡使用的switch是 **Bmv2** ( behavioral model version 2 )
這個switch是由c++ 11 寫成的,bvm2並不是一個生產力導向的switch(像是ovswitch),而是一個偏向開發使用的switch,測試和debug p4 的data plane。
P4中有5個語言組件
header、parser、table、action、control。
**headers**:headers有分為兩種,一種是packet header另一種是metadata。

**Parsers**:parser是將封包對照進headers跟metadata,用state machine style

**Controls** : 跟C語言裡的function一樣
**Actions**:主要分為primitive action與compound action。Primitive actions包括封包的修改、基本運算、hash運算等等。Compound actions通常都由用戶自己定義。

**Tables**:當table中的欄位與封包配對成功時,就會執行相對應的工作。如果沒也成功配對則會標記成miss。

###### tags: `P4`