First, I think it’s important that we use the correct terminology here. OSPF has nothing to do with Layer-2 of the OSI model. So it’s confusing and misleading to refer to something OSPF is doing as “L2 Network Type” because that gets one thinking about Layer-2 (the Datalink Layer) of the OSI model which OSI has nothing to do with.
Instead lets use this terminology:
A. When you say, “L2 Network Type” = Link Type
B. When you say, “L3 Link Type” = Network Type
So in the world of OSPF, what you and I would call an interface (i.e. interface Gigabit0/1) is classified by OSPF in two ways:
—the “Link Type” of that interface
—the “Network Type” that interface connects to.
By default, the “Network Type” is derived from the Link Type. So OSPF first determines the Link Type of a port/interface. It does this by looking at the Layer-2 encapsulation configured on that interface. Keep in mind OSPF knows NOTHING about how that Layer-2 encapsulation works, what rules it has, how it performs addressing (at Layer-2), or any of that stuff. All OSPF knows is this:
—At first, all links are classified as “Stub.” This is because, at the beginning, OSPF doesn’t know if any other OSPF routers exist on the link. Assuming it is the only router on the link, the link type is set to Stub (i.e. “There are no other routers beyond me at this point. I’m the end-of-the-line.”)
—If the L2 encapsulation is Ethernet or Frame-Relay, then this link (i.e., interface) could possibly connect to multiple routers…all of which see each other and can communicate directly. If OSPF receives a Hello packet on this type of link, it re-classifies this as Transit and determines that a DR/BDR election needs to take place.
—If the L2 encapsulation is PPP or HDLC, then OSPF knows this link could only connect to one other router. Once again, the link starts out as “Stub” and then, if a Hello packet is received it retains the “Stub” classification but then also describes the link again as Point-to-Point. Don’t ask me why OSPF does this…it just does.
AFTER all of that is done and the Link Type has been determined…THEN OSPF will use that information (the Link Type value) to determine the Network Type. If the Link Type was Point-to-Point, then the Network Type will also be Point to Point. If the Link Type was determined to be Stub then OSPF will once again look at the L2 Encapsulation on that link. Ethernet will become OSPF Network Type = Broadcast. Frame-Relay will become OSPF Network Type Non-Broadcast Multi-Access.
So as you can see, by default OSPF first determined the Link Type…then determines the Network Type.
However, let’s say you have a Serial interface that is currently disabled (shutdown). YOu have activated OSPF on that interface and you have also implemented the command, “ip ospf network xxxx”. Then you enable the interface. In this case, you are forcing OSPF to FIRST determine the Network Type, which you have pre-determined with the command. Once it sees your pre-configured Network Type it will do the following:
- OSPF starts sending Hello Packets.
- Regardless of the preconfigured network type, initially OSPF will create a Router LSA describing that link as “Stub” because it doesn’t know if another OSPF router exists on the link.
- The moment an incoming OSPF Hello packet is received, OSPF will look at the pre-configured Network Type and make a decision about the resulting Link Type:
-----3a. If the configured Network Type is “broadcast” or “non-broadcast” the Link Type will be set to “Transit”
-----3b. If the configured Network Type is “point-to-point” or “point-to-multipoint” the Link Type will be set to a combination of “Stub” and “Point to Point”.
I hope that clarifies things.