In DMVPN Phase 2 and in order to achieve spoke to spoke connectivity, when using OSPF Routing Protocol, the recommendation is to use OSPF Network Type Broadcast instead of OSPF Network Type Point to MultiPoint. But there is no detailed explanation to tell us why in Broadcast Network Type, OSPF avoids the extra hop routing, where and at which level an OSPF router knows that there is a risk of extra hop routing and there is a choice of a direct and optimal path.
See how to answer the question by looking inside the LSA Types and how the logic works in OSPF.
You need know that The Type-1 LSA describes the router’s type of connections (in other words interfaces or links) to the area. Each Link Type represents the kind of attached network. Each link is also marked with its Link ID. This Link ID gives a name to the entity on the other end of the link.
The Link Data field is specified for each link. This field represents 32-bits of extra information for the link. For links connected to transit network, point-to-point links and virtual link, this field specifies the IP interface address of the associated router interface (this is needed for routing table calculation). For links connected to stub network, this field specifies the stub network’s IP address and the subnet mask.
OSPF Network Type Point To Multipoint
In RFC 2328:
22.214.171.124. Describing Point-to-MultiPoint interfaces
For operational Point-to-MultiPoint interfaces, one or more link descriptions are added to the router-LSA as follows: A single Type 3 link (stub network) is added with Link ID set to the router's own IP interface address, Link Data set to the mask 0xffffffff (indicating a host route), and cost set to 0. For each fully adjacent neighbor associated with the interface, add an additional Type 1 link (point-to- point) with Link ID set to the Router ID of the neighboring router, Link Data set to the IP interface address and cost equal to the interface's configured output cost.
The router generates one Router LSA which contains:
a- Type-1 point-to-point link with Link ID set to the Router ID of the fully-adjacent neighboring router and Link Data set to the IP address of this router.
b- Type-3 Stub network with Link ID set to the router’s own interface IP address and Link Data set to 0xffffffff (indicating a host route).
This is what we can see in the Type-1 LSA’ s R3.
R3 advertises a Type-1 LSA with Advertising Router 0.0.0.3 and three Links:
-Link connected to Stub Network with Link ID 10.3.3.0 and Link Data 255.255.255.0
-Link connected to a point to point router with Link ID 0.0.0.1 and Link Data 172.16.1.3
-Link connected to Stub Network with Link ID 172.16.1.3 and Link Data 255.255.255.255
R1 advertises a Type-1 LSA with Advertising Router 0.0.0.3 and four Links:
-Link connected to Stub Network with Link ID 10.1.1.0 and Link Data 255.255.255.0
-Link connected to a point to point router with Link ID 0.0.0.3 and Link Data 172.16.1.1
-Link connected to a point to point router with Link ID 0.0.0.2 and Link Data 172.16.1.1
-Link connected to Stub Network with Link ID 172.16.1.1 and Link Data 255.255.255.255
From R2’s perspective, R2 concludes that R1 is neighbor with R3, and sees itself as neighbor with R1, to reach the Stub Network 10.3.3.0/24 behind R3, it will add the metric to R1 (100 which is the default cost of tunnel interface) listed in its Type-1 LSA to the metric between R1 and R3 listed in the Type-1 LSA’s R1, exactly in the Link Type 1 which is 1000 and the metric listed in the Type-1 LSA ‘ s R3, exactly Link Type 3 for Stub Network 10.3.3.0 which is 1. R2 will use R1’s IP address 172.16.1.1 as the Next Hop listed in the Type-1 LSA ‘ s R1, exactly in Link Type 1 to reach the subnet 10.3.3.0/24 causing suboptimal routing.
The reason is mentioned in RFC 2328 in the following section:
16.1.1. The next hop calculation
If there is at least one intervening router in the current
shortest path between the destination and the root, the
destination simply inherits the set of next hops from the
parent. Otherwise, there are two cases. In the first case,
the parent vertex is the root (the calculating router
itself). This means that the destination is either a
directly connected network or directly connected router.
The outgoing interface in this case is simply the OSPF
interface connecting to the destination network/router. If
the destination is a router which connects to the
calculating router via a Point-to-MultiPoint network, the
destination’s next hop IP address(es) can be determined by
examining the destination’s router-LSA: each link pointing
back to the calculating router and having a Link Data field
belonging to the Point-to-MultiPoint network provides an IP
address of the next hop router. If the destination is a
directly connected network, or a router which connects to
the calculating router via a point-to-point interface, no
next hop IP address is required. If the destination is a
router connected to the calculating router via a virtual
link, the setting of the next hop should be deferred until
the calculation in Section 16.3.
In the second case, the parent vertex is a network that directly connects the calculating router to the destination router. The list of next hops is then determined by examining the destination's router-LSA. For each link in the router-LSA that points back to the parent network, the link's Link Data field provides the IP address of a next hop router. The outgoing interface to use can then be derived from the next hop IP address (or it can be inherited from the parent network).
OSPF Network Type Broadcast
In broadcast network type, a DR must be elected. The router is fully adjacent to the DR, or the router itself is a DR and is fully adjacent to at least one another router, a single Type-2 link (link to transit network) is added to the Router LSA with Link ID set to IP interface address of the DR and Link Data set to router’s own IP interface address. The body contains a List of Attached or Connected routers.
R1 is the Hub and forced to be a DR, so it advertises a Type-2 LSA with the Link State ID 172.16.1.1 with Network Mask /24 and a list of Attached Routers R1 0.0.0.1, R2 0.0.0.2 and R3 0.0.0.3 that share the same segment or transit network with the subnet 172.16.1.0/24.
R2 receives the Type-2 LSA’s R1 and detects that R3 is located in the same subnet and can be reached directly. R3 advertises to R1 a Type-1 LSA with its own RID 0.0.0.3 as a Link State ID and listing in the body’s LSA two links.
A Link Type 3 with Link ID 10.3.3.0 and Link Date 255.255.255.0 as Stub Network and a Link Type 2 to indicate to R2 that it is connected to the same Transit Network where the same DR R1 is electected, the Data Link lists the IP Address ‘s R3 172.16.1.3 that the router R2 will use as the Next Hop to reach any subnet located behind R3 and listed in Link Type 3, such as 10.3.3.0/24.
Finally R2 sees the router R3 0.0.0.3 in the same Transit Network 172.16.1.0/24 where both agree on the same DR R1, this informations is derived from the Type-2 LSA generated by R1, it looks at the Type-1 LSA’S R3 to find the Next Hop ‘s R3 so that it can install any subnet advertised by R3 in its own Type-1 LSA in the routing table with the 172.16.1.3 as the Next Hop to avoid extra hop routing.
This is why it is recommended to use OSPF Network Type Broadcast instead of Point to Multipoint in DMVPN Phase 2.