OSPF

    

         

               O                S                P                F

               Open          Shortest    Path          First


    Short and Simple Bullet Points:

  >  Link state routing protocol

 >  Classless routing protocol

 >  Supports VLSM (Variable Length Subnet Mask) 

 >  Uses multicast address for routing updates (224.0.0.5 and               224.0.0.6)

>  Sends partial routing updates.

 >  Supports only equal cost load balancing

 >  Manual summarization can be done only on ABRs and                 ASBRs

 >  Uses interface cost as a metric

 >  Uses Dijkstra Algorithm also known as shortest path First           Algorithm

 >  Supports clear-text and MD5 authentication

 >  The OSPF stands for Open Shortest Path First. 

>   It is a widely used and supported routing protocol. 

>   It is an intradomain protocol, which means that it is used             within an area or a network.

>   It is an interior gateway protocol that has been designed               within a single autonomous system.

                   HOW OSPF WORKS?

1.  The first step is to become neighbors with other routers                 connected to the same segment.

2.  Then the routers exchange the Link State Advertisements            (LSAs) with neighbor routers.

3.   After that, each router independently calculates the best             routes to each destination. 

4.   Then it inserts all of these into the routing table. 


                          OSPF : MERITS

 1. OSPF can be configured on both IPv4 and IPv6 versions of          IP Addresses.

2. It can carry out load balancing.

3. It uses the SPF algorithm to present a loop-free technology.

4. It is not Cisco proprietary. It can run on many routers.

5. It is a classless protocol. 

6. It has unlimited hop counts.


                        OSPF : DEMERITS


1. It needs extra storage. Therefore, it means that it needs an            extra CPU process to run the SPF algorithm.

2. It needs more RAM to save adjacency topology.

3. It is very complex. Therefore, it’s very difficult to troubleshoot.

   


          Let's Dig Deep into theory Part: ðŸ˜•



OSPF

The OSPF stands for Open Shortest Path First. It is a widely used and supported routing protocol. It is an intradomain protocol, which means that it is used within an area or a network. It is an interior gateway protocol that has been designed within a single autonomous system.

 It is based on a link-state routing algorithm in which each router contains the information of every domain, and based on this information, it determines the shortest path. 

The goal of routing is to learn routes. The OSPF achieves by learning about every router and subnet within the entire network. Every router contains the same information about the network. The way the router learns this information by sending LSA (Link State Advertisements). 

These LSAs contain information about every router, subnet, and other networking information. Once the LSAs have been flooded, the OSPF stores the information in a link-state database known as LSDB. The main goal is to have the same information about every router in an LSDBs.

 




OSPF divides the autonomous systems into areas where the area is a collection of networks, hosts, and routers. Like internet service providers divide the internet into a different autonomous system for easy management and 

OSPF further divides the autonomous systems into Areas.


Routers that exist inside the area flood the area with routing information.


In Area, the special router also exists. 

The special routers are those that are present at the border of an area, and these special routers are known as Area Border Routers. This router summarizes the information about an area and shares the information with other areas.

All the areas inside an autonomous system are connected to the backbone routers, and these backbone routers are part of a primary area. The role of a primary area is to provide communication between different areas.



                How does Neighbor ship Forms?


Prior to any sort of relationship developing, each router selects its own router ID.

    

            What is Router Id?

Every router on a network is uniquely identified by a number called the router ID. The IPv4 address format is used for the router ID. There are two methods for configuring the router ID: one involves manually entering the ID, and the other involves letting the router choose.

The router uses the reasoning listed below to determine the router ID:
Manually assigned: The router checks whether the router ID is manually set or not. If it manually set, then it is a router ID. If it is not manually set, then it will choose the highest 'up' status loopback interface IP address. If there are no loopback interfaces, then it will choose the highest 'up' status non-loopback interface IP address.

