A routing protocol is the means by which computer networking is able to direct traffic efficiently via devices called routers. Any such protocol is essentially an algorithm designed to prevent and correct loops, gather information about the network topology and distribute that information to other routers and ultimately select the paths traffic should take. Some of these protocols handle the traffic inside a network, directing it to other routers within a controlled network. When communications need to enter or leave a particular network, it is directed by another type of routing protocol that watches the traffic at the edge, or border, of the network.
When a routing protocol is used on the inside of a network, it is referred to as an interior gateway protocol (IGP). Using the same routing protocol together, they form a routing domain. Subsequently, any number of routing domains together form a network that comprises an autonomous system (AS). Here, on the inside of an AS, the protocols fall into two primary categories, a link-state protocol, or a vector-based protocol.
With a link-state protocol, the routers talk to each other in order to map out the entire network, assess the state of the connections between them, and then calculate the best possible paths that traffic can take to get around. This method is useful in determining which paths may have a faster connection speed than another path and for figuring out the shortest path. These types of routing protocol are very fast in getting the routers to converge with one another, updating their knowledge of the network, when a new router is added or one goes off-line.
A vector-based routing protocol comes in two flavors: the distance vector and path vector, where the latter is a sub-class of the former. Distance vector methods use what is known as a hop count to determine the shortest path from one router to the next. Here, the router counts the number of other routers communication must traverse, each representing one hop, and then builds its map of the best possible routes. In comparison to a link-state protocol, a distance vector algorithm can't tell how fast a particular hop is compared to another and may ultimately choose a slower route even though it requires fewer hops. It also suffers from delays when a router is added to or removed from the network, since it has to count hops again to rebuild its map of the network.
A path vector routing protocol is often used on the border of a network in what's referred to as a border gateway protocol (BGP). In addition to counting hops, the border router also advertises its availability by sending out a path vector message. The border routers of other networks then build their knowledge of paths outside of an AS by watching for these messages from one another.
In some cases, a routing protocol may actually be routed over an existing communications protocol. Whether they are routed depends on the open systems interconnection (OSI) model's layer under which they operate, such as IS-IS, the data link layer, and is a non-routed protocol. Internet protocol (IP) and transmission control protocol (TCP), operate at layers three and four, respectively, and are two means by which a routing protocol can be routed. Most notable are the BGPs that run over TCP.