Routing Algorithm
What is routing?
Routing is the process of path selection in any network. A computer
network is made of many machines, called nodes, and paths or links
that connect those nodes. Communication between two nodes in an
interconnected network can take place through many different paths.
Routing is the process of selecting the best path using some
predetermined rules.
Why is routing important?
Routing creates efficiency in network communication. Network
communication failures result in long wait times for website pages to
load for users. It can also cause website servers to crash because they
can't handle a large number of users. Routing helps minimize network
failure by managing data traffic so that a network can use as much of its
capacity as possible without creating congestion.
• What is a router?
• A router is a networking device that connects computing devices and
networks to other networks. Routers primarily serve three main
functions.
Path determination
• A router determines the path data takes when it moves from a source
to a destination. It tries to find the best path by analyzing network
metrics such as delay, capacity, and speed.
Data forwarding
• A router forwards data to the next device on the selected path to
eventually reach its destination. The device and router may be on the
same network or on different networks.
• Load balancing
• Sometimes the router may send copies of the same data packet by
using multiple different paths. It does this to reduce errors due to
data losses, create redundancy, and manage traffic volume.
What are the types of routing?
• There are two different types of routing, which are based on how the
router creates its routing tables:
• Static routing
• In static routing, a network administrator uses static tables to manually
configure and select network routes. Static routing is helpful in situations
where the network design or parameters are expected to remain
constant.
• The static nature of this routing technique comes with expected
drawbacks, such as network congestion. While administrators can
configure fallback paths in case a link fails, static routing generally
decreases the adaptability and flexibility of networks, resulting in limited
network performance.
• Dynamic routing
• In dynamic routing, routers create and update routing tables at
runtime based on actual network conditions. They attempt to find the
fastest path from the source to the destination by using a dynamic
routing protocol, which is a set of rules that create, maintain, and
update the dynamic routing table.
• The biggest advantage of dynamic routing is that it adapts to changing
network conditions, including traffic volume, bandwidth, and network
failure.
The Distance vector algorithm is iterative,
asynchronous and distributed.
• Distributed: It is distributed in that each node receives information from one
or more of its directly attached neighbors, performs calculation and then
distributes the result back to its neighbors.
• Iterative: It is iterative in that its process continues until no more information
is available to be exchanged between neighbors.
• Asynchronous: It does not require that all of its nodes operate in the lock step
with each other.
• The Distance vector algorithm is a dynamic algorithm.
• It is mainly used in ARPANET, and RIP.
• Each router maintains a distance table known as Vector.
• Three Keys to understand the working of Distance Vector Routing Algorithm:
• Knowledge about the whole network: Each router shares its knowledge
through the entire network. The Router sends its collected knowledge about
the network to its neighbors.
• Routing only to neighbors: The router sends its knowledge about the
network to only those routers which have direct links. The router sends
whatever it has about the network through the ports. The information is
received by the router and uses the information to update its own routing
table.
• Information sharing at regular intervals: Within 30 seconds, the router
sends the information to the neighboring routers.
• Distance Vector Routing Algorithm
• Let dx(y) be the cost of the least-cost path from node x to node y. The
least costs are related by Bellman-Ford equation,
dx(y) = minv{c(x,v) + dv(y)}
What are the main routing
protocols?
• A routing protocol is a set of rules that specify how routers identify
and forward packets along a network path. Routing protocols are
grouped into two distinct categories: interior gateway protocols and
exterior gateway protocols.
• Interior gateway protocols work best within an autonomous system—
a network administratively controlled by a single organization.
External gateway protocols better manage the transfer of information
between two autonomous systems.
Interior gateway protocols
• These protocols assess the autonomous system and make routing
decisions based on different metrics, such as the following:
• Hop counts, or the number of routers between the source and the
destination
• Delay, or the time taken to send the data from the source to the
destination
• Bandwidth, or the link capacity between the source and the destination
• The following are some examples of interior gateway protocols.
• Routing Information Protocol
• The Routing Information Protocol (RIP) relies on hop counts to
determine the shortest path between networks. RIP is a legacy
protocol that no one uses today because it does not scale well for
larger network implementation.
• Open Shortest Path First protocol
• The Open Shortest Path First protocol (OSPF) collects information
from all other routers in the autonomous system to identify the
shortest and fastest route to a data packet’s destination. You can
implement OSPF using various routing algorithms or computer
processes.
External gateway protocols
• The Border Gateway Protocol (BGP) is the only external gateway
protocol.
• Border Gateway Protocol
• BGP defines communication over the internet. The internet is a large
collection of autonomous systems all connected together. Every
autonomous system has autonomous system number (ASN) that it
obtains by registering with the Internet Assigned Numbers Authority.
• BGP works by keeping track of the closest ASNs and mapping
destination addresses to their respective ASNs.
Border Gateway Protocol (BGP)
• The protocol can connect any internetwork of the autonomous
system using an arbitrary topology. The only requirement is that each
AS have at least one router that can run BGP and that is the router
connected to at least one other AS’s BGP router. BGP’s main function
is to exchange network reachability information with other BGP
systems. Border Gateway Protocol constructs an autonomous systems
graph based on the information exchanged between BGP routers.
• Characteristics of Border Gateway Protocol (BGP)
• Inter-Autonomous System Configuration: The main role of BGP is to provide communication between
two autonomous systems.
• BGP supports the Next-Hop Paradigm.
• Coordination among multiple BGP speakers within the AS (Autonomous System).
• Path Information: BGP advertisements also include path information, along with the reachable
destination and next destination pair.
• Policy Support: BGP can implement policies that can be configured by the administrator. For ex:- a
router running BGP can be configured to distinguish between the routes that are known within the AS
and that which are known from outside the AS.
• Runs Over TCP.
• BGP conserves network Bandwidth.
• BGP supports CIDR.
• BGP also supports Security.
• Importance of Border Gateway Protocol(BGP)
• Security: BGP is highly secure because it authenticates messages between routers
using preconfigured passwords through which unauthorized traffic is filtered out.
• Scalability: BGP is more scalable because it manages a vast number of routes and
networks present on the internet.
• Supports Multihoming: BGP allows multihoming means an organization can
connect to multiple networks simultaneously.
• Calculate the Best Path: As we know data packets is traveled across the internet
from source to destination every system in between the source and destination has
to decide where the data packet should go next
• TCP/IP Model: BGP is based on the TCP/IP model and it is used to control the
network layer by using transport layer protocol.
Types of Border Gateway
Protocol
• External BGP: It is used to interchange routing information between
the routers in different autonomous systems, it is also known as
eBGP(External Border Gateway Protocol). The below image shows
how eBGP interchange routing information.
• Internal BGP: It is used to interchange routing information between
the routers in the same autonomous system, it is also known as
iBGP(Internal Border Gateway Protocol). Internal routers also ensure
consistency among routers for sharing routing information. The below
image shows how iBGP interchange routing information.
• Elements of BGP
• Some elements of BGP are assigned to each path and these elements help routers to
select a path from multiple [Link] below are some elements of BGP:
• Weight: Weight is defined as a Cisco-specific attribute that tells a router which path is
preferred. The weight having a higher value is preferred.
• Originate: This tells how a router choose routes and adds to BGP itself.
• Local Preference: Local Preference is an element used to select the outbound routing
path. Greater local preference is preferred.
• Autonomous System Path: This element tells the router to select a path having a
shorter length.
• Next Hop: To reach the destination the next hop elements specify the IP address that
should be used as the next hop.
• Key Concepts of BGP:
• Autonomous System (AS):
• An AS is a group of IP networks under a single administrative domain that shares a common
routing policy. BGP is used to route data between different ASes.
• Inter-Domain Routing:
• BGP is used for routing between autonomous systems, making it essential for large-scale routing
on the internet. It determines the best path for data to travel between ASes.
• Path Vector Protocol:
• Unlike distance-vector or link-state protocols, BGP advertises the entire path (list of ASes) that a
packet will traverse. This makes BGP more reliable and avoids routing loops.
• Types of BGP:
• External BGP (eBGP): Used for communication between routers in different autonomous systems.
• Internal BGP (iBGP): Used for communication between routers within the same AS.
• BGP Attributes:
• BGP uses various attributes to select the best path. Some important attributes
include:
• AS Path: Lists the ASes that the packet must pass through.
• Next-Hop: Specifies the next router to which the packet should be forwarded.
• Local Preference: Determines the preferred path for outgoing traffic within an AS.
• Multi-Exit Discriminator (MED): Helps determine the best path when multiple entry
points exist between two ASes.
• BGP Peers and Sessions:
• BGP routers (peers) establish sessions to exchange routing information. These
sessions can be between eBGP or iBGP peers.
• BGP sessions use TCP (port 179) for reliable communication.
• Route Selection in BGP: BGP uses a complex decision process to
select the best route. The selection criteria include:
• Highest Local Preference.
• Shortest AS Path.
• Lowest MED.
• Prefer routes learned via eBGP over iBGP.
• Lowest IGP (Interior Gateway Protocol) cost to the next hop.
BGP VS OSPF
• What are routing algorithms?
• Routing algorithms are software programs that implement different routing protocols. They work by
assigning a cost number to each link; the cost number is calculated using various network metrics. Every
router tries to forward the data packet to the next best link with the lowest cost.
• The following are some example algorithms.
• Distance Vector Routing
• The Distance Vector Routing algorithm requires all routers to periodically update each other about the
best path information they have found. Each router sends information about the current assessment of
the total cost to all known destinations.
• Eventually, every router in the network discovers the best path information for all possible destinations.
• Link State Routing
• In Link State Routing, every router discovers all other routers in the network. Using this information, a
router creates a map of the complete network and then calculates the shortest path for any data packet.
• Scenario:
• Router A belongs to Autonomous System (AS) 100.
• Router B belongs to Autonomous System (AS) 200.
• The routers will use their external interfaces to communicate via BGP.
Network Setup:
Router A: AS 100, IP: [Link]/30
Router B: AS 200, IP: [Link]/30
Network to be advertised from Router A: [Link]/24
Network to be advertised from Router B: [Link]/24
BGP Configuration on Router A (AS
100)
• outerA(config)# router bgp 100
• RouterA(config-router)# neighbor [Link] remote-as 200
RouterA(config-router)# network [Link] mask [Link]
RouterA(config-router)# exit
• RouterA(config)# interface GigabitEthernet0/0
• RouterA(config-if)# ip address [Link] [Link]
RouterA(config-if)# no shutdown
Explanation for Router A:
•router bgp 100: Configures BGP on Router A and assigns it to AS 100.
•neighbor [Link] remote-as 200: Specifies Router B’s IP and indicates it
•network [Link] mask [Link]: Advertises the [Link]/24 network.
•interface GigabitEthernet0/0: Configures the interface connected to Router B
•ip address [Link] [Link]: Assigns an IP address to the interfac
BGP Configuration on Router B (AS
200)
• RouterB(config)# router bgp 200
• RouterB(config-router)# neighbor [Link] remote-as 100
RouterB(config-router)# network [Link] mask [Link]
RouterB(config-router)# exit
• RouterB(config)# interface GigabitEthernet0/0
• RouterB(config-if)# ip address [Link] [Link]
RouterB(config-if)# no shutdown
Explanation for Router B:
•router bgp 200: Configures BGP on Router B and assigns it to AS 200.
•neighbor [Link] remote-as 100: Specifies Router A’s IP and indicates
it belongs to AS 100.
•network [Link] mask [Link]: Advertises the [Link]/24
network.
•interface GigabitEthernet0/0: Configures the interface connected to
Router A.
•ip address [Link] [Link]: Assigns an IP address to the
interface.
Verifying the Configuration
• Check BGP neighbors: On either router, use the command:
• RouterA# show ip bgp summary
• This command will display the status of the BGP neighbors. You
should see the neighbor listed with a state of Established.
• Check BGP routing table: To see the BGP routes learned from the
neighbor:
• RouterA# show ip bgp
This will show the BGP routing table, including routes learned from Router B ( [Link]/24 on Router A) and vice versa.
• Check advertised routes: You can check which networks a router is
advertising using the following command:
• RouterA# show ip bgp neighbors [Link] advertised-routes
This will display the routes advertised to the neighbor.