RFC 1701

Generic Routing Encapsulation (GRE)

๐Ÿ“… published October 1994, from ietf

Generic Routing Encapsulation (GRE) ๐ŸŽ€

Okay bestie, this is RFC 1701 ๐Ÿ“œ and it's all about Generic Routing Encapsulation (GRE) ๐Ÿ’–. It came out of the Network Working Group in October 1994. The category is Informational, which is giving "here's some useful info, but it's not a standard" ๐Ÿ’…. S. Hanks wrote it from NetSmiths, Ltd., and T. Li, D. Farinacci and P. Traina are the other authors, with cisco Systems listed as their affiliation. It doesn't list anything it obsoletes or updates, so no drama there โœจ.

Status of this Memo โœจ

This memo is here to provide information for the Internet community ๐ŸŒˆ. It doesn't specify an Internet standard of any kind, so don't go calling it one ๐Ÿ™ˆ. Distribution of this memo is unlimited ๐Ÿ’œ.

Abstract ๐Ÿฆ‹

This doc specifies a protocol for encapsulating an arbitrary network layer protocol inside another arbitrary network layer protocol ๐ŸŽ€.

Introduction ๐ŸŒธ

Okay so there are already a bunch of proposals [RFC 1234, RFC 1226] for encapsulating one protocol over another ๐Ÿ‘€. Other types of encapsulation [RFC 1241, SDRP, RFC 1479] have been proposed for transporting IP over IP for policy purposes ๐Ÿงณ. This memo describes a protocol that's super similar to those proposals, just more general ๐Ÿ’….

Going more general means a lot of protocol-specific nuances got left out โœจ. So this proposal may be less suitable for a situation where a specific "X over Y" encapsulation has already been described ๐Ÿคทโ€โ™€๏ธ. The whole point of this protocol is to be a simple, general purpose mechanism that takes the problem of encapsulation from its current O(n^2) problem to a much more manageable state ๐Ÿงš. It also gives you a lightweight encapsulation for use in policy based routing ๐Ÿ“.

This memo explicitly doesn't get into when a packet gets encapsulated ๐Ÿ™…โ€โ™€๏ธ. It's aware of problems with mutual encapsulation [RFC 1326], but it doesn't address them ๐Ÿ’€.

In the most general case, a system has a packet that needs to be encapsulated and routed. We'll call this the payload packet ๐ŸŽ. The payload gets encapsulated in a GRE packet first, and that GRE packet may also include a route ๐Ÿ›ฃ๏ธ. The resulting GRE packet can then be encapsulated in some other protocol and forwarded from there. We'll call this outer protocol the delivery protocol ๐Ÿšš. The algorithms for processing this packet are discussed later ๐Ÿ”œ.

Overall packet ๐Ÿงš

The entire encapsulated packet ends up looking like this:

                  ---------------------------------
                  |                               |
                  |       Delivery Header         |
                  |                               |
                  ---------------------------------
                  |                               |
                  |       GRE Header              |
                  |                               |
                  ---------------------------------
                  |                               |
                  |       Payload packet          |
                  |                               |
                  ---------------------------------

Packet header ๐Ÿ’…

The GRE packet header has the form:

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |C|R|K|S|s|Recur|  Flags  | Ver |         Protocol Type         |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |      Checksum (optional)      |       Offset (optional)       |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                         Key (optional)                        |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                    Sequence Number (optional)                 |
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      |                         Routing (optional)
      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Flags and version (2 octets)

The GRE flags live in the first two octets ๐ŸŽ€. Bit 0 is the most significant bit and bit 15 is the least significant bit ๐Ÿ”ข. Bits 13 through 15 are reserved for the Version field ๐Ÿ’œ. Bits 5 through 12 are reserved for future use and MUST be transmitted as zero. ๐Ÿซถ

Checksum Present (bit 0)

If the Checksum Present bit is set to 1, then the Checksum field is present and contains valid information โœ….

If either the Checksum Present bit or the Routing Present bit is set, BOTH the Checksum and Offset fields are present in the GRE packet ๐Ÿ‘ฏ.

Routing Present (bit 1)

If the Routing Present bit is set to 1, then it means the Offset and Routing fields are present and contain valid information ๐Ÿ›ฃ๏ธ.

If either the Checksum Present bit or the Routing Present bit is set, BOTH the Checksum and Offset fields are present in the GRE packet ๐Ÿ‘ฏ.

