The routing table data structure contains all the information
necessary to forward an IP data packet toward its destination. Each
routing table entry describes the collection of best paths to a
particular destination. When forwarding an IP data packet, the
routing table entry providing the best match for the packet's IP
destination is located. The matching routing table entry then
provides the next hop towards the packet's destination. OSPF also
provides for the existence of a default route (Destination ID =
DefaultDestination, Address Mask = 0x00000000). When the default
route exists, it matches all IP destinations (although any other
matching entry is a better match). Finding the routing table entry
that best matches an IP destination is further described in Section
11.1.
There is a single routing table in each router. Two sample routing
tables are described in Sections 11.2 and 11.3. The building of the
routing table is discussed in Section 16.
The rest of this section defines the fields found in a routing table
entry. The first set of fields describes the routing table entry's
destination.
Destination Type
The destination can be one of three types. Only the first type,
Network, is actually used when forwarding IP data traffic. The
other destinations are used solely as intermediate steps in the
routing table build process.
Network
A range of IP addresses, to which IP data traffic may be
forwarded. This includes IP networks (class A, B, or C), IP
subnets, IP supernets and single IP hosts. The default
route also falls in this category.
Area border router
Routers that are connected to multiple OSPF areas. Such
routers originate summary link advertisements. These
routing table entries are used when calculating the inter-
area routes (see Section 16.2). These routing table entries
may also be associated with configured virtual links.
AS boundary router
Routers that originate AS external link advertisements.
These routing table entries are used when calculating the AS
external routes (see Section 16.4).
Destination ID
The destination's identifier or name. This depends on the
Destination Type. For networks, the identifier is their
associated IP address. For all other types, the identifier is
the OSPF Router ID.[9]
Address Mask
Only defined for networks. The network's IP address together
with its address mask defines a range of IP addresses. For IP
subnets, the address mask is referred to as the subnet mask.
For host routes, the mask is "all ones" (0xffffffff).
Optional Capabilities
When the destination is a router (either an area border router
or an AS boundary router) this field indicates the optional OSPF
capabilities supported by the destination router. The two
optional capabilities currently defined by this specification
are the ability to route based on IP TOS and the ability to
process AS external link advertisements. For a further
discussion of OSPF's optional capabilities, see Section 4.5.
The set of paths to use for a destination may vary based on IP Type
of Service and the OSPF area to which the paths belong. This means
that there may be multiple routing table entries for the same
destination, depending on the values of the next two fields.
Type of Service
There can be a separate set of routes for each IP Type of
Service. The encoding of TOS in OSPF link state advertisements
is described in Section 12.3.
Area
This field indicates the area whose link state information has
led to the routing table entry's collection of paths. This is
called the entry's associated area. For sets of AS external
paths, this field is not defined. For destinations of type
"area border router", there may be separate sets of paths (and
therefore separate routing table entries) associated with each
of several areas. This will happen when two area border routers
share multiple areas in common. For all other destination
types, only the set of paths associated with the best area (the
one providing the shortest route) is kept.
The rest of the routing table entry describes the set of paths to
the destination. The following fields pertain to the set of paths
as a whole. In other words, each one of the paths contained in a
routing table entry is of the same path-type and cost (see below).
Path-type
There are four possible types of paths used to route traffic to
the destination, listed here in order of preference: intra-area,
inter-area, type 1 external or type 2 external. Intra-area
paths indicate destinations belonging to one of the router's
attached areas. Inter-area paths are paths to destinations in
other OSPF areas. These are discovered through the examination
of received summary link advertisements. AS external paths are
paths to destinations external to the AS. These are detected
through the examination of received AS external link
advertisements.
Cost
The link state cost of the path to the destination. For all
paths except type 2 external paths this describes the entire
path's cost. For Type 2 external paths, this field describes
the cost of the portion of the path internal to the AS. This
cost is calculated as the sum of the costs of the path's
constituent links.
Type 2 cost
Only valid for type 2 external paths. For these paths, this
field indicates the cost of the path's external portion. This
cost has been advertised by an AS boundary router, and is the
most significant part of the total path cost. For example, a
type 2 external path with type 2 cost of 5 is always preferred
over a path with type 2 cost of 10, regardless of the cost of
the two paths' internal components.
Link State Origin
Valid only for intra-area paths, this field indicates the link
state advertisement (router links or network links) that
directly references the destination. For example, if the
destination is a transit network, this is the transit network's
network links advertisement. If the destination is a stub
network, this is the router links advertisement for the attached
router. The advertisement is discovered during the shortest-
path tree calculation (see Section 16.1). Multiple
advertisements may reference the destination, however a tie-
breaking scheme always reduces the choice to a single
advertisement. The Link State Origin field is not used by the
OSPF protocol, but it is used by the routing table calculation
in OSPF's Multicast routing extensions (MOSPF).
When multiple paths of equal path-type and cost exist to a
destination (called elsewhere "equal-cost" paths), they are stored
in a single routing table entry. Each one of the "equal-cost" paths
is distinguished by the following fields:
Next hop
The outgoing router interface to use when forwarding traffic to
the destination. On multi-access networks, the next hop also
includes the IP address of the next router (if any) in the path
towards the destination. This next router will always be one of
the adjacent neighbors.
Advertising router
Valid only for inter-area and AS external paths. This field
indicates the Router ID of the router advertising the summary
link or AS external link that led to this path.