Search this Blog

Tuesday, February 4, 2014

How to build the topology of an OSPF area?

How can we build the entire topology of an OSPF area by sitting on just one router (any random router in that area) and looking at the LSAs?

Let’s say we’re given access to router R5. Look at the OSPF database overview as your first step:

R5#show ip ospf database

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

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count

1.1.1.1 1.1.1.1 540 0x80000002 0x003D7D 2

2.2.2.2 2.2.2.2 416 0x80000003 0x00DA53 5

3.3.3.3 3.3.3.3 346 0x80000003 0x00C74B 2

4.4.4.4 4.4.4.4 431 0x80000002 0x00B86F 1

5.5.5.5 5.5.5.5 388 0x80000002 0x00C139 4

6.6.6.6 6.6.6.6 367 0x80000002 0x00C38F 3

Net Link States (Area 0)

Link ID ADV Router Age Seq# Checksum

192.168.3.4 4.4.4.4 431 0x80000001 0x00E7A9

Summary Net Link States (Area 0)

Link ID ADV Router Age Seq# Checksum

192.168.1.0 1.1.1.1 605 0x80000001 0x00315D

Focus on the ‘Router Link States’ part. This lists out all the router LSAs (LSA Type 1). These are LSAs generated by every OSPF running router in the area, advertising itself. So we now know that there are 6 routers in area 0, with router IDs as mentioned under the ‘Link ID’ column.

The next step is to zoom in on individual router IDs. By doing this, we can find out details of what each of these routers are connected to. Since we’re sitting on R5, let’s start by zooming in on R5:

R5#show ip ospf database router 5.5.5.5

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

Router Link States (Area 0)

LS age: 616

Options: (No TOS-capability, DC)

LS Type: Router Links

Link State ID: 5.5.5.5

Advertising Router: 5.5.5.5

LS Seq Number: 80000002

Checksum: 0xC139

Length: 72

Number of Links: 4

Link connected to: another Router (point-to-point)

(Link ID) Neighboring Router ID:6.6.6.6

(Link Data) Router Interface address:192.168.5.5

Number of TOS metrics: 0

TOS 0 Metrics: 64

Link connected to: a Stub Network

(Link ID) Network/subnet number: 192.168.5.0

(Link Data) Network Mask: 255.255.255.0

Number of TOS metrics: 0

TOS 0 Metrics: 64

Link connected to: another Router (point-to-point)

(Link ID) Neighboring Router ID: 2.2.2.2

(Link Data) Router Interface address:192.168.4.5

Number of TOS metrics: 0

TOS 0 Metrics: 64

Link connected to: a Stub Network

(Link ID) Network/subnet number: 192.168.4.0

(Link Data) Network Mask: 255.255.255.0

Number of TOS metrics: 0

The important things to look for have been highlighted above. We can see that R5 is connected to two routers via a point-to-point connection: router with router ID 6.6.6.6 and router with router ID 2.2.2.2. R5s IP address towards 6.6.6.6 is 192.168.5.5 and R5s IP address towards 2.2.2.2 is 192.168.4.5.

The stub networks listed here simply indicate the subnets in use.

Remember, the SPF algorithm does not run recursively on stub networks. So those can be ignored. Up till now, we have the following topology built:

SPF will continue to recursively run until only stub networks are left. Let’s move to router ID 6.6.6.6 next and check what it is connected to (remember, all commands are being executed from just one router – R5):

R5#show ip ospf database router 6.6.6.6

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

Router Link States (Area 0)

LS age: 1298

Options: (No TOS-capability, DC)

LS Type: Router Links

Link State ID: 6.6.6.6

Advertising Router: 6.6.6.6

LS Seq Number: 80000002

Checksum: 0xC38F

Length: 60

Number of Links: 3

Link connected to: a Stub Network

(Link ID) Network/subnet number: 6.6.6.6

(Link Data) Network Mask: 255.255.255.255

Number of TOS metrics: 0

TOS 0 Metrics: 1

Link connected to: another Router (point-to-point)

(Link ID) Neighboring Router ID: 5.5.5.5

(Link Data) Router Interface address: 192.168.5.6

Number of TOS metrics: 0

TOS 0 Metrics: 64

Link connected to: a Stub Network

(Link ID) Network/subnet number: 192.168.5.0

(Link Data) Network Mask: 255.255.255.0

Number of TOS metrics: 0

TOS 0 Metrics: 64

It lists two stub networks – the first one looks like a loopback with the IP address of 6.6.6.6/32 (loopbacks are treated as stub networks as well), while the second stub network simply defines the subnet. Both of these will be ignored. It also lists a point-to-point connection back to 5.5.5.5 and says that IP address towards 5.5.5.5 is 192.168.5.6. We can add this little piece of information in our topology:

There are only stub networks left on 6.6.6.6 so there is nothing more to check on that router. We move on to router with router ID 2.2.2.2 now and this is where things get more interesting:

R5#show ip ospf database router 2.2.2.2

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

Router Link States (Area 0)

LS age: 1446

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: 80000003

Checksum: 0xDA53

Length: 84

Number of Links: 5

Link connected to: another Router (point-to-point)

(Link ID) Neighboring Router ID:5.5.5.5

