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
editOffset | Octet | 0 | 1 | 2 | 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) | IHL | DSCP | ECN | Total length | |||||||||||||||||||||||||||
4 | 32 | Identification | Flags | Fragment offset | |||||||||||||||||||||||||||||
8 | 64 | Time to Live | Protocol (4) | Header checksum | |||||||||||||||||||||||||||||
12 | 96 | Source address | |||||||||||||||||||||||||||||||
16 | 128 | Destination address | |||||||||||||||||||||||||||||||
20 | 160 | (Options) (if IHL > 5) | |||||||||||||||||||||||||||||||
⋮ | ⋮ | ||||||||||||||||||||||||||||||||
56 | 448 | ||||||||||||||||||||||||||||||||
60 | 480 | Encapsulated IP packet (TTL decremented, but unaltered otherwise) | |||||||||||||||||||||||||||||||
64 | 512 | ||||||||||||||||||||||||||||||||
⋮ | ⋮ |
Outer IP header has the following fields:
- Version: 4 bits
- This field is the Internet Protocol version number. Set to 4 to indicate IPv4.
- Internet Header Length (IHL): 4 bits
- This field is the length of outer IP header.
- Differentiated Services Code Point (DSCP): 6 bits
- This field is copied from the inner IP header.
- Explicit Congestion Notification (ECN): 2 bits
- This field is copied from the inner IP header.
- Total Length: 16 bits
- This field is the length of the encapsulated IP packet (including Outer IP Header, Inner IP Header, IP Payload).
- Identification: 16 bits
- This field is used to identify the fragments of a datagram which will be helpful while reassembling the datagram as the encapsulator might fragment the datagram. For the Outer IP Header, a new number is generated.
- Flags: 3 bits
- There are three flags defined within this field.
- Reserved (R): 1 bit
- Reserved. Should be set to 0.
- Don't Fragment (DF): 1 bit
- This field specifies whether the datagram can be fragmented or not. If this bit is set to 1 in the inner header, then the outer header also have this bit set to 1 saying that this datagram cannot be fragmented. If this bit is set to 0 in the inner header, then the outer header may set to 0 or 1.
- More Fragments (MF): 1 bit
- This field is required when the datagram is fragmented saying whether the datagram contains some more fragments. This field is not copied from inner header.
- Fragment offset: 13 bits
- This field is used while reassembling the fragments.
- Timo To Live (TTL): 8 bits
- This field is used to track the lifetime of the datagram. The inner header TTL is decremented before encapsulation and is not changed in decapsulator. The outer header TTL is set to value such that the datagram is delivered to tunnel end point.
- Protocol: 8 bits
- This field indicates the transport layer protocol of the datagram following this header. The value is set to 4 for IP in IP. Not to be mistaken with value 4 in the Version field, which indicates IPv4.
- Header Checksum: 16 bits
- This field is the IP checksum of outer header.
- Source IP Address: 32 bits
- This field is the IP address of the encapsulator.
- Destination IP Address: 32 bits
- This field is the IP address of the decapsulator.
- Options: 0 - 320 bits, padded to multiples of 32 bits
- This field in general is NOT copied from the inner IP header. New options can be added.
See also
editReferences
edit- ^ C. Perkins (October 1996). IP Encapsulation within IP. Network Working Group. doi:10.17487/RFC2003. RFC 2003. Proposed Standard. Updated by RFC 3168 and 6864.