RFC 2004

Minimal Encapsulation within IP

๐Ÿ“… published October 1996, from ietf

RFC 2004: Minimal Encapsulation within IP โœจ

  • Number: RFC 2004
  • Title: Minimal Encapsulation within IP
  • Author: C. Perkins, IBM
  • Category: Standards Track
  • Date: October 1996
  • Obsoletes / Updates: the header doesn't list anything this RFC obsoletes or updates ๐Ÿ“œ

Status of This Memo ๐Ÿ“œ

This doc is a Standards Track protocol spec for the Internet community, and it's asking for discussion and suggestions to make it better ๐Ÿซถ. If you want to know where this protocol stands in the standardization process, check the current "Internet Official Protocol Standards" (STD 1) ๐Ÿ’…. Distribution of this memo is unlimited ๐ŸŒธ.

Abstract ๐Ÿฆ‹

Okay so this doc explains how to pop one IP datagram inside another IP datagram as its payload ๐ŸŽ. It's way lighter than "conventional" IP encapsulation, which slaps a whole second IP header on every packet you wrap ๐Ÿ’€. Encapsulation is basically a way to change how datagrams normally get routed. You deliver them to some middle destination that the network part of the IP Destination Address in the original header would never have picked on its own ๐Ÿงš. Encapsulation can be used for lots of stuff, like getting a datagram to a mobile node that's using Mobile IP ๐ŸŒˆ.

1. Introduction ๐Ÿงš

This doc is about the same idea as above: wrapping an IP datagram inside another IP datagram, with way less overhead than "conventional" IP encapsulation [4], which adds a second IP header to every encapsulated datagram ๐Ÿ“. Encapsulation changes normal routing by delivering datagrams to an intermediate destination the network part of the original Destination Address field would not have chosen ๐Ÿ’œ.

Wrapping and unwrapping a datagram is usually called "tunneling" ๐Ÿš‡. The encapsulator and decapsulator are the two "endpoints" of the tunnel ๐Ÿ‘‘. The encapsulator node is the "entry point" of the tunnel, and the decapsulator node is the "exit point" โœจ.

2. Motivation ๐Ÿ’–

The Mobile IP working group came up with encapsulation as a way to get packets from a mobile node's "home network" to an agent that can deliver them locally, using normal methods, wherever the mobile node currently is ๐ŸŒธ [5]. Encapsulation can also be used whenever the source of a datagram (or some router along the way) needs to influence which route the datagram takes to its final destination ๐Ÿ”ฅ. Other uses include multicasting, preferential billing, picking routes with certain security attributes, and general policy routing ๐Ÿ’….

Take a look at [4] for a discussion of the advantages encapsulation has over the IP loose source routing option ๐Ÿ™ˆ. Using IP headers to encapsulate IP datagrams duplicates several fields in the inner header for no reason, so this spec defines a new encapsulation method that gets rid of the duplication and saves some space ๐ŸŽ€. The scheme here came from the Mobile IP Working Group (in earlier Internet Drafts) and is similar to what was defined in [2] ๐Ÿฆ‹.

3. Minimal Encapsulation ๐ŸŽ€

A minimal forwarding header is defined for datagrams that were not fragmented before they got encapsulated ๐Ÿง. Using this encapsulation method is optional ๐ŸŒˆ. Minimal encapsulation MUST NOT be used when the original datagram is already fragmented, because the minimal forwarding header has no room to store fragmentation info ๐Ÿ’€. To encapsulate a datagram this way, you insert the minimal forwarding header into the datagram like this:

     +---------------------------+       +---------------------------+
     |                           |       |                           |
     |         IP Header         |       |     Modified IP Header    |
     |                           |       |                           |
     +---------------------------+ ====> +---------------------------+
     |                           |       | Minimal Forwarding Header |
     |                           |       +---------------------------+
     |         IP Payload        |       |                           |
     |                           |       |                           |
     |                           |       |         IP Payload        |
     +---------------------------+       |                           |
                                         |                           |
                                         +---------------------------+

The original IP header gets modified, and the minimal forwarding header goes in right after it ๐Ÿงš. The IP payload stays exactly the same after that, like the transport header and transport data ๐Ÿซถ. No extra IP header gets added at all ๐Ÿ™Œ.

When you encapsulate, the original IP header [6] gets changed like this:

  • The Protocol field gets replaced with protocol number 55, which is the minimal encapsulation protocol ๐Ÿ”ฅ.
  • The Destination Address field gets replaced with the IP address of the tunnel's exit point ๐Ÿฆ‹.
  • If the encapsulator isn't the original source of the datagram, the Source Address field gets replaced with the IP address of the encapsulator ๐Ÿ’œ.
  • The Total Length field goes up by the size of the minimal forwarding header. That's either 12 or 8 octets, depending on whether the Original Source Address Present (S) bit is set in the forwarding header ๐Ÿ“.
  • The Header Checksum field gets recomputed [6] or updated to account for all the header changes listed here ๐Ÿงฎ.

