Sunday 26 April 2009

OSPF Packet Type

Five types of OSPF packet:

- Hello, used for maintaining neighbour relationships
- Database Descriptor, sending a list of router-ids, current sequence numbers, maintaining current version of link state database
- Link state requests (LSR), request for any missing LSAs
- Link state update, reply to a link state request
- Link state acknowledgement (LSAck), receipt of link state information

OSPF - DR/BDR

When mulitple routers are on the same segment, running OSPF, they form adjacencies with a designated router, and a backup designated router, this prevents routers from having to form large numbers of adjacencies with all routers.

Designated router is the router with highest interface IP address, or preferably loopback interface, BDR is router with second highest. A new router with highest IP address can not preempt the current DR. To force a DR re-election use command "clear ip ospf process *" on DR router. Use the router-id command to force the ip address used for ospf process router-id.

The DR will receive updates and send updates to segment routers. Segment routers advertise changes to the DR/BDR using multicast address 224.0.0.6.

*Mar 1 00:30:44.531: Processing link 0, id 172.16.0.1, link data 255.255.255.255, type 3
*Mar 1 00:30:44.531: Add better path to LSA ID 172.16.0.1, gateway 172.16.0.1, dist 2
*Mar 1 00:30:44.531: Add path: next-hop 192.168.0.1, interface FastEthernet0/0
*Mar 1 00:30:44.531: Processing link 1, id 192.168.0.2, link data 192.168.0.1, type 2
*Mar 1 00:30:44.535: Ignore newdist 2 olddist 1
*Mar 1 00:30:44.535: OSPF: Adding Stub nets
*Mar 1 00:30:44.535: OSPF: Add Network Route to 172.16.0.1 Mask /32. Metric: 2, Next Hop: 192.168.0.1
*Mar 1 00:30:44.535: OSPF: insert route list LS ID 172.16.0.1, type 0, adv rtr 192.168.0.1


Router#sh run sec router osp
router ospf 72
router-id 172.16.0.1
log-adjacency-changes
network 172.16.0.0 0.0.0.255 area 51
network 192.168.0.0 0.0.0.255 area 51

OSPF Neighbours/Adjacencies

Routers running OSPF need to be directly connected in order to form adjacencies, routers exchange hello messages and update their respective neighbour tables.

Hello messages are sent to multicast address: 224.0.0.5

*Mar 1 00:17:10.235: OSPF: Send hello to 224.0.0.5 area 51 on FastEthernet0/0 from 192.168.0.2
*Mar 1 00:17:11.503: OSPF: Rcv hello from 192.168.0.1 area 51 from FastEthernet0/0 192.168.0.1
*Mar 1 00:17:11.503: OSPF: End of hello processing


Router1#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.0.1 1 FULL/BDR 00:00:28 192.168.0.1 FastEthernet0/0


Router2#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.0.2 1 FULL/DR 00:00:39 192.168.0.2 FastEthernet0/0


Hello messages are sent every 10 seconds on a broadcast link, or every 30 seconds on a non-broadcast link.

OSPF General

OSPF is a link-state protocol based on Dijkstra shortest path first algorithm.

Routers running OSPF neighbour with routers that are directly connected, with the same network address. Link State Advertisements (LSA) are sent between routers to create a topology table, which should be consistant on all routers within the same area.

OSPF populates the following three tables:

- Neighbour table (show ip ospf neighbour
- Topology table (sh ip ospf database)
- Routing table (sh ip route)

Router#sh run sec router ospf
router ospf 72
log-adjacency-changes
network 172.16.0.0 0.0.0.255 area 51
network 192.168.0.0 0.0.0.255 area 51