1 Mar 2013

Routing protocols - Open Shortest Path First (OSPF)

1 comments
   Link-state routing protocols are a more complex category of dynamic routing protocols. These type of protocols use a different approach when interacting with network resources. Devices that run a link state routing protocol share a network topology end each one plays an important role in selecting the best routes. Routers exchange their directly connected links to all other routers in the network hence the name link state routing protocols. A "link" is actually a router interface that is in the state of "up" (IP address and network mask are assigned and the "no shutdown" command is executed) and is included in the routing process. Each router has it's own network topology used for updating routing information. There are two main link-state routing protocols, Open Shortest Path First (OSPF) and Intermediate System-to-Intermediate System (IS-IS). Link-state protocols are based on the Dijkstra's algorithm, this algorithm is also known as the shortest path first (SPF) algorithm. The concept is pretty simple, each link receives a cost and by summing all the costs from source to destination, the best path is chosen. A router connected to a network that runs a link state routing protocol will take the following steps:
   Upon startup the router will learn about the directly connected networks, this is done by sending a hello message to each of the neighboring routers. After learning about the directly connected routers, devices form a Link State Packet (LSP - a packet that contains the state of each link) and then flood all neighboring routers with it. Upon receiving the LSP packet, a router builds it's own network topology in which all links are stored. A big advantage of link-state routing protocols is the fast speed of converge. Because these protocols tend to use a big percent of the network resources (CPU, memory, bandwidth, etc.), networks are divided into multiple areas.
   In this post we will focus on the OSPF protocol, one of the well known link-state protocols used in today's networks. Like other routing protocols, OSPF uses it's own elements: the 89 port number, the 224.0.0.5 and 224.0.0.6 multicast IP addresses, the 01-00-5E-00-00-05 and 01-00-5E-00-00-06 MAC addresses. Just like EIGRP, OSPF supports authentication and encryption of network messages. The administrative distance of OSPF is 110.
   Before exchanging messages, routers must agree on three elements that they will use: the network type, the Hello interval and the dead interval. As an administrator you have the possibility to configure these elements, but by default the hello interval is set to 30 seconds on NBMA networks (non-broadcast multiacces networks) and 10 seconds to multiaccess networks. The dead interval is a value that measures the time a router must wait before setting a link in the "down" state. A link that is in the "down" state will be ignored by other routers and will not participate in the routing mechanism.
   As I've told you earlier, OSPF uses specific types of messages that are sent across networks:
Hello - used for discovering neighboring routers
Link-State Request (LSR) - a OSPF request message
Link-State Update (LSU) - OSPF update message. Remember that this type of message has different Link-State Advertisments (LSAs). A LSA is an advertisment that specifies what kind of LSU packet the router has sent/received (a network LSA, a router LSA, a summary LSA, etc.). Read more about LSAs on this article from Wikipedia: http://en.wikipedia.org/wiki/Link-state_advertisement.
Link-State Acknowledgement (LSAck) - confirms that a packet has been received
Database Description (DBD) - used for database syncronization.
   I've written earlier that OSPF uses the overall cost of links from source to destination, to determine the best path that packets must follow. This cost is actually the metric element used by all dynamic routing protocols. OSPF will calculate the costs based on two elements: the link's bandwidth and the reference bandwidth. The protocol uses the following formula:
10^8/link's bandiwdth. The 10^8 is the reference bandwidth (the reference bandwidth can be changed unsing the auto-cost reference-bandwidth command). For example, Fast Ethernet will have the cost of 10^8/100000000 bps =1, T1 will have the cost of 10^8/1544000 bps=64, 56 kbps will have the cost of 10^8/56000 bps=1785. As you can see, the better the link's bandwidth, the lower the cost. OSPF will always use the lowest cost on a link.
   To enable OSPF on a Cisco router, type router ospf ID. The ID is local significance only, unlike EIGRP, the OSPF id don't have to be the same to all routers in the network. I will use the 123 ID to specify the OSPF process:
ospf configuration

   As you can see from the image, you will have to configure an interface in order to start the OSPF process. After configuring the OSPF process, add the directly connected networks by using the network command. This command is different from other routing protocols, you will have to use the wildcard mask and the area id:
ospf configuration commands

   One unique element of OSPF is the router ID, this is used for identifying all routers that participate in the OSPF process. This is actually an IP address but has nothing to do with the networking protocol, it is simply used for identifying devices in the OSPF mechanism The router ID can be configured by using the router-id command:
router-id ospf

   To distribute the default route to all routers in the network, use the default-information originate command. First, add a static configured route then enter the desired OSPF process and execute the command:
default-information originate command

   If the router's ID was not configured with this command, OSPF will choose the highest IP address from the router's loopack interfaces. If there is no loopback interface configured, the highest IP address from the physical interfaces will be chosen. To verify your OSPF configuration, use the same command you are already used with, the show ip protocols command:
show ip protocols

   Some new commands that are used only by OSPF are: show ip ospf neighbor, show ip ospf, show ip ospf interface. Check each one of these commands to see their output. In OSPF, Administrators can change the hello and dead intervals times by using the following commands:
Router(config-if)#ip ospf hello-interval [seconds] and Router(config-if)#ip ospf dead-interval [seconds]:
interface configuration

   Administrators can modify the cost of a link by changing the link's bandwidth, to do this use the bandwidth [kbps] command, from the interface configuration mode:
Cisco interface configuration

Another way to change the link's cost, is to type the ip ospf cost [number] command from the interface configuration mode:
Ospf Cost

   In a multiaccess network, there is a possibility that the LSAs packets will flood the network, increasing the network traffic. To address this issue, two elements were introduces the DR (Designated Router) and the DBR (Backup Designated Router). OSPF will choose the DR and BDR based on the router's priority. To change a router's priority in the OSPF process, type the ip ospf priority [number] command in the interface configuration mode. The priority is a number from 0 to 255:
Ospf priority

   The router with the highest priority will be chosen as DR and the BDR will be the router with the second highest priority. If routers have the same priority number, OSPF will choose DR and BDR based on the highest ID.
   OK folks, I hope I've covered all the important aspects of OSPF. If you think there is something more to add here just leave a comment. Also, remember that I will make a video tutorial on how to configure OSPF. Have a nice day and stay tuned for more articles to come.
author

About me

After finishing a Computer Science University I've started working as an IT support technician for an Outsourcing company. Since then, I've changed my profile a couple of times and now I work as a System Administrator at one of the biggest companies in the gaming industry. I'm constantly learning new things in this domain so I thought of creating this website for sharing my experiences. Until now, I've taken the Cisco Certificate Network Associate exam and several Microsoft certifications. Now, I am in the process of learning Unix and enhance my programming skills.

1 comments :

  1. Nice post, things explained in details. Thank You.

    ReplyDelete

Blogroll