Key Present (bit 2)

If the Key Present bit is set to 1, then the Key field is present in the GRE header ๐Ÿ”‘. Otherwise, the Key field is not present in the GRE header ๐Ÿ™ƒ.

Sequence Number Present (bit 3)

If the Sequence Number Present bit is set to 1, then the Sequence Number field is present ๐Ÿ”ข. Otherwise, the Sequence Number field is not present in the GRE header ๐Ÿซ .

Strict Source Route (bit 4)

The meaning of the Strict Source Route bit is defined in other documents ๐Ÿ“š. It's recommended that this bit only be set to 1 if all of the Routing Information consists of Strict Source Routes ๐Ÿงญ.

Recursion Control (bits 5-7)

Recursion control is a three bit unsigned integer. It holds the number of additional encapsulations that are permissible ๐ŸŒ€. This SHOULD default to zero. ๐Ÿ’…

Version Number (bits 13-15)

The Version Number field MUST contain the value 0. Other values are outside the scope of this document ๐Ÿšซ.

Protocol Type (2 octets)

The Protocol Type field holds the protocol type of the payload packet ๐Ÿ“ฆ. In general, the value will be the Ethernet protocol type field for the packet ๐Ÿชช. Currently defined protocol types are listed below ๐Ÿ“‹. Additional values may be defined in other documents ๐Ÿ“š.

Offset (2 octets)

The offset field tells you the octet offset from the start of the Routing field to the first octet of the active Source Route Entry to be examined ๐Ÿ‘€. This field is present if the Routing Present or the Checksum Present bit is set to 1, and it only contains valid information if the Routing Present bit is set to 1 ๐ŸŽฏ.

Checksum (2 octets)

