Generic Routing Encapsulation (GRE) is a
tunneling protocol
In computer networks, a tunneling protocol is a communication protocol which allows for the movement of data from one network to another. It involves allowing private network communications to be sent across a public network (such as the Internet ...
developed by
Cisco Systems
Cisco Systems, Inc., commonly known as Cisco, is an American-based multinational corporation, multinational digital communications technology conglomerate (company), conglomerate corporation headquartered in San Jose, California. Cisco develo ...
that can
encapsulate a wide variety of
network layer
In the seven-layer OSI model of computer networking, the network layer is layer 3. The network layer is responsible for packet forwarding including routing through intermediate routers.
Functions
The network layer provides the means of trans ...
protocols inside virtual
point-to-point links or point-to-multipoint links over an
Internet Protocol
The Internet Protocol (IP) is the network layer communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet.
...
network.
Example uses
* In conjunction with
PPTP
The Point-to-Point Tunneling Protocol (PPTP) is an obsolete method for implementing virtual private networks. PPTP has many well known security issues.
PPTP uses a TCP control channel and a Generic Routing Encapsulation tunnel to encapsulate P ...
to create
VPNs.
* In conjunction with
IPsec
In computing, Internet Protocol Security (IPsec) is a secure network protocol suite that authenticates and encrypts packets of data to provide secure encrypted communication between two computers over an Internet Protocol network. It is used in ...
VPNs to allow passing of routing information between connected networks.
* In
mobility protocols.
* In
A8/A10 interfaces to encapsulate IP data to/from Packet Control Function (PCF).
*
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
and
BSD can establish ad-hoc IP over GRE tunnels which are interoperable with Cisco equipment.
*
Distributed denial of service (DDoS) protected appliance to an unprotected
endpoint.
Example protocol stack
Based on the principles of protocol layering in OSI, protocol encapsulation, not specifically GRE, breaks the layering order. It may be viewed as a separator between two different protocol stacks, one acting as a carrier for another.
Delivery protocols
GRE packets that are encapsulated within
IP directly, use IP protocol
type 47 in the IPv4 header's ''Protocol'' field or the
IPv6 header's ''Next Header'' field.
For performance reasons, GRE can also be encapsulated in UDP packets. Better throughput may be achieved by using
Equal-cost multi-path routing.
Packet header
Extended GRE packet header (RFC 2890)
The extended version of the GRE
packet header is represented below:
:
; ''C (1 bit)'':
Checksum
A checksum is a small-sized block of data derived from another block of digital data for the purpose of detecting errors that may have been introduced during its transmission or storage. By themselves, checksums are often used to verify dat ...
bit. Set to 1 if a checksum is present.
; ''K (1 bit)'': Key bit. Set to 1 if a key is present.
; ''S (1 bit)'': Sequence number bit. Set to 1 if a sequence number is present.
; ''Reserved 0 (9 bits)'': Reserved bits; set to 0.
; ''Version (3 bits)'': GRE Version number; set to 0.
; ''Protocol Type (16 bits)'': Indicates the
ether protocol type of the encapsulated payload. (For
IPv4
Internet Protocol version 4 (IPv4) is the fourth version of the Internet Protocol (IP). It is one of the core protocols of standards-based internetworking methods in the Internet and other packet-switched networks. IPv4 was the first version d ...
, this would be hex 0800.)
; ''Checksum (16 bits)'': Present if the ''C'' bit is set; contains the checksum for the GRE header and payload.
; ''Reserved 1 (16 bits)'': Present if the ''C'' bit is set; is set to 0.
; ''Key (32 bits)'': Present if the ''K'' bit is set; contains an application-specific key value.
; ''Sequence Number (32 bits)'': Present if the ''S'' bit is set; contains a sequence number for the GRE packet.
Standard GRE packet header (RFC 2784)
A standard GRE
packet header structure is represented in the diagram below.
:
; ''C (1 bit)'':
Checksum
A checksum is a small-sized block of data derived from another block of digital data for the purpose of detecting errors that may have been introduced during its transmission or storage. By themselves, checksums are often used to verify dat ...
bit. Set to 1 if a checksum is present.
; ''Reserved 0 (12 bits)'': Reserved bits; set to 0.
; ''Version (3 bits)'': GRE Version number; set to 0.
; ''Protocol Type (16 bits)'': Indicates the
ether protocol type of the encapsulated payload. (For
IPv4
Internet Protocol version 4 (IPv4) is the fourth version of the Internet Protocol (IP). It is one of the core protocols of standards-based internetworking methods in the Internet and other packet-switched networks. IPv4 was the first version d ...
, this would be
hexadecimal
In mathematics and computing, the hexadecimal (also base-16 or simply hex) numeral system is a positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system representing numbers using 10 symbols, h ...
0x0800; for
IPv6
Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet. I ...
, it would be 0x86DD.)
; ''Checksum (16 bits)'': Present if the ''C'' bit is set; contains the checksum for the GRE header and payload.
; ''Reserved 1 (16 bits)'': Present if the ''C'' bit is set; its contents is set to 0.
Original GRE packet header (RFC 1701)
The newer structure superseded the original structure:
:
The original GRE RFC defined further fields in the packet header which became obsolete in the current standard:
; ''C (1 bit)'':
Checksum
A checksum is a small-sized block of data derived from another block of digital data for the purpose of detecting errors that may have been introduced during its transmission or storage. By themselves, checksums are often used to verify dat ...
bit. Set to 1 if a checksum is present.
; ''R (1 bit)'': Routing Bit. Set to 1 if Routing and Offset information are present.
; ''K (1 bit)'': Key bit. Set to 1 if a key is present.
; ''S (1 bit)'': Sequence number bit. Set to 1 if a sequence number is present.
; ''s (1 bit)'': Strict source route bit.
; ''Recur (3 bits)'':
Recursion
Recursion (adjective: ''recursive'') occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematic ...
control bits.
; ''Flags (5 bits)'': Reserved for future use, set to 0.
; ''Version (3 bits)'': Set to 0.
; ''Protocol Type (16 bits)'': Indicates the
ether protocol type of the encapsulated payload.
; ''Checksum (16 bits)'': Present if the ''C'' bit is set; contains the checksum for the GRE header and payload.
; ''Offset (16 bits)'': Present if ''R'' bit or ''C'' bit is set; contains valid information, only if ''R'' bit is set. An offset field indicating the offset within the ''Routing'' field to the active source route entry.
; ''Key (32 bits)'': Present if the ''K'' bit is set; contains an application-specific key value.
; ''Sequence Number (32 bits)'': Present if the ''S'' bit is set; contains a sequence number for the GRE packet.
; ''Routing (variable)'': Present if ''R'' bit is set; contains a list of source route entries, therefore is of variable length.
PPTP GRE packet header
The
Point-to-Point Tunneling Protocol (PPTP) uses a variant GRE packet header structure, represented below. PPTP creates a GRE tunnel through which the PPTP GRE packets are sent.
:
; ''C (1 bit)'':
Checksum
A checksum is a small-sized block of data derived from another block of digital data for the purpose of detecting errors that may have been introduced during its transmission or storage. By themselves, checksums are often used to verify dat ...
bit. For PPTP GRE packets, this is set to 0.
; ''R (1 bit)'': Routing bit. For PPTP GRE packets, this is set to 0.
; ''K (1 bit)'': Key bit. For PPTP GRE packets, this is set to 1. (All PPTP GRE packets carry a key.)
; ''S (1 bit)'': Sequence number bit. Set to 1 if a sequence number is supplied, indicating a PPTP GRE data packet.
; ''s (1 bit)'': Strict source route bit. For PPTP GRE packets, this is set to 0.
; ''Recur (3 bits)'':
Recursion
Recursion (adjective: ''recursive'') occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematic ...
control bits. For PPTP GRE packets, these are set to 0.
; ''A (1 bit)'': Acknowledgment number present. Set to 1 if an acknowledgment number is supplied, indicating a PPTP GRE acknowledgment packet.
; ''Flags (4 bits)'': Flag bits. For PPTP GRE packets, these are set to 0.
; ''Version (3 bits)'': GRE Version number. For PPTP GRE packets, this is set to 1.
; ''Protocol Type (16 bits)'': For PPTP GRE packets, this is set to hex 880B.
; ''Key Payload Length (16 bits)'': Contains the size of the payload, not including the GRE header.
; ''Key Call ID (16 bits)'': Contains the Peer's Call ID for the session to which the packet belongs.
; ''Sequence Number (32 bits)'': Present if the S bit is set; contains the GRE payload sequence number.
; ''Acknowledgement Number (32 bits)'': Present if the A bit is set; contains the sequence number of the highest GRE payload packet received by the sender.
Standards
* : ''Generic Routing Encapsulation (GRE)'' (informational)
* : ''Generic Routing Encapsulation over IPv4 networks'' (informational)
* : ''Point to Point Tunneling Protocol'' (informational)
* : ''Generic Routing Encapsulation (GRE)'' (proposed standard, updated by RFC 2890)
* : ''Key and Sequence Number Extensions to GRE'' (proposed standard)
* : ''GRE-in-UDP Encapsulation'' (proposed standard)
See also
*
Network Virtualization using Generic Routing Encapsulation
Network Virtualization using Generic Routing Encapsulation (NVGRE) is a network virtualization technology that attempts to alleviate the scalability problems associated with large cloud computing deployments. It uses Generic Routing Encapsulatio ...
- carries L2 packets over GRE
References
External links
{{Commons, Generic Routing Encapsulation
Generic Routing Encapsulation Subprotocol homepage at Cisco
Generic Routing Encapsulation Entry in Cisco DocWiki (formerly known as the "Internetworking Technology Handbook")
Tunneling protocols