----------------------------------------------------------------- Basic Forwarding과 다르게 Tunnel에 관련된 헤더가 추가되어 패킷을 분석할때 Tunnel에 관련된 헤더도 분석하기 위해 경우를 추가.
state parse_ethernet {
packet.extract(hdr.ethernet);
transition select(hdr.ethernet.etherType) {
TYPE_MYTUNNEL: parse_myTunnel;
TYPE_IPV4: parse_ipv4;
default: accept;
}
}
----------------------------------------------------------------------etherType 이 Tunnel인 경우 parse_myTunnel의 함수를 이용하여 패킷을 먼저 분리 그 다음에 Forwarding과 같이 IPV4에 관하여 분석.
state parse_myTunnel {
packet.extract(hdr.myTunnel);
transition select(hdr.myTunnel.proto_id) {
TYPE_IPV4: parse_ipv4;
default: accept;
}
}
----------------------------------------------------------------------ingress하기 위해 터널 헤더에 맞는 테이블 값이 있을 시에 행동을 취하게 끔 분석 및 전송을 하는 함수.
action myTunnel_forward(egressSpec_t port) {
standard_metadata.egress_spec = port;
}
table myTunnel_exact {
key = {
hdr.myTunnel.dst_id: exact;
}
actions = {
myTunnel_forward;
drop;
}
size = 1024;
default_action = drop();
} |