The Checksum field has the IP (one's complement) checksum of the GRE header and the payload packet ๐Ÿงฎ. This field is present if the Routing Present or the Checksum Present bit is set to 1, and it only contains valid information if the Checksum Present bit is set to 1 โœ….

Key (4 octets)

The Key field is a four octet number that was inserted by the encapsulator ๐Ÿ”. The receiver can use it to authenticate the source of the packet ๐Ÿ•ต๏ธโ€โ™€๏ธ. How you actually determine authenticity is outside the scope of this document ๐Ÿ™ˆ. The Key field is only present if the Key Present field is set to 1.

Bestie, the authentication techniques aren't in this doc, so don't go hunting for them here ๐Ÿ™ˆ

Sequence Number (4 octets)

The Sequence Number field is an unsigned 32 bit integer that was inserted by the encapsulator ๐Ÿ”ข. The receiver can use it to work out the order in which packets were transmitted from the encapsulator to the receiver ๐Ÿ“ฌ. The exact algorithms for generating the Sequence Number and the semantics of receiving it are outside the scope of this document ๐Ÿง .

Routing (variable)

The Routing field is optional. It's only present if the Routing Present bit is set to 1 ๐Ÿ›ฃ๏ธ.

The Routing field is a list of Source Route Entries (SREs). Each SRE has the form:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |       Address Family          |  SRE Offset   |  SRE Length   |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                        Routing Information ...
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The routing field ends with a "NULL" SRE. That one has an address family of type 0x0000 and a length of 0 ๐Ÿ.

Address Family (2 octets)

The Address Family field is a two octet value that tells you the syntax and semantics of the Routing Information field ๐Ÿ—‚๏ธ. The values for this field, and the matching syntax and semantics for Routing Information, are defined in other documents ๐Ÿ“š.

SRE Offset (1 octet)

The SRE Offset field is the octet offset from the start of the Routing Information field to the first octet of the active entry in the Source Route Entry that needs to be examined ๐ŸŽฏ.

SRE Length (1 octet)

The SRE Length field holds the number of octets in the SRE ๐Ÿ“. If the SRE Length is 0, that means this is the last SRE in the Routing field ๐Ÿ.

Routing Information (variable)

The Routing Information field has data that may be used for routing this packet ๐Ÿ—บ๏ธ. The exact semantics of this field are defined in other documents ๐Ÿ“š.

Forwarding of GRE packets ๐Ÿ’–

Okay this part is so important ๐Ÿ˜ญ. Normally, a system that's forwarding delivery layer packets won't treat GRE packets differently from any other packets ๐Ÿซฅ. However, a GRE packet might get received by a system. In that case, the system should use some delivery-specific means to figure out that this is a GRE packet ๐Ÿ•ต๏ธ. Once that's determined, the Key, Sequence Number and Checksum fields can be checked, as long as they contain valid information according to their corresponding flags ๐Ÿ”. If the Routing Present bit is set to 1, then the Address Family field should be checked to determine the semantics and use of the SRE Length, SRE Offset and Routing Information fields ๐Ÿงฉ. The exact semantics for processing an SRE for each Address Family are defined in other documents ๐Ÿ“š.

Once all SREs have been processed, the source route is complete ๐Ÿ. The GRE header should be removed, and the payload's TTL MUST be decremented (if one exists). After that, the payload packet should be forwarded as a normal packet ๐Ÿš€. The exact forwarding method depends on the Protocol Type field ๐ŸŽ€.

Current List of Protocol Types โœจ

Okay bestie, here's the list of protocol types that are currently assigned for GRE ๐Ÿฆ‹ Future protocol types must be taken from DIX ethernet encoding, no cap. For historical reasons, a bunch of other values have been used for some protocols, which is messy but iconic ๐Ÿ’€ The following table of values MUST be used to identify the protocols ๐Ÿ’…

       Protocol Family                     PTYPE
       ---------------                     -----
       Reserved                            0000
       SNA                                 0004
       OSI network layer                   00FE
       PUP                                 0200
       XNS                                 0600
       IP                                  0800
       Chaos                               0804
       RFC 826 ARP                         0806
       Frame Relay ARP                     0808
       VINES                               0BAD
       VINES Echo                          0BAE
       VINES Loopback                      0BAF
       DECnet (Phase IV)                   6003
       Transparent Ethernet Bridging       6558
       Raw Frame Relay                     6559
       Apollo Domain                       8019
       Ethertalk (Appletalk)               809B
       Novell IPX                          8137
       RFC 1144 TCP/IP compression         876B
       IP Autonomous Systems               876C
       Secure Data                         876D
       Reserved                            FFFF

For the complete list of these values, check the IANA list of Ether Types ๐Ÿงš

URL = ftp://ftp.isi.edu/in-notes/iana/assignments/ethernet-numbers.


References ๐Ÿ“š

RFC 1479 Steenstrup, M. "Inter-Domain Policy Routing Protocol Specification: Version 1", RFC1479, BBN Systems and Technologies, July 1993.

RFC 1226 Kantor, B. "Internet Protocol Encapsulation of AX.25 Frames", RFC 1226, University of California, San Diego, May 1991.

RFC 1234 Provan, D. "Tunneling IPX Traffic through IP Networks", RFC 1234, Novell, Inc., June 1991.

RFC 1241 Woodburn, R., and D. Mills, "Scheme for an Internet Encapsulation Protocol: Version 1", RFC 1241, SAIC, University of Delaware, July 1991.

RFC 1326 Tsuchiya, P., "Mutual Encapsulation Considered Dangerous", RFC 1326, Bellcore, May 1992.

SDRP Estrin, D., Li, T., and Y. Rekhter, "Source Demand Routing Protocol Specification (Version 1)", Work in Progress.

RFC 1702 Hanks, S., Li, T., Farinacci, D., and P. Traina, "Generic Routing Encapsulation over IPv4 networks", RFC 1702, NetSmiths, Ltd., cisco Systems, October 1994.


Security Considerations ๐Ÿ”’

Security issues are not discussed in this memo, so that's a whole plot twist ๐Ÿ˜ญ

Acknowledgements ๐Ÿซถ

The authors would like to shout out Yakov Rekhter (IBM) and Deborah Estrin (USC) for their advice, encouragement and insightful comments. Iconic support, honestly ๐Ÿ‘‘

Authors' Addresses ๐Ÿงš

Stan Hanks

NetSmiths, Ltd.
2025 Lincoln Highway
Edison NJ, 08817

EMail: stan@netsmiths.com

Tony Li

cisco Systems, Inc.
1525 O'Brien Drive
Menlo Park, CA 94025

EMail: tli@cisco.com

Dino Farinacci

cisco Systems, Inc.
1525 O'Brien Drive
Menlo Park, CA 94025

EMail: dino@cisco.com

Paul Traina

cisco Systems, Inc.
1525 O'Brien Drive
Menlo Park, CA 94025

EMail: pst@cisco.com
๐Ÿ“ฆ where this page comes from