i am learning networks and tunneling and i have problems with understanding some things about GRE. The structure of tunneling below: [Transport Protocol][ensapsulationg protocol(GRE)][encapsulateed protocol]. Let transport and encapsulated protocol be IPv4, so the questions are: Why not just put ipv4 into ipv4? Will it make problems and how?

  • What if your tunnel must cross a non-IPv4 network? – Ron Maupin Nov 24 '19 at 18:24
  • @RonMaupin ok, so why we just not put our IPv4 in non-IPv4 packet without gre header? – violetapple Nov 24 '19 at 18:42
  • @Zac67 has explained it for you. You can have different combinations of network and encapsulated protocols, and GRE is generic, working with many different protocols, some of which do not know anything about the other protocols. GRE fills a need, and it works quite well. There are other tunneling protocols, but many of them cannot handle things like multicasting or routing protocols, but GRE is generic enough to do all that. – Ron Maupin Nov 24 '19 at 18:48

The network layer passes its payload to the registered upper protocol, depending on the header's protocol field: the payload requires some kind of handler for processing. At minimum, the protocol inside the encapsulation needs to be identified, just like LLC or the EtherType field do. If you didn't identify the protocol it would need to be configured on each side. Or imagine different protocols being passed through the same tunnel, e.g. IPv4 and IPv6.

Note that basic GRE does little more than multiplex the tunnel like that. Its 32 bits header (at minimum) uses 16 bit for the encapsulated protocol identification, reusing the EtherType numbers. GRE's use is so widespread because it's generic, ie. it can transport any inner protocol and its overhead is usually negligible.

Other options include IP-in-IP, but that's limited to tunneling IPv4 only.

  • so there is EtherType for gre, right? And the unpacking GRE encapsulated packet on the receving side will be something like this: ethernet -> gre -> IP (based on EtherType in gre header) -> TCP/UDP -> ..., right? – violetapple Nov 24 '19 at 18:52
  • It's actually Ethernet -> IP -> GRE -> IP -> TCP/UDP. – Zac67 Nov 24 '19 at 19:08
  • ok, now things become much clearer, thank you very much! – violetapple Nov 24 '19 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.