# IP in IP

IP in IP is an IP tunneling protocol that encapsulates one IP packet in another IP packet. To encapsulate an IP packet in another IP packet, an outer header is added with Source IP, the entry point of the tunnel, and Destination IP, the exit point of the tunnel. While doing this, the inner packet is unmodified (except the TTL field, which is decremented). The Don't Fragment and the Type Of Service fields should be copied to the outer packet. If the packet size, including the outer header, is greater than the Path MTU, the encapsulator fragments the packet. The decapsulator will reassemble the packet.

## IP packet encapsulated in IP packet

Outer IPv4 header :
| Offset | Octet | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
| Octet | Bit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
| 0 | 0 | Version (4) | Version (4) | Version (4) | Version (4) | IHL | IHL | IHL | IHL | DSCP | DSCP | DSCP | DSCP | DSCP | DSCP | ECN | ECN | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length | Total length |
| 4 | 32 | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Identification | Flags | Flags | Flags | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset | Fragment offset |
| 8 | 64 | Time to Live | Time to Live | Time to Live | Time to Live | Time to Live | Time to Live | Time to Live | Time to Live | Protocol (4) | Protocol (4) | Protocol (4) | Protocol (4) | Protocol (4) | Protocol (4) | Protocol (4) | Protocol (4) | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum | Header checksum |
| 12 | 96 | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address | Source address |
| 16 | 128 | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address | Destination address |
| 20 | 160 | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) |
| ⋮ | ⋮ | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) |
| 56 | 448 | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) | (Options) (if IHL > 5) |
| 60 | 480 | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) |
| 64 | 512 | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) |
| ⋮ | ⋮ | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | Encapsulated IP packet (TTL decremented, but unaltered otherwise) |
Outer IP header has the following fields: