Mobile IPv6 Host Sending and Receiving Algorithm
A Mobile IPv6 node can be both a mobile node and correspondent node at the same time. Therefore, the host sending algorithm for a Mobile IPv6 node must take into account the following:
- If the sending host is away from home: If so, the sending host must set the source address of the IPv6 header to the sending host's care-of address and include the Destination Options header with the Home Address option set to the node's home address.
- If the receiving node is away from home: If so, the sending host must set the destination address of the IPv6 header to the receiving node's care-of address and include a Type 2 Routing header with the Home Address field set to the receiving node's home address.
The sending host must also determine if the receiving node has already been determined to be Mobile IPv6-capable, and if not, whether or not a correspondent registration has already been initiated.
A Mobile IPv6 host uses the following algorithm when sending a unicast or anycast packet to an arbitrary destination:
- Check the destination cache for an entry matching the destination address.
- If an entry matching the destination address is not found in the destination cache, go to step 13.
- If an entry matching the destination address is found in the destination cache, check for a pointer to an entry in the binding cache. (This algorithm assumes the use of separate destination and binding caches.) This pointer will be present if the destination is a mobile node away from home.
- If there is a pointer to an entry in the binding cache, set the destination address in the IPv6 header to the destination node's care-of address and inserts a Type 2 Routing header that includes the destination node's home address. The binding cache entry for the home address contains a pointer to the destination cache entry for the care-of address, from which the sending host obtains the next-hop address and interface for the care-of address.
- If there is no pointer to an entry in the binding cache, obtain the next-hop address and interface from the destination cache entry.
- If the packet is tunneled to the home agent, go to step 16.
- If the sending host is a mobile node that is at home, go to step 16.
- If the sending host is a mobile node away from home, it checks its binding update list for an entry matching the destination.
- If an entry is found, set the source address in the IPv6 header to the sending host's care-of address and insert a Destination Options header that includes the Home Address option containing the sending host's home address. Go to step 16.
- If an entry is not found, check whether the destination has been determined to be Mobile IPv6-capable. If the destination is not Mobile IPv6-capable, go to step 12.
- If the sending host has not yet determined whether the destination is Mobile IPv6- capable (the assumption is that it is capable until determined otherwise), it checks whether a correspondent registration has already been initiated with the destination, and if not, it initiates one.
- Set the source address to the home address and the destination address to the correspondent node's address, and then encapsulate the packet with an IPv6 header from the care-of address to the home agent's address. Go to step 1.
- Check the local IPv6 routing table for the longest matching route with the lowest metric to the destination address. If there are multiple longest matching routes with the lowest metric, IPv6 chooses a route to use.
- Based on the chosen route, determine the next-hop interface and address used for forwarding the packet.
- Update the destination cache.
- Check the neighbor cache for an entry matching the next-hop address.
- If an entry matching the next-hop address is found in the neighbor cache, obtain the link-layer address.
- If an entry matching the next-hop address is not found in the neighbor cache, use address resolution to obtain the link-layer address for the next-hop address. If address resolution is not successful, indicate an error.
- Send the packet by using the link-layer address of the neighbor cache entry.
Mobile IPv6 Host Receiving Algorithm
A Mobile IPv6 node can be both a mobile node and correspondent node at the same time. Therefore, the host receiving algorithm for a Mobile IPv6 node must take into account the following:
- If the receiving node is away from home: If so, the receiving node processes the Type 2 Routing header in the IPv6 packet and logically sets the destination address of the IPv6 header to the value of the Home Address field in the Type 2 Routing header.
- If the sending host is away from home: If so, the receiving node processes the Destination Options header and logically sets the source address of the IPv6 packet to the home address contained in the Home Address option.
Additionally, a receiving Mobile IPv6 host must recognize a packet tunneled from its home agent in order to determine when to initiate a correspondent registration to a new correspondent node.
A Mobile IPv6 host uses the following algorithm when receiving a unicast or anycast packet from an arbitrary source:
- Verify whether the destination address in the IPv6 packet corresponds to an IPv6 address assigned to a local host interface.
If the destination address is not assigned to a local host interface, silently discard the IPv6 packet. - Check to see if there is a Type 2 Routing header present. If so, process it and set the destination address of the IPv6 packet to the value of the Home Address field in the Type 2 Routing header.
- Check to see if the packet was tunneled from the home agent. If the packet was not tunneled from the home agent, go to step 8.
- If the packet is a Home Test (HoT) message, process its contents.
- If the packet is not a HoT message, check to see whether the sender has been determined to be Mobile IPv6-capable. If the sender is not Mobile IPv6-capable, go to step 7.
- If the sender has not been determined to be Mobile IPv6-capable (the assumption is that it is capable until determined otherwise), it checks whether a correspondent registration has already been initiated with the sender, and if not, the receiver initiates one.
- Strip the outer IPv6 header (in which the destination address is set to the receiving node's care-of address and the source address is set to the home agent), and then process and remove the ESP header and trailer, if present.
- Check to see if there is a Destination Options header with a Home Address option. If so, logically set the source address of the IPv6 packet to the home address in the Home Address option.
- Based on the Next Header field, process extension headers (if present) and pass the upper-layer PDU to the appropriate upper-layer protocol.
If the protocol does not exist, send an ICMPv6 Parameter Problem-Unrecognized Next Header Type Encountered message back to the sender and discard the packet. - If the upper-layer PDU is not a TCP segment or UDP message, pass the upper-layer PDU to the appropriate protocol.
- If the upper-layer PDU is a TCP segment or UDP message, check the destination port.
If no application exists for the UDP port number, send an ICMPv6 Destination Unreachable-Port Unreachable message back to the sender and discard the packet. If no application exists for the TCP port number, send a TCP Connection Reset segment back to the sender and discard the packet. - If an application exists for the UDP or TCP destination port, process the contents of the TCP segment or UDP message.