1. gre protocol
In the most general case, a system has a packet that needs to be encapsulated and delivered to some destination.  We will call this the payload packet.  The payload is first encapsulated in a GRE packet.  The resulting GRE packet can then be encapsulated in some other protocol and then forwarded.  We will call this outer protocol the delivery protocol.
base header
struct gre_base_hdr {
        __be16 flags;
        __be16 protocol;
};
flags:
flags bit 0: with checksum
flags bit 1: with key 
flags bit 2: with sequence
protocol: the protocol type of higher level packet