The services of the network layer are routing the packets from source to destination devices. It can do this in a single pass or many passes. The algorithm which selects the routes and data structures that they facilitate is known as the routing algorithm. This is a significant field of network layer design. They are that element of network layer application responsible for transmitting the output channel for an incoming packet.
In the case of datagrams, the decisions create new for each appearing data packet, and in the case of the virtual circuit, they are made only once, i.e., when a new virtual circuit is being established. In the case of the virtual circuit, the route remains in force for a whole session. Therefore, it is also known as session routing.
A routing algorithm should be adequate to cope with adjustment in the topology and traffic without resetting the network. Correctness and simplicity are not required. Security is also important. Fairness and optimality are needed to enhance delay and decrease the quantity of bandwidth consumed.
There are two types of Routing Algorithm which are as follows −
Adaptive algorithms or dynamic routing can modify their routing decisions to reverse modifiers in the topology and the traffic. Routers necessarily upgrade routing data when transforms are created to the network established.
It is efficient as it does not contain human intervention to transform the network set up. Its drawback is that the overhead needed to share configuration change data can be a huge difficulty. It is referred to as dynamic routing.
It evaluates the least-cost direction between source and destination by using complete and worldwide knowledge about the network. This algorithm creates the connectivity between the nodes and link cost as input, and this data is acquired before actually implementing any calculation.
Non-adaptive algorithms or static routing are separate from modern traffic and topology size. They determine the path to which a datagram is to transmit off-line. The route is evaluated in advance, and log in to the routers when the network is bounced.
The routing data is manually determined. It supports fixed-route data to every router. If there should be no change in route, it is created manually. This process is known as static routing.
There are two types of non-adaptive algorithms which are as follows −
Flooding − In flooding, each incoming packet is transmitted to all the outgoing links except the one from which has been arrived. The drawback of flooding is that nodes can include various copies of a specific packet.
Random walks − In random walks, a packet is transmitted by the node to one of its neighbours randomly. An advantage of using random walks is that it facilitates alternative routes very effectively.