packet_in:输入参数,是接收的数据包内容,常用于parser处。通常是与其他特定类型参数一起使用的,例如out headers hdr(表示解析后的头部信息)、inout metadata meta(元数据,用于传递额外信息)、inout standard_metadata_t standard_metadata(标准元数据,包含了一些标准字段,如端口号等)等。 out:表示参数是输出参数,即函...
交换机体系结构自带的元数据(standard metadata):时间戳均为 微秒 单位 ingress_port:数据包到达设备的入口端口号(只读) packet_length:对于来自端口的包或者再循环的包的长度(bytes) egress_spec:输出端口(入口匹配控制块) egress_port:数据包的目的输出端口(只在 出口匹配控制块访问,只读) instance_type:(只读) ...
inout standard_metadata_t standard_metadata) { action drop() { mark_to_drop(standard_metadata); } action multicast() { standard_metadata.mcast_grp = 1; //组播的group id字段,保存在标准元数据中 } action mac_forward(egressSpec_t port) { standard_metadata.egress_spec = port;...
control MyIngress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { action drop() { mark_to_drop(); } action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) { standard_metadata.egress_spec = port; hdr.ethernet.srcAddr = hdr.ethernet.dstAddr; hdr....
standard_metadata.ingress_port: ternary; hdr.ethernet.dst_addr: ternary; hdr.ethernet.src_addr: ternary; hdr.ethernet.ether_type: ternary; local_metadata.ip_proto: ternary; local_metadata.icmp_type: ternary; local_metadata.l4_src_port: ternary; ...
所述v1model.p4的standard_metadata字段mcast_grp在范围[1, 65535]指定65535个多播组ID值中的一个。mcast_grp等于0表示不组播复制数据包。simple_switch可以使用更大范围的多播组ID。此处给出的范围受p4c的v1model.p4包含文件中类型为bit<16>的standard_metadata字段mcast_grp的定义所限制。
inout standard_metadata_t standard_metadata) { state start { transition parse_ethernet; } state parse_ethernet { packet.extract(hdr.ethernet); transition select(hdr.ethernet.etherType) { TYPE_MYTUNNEL: parse_myTunnel; TYPE_IPV4: parse_ipv4; ...
TODO:定义一个名为的新操作myTunnel_forward,它只是将出口端口(即总线的egress_spec字段standard_metadata)设置为控制平面提供的端口号。 TODO:定义一个名为的新表myTunnel_exact,它dst_id在myTunnel标题的字段上执行完全匹配。如果表中myTunnel_forward存在匹配项,则此表应调用该drop操作,否则应调用该操作。
standard_metadata.egress_spec = port; hdr.ethernet.srcAddr = hdr.ethernet.dstAddr; hdr.ethernet.dstAddr = dstAddr; hdr.ipv4.ttl = hdr.ipv4.ttl - 1; } table ipv4_lpm { key = { hdr.ipv4.dstAddr: lpm; } actions = { ipv4_forward; ...
standard_metadata.egress_spec = port; hdr.ethernet.srcAddr = hdr.ethernet.dstAddr; hdr.ethernet.dstAddr = dstAddr; hdr.ipv4.ttl = hdr.ipv4.ttl - 1; } table ipv4_lpm { key = { hdr.ipv4.dstAddr: lpm; } actions = { ipv4_forward; ...