Okay so here's the thing that's kinda iconic: unlike IP-in-IP encapsulation [4], the Time to Live (TTL) field is not modified during encapsulation ๐Ÿ‘‘. If the encapsulator is forwarding the datagram, it'll decrement the TTL as part of normal IP forwarding ๐ŸŒธ. And since the original TTL stays in the IP header after encapsulation, hops the datagram takes inside the tunnel are visible to things like "traceroute" ๐Ÿ”โœจ.

The minimal forwarding header looks like this:

    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |   Protocol    |S|  reserved   |        Header Checksum        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                 Original Destination Address                  |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   :            (if present) Original Source Address               :
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Here's what each field does ๐Ÿ’–:

  • Protocol: copied from the Protocol field in the original IP header ๐ŸŽ€.
  • Original Source Address Present (S): the field tells you how long the header is ๐Ÿง .
    • 0: the Original Source Address field is not present, and the minimal tunneling header is 8 octets long ๐Ÿ™ˆ.
    • 1: the Original Source Address field is present, and the minimal tunneling header is 12 octets long ๐Ÿ’….
  • reserved: sent as zero, and ignored when received ๐ŸŒˆ.
  • Header Checksum: the 16-bit one's complement of the one's complement sum of all 16-bit words in the minimal forwarding header ๐Ÿงฎ. To compute it, the checksum field's value is 0 ๐Ÿง. The IP header and the IP payload after the minimal forwarding header are not included in this checksum ๐Ÿซถ.
  • Original Destination Address: copied from the Destination Address field in the original IP header ๐Ÿฆ‹.
  • Original Source Address: copied from the Source Address field in the original IP header ๐Ÿ’œ. This field only shows up if the Original Source Address Present (S) bit is set โœจ.

When you decapsulate a datagram, the fields in the minimal forwarding header get restored into the IP header, and then the forwarding header gets removed from the datagram ๐Ÿ”„. The Total Length field in the IP header goes down by the size of the forwarding header you removed ๐Ÿ“‰. The Header Checksum field gets recomputed [6] or updated to account for the decapsulation changes to the IP header ๐Ÿงฎ.

The encapsulator can use the existing IP mechanisms that make sense for delivering the encapsulated payload to the tunnel exit point ๐Ÿš€. IP options are allowed ๐ŸŽ. Fragmentation is allowed too, unless the "Don't Fragment" bit is set in the IP header ๐Ÿ™Œ. That fragmentation restriction is required so that nodes using Path MTU Discovery [3] can get the info they're looking for ๐Ÿ”๐Ÿ’–.

4. Routing Failures ๐Ÿ’€

Using any encapsulation method for routing purposes makes routing loops way more likely ๐ŸŒ€. To cut down on that danger, a router should follow the same procedures outlined in [4] ๐Ÿ›ก๏ธ.

5. ICMP Messages from within the Tunnel ๐Ÿ’Œ

ICMP messages should be handled as specified in [4] ๐Ÿซถ. That includes maintaining the tunnel "soft state" ๐Ÿงš.

6. Security Considerations ๐Ÿ”

Security considerations are not addressed in this document ๐Ÿ˜ญ. They're generally similar to the ones outlined in [4] ๐Ÿ’œ. Don't assume this spec has you covered on security. Go read [4] before you ship anything ๐Ÿšจ.

7. Acknowledgements ๐Ÿซถ

The original text for much of Section 3 came from the Mobile IP draft [1] ๐Ÿ“œ. Huge thanks to David Johnson for improving consistency and making a bunch of other improvements to the draft ๐Ÿ‘‘.

References ๐Ÿ“š

  • [1] Perkins, C., Editor, "IPv4 Mobility Support", Work in Progress, May 1995.
  • [2] David B. Johnson. Scalable and Robust Internetwork Routing for Mobile Hosts. In Proceedings of the 14th International Conference on Distributed Computing Systems, pages 2--11, June 1994.
  • [3] Mogul, J., and S. Deering, "Path MTU Discovery", RFC 1191, November 1990.
  • [4] Perkins, C., "IP Encapsulation within IP", RFC 2003, October 1996.
  • [5] Perkins, C., Editor, "IP Mobility Support", RFC 2002, October 1996.
  • [6] Postel, J., Editor, "Internet Protocol", STD 5, RFC 791, September 1981.

Author's Address ๐Ÿ’Œ

Questions about this memo can be sent to Charles Perkins ๐Ÿ“ฌ:

Charles Perkins
Room H3-D34
T. J. Watson Research Center
IBM Corporation
30 Saw Mill River Rd.
Hawthorne, NY  10532

Work:   +1-914-784-7350
Fax:    +1-914-784-6205
EMail: perk@watson.ibm.com

The working group can be reached through the current chair ๐ŸŽ€:

Jim Solomon
Motorola, Inc.
1301 E. Algonquin Rd.
Schaumburg, IL  60196

Work:   +1-847-576-2753
EMail: solomon@comm.mot.com
๐Ÿ“ฆ where this page comes from