The Routing header influences the route of the datagram. It allows you to define some sequence of “checkpoints” (IPv6 addresses) which the datagram must pass through.
Two types of Routing header (identified by a field inside the extension header) have been defined: Type 0 is a general version allowing an arbitrary checkpoint sequence and type 2 is a simplified version used for mobility purposes. The definition is extensible, so more types can be added later. Let’s describe the general one first. In this case the Routing header contains two pieces of information:
1. sequence of checkpoint addresses
2. counter (named Segments Left) identifying how many of them remain to pass through
The datagram sender wanting to use this feature adds the Routing header to the datagram. It places the address of first checkpoint into the Destination address field inside the basic header. It also adds the Routing header containing the sequence of remaining checkpoints. The final datagram destination (its real target) is the last member of this sequence. Segments Left contains the number of elements in the sequence. Than the datagram is sent as usual.
When delivered to the Destination Address (actually the first checkpoint) the router finds the Routing header and realises that it is just an intermediate station. So it swaps the address in the Destination Address and the Nth address from behind of the Routing header sequence (where N is the current value of Segments Left). Segments Left is than decreased by 1 and datagram is sent to the new destination (which is the next checkpoint).
This procedure is executed on every checkpoint. As you can see the Segments Left header actually separates the addresses already passed and addresses to be visited in the checkpoint sequence. When the addressee sees that Segments Left contains zero, it knows that this is the final datagram destination and the datagram will be processed and passed to the upper layer protocol. The whole mechanism is illustrated in Figure 2-4.
.jpg)
Figure 2-4 Changes in the Routing Header During Datagram Transport
The type 2 Routing header defined as a part of mobility support is a simplified version of the general type described above. It contains just one address instead of sequence of checkpoints. The general idea is following: some mobile node having a permanent address (so called home address) is travelling at present. It is connected to some strange network and obtained a temporary (care-of) address. The goal is to deliver datagrams to the care-of address, but to hide its existence from the upper layers.
So when a datagram is sent to the mobile node, the care-of address is used as the destination in basic IPv6 header. However, a routing header Type 2 is attached containing the home (permanent) address of the mobile node. When the datagram arrives at the target, the addresses are swapped and the home address is presented as the destination to upper layers.
