Routing – OSPF and routing table

ospfrouting

I have several questions on OSPF.

1 OSPF is a link-state prototol, so routers inside an AS only broadcast their link states to all the other routers.

I'm wondering if a router doesn't tell other routers its routing table, how can other routers know what packets should be destined to it?

for example, if a router A is an edge router(leaf router) which interfaces the subnet 10.0.2.1/24. Assume another router B receives a packet with destination IP 10.0.0.2.4. From OSPF, B knows the shortest path to A, but B doesn't know A is an edge router interfacing the subnet 10.0.2.1/24, so how will B route this packet?

2 if a router receives a packet with destination outside the AS, according to my understanding, the packet will follow the default route 0.0.0.0 and the router will route the packet to a ABR. but ususally an AS has several ABR, so how does a router select one from these ABRs?

Best Answer

OSPF is a link state protocol that uses multicast. It sends Link State Advertisements (LSAs) that are flooded.

Every router builds a tree by running SPF where the router itself is the root of the tree. In OSPF we have transit networks and stub networks. Transit networks are networks that are used for transit to reach networks while stub networks are the endpoints or leaves as you described it.

If we are in the same area then the router LSA (type-1) is examined to find the destination. Here is a router-LSA to reach the network of R1 which has a RID of 1.1.1.1.

R2#sh ip ospf data router 1.1.1.1

            OSPF Router with ID (2.2.2.2) (Process ID 1)

                Router Link States (Area 0)

  LS age: 256
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 1.1.1.1
  Advertising Router: 1.1.1.1
  LS Seq Number: 80000005
  Checksum: 0x4B09
  Length: 60
  Number of Links: 3

    Link connected to: a Stub Network
     (Link ID) Network/subnet number: 1.1.1.1
     (Link Data) Network Mask: 255.255.255.255
      Number of TOS metrics: 0
       TOS 0 Metrics: 1

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 13.13.13.1
     (Link Data) Router Interface address: 13.13.13.1
      Number of TOS metrics: 0
       TOS 0 Metrics: 10

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 12.12.12.2
     (Link Data) Router Interface address: 12.12.12.1
      Number of TOS metrics: 0
       TOS 0 Metrics: 10

R1 has a cost of 1 to this stub network. R2 can reach this network through the 12.12.12.0/24 transit network. So we need to add a cost of 10 which brings the total metric to 11.

R2#sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
  Known via "ospf 1", distance 110, metric 11, type intra area
  Last update from 12.12.12.1 on FastEthernet0/0, 00:06:49 ago
  Routing Descriptor Blocks:
  * 12.12.12.1, from 1.1.1.1, 00:06:49 ago, via FastEthernet0/0
      Route metric is 11, traffic share count is 1

This is an intra area route. For inter area routes OSPF actually behaves like a distance vector protocol because traffic is sent through the ABR. How can we identify an ABR?

R4#sh ip ospf data router 2.2.2.2

            OSPF Router with ID (4.4.4.4) (Process ID 1)

                Router Link States (Area 1)

  Routing Bit Set on this LSA
  LS age: 573
  Options: (No TOS-capability, DC)
  LS Type: Router Links
  Link State ID: 2.2.2.2
  Advertising Router: 2.2.2.2
  LS Seq Number: 80000002
  Checksum: 0xCCB6
  Length: 36
  **Area Border Router**
  Number of Links: 1

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 24.24.24.2
     (Link Data) Router Interface address: 24.24.24.2
      Number of TOS metrics: 0
       TOS 0 Metrics: 10

The B bit is set in the OSPF header which makes a router an ABR.

This can be seen in a packet capture.

OSPF ABR B bit

To find the metric of an inter area route the metric of the ABR to the destination + the metric of the local route to the ABR is added.

R4#sh ip ospf border-routers 

OSPF Process 1 internal Routing Table

Codes: i - Intra-area route, I - Inter-area route

i 2.2.2.2 [10] via 24.24.24.2, FastEthernet0/0, ABR, Area 1, SPF 4
i 3.3.3.3 [10] via 34.34.34.3, FastEthernet0/1, ABR, Area 1, SPF 4
R4#

Here the cost is 10 to reach the two ABRs. Because the cost was 11 from the ABR to the destination that should mean that R4 has a metric of 21.

R4#sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
  Known via "ospf 1", distance 110, metric 21, type inter area
  Last update from 24.24.24.2 on FastEthernet0/0, 00:09:37 ago
  Routing Descriptor Blocks:
  * 34.34.34.3, from 3.3.3.3, 00:09:37 ago, via FastEthernet0/1
      Route metric is 21, traffic share count is 1
    24.24.24.2, from 2.2.2.2, 00:09:37 ago, via FastEthernet0/0
      Route metric is 21, traffic share count is 1

Which it is. Because there are two ABRs here with the same cost both routes are installed into the RIB/FIB. If we increase the cost to one ABR then only one entry will be installed.

R4#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R4(config)#int f0/0
R4(config-if)#ip ospf cost 11
R4(config-if)#^Z
R4#sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
  Known via "ospf 1", distance 110, metric 21, type inter area
  Last update from 34.34.34.3 on FastEthernet0/1, 00:10:58 ago
  Routing Descriptor Blocks:
  * 34.34.34.3, from 3.3.3.3, 00:10:58 ago, via FastEthernet0/1
      Route metric is 21, traffic share count is 1

There really is no concept of AS in OSPF but you can originate a default route and then the best metric would win. I recommend that you read through RFC 2328 and OSPF: Anatomy of an Internet Routing Protocol if you want more understanding of OSPF.

Related Topic