(Link Data) Router Interface address:192.168.4.2

Number of TOS metrics: 0

TOS 0 Metrics: 64

Link connected to: a Stub Network

(Link ID) Network/subnet number: 192.168.4.0

(Link Data) Network Mask: 255.255.255.0

Number of TOS metrics: 0

TOS 0 Metrics: 64

Link connected to: another Router (point-to-point)

(Link ID) Neighboring Router ID:1.1.1.1

(Link Data) Router Interface address:192.168.2.2

Number of TOS metrics: 0

TOS 0 Metrics: 64

Link connected to: a Stub Network

(Link ID) Network/subnet number: 192.168.2.0

(Link Data) Network Mask: 255.255.255.0

Number of TOS metrics: 0

TOS 0 Metrics: 64

Link connected to: a Transit Network

(Link ID) Designated Router address:192.168.3.4

(Link Data) Router Interface address:192.168.3.2

Number of TOS metrics: 0

TOS 0 Metrics: 10

Let’s understand this one by one. The first connection is a point-to-point link to 5.5.5.5. We know this is R5 and now we know the IP address of this router towards R5 – 192.168.4.2. The second connection is a stub network which simply lists the subnet. This can be ignored.

The third connection is another point-to-point link to a router with router ID 1.1.1.1 and the IP address of this router towards 1.1.1.1 is 192.168.2.2. The fourth is a stub network listing the subnet and it can be ignored. Let’s add all this information to our topology:

The last connection type is quite interesting to build out. It says it is a ‘Transit Network’. A transit network is one where a DR/BDR election takes place, like an Ethernet segment. The output also says that the DRs IP address is 192.168.3.4 and my local IP address towards the DR is 192.168.3.2.

Remember, the DR is treated like a pseudo-node and all routers in that segment behave like they are directly attached to the DR. So, in order to build out this part of the topology, we need to focus on the DR and see what it is connected to. This is done by zooming in on the network LSAs (LSA type 2). You will need to use the DRs IP address to zoom in.

R5# show ip ospf database network 192.168.3.4

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

Net Link States (Area 0)

Routing Bit Set on this LSA

LS age: 1722

Options: (No TOS-capability, DC)

LS Type: Network Links

Link State ID:192.168.3.4 (address of Designated Router)

Advertising Router:4.4.4.4

LS Seq Number: 80000001

Checksum: 0xE7A9

Length: 36

Network Mask: /24

Attached Router: 4.4.4.4

Attached Router: 2.2.2.2

Attached Router: 3.3.3.3

The above gives us a lot of information about this segment. Firstly, it tells us the router ID of the DR which is the advertising router. It also tells us that the IP address of 4.4.4.4 towards this segment is 192.168.3.4 (taken from the link state ID). Lastly, it lists all the routers that are attached to this segment. Routers with router IDs 2.2.2.2, 3.3.3.3 and 4.4.4.4 are connected on this segment.

You should draw this out by imagining a pseudo node in the middle (which is the DR) and all these routers connected to it. Let’s add all this information to our topology now:

Now look at router ID 3.3.3.3 which is one of the attached routers on this segment:

R5#show ip ospf database router 3.3.3.3

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

Router Link States (Area 0)

LS age: 1796

Options: (No TOS-capability, DC)

LS Type: Router Links

Link State ID: 3.3.3.3

Advertising Router: 3.3.3.3

LS Seq Number: 80000003

Checksum: 0xC74B

Length: 48

Number of Links: 2

Link connected to: a Stub Network

(Link ID) Network/subnet number: 3.3.3.3

(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: 192.168.3.4

(Link Data) Router Interface address: 192.168.3.3

Number of TOS metrics: 0

TOS 0 Metrics: 10

It has a loopback, which is a stub network, so SPF will not be run on that. And it is also connected to the transit network with an IP address of 192.168.3.3. We can put this into the topology now.

Now, let’s zoom in on the second attached router to the DR segment – 4.4.4.4:

R5#show ip ospf database router 4.4.4.4

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

Router Link States (Area 0)

LS age: 1892

Options: (No TOS-capability, DC)

LS Type: Router Links

Link State ID: 4.4.4.4

Advertising Router: 4.4.4.4

LS Seq Number: 80000002

Checksum: 0xB86F

Length: 36

Number of Links: 1

Link connected to: a Transit Network

(Link ID) Designated Router address: 192.168.3.4

(Link Data) Router Interface address: 192.168.3.4

Number of TOS metrics: 0

TOS 0 Metrics: 10

It has only one link, and we already know all of the information for that link/segment so there is no new information to be added.

The only router we have not explored yet is the router with router ID 1.1.1.1, so let’s look at that:

It has just one point-to-point link which connects to 2.2.2.2 via IP address 192.168.2.1. At this point, we have traversed through all routers in area 0 and have successfully built the entire topology for your area 0. Adding the last few IP addresses, we get this:

Here is the actual topology that we were working:

You can compare that just by sitting on R5 we were successfully able to build the entire topology for whichever area R5 belonged to (area 0 in this case).

Citation - This blog post does not reflect original content from the author. Rather it summarizes content that are relevant to the topic from different sources in the web. The sources might include any online discussion boards, forums, websites and others.