OSPF Refresher
Overview
OSPF is a link state routing protocol
OSPF neighbors share (flood) with each other, info (link state info also called LSAs) about their attached links (networks) and their states
i.e the LSA contains the advertising router's id, its neighbor routers, its attached networks (connected routes), and the costs associated with those neighboring routers and attached networks.
the flooding is done to the OSPF multicast address 224.0.0.5
each router (neighbors) maintain a LSDB which is a series of typically thousands of LSAs, and this LSDB must be identical for each neighbor in the OSPF area. The LSDB is also called as topological database.
The LSDB is used to calculate the best path (least cost path) for each destination prefix, all at once, using SPF (Dijsktra) algortithm. And the results from the Dijsktra's algorithm are handled to the router's routing table for the actual forwarding of packets.
Note: Dijkstra's algorithm is commonly used in GPS systems to help find shortest traffic paths
OSPF process in a router: LSAs -> LSDB -> SPF -> Routing Table
Packet types
There are 5 types of packets that are flooded between routers in an OSPF area.
Type 1 - Hello
Type 2 - Database Description (DD)
types 3,4 and 5 form the LSAs(Advertisements)
Type 3 - Link-State Request
Type 4 - Link-State Update
Type 5 - Link-State Acknowledgement
OSPF Header is included in all 5 packet types
Its length is 24Bytes.
ABR
When a router acts as an ABR after manual configuration by the administrator, it would set the B bit in the router LSA(type 1) that it floods to other routers in the area, note that the other bits V and E represent virtual link and ASBR(External) functionality of the router respectively
Hello
Multi cast Hello Packet is sent to all OSPF routers' address 224.0.0.5
It consits of the OSPF Header(24B) + Following Fields:
NM* | HI* | DI* | Options*(8b)
RP | DR | BDR | Neighbor
the first row with* needs to match among two routers to form neighborship
NM matching isnt reqd. for p2p links, its appl only for B/C Media Like Eth.
All routers on the segment must agree on the subnet mask of the link.
NM=Mask, HI/DI=Hello/Dead Interval, RP=Pri., DR/BDR=Designated/Backup
HI=Flooding Interval(10s by def)
DeadInterval/keepalive= how long to wait before removing the adjaceny from a neighbor
Options= represents such things as the ability to be a stub area
Database Description
Database Description Packet
only during adjacency formation
serves two purposes
1. determine which router is incharge(master) for transferring the LSAs (among the two: master and slave)
2. the incharge transfers the LSA headers, LSDB sync between the two.
the router with the highest RID among the two, is the master, and the other one the slave.
master sets the sequence no. for LSA transfers so that LSDBs sync. once the LSDBs sync, and the transfer is complete, the master/slave relation is forgotten.
DD packet contents:
OSPF Header(24B) + Seq.no. + LSA Header
Seq. no. is set to a unique value by the master in the first DD packet. and the sequence is incremented in subsequent packets. seq. no. ensures complete DD packets are received during the LSDB sync. Process.
LSA Header: lists some or all of the headers of the LSAs in the originator's LSDB. The LSA Header contains enough information to uniquely identify the LSA and the particular instance of the LSA.
Link state request
after receiving a number of DD packets from the master, if the slave router detects that the master has sent a linkstate header, which is not in the slave's LSDB
then the slave sends the LSR packet which contains the LSA header for the missing link
Link State Request (Type 3)
---------------------------
LSR packet contents:
-------------------
OSPF Header (24B)
+
Link state type (LSAdv Type No., router/network LSA)
+
Link-State ID (type dependent on the LSA header)
+
Adv. Router (the router that originated the LSA)
Who sends it
------------
sent by a router which detects its LSDB is stale, so that it receives the precise version of the LSDB
LinkState Update
LinkStateUpdate (Type4)
-----------------------
These packets are the basic information block in OSPF
contents
--------
OSPF Header(24Bytes)
+
No. of LSAs
+
Full LSAs (the packet carries multiple LSAs depending on the maximum packet size) in OSPF LSA Formats
Sent to?
--------
Update Packets are mulitcast transmitted to either all OSPF routers (224.0.0.5) or to all DRs (224.0.0.6) depending on the link type
Sent When?
----------
In response to an LSRequest packet during the adjacency database sync. or after an adjacency is formed, if the information about that link changes
LinkState Acknowledgement
sent when?
----------
In response to LSUpdate Packets
A single LSAck packet can contain responses to multiple LSUpdate Packets
LSAck packets are sent in unicast fashion to the originating router, to acknowledge, and this implies reliable flooding in OSPF
contents
--------
OSPF Header(24Bytes)
+
LSA Header(s) = single header for ack single LSA or multiple headers for ack multiple LSAs
States
7 States of an OSPF router
--------------------------
1. Down: OSPF process not turned ON, OSPF is waiting for a start event
2. Init: Hello packet sent, but not received
3. 2Way: Hello packet (Type1) received
4. ExStart: Master/Slave Determination
5. Exchange: LSA headers transferred (DD packets type2)
6. Loading: router has finished transferring its database to its peer, but is still receiving database from the peer
7. Full: The database is completely sync between the two routers
once the state is full, that particular link information could be advertised to OSPF
Designated Router
A single router in an OSPF area will be responsible for forming adjaceny will all other routers (DR Other)
And the DR will advertise the link state information to the AS
DR election significantly reduces traffic on the segment, and implies adjaceny optimisation.
Backup Designated Router
if the DR fails, then the BDR takes over the role of DR. BDR also forms adjaceny with all other routers (DR Other), but doesnt adv the linkstate information to the AS. It advertises the linkstate information once it assumes the role of DR.
DR Election
Higher value wins
First Tie Breaker - Priority (0-255, junos def-128), 0 isnt eligible.
Second tie breaker - RID.
The BDR is election is also similar
Both DR and BDR elections are non-deterministic, implies the router assumes the role of DR/BDR until it leaves the N/W, even if another router with a higher pri/RID joins.
The election of the first DR in a segment occurs within 40s of the first router transmitting the Hello packet. this wait time is honoured every time an election is held.
OSPF interface. But, if the device with the higher priority has preemt configured, it can trigger the election and become the DR, as and when it comes up.
p2p
------
There is no DR/BDR election in p2p link and about 40s is saved.
we configure the interface as p2p,
edit -> prtotocols -> ospf -> area 0.0.0.0 -> interface ge-1/0/0 -> unit 0 -> interface-type p2p
As per RFC2328, section 10.5 (Receiving Hello Packets), for Point-to-Point interfaces and on virtual links, the network mask in the received hello packets should be ignored.
However, in Junos OS, the network mask will still be considered when Ethernet interfaces are used as Point-to-Point. When Ethernet interfaces are used as Broadcast, Junos OS will still consider the network mask; in case of a mismatch, the
OSPF neighbor will not form. The RFC exception applies to only actual Point-to-Point interfaces, such as Frame Relay; so, when configuring the Ethernet as Point-to-Point, it is recommended that the network mask also matches with the peer.
Areas
As the network size grows, if all the routers belong to only one area, their resources will be heavily utilised just for flooding the LSAs so as to sync the LSDB, and in computing the best path using the SPF algorithm, this way the routers couldn't route correctly.
So we divide a single big area(AS) into multiple small areas. Thus the LSDB size will be reduced. each router with in an area maintains an identical copy of the LSDB of the area to which it belongs to.
Route summarization
1) reduces the size of the LSDB
2) hides instabilities in one area from other areas
For route summarization to be effective, careful addressing needs to be done with in the OSPF Network, so that subnets can be more easily summarized.
Backbone Area
Area 0 or 0.0.0.0 by default, all other areas should get connected / pass traffic through the back bone area to ensure routing.
RFC5185 describes how to eliminate the default behaviour of transiting all inter area traffic through the backbone area
When a new area is introduced, and it doesn't have a direct physical connectivity with the Backbone area, we can configure virtual links.
Virtual links cannot be configured through a stub area.
Stub Area
Need of Stub Area
------------------
Stub areas would be created when much of the topological database consists of AS external advertisements (types 4 and 5 LSAs). Doing so, reduces the size of the topological databases and, therefore, the amount of memory required on the internal routers in the stub area.AS External advertisements (types 4 and 5 LSAs) are not flooded into or through a stub area.
Stub area allows intra-area (internal) routes and default route.
Default Route
-------------
Stub areas block external advertisements and advertise only default routes in place of external routes.
Default route from the backbone area is advertised into the stub area through the ABR, and in junOS the ABR meant for a stub area, needs to be explicitly configured for default route generation.
The default route provides the stub area with reachability to external routes.
Note:
-----
A stub area can not contain ASBRs (as ASBRs are used only for external routes) and virtual links cannot be created through a stub area.
A totally stubby area doesnt allow types3,4, and 5 LSAs
It allows only a default route.
A Not so stubby area advertises a default route from the backbone area.
It allows external routes but not from other areas (types 4 and 5 LSAs are blocked).
stub -- LSA type 1,2,3
default route from abr to reach external route
tsa - type 1,2
default route from abr to reach both inter area and external route
nssa - type 1,2,3,7
totally nssa - 1,2,7
LSA types
Routers are not required to store or forward LSAs with unkown LS Type
looking at the options field advertised by its neighbor, a router knows which LSAs to forward and which LSAs to keep itself
Type1 - Router (Intra Area)
Type2 - Network (Intra Area) originated by DR
Type3 - Network (Inter Area / Summary) Originated by ABR
Type4 - ASBR Summary (Inter Area), originated by ABR of an area where the ASBR also resides.
Type5 - External Links originated by ASBR
Type7 - Extenral Links originated by ASBR in an NSSA
Type 6: Multicast OSPF LSA
Type 8: External attributes LSA
Type 9: Opaque LSA (link scope)
Type 10: Opaque LSA (area scope—used for traffic engineering) and
Type 11: Opaque LSA (AS scope)
LS Type1 = Router LSA, 1 LSA per router, indicates active interfaces, IP addresses and neighbors, p2p networks contains only type1 LSAs
LS Type2 = Network LSA, to describe the network segment along with list of currently attached routers, Network summary LSAs are used in the SPF calculation only when their advertising router is reachable
Commands
user@R1# edit protocols ospf
user@R1# set area 0.0.0.0 interface ge-1/0/0 unit 0 interface-type p2p
user@R1> show ospf interface
Interface State Area DR ID BDR ID Nbrs
ge-1/0/0.0 PtToPt 0.0.0.0 0.0.0.0 0.0.0.0 1
Its a point to point to link and there is no DR/BDR election in this case
DR/BDR election is only applicable for broadcast network like ethernet
configuring the link as p2p saves up to 40s for the adjaceny to form, as no DR-BDR election will be done, and no type 2 LSA (indicating multi-access segment) will be generated, reducing the size of LSDB
user@router> show ospf neighbor
Address Interface State ID Pri Dead
172.25.0.1 ge-0/0/1.0 Full 1.1.1.1 255 37
172.25.0.3 ge-0/0/1.0 2Way 1.1.1.3 128 34
DR-Other routers form 2Way States with other DR-Other routers
LSA = LSA Header + DATA (varies for each type)
LSA Header 20B
LS Age 2B | Options 1B | LS Type 1B
LS ID 4B
Adv. Router 4B
LS Seq. No. 4B
LS Checksum 2B | Length 2B
The LS Age field is incremented at each hop during flooding, which eventually breaks any flooding loop by causing a looping LSA's LS Age field to reach the MaxAge
options E bit (7) == external lsas, P bit (5) == nssa external lsas
accordingly lsa4 would be generated by ABR
N/P = NSSA/Propagate 1=>translate and propagate lsa7to4
O(2) = if set allows remote router to flood lsas to the local router
LS TYPE (1B), LS ID (4B), Adv Router (4B)
Router(1), Local router id, Router id
Network(2), DRs IP, DR ID
Summary(3), Network Address, Router ID
ASBR Summary(4), ASBR address, ABR ID
External(5), Network Address, ASBR ID
NSSA External(7), Network Address, ASBR ID
LSID = router id (for router LSA, both LS ID, and ADR same)
OSPFv2 uses linear sequence space, the sequence no.s are 32 bit signed values, the sequence number is inceremented by 1 each time the LSA is updated by the advertising router, the InitialSequenceNumber S0 is 0x80000001,
and the MaximumSequenceNumber Smax is 0x7fffffff, after which it has to start again from S0 rolling over the sequence space, but it should flood this LSA with sequence number S0 only after deleting the LSA instance with
sequence number Smax, so that other routers can consider the new LSA instance with S0 as recent and accept it. OSPF routers are not allowed to update their self-orignated LSAs more than once every 5 seconds, in the absence
of h/w or s/w errors, this 32 bit sequence could take more than 600 years to roll over
LS checksums are used to detect data corruption with in an LSA
Components to check recency of an LSA = LS Seq no., LS Age, LS Check sum
Routers are allowed only to update or delete only self originated LSAs in which advertising router field refers to its own router ID, a self originated LSA can be updated by incrementing the LS Seq. number, which could then be used
to replace any instances of this LSA with lesser seq. no. on other routers, if the Seq. no.s are same on two instances of the LSA, then the LS Age and LS Checksum fields are checked by the router before declaring the two LSA
instances identical
LSA Data
Type1 Router LSA
00000VEB + Res(1B, all 0) + no.of links (2B) + link-id (4B) + link-data (4B) + link type (1B) + No.ofTos metrics (1B, all 0) + Metric(2B) + Additional Tos data(4B,unused)
Type2 Network LSA
NWMask(4B) + Attached Router(s)(4B)
Type3 Summary LSA
NWMask(4B) + Res(1B, all0), Metric(3B), TOS(1B, unused), TOS Metric(3B, unused)
Type4 ASBR Summary LSA
NWMask(4B all 0) + Res(1B, all0) + Metric(3B), TOS(1B, unused), TOS Metric(3B, unused)
Type5 external / Type7 NSSA external LSA
NWMAsk(4B) + E 7*0s + Met(3) + FWAdd(4) + ExtRouTag(4) + ToS (4)
FWAdd === ASBR (0.0.0.0) or the nexthop
for NSSA FWAdd = 0.0.0.0 or ASBR ID
type 6 - multicast
type 8 - external attributes
type 9 - opaque, gr, link-local
type 10 - opaque, mpls te, area
type 11 - opaque, not supp, domain
Link-type, Link-ID, Link Data
- p2p(1), neighbor rid, local interface ip
- transit(2), DR's interface ip, local interface ip
- stub(3), network number, subnet mask
- virtual link(4), neighbor rid, local interface ip
Default route
The OSPF router does not, by default, generate a default route into the OSPF domain. In order for OSPF to generate a default route, you must use the default−information originate command in Cisco. There are two ways to advertise a default route into a normal area. The first is to advertise 0.0.0.0 into the OSPF domain, provided the advertising router already has a default route. The second is to advertise 0.0.0.0
regardless of whether the advertising router already has a default route. The second method can be accomplished by adding the keyword always to the default−information originate command. In both cases the router would originate a type 5 LSA with a link ID of 0.0.0.0.
External route
External routing information may originate from another routing protocol such as BGP, or be statically configured (static routes). Default routes can also be included as part of the Autonomous System external routing information.
cost to a destination network is the sum of the cost to the advertising router and the cost advertised in the LSA
Type 1 external metrics are expressed in the same units as OSPF interface cost. Type 2 external metrics assumes that routing between AS'es is the major cost of routing a packet, and eliminates the need for conversion of external costs to internal link state
metrics.
E = 0, type-1 metric
E = 1, type-2 metric
Both Type 1 and Type 2 external metrics can be present in the AS
at the same time. In that event, Type 1 external metrics always
take precedence.
--end-of-post--