Two routers connected to each other through point to point or multiple routers are connected can communicate with each other through an OSPF protocol. The two routers are adjacent only when both the routers send the HELLO packet to each other. When both the routers receive the acknowledgment of the HELLO packet, then they come in a two-way state. As OSPF is a link state routing protocol, so it allows to create the neighbor relationship between the routers. The two routers can be neighbors only when they belong to the same subnet, share the same area id, subnet mask, timers, and authentication. The OSPF relationship is a relationship formed between the routers so that they can know each other. The two routers can be neighbors if at least one of them is designated router or backup designated router in a network, or connected through a point-to-point link.

   






                    OSPF Message Format



1. Version:    It is an 8-bit field that specifies the OSPF protocol version.

    2. Type:        It is an 8-bit field. It specifies the type of the OSPF packet.

              3.Message:  It is a 16-bit field that defines the total length of the message,                                       including the header. Therefore, the total length is equal to the                                     sum of the length of the message and header.

4. Source IP address:     It defines the address from which the packets are sent. It is a sending routing IP address.
5. Area identification:     It defines the area within which the routing takes place.

6. Checksum:     It is used for error correction and error detection. 

7. Authentication type:     There are two types of authentication, i.e., 0 and 1. Here,                                           0 means for none that specifies no authentication is available and 1 means for pwd that specifies the password-based authentication.

8. Authentication:             It is a 32-bit field that contains the actual value of the                                                     authentication data.

    

OSPF has 5 packet types namely, 

          (i) Hello
           (ii) Data Base Description(DBD)
          (iii) Link State Request(LSR) 
          (iv) Link State Update(LSU)
           (v) Link State Acknowledgment




1. Hello packet:

                                    The Hello packet is used to create a neighborhood relationship and check the neighbor's reachability. Therefore, the Hello packet is used when the connection between the routers need to be established.




2. Database Description: 

                                                       After establishing a connection, if the neighbor router is communicating with the system first time, it sends the database information about the network topology to the system so that the system can update or modify accordingly.



     3. Link state request: 

                                                                The link-state request is sent by the router to obtain the information of a specified route. Suppose there are two routers, i.e., router 1 and router 2, and router 1 wants to know the information about the router 2, so router 1 sends the link state request to the router 2. When router 2 receives the link state request, then it sends the link-state information to router 1.



4. Link state update: 

                                                        The link-state update is used by the router to advertise the state of its links. If any router wants to broadcast the state of its links, it uses the link-state update.



5. Link state acknowledgment: 

                                                                                The link-state acknowledgment makes the routing more reliable by forcing each router to send the acknowledgment on each link state update. For example, router A sends the link state update to the router B and router C, then in return, the router B and C sends the link- state acknowledgment to the router A, so that the router A gets to know that both the routers have received the link-state update.


OSPF States:

Down:   If the device is in a down state, it has not received the HELLO packet. Here, down does not mean that the device is physically down; it means that the OSPF process has not been started yet.
Init: If the device comes in an init state, it means that the device has received the HELLO packet from the other router. 
init" refers to a neighbor state in which a hello package has been received, but no router ID has been received
2WAY:  If the device is in a 2WAY state, which means that both the routers have received the HELLO packet from the other router, and the connection gets established between the routers.
Exstart: Once the exchange between the routers get started, both the routers move to the Exstart state. In this state, master and slave are selected based on the router's id. The master controls the sequence of numbers, and starts the exchange process.
Exchange:  In the exchange state, both the routers send a list of LSAs to each other that contain a database description.

Loading: On the loading state, the LSR, LSU, and LSA are exchanged.

Full: Once the exchange of the LSAs is completed, the routers move to the full state.




In OSPF Functioning of a Router: 


Before going to the Extract state, OSPF chooses one router as a Designated router and another router as a backup designated router. 


These routers are not the type, but they are the attributes of a router. 


In the case of broadcast networks, the router selects one router as a designated router and another router as a backup designated router. 


The election of designated and the backup designated router is done to avoid the flooding in a network and to minimize the number of adjacencies.


They serve as a central point for exchanging the routing information among all the routers. Since point-to-point links are directly connected, so DR and BDR are not elected.


