"Distance Vector" and "Link State" are terms used to describe routing protocols which are used by routers to forward packets between networks. The purpose of any routing protocol is to dynamically communicate information about all network paths used to reach a destination and to select from those paths, the best path to reach a destination network. The terms distance vector and link state are used to group routing protocols into two broad categories based on whether the routing protocol selects the best routing path based on a distance metric (the distance) and an interface (the vector), or selects the best routing path by calculating the state of each link in a path and finding the path that has the lowest total metric to reach the destination.
Distance vector routing: In distance vector routing, a router need not know the entire path to every network segment, it only requires to know the direction or vector in which to send the packet. The technique determines the direction (vector) and distance (hop count) to any network in the internetwork. Distance vector routing algorithms periodically send all or parts of their routing table to their adjacent neighbors. The routers running a distance vector routing protocol will automatically send periodic updates even if there are no changes in the network.
RIP and EIGRP is a commonly used distance vector protocol that uses hop counts or its routing metrics.
Link-state routing: In link-state routing, each router attempt to construct its own internal map of the network topology. At the initial stage of start-up, when a router becomes active, it sends the messages into the network and collects the information from the routers to which it is directly connected. It also provides the information about whether the link to reach the router is active or not. This information is used by other routers to build a map of network topology. Then the router uses the map to choose the best path. OSPF protocol is the example for link state routing.
Difference between Distance-vector and Link-state
It uses Bellman Ford algorithm for calculating the shortest cost path.
Each router periodically sends information to each of its neighbors.
As the packet travels one node to another towards destination, a cost is incurred. In case of RIP, the cost relates to the hop count.
It is decentralized routing algorithm.
RIP is an example protocol, which follows the distance vector routing.
It needs less CPU utilization and less memory space compare than Link state.
It uses dijkstras algorithm for calculating the shortest path.
Each router building up the complete topology of the entire internetwork, thus each router contains the same information.
Link-state is also known as the shortest path first.
OSPF, BGP and EGP are the examples for link state.
It needs more CPU utilization and more memory space compare than Distance vector.