"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.
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 neighbours. 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.
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 link state routing.
Difference between Distance-vector and Link-state
Distance vector :
Interior Gateway Protocol (IGP) : A routing protocol that was designed and intended for use inside a single autonomous system (AS)
Known Interior Gateway Protocols (IGP) are Routing Information Protocol (RIP), Interior Gateway Routing Protocol (IGRP), Open Shortest Path First (OSPF) and Intermediate System to Intermediate System (IS-IS)
Exterior Gateway Protocol (EGP) : A routing protocol that was designed and intended for use between different autonomous systems Exterior Gateway Protocol (EGP) is commonly used in the Internet to exchange routing table information. There is only one Exterior Gateway Protocol (EGP) exists and it is Border Gateway Protocol (BGP).