If DR and BDR are not elected, the router will send the update to all the adjacent neighbors, leading to the flooding in a network. To avoid this problem, DR and BDR are elected. 


Each non-DR and non-BDR send the update only to the DR and BDR instead of exchanging it with other routers in a network segment. DR then distributes the network topology information to other routers in the same area whereas the BDR serves a substitute for the DR. 


The BDR also receives the routing information from all the router but it does not distribute the information. It distributes the information only when the DR fails.
The multicast address 224.0.0.6 is used by the non-DR and non-BDR to send the routing information to the DR and BDR. 


The DR and BDR send the routing information to the multicast address 224.0.0.5.


Based on the following rules, the DR and BDR are elected:


The router with the highest OSPF priority is chosen as the DR. By default, the highest priority is set as 1.


If there is no highest priority, then the router with the highest router Id is chosen as the DR, and the router with the second-highest priority is chosen as the BDR.






OSPF Network Types – Point-to-Point and Broadcast:



        Point-to-Point:

A Point-to-Point network type is, as its name implies, a connection between two specific points (or OSPF routers). On a point-to-point link, a packet delivered from one of the routers will always have precisely one recipient. It does not maintain a DR/BDR relationship, and it has a 10-second hello and 40-second dead timer. Leased lines running Point-to-Point Protocol (PPP) and High-Level Data Link Control (HDLC) are some examples of point-to-point links.


 

Broadcast:

The broadcast network type is the default network type for an OSPF-enabled Ethernet interface. It requires a link that supports Layer 2 broadcast. It requires the use of a DR/BDR relationship, and it has a 10-second hello and 40-second dead timer.



                                                             

Configuring the Network Types: 

OSPF is a very versatile protocol. Take into account its capacity to support both broadcast and non-broadcast multi-access (NBMA) network types. OSPF responds by changing its operation to match the settings you’ve provided.
OSPF makes an attempt to detect physical media and defaults to the appropriate behavior. If you don’t like the default behavior, you can override it using the following command:



Router#conf t
Router(config)#int gi0/0
Router(config-if)#ip ospf ne
Router(config-if)#ip ospf network ?
  broadcast            Specify OSPF broadcast multi-access network
  non-broadcast        Specify OSPF NBMA network
  point-to-multipoint  Specify OSPF point-to-multipoint network
  point-to-point       Specify OSPF point-to-point network




Let’s have an example. We can see below that the default network type is Broadcast and with DR neighbor:


Router#sh ip ospf int gi0/0
GigabitEthernet0/0 is up, line protocol is up 
  Internet Address 10.1.1.1/30, Area 0, Attached via Network Statement
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1




Router#sh ip ospf neighbor:
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:34    10.1.1.2        GigabitEthernet0/0


Change the interface network type from Broadcast to Point-to-Point:



Router#conf t
Router(config)#int gi0/0
Router(config-if)#ip ospf network point-to-point



Upon checking again, we can see that the network type is now POINT_TO_POINT:

Router#sh ip ospf int gi0/0
GigabitEthernet0/0 is up, line protocol is up 
  Internet Address 10.1.1.1/30, Area 0, Attached via Network Statement
  Process ID 1, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 1



If we check the OSPF neighbor again, we will no longer see the DR/BDR relationship:

Router#sh ip ospf  neighbor 
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:00:37    10.1.1.2        GigabitEthernet0/0









Routing protocols allow routers to exchange information on networks, pick best routes, notify each other of changes in network topology, and automatically change routes (reconverge) if required due to changes in topology (ie link comes up or goes down). 


Routing protocols can be split into two main types: 


● Interior gateway protocols (IGPs)
 ● Exterior gateway protocols (EGPs)


 Interior gateway protocols are used for routing within an organisation. Exterior gateway protocols are used for routing between organisations over the Internet. The only EGP in use today is BGP (Border Gateway Protocol)




Interior gateway protocols can be split into two main types: 


