WRAP [1] is a shim protocol that uses a variable-length header between the IP layer and the transport layer, providing NAT with extensible addressing.
A WRAP packet is formatted as in Fig. 2 as the payload of an IPv4 packet.
The protocol field specifies the higher-layer protocol in the ``data'' field using the same types as for IP, e.g 6 for TCP. The length field is the number of 32-bit components in the header. Thus, the WRAP header length in octets is 4 + length * 4. The foffset field is an offset into the list of components where the forwardToken starts, with 0 referring to a null reverseToken, so the forward token starts in the first 32-bit field. The forwardToken is a value used by the next relay agent to determine how to relay the packet to its destination. The reverseToken is a value used by the previous relay agent to refer to where the packet came from.
The data field contains a TCP, UDP, or other transport protocol packet.
A WRAP source sends packets to a destination by forming an IPv4 packet with the IP destination address set to the relay agent address and an appropriate WRAP header. The WRAP forwardToken contains the IRT of the destination relative to this RA, and the reverseToken is null. Thus, the length field is the length of the forwardToken and the foffset field is 0. (The foffset value is also the length of the reverseToken.)
The RA, on receiving an WRAP packet:
Normally, an RA just rewrites the first forward token component and increments the foffset by 1. In the simplest case, the rewritten component is just encodes the IP source address of the incoming packet (that is, the last relay point.) This restricted form of relaying, though less general than WRAP allows, is more amenable to hardware implementation, since less of the packet needs to be rewritten.
If the RA does not recognize the forward token, it drops the packet and may send a WRAMP message back to the previous RA. The relaying state may include filters on sources from which to accept packets and destinations allowed for given sources.
The receiver of a WRAP packet is a node that receives an WRAP packet with a null forwardToken, or receives a packet with a multicast destination and subscribes to that multicast source.
The actual source of the packet is identified by the reverseToken and the last hop RA for the packet. The receiver can contact this last hop RA to do a reverse name lookup on this IRT to determine the name of the actual source, as described in Section 2.
Between relay agents, a packet is routed by the normal IPv4 routing protocols used within the realm, so WRAP is similar to loose source routing with the relay agents as the designated nodes on the path it is to follow. A packet that does not travel outside of a single address realm can (and should) omit the WRAP header entirely.
With WRAP, a packet is reassembled from fragments at each intermediate relay agent, because each relay agent is a destination from the IP standpoint. This feature reduces the risk of carrying packet fragments all the way to the destination only to discover some fragment is missing.