Generic Routing Encapsulation (GRE)
RFC 2784, `Generic Routing Encapsulation' (GRE), provides a mechanism for encapsulating a payload packet to send that packet over a network of a different type. First, a GRE header is prepended to the payload packet, and the Ethertype for the protocol used in that packet is included in the GRE header. Then, a Delivery header is prepended to the GRE header, which adds a Layer 2 Data Link Layer address plus a Layer 3 Network address (for a network protocol in this implementation, either IPv4 or IPv6). After a GRE-encapsulated payload packet has reached the last router of the GRE `tunnel,' this router removes the GRE header and forwards the payload as a `normal' packet for the native protocol in the network.
This is a relatively simple type of encapsulation and can be used to transparently carry packets for many different protocols, since it is based on Ethertypes. The original specifications for this encapsulation were RFC 1701, `Generic Routing Encapsulation (GRE),' published in 1994, and RFC 1702, `Generic Routing Encapsulation over IPv4 Networks,' also published in 1994.
RFC 2890, `Key and Sequence Number Extensions to GRE,' provides optional fields for identifying individual traffic flows within a GRE tunnel through an authentication key value, and for monitoring the sequence of packets within each GRE tunnel.
GRE Packet Format
Both control and data packets can be GRE-encapsulated. The overall format of a GRE-encapsulated packet is shown in the following figure.
Figure: GRE-Encapsulated Packet
GRE Packet Headers
There are two formats for the GRE Packet Headers:
GRE Header per RFC 2784
The format of a GRE packet header per RFC 2784 is shown in the following figure.
Figure: GRE Packet Header (per RFC 2784)
The fields in the GRE header, per RFC 2784, are described in the following table.
Field | Description |
---|---|
C |
The Checksum Present flag bit. If set (= 1), the Checksum and Reserved1 fields are present, and the information in the Checksum field is valid. |
Reserved0 |
(Bits 1 - 12)
|
Ver |
The Version Number field. The value must be zero. |
Protocol Type |
Protocol Type field. The protocol type of the payload packet. These values are defined in RFC 1700, `Assigned Numbers' and by the IANA `ETHER TYPES' document. When the payload is an IPv4 packet, the protocol type must be set to 0x800 (Ethertype for IPv4). |
Checksum |
(Optional) The IP (one's complement) checksum of all of the 16-bit words in the GRE header and the payload packet. The value of the checksum field = zero for the purpose of computing the checksum. The checksum field is present only if Checksum Present bit is set (= 1). |
Reserved1 |
(Optional) These bits are reserved for future use. This field is present only if the Checksum field is present (that is, the Checksum Present bit = 0). If present, this field must be transmitted as zero. |
GRE Header per RFC 2890
The format of a GRE header, with added information per RFC 2890, is shown in the following figure.
Figure: GRE Header (per RFC 2890)
The fields in the GRE header, per RFC 2890, are described in the following table.
Field | Description |
---|---|
C |
The Checksum Present flag bit. If set (= 1), the Checksum field and the Reserved1 is present, and the information in the Checksum field is valid. |
Reserved0 |
Bits 1 - 12. For bits 1 - 5, unless the receiver is implementing RFC 1701 the receiver must discard the packet if any of these bits are non-zero. For bits 6 - 12, these bits are reserved for future use. |
K |
The Key Present flag bit. If set (= 1), the Key field is present. If not set (= 0), this field is not present. (Compatible with RFC 1701) |
S |
The Sequence Number Present flag bit. If set (= 1), the Sequence Number Present field is present. If not set (= 0), this field is not present. (Compatible with RFC 1701) |
Ver |
The Version Number field. The value must be zero. |
Protocol Type |
Protocol Type field. The protocol type of the payload packet. These values are defined in RFC 1700, `Assigned Numbers' and by the IANA `ETHER TYPES' document (located at www.iana.org/assignments/ethernet-numbers). When the payload is an IPv4 packet, the protocol type must be set to 0x800 (Ethertype for IPv4). |
Checksum |
(Optional) The IP (one's complement) checksum of all of the 16-bit words in the GRE header and the payload packet. The value of the checksum field = zero for the purpose of computing the checksum. The checksum field is present only if Checksum Present bit is set (= 1). |
Reserved1 |
(Optional) These bits are reserved for future use. This field is only present if the Checksum field is present (that is, the Checksum Present bit = 0). If present, this field must be transmitted as zero. |
Key Present |
(Optional) This field is present only if the Key Present bit is set (= 1). A 4-octet number that can be used to identify an individual, logical traffic flow within the GRE tunnel. The encapsulator/sender uses the same key value for all packets within a single flow, for identification by the decapsulator/receiver. |
Sequence Number Present |
(Optional) This field is present only if the Sequence Number Present bit is set (= 1). A 4-octet number that can be used to identify the order of transmission of the packets, with the goal of providing unreliable, but in-order delivery of packets. The decapsulator/receiver uses the sequence number to monitor the order of the packets as they are received. Out-of-sequence packets should be silently discarded. The sequence number of the first packet = 0. The value range is from 0 to (2 ** 32) -1. |