● Distance Vector routing protocols 
● Link State routing protocols


 In Distance Vector protocols,

 Each router sends its directly connected neighbours a list of all its known networks along with its own distance to each of those networks.


 Distance vector routing protocols do not advertise the entire network topology - a router only knows its directly connected neighbours and the lists of networks those neighbours have advertised.


 It doesn’t have detailed topology information beyond its directly connected neighbours.


Because of this, Distance Vector routing protocols are sometimes called ‘Routing by rumour’. 


In Link State routing protocols,

 Each router describes itself and its interfaces to its directly connected neighbours (information is directly exchanged only between directly connected neighbours in both Distance Vector and Link State protocols). 


This information is passed unchanged from one router to another.


 Every router learns the full picture of the network area including every router, its interfaces and what they connect to. 



Multi-area OSPF design

 Every OSPF router learns the full picture of the network including every router, its interfaces and what they connect to. 

This can cause issues in large networks:


 ● Too many routes can use up too much router memory 


● Network changes cause all routers to reconverge which takes time and CPU resources 


OSPF supports a hierarchical design which segments large networks into smaller areas to solve this problem. 
Each router maintains full information about its own area, but only summary information about other areas. 

A two level hierarchy is used: 

● Transit area (backbone or area 0). Does not generally contain end users.


 ● Regular areas (nonbackbone areas). Used to connect end users to the Transit area. 


By default, all transit traffic goes through the Transit area. Routers maintain a full LSDB of other routers and links in their own area Small networks do not require a hierarchical design and all routers can be in Area 0. 

The recommendation is up to 50 routers in an area


Routers which have all their OSPF interfaces in Area 0 are Backbone Routers.


Routers which have interfaces in multiple areas are Area Border Routers (ABRs)

Routers which redistribute routes from another routing protocol or static routes into OSPF are Autonomous System Boundary Routers (ASBRs


Some Common Commands under OSPF Lab:

Show ospf status: 
● # show ip protocols – show configuration (works in user mode too!) 
● # show ip ospf interface [ifname] – show OSPF operations — including number of neighbours and link type — on all interfaces, or on a given interface if optional argument given.
 ● # show ip ospf neighbour [ifname] – show OSPF neighbours on all interfaces, or on a given interface if optional argument given 
● #show ip ospf database – show the LSDB 
● #show ip ospf rib – show Routing Information Base (RIB)
 ● #show ip route – show routes 
● #show ip route ospf – show only OSPF-learned routes 

For neighbour relationship to work:

 ● Interfaces must be up/up 


● ACL must not filter routing protocol messages

 
● Interfaces must be in same IP subnet 


● Interfaces must be authenticated, if authentication is used 


● Hello/Dead timers must match 


● RIDs must be unique 


● Interfaces must be in the same area 


● OSPF process must not be shutdown


 ● Matching MTU setting 


● Matching network type If the last two requirements are not satisfied routers will see each other as neighbours, but OSPF will not work (i.e. LSAs are not exchanged) 


OSPF process shutdown: 

● (config-router) shutdown 

This retains configuration but ceases OSPF activities, clears LSDB, brings down any neighbour relationships and removes OSPF-learned routes from the routing table.
















                                                            

Summarize Important Bullet Point:



1. OSPF IP Protocol number is 89 and it operates on top of IP, i.e. at Transport Layer.
 
2. OSPF LSAs report the state of routers and the links between routers—hence the term link-state protocol.
 
3. Each OSPF packet contains a fixed header. Few common fields of OSPF packets header are 

(i)    OSPF version
(ii)   Packet Type
(iii)  Packet Length
(iv)  Area ID
(v)   Router ID.
 
4. Similarly, each OSPF LSA has a 20-byte fixed header. Few fields are 
    LSA Type, LSA Age, Advertising router, Link State ID, Options, Checksum, and Length.
 
5. LSAs are reliable; there is a method for acknowledging their delivery. 
    LSAs are flooded throughout the area (or throughout the domain if there is only one area).
     LSAs have a sequence number and a set lifetime, so each router recognizes that it has the most                current version of the LSA. 
     LSAs are periodically refreshed to confirm topology information before they age out of the LSDB.

 6. OSPF follows a two-level hierarchy. 
        There should always be an Area 0 in the network(Transit area or backbone area) and
         all other regular areas should be directly connected to it. 
        In case a regular area cannot be directly connected to Area 0,
         we can use the virtual-link mechanism to connect a remote area to Area 0.
 
 7.   Areas are created in OSPF to minimize routing table entries,
        localize the impact of topology change within an area and 
          to stop details LSA flooding at the area boundary.
 
 8.   The ABR in the OSPF domain separates LSA flooding zones and
        becomes the primary point for area address summarization. 
         It functions regularly as the source of default routes and 
            also maintains the LSDB for each area with which it is connected.

  9.   OSPF adjacency cannot form on secondary networks (Secondary IP on the interface)
          because the secondary address is considered as stub networks and therefore, 
         cannot form an adjacency.

10.    OSPF has its own reliability mechanism. 
          It uses Sequence Number and Acknowledgement fields in the LSA for reliable delivery.
 
11.    The order of the OSPF Path Selection Process is given below. 
           The below sequence is preferred regardless of metric or administrative distance.
            Intra-Area (O)
            Inter-Area (O IA)
            External Type 1 (E1)
            External Type 2 (E2)
            NSSA Type 1 (N1)
            NSSA Type 2 (N2

12.     DR/BDR is elected per shared network in an Area. 
           Therefore, more than 1 DR/BDR can exist in an Area.

13.     OSPF has 5 packet types namely, 
          (i) Hello
           (ii) Data Base Description(DBD)
          (iii) Link State Request(LSR) 
          (iv) Link State Update(LSU)
           (v) Link State Ack. 
                                                There no such packet type name Link State Advertisement (LSA). LSA                                                     are advertised in LSU packets.

14.  Difference between DBD and LSU packets is that DBD packets only contain LSA headers and
       LSU packet contains LSA header (20byte) along with other information about the link for example         LSA1 contain V, E, B bits, Metric, etc as extra fields apart from LSA header.


 

 
15.   The only time that OSPF will form an adjacency between neighbors that are not on the same                   subnet is when the neighbors are connected through point-to-point links using “ip unnumbered”              command.
 
16.   To establish OSPF neighbor adjacency, Hello/Dead timers, MTU  
        (otherwise use ‘ip ospf mtu-ignore’) must match, and also a unique Router-ID is required.
 
17.     OSPF's Link state property only works within a specific area. As the area changes, the Link state property disappears and changes to Distance Vector as ABR becomes the advertising-router of the LSA.
 

18.  OSPF link cost (metric) can be changed using "ip ospf cost cost-value" interface configuration                command.
 
19.  If a router is set with priority zero, it doesn't participate in DR/BDR election. 
        This is used when configuring OSPF (Non Broadcast Multi Access) in Hub/Spoke setup and zero              priority is generally set on Spokes to deny them to be DR/BDR.
 
20.   Options field is contained in OSPF packet types Hello, DBD and LSA Header.
 
21.  Hello and Hold down timers for NBMA, Point to Multipoint Broadcast and Point to Multipoint Non-Broadcast OSPF networks are 30 and 120 Seconds respectively.



 
Various Types of OSPF Routes are as below:
          O*  -   OSPF Default Route
          O    -   OSPF Intra Area Route
          OIA -  OSPF Inter Area Route
          O*IA - OSPF Intra Area Default Route
          OE1 -   OSPF External Type 1 Route
          O*E1 - OSPF External Type 1 Default Route
          OE2 -   OSPF External Type 2 Route
          O*E2  - OSPF External Type 2 Default Route
          ON1   - OSPF NSSA Type 1 Route
          O*N1 - OSPF NSSA Type 1 Default Route
          ON2  -  OSPF NSSA Type 2 Default Route
          O*N2 - OSPF NSSA Type 2 Default Route


Comments

Popular Posts