CN Unit 4
CN Unit 4
1. ROUTING
A Router is a process of selecting path along which the data can be transferred from source to the
destination. Routing is performed by a special device known as a router.
A Router works at the network layer in the OSI model and internet layer in TCP/IP model
A router is a networking device that forwards the packet based on the information available in
the packet header and forwarding table.
The routing algorithms are used for routing the packets. The routing algorithm is nothing but a
software responsible for deciding the optimal path through which packet can be transmitted.
The routing protocols use the metric to determine the best path for the packet delivery. The
metric is the standard of measurement such as hop count, bandwidth, delay, current load on the
path, etc. used by the routing algorithm to determine the optimal path to the destination.
The routing algorithm initializes and maintains the routing table for the process of path
determination.
Routing metrics and costs are used for determining the best route to the destination. The factors
used by the protocols to determine the shortest path, these factors are known as a metric.
Metrics are the network variables used to determine the best route to the destination. For some
protocols use the static metrics means that their value cannot be changed and for some other
routing protocols use the dynamic metrics means that the system administrator can assign their
value.
Hop count: Hop count is defined as a metric that specifies the number of passes through
internetworking devices such as a router, a packet must travel in a route to move from source to the
destination. If the routing protocol considers the hop as a primary metric value, then the path with
the least hop count will be considered as the best path to move from source to the destination.
Delay: It is a time taken by the router to process, queue and transmit a datagram to an interface.
The protocols use this metric to determine the delay values for all the links along the path end-to-
end. The path having the lowest delay value will be considered as the best path.
Bandwidth: The capacity of the link is known as a bandwidth of the link. The bandwidth is
measured in terms of bits per second. The link that has a higher transfer rate like gigabit is
preferred over the link that has the lower capacity like 56 kb. The protocol will determine the
bandwidth capacity for all the links along the path, and the overall higher bandwidth will be
considered as the best route.
Load: Load refers to the degree to which the network resource such as a router or network link is
busy. A Load can be calculated in a variety of ways such as CPU utilization, packets processed per
second. If the traffic increases, then the load value will also be increased. The load value changes
with respect to the change in the traffic.
Reliability: Reliability is a metric factor may be composed of a fixed value. It depends on the
network links, and its value is measured dynamically. Some networks go down more often than
others. After network failure, some network links repaired more easily than other network links.
Any reliability factor can be considered for the assignment of reliability ratings, which are
generally numeric values assigned by the system administrator.
Types of Routing
Static Routing
Default Routing
Dynamic Routing
Static Routing:
No Overhead: It has ho overhead on the CPU usage of the router. Therefore, the cheaper router
can be used to obtain static routing.
Bandwidth: It has not bandwidth usage between the routers.
Security: It provides security as the system administrator is allowed only to have control over the
routing to a particular network.
For a large network, it becomes a very difficult task to add each route manually to the routing
table.
The system administrator should have a good knowledge of a topology as he has to add each
route manually.
Default Routing:
Default Routing is a technique in which a router is configured to send all the packets to the same
hop device, and it doesn't matter whether it belongs to a particular network or not. A Packet is
transmitted to the device for which it is configured in default routing.
Default Routing is used when networks deal with the single exit point.
It is also useful when the bulk of transmission networks have to transmit the data to the same hp
device.
When a specific route is mentioned in the routing table, the router will choose the specific route
rather than the default route. The default route is chosen only when a specific route is not
mentioned in the routing table.
Dynamic Routing:
All the routers must have the same dynamic routing protocol in order to exchange the routes.
If the router discovers any change in the condition or topology, then router broadcast this
information to all other routers.
It is easier to configure.
It is more effective in selecting the best route in response to the changes in the condition or
topology.
2. UNICAST ROUTING
unicast means that the transmission from a single sender to a single receiver. Most of the traffic on
the internet and also an intranet is known as unicast data means that unicast traffic is sent with a
specified destination. Unicast is a transmission from point to point means (single sender to a single
receiver). It is the simplest form of routing because the destination which is already known. There
is various unicast protocol such as TCP, HTTP, etc.
TCP is one of the uses unicast protocol. It is a connection-oriented protocol that relays on
acknowledgment from the receiver side. While HTTP is an object-oriented protocol for
communication.
There are basically three types of major routing protocol for unicast routing is:
3. DISTANCE-VECTOR ROUTING
In distance-vector routing, a router continuously tells all of its neighbors what it knows
about the whole internet.
Bellman-Ford Equation
In distance-vector routing Bellman-Ford equation is used to find the least cost (shortest
distance) between a source node, x, and a destination node, y, through some intermediary nodes (a,
b, c) when the costs between the source and the intermediary nodes and the least costs between the
intermediary nodes and the destination are given.
The following shows the general case in which Dij is the shortest distance and cij is the cost
between nodes i and j.
In distance-vector routing, we want to update an existing least cost with aleast cost through an
intermediary node, such as z, ie, if the intermediate node is shorter.
Bellman-Ford equation help us to build a new least-cost path from previously established
least-cost paths.
In the Figure (above), we can think of (a-y),(b-y), and (c-y) as previously established least-
cost paths and (x-y) as the new least-cost path.
We can even think of this equation as the builder of a new least-cost tree from previously
established least-cost trees if we use the equation repeatedly.
Distance Vectors
The concept of a distance vector is the reason for the name distance-vector routing. A least-
cost tree is a combination of least-cost paths from the root of the tree to all destinations.
Figure shows the tree for node A in the internet in Figure and the corresponding distance
vector.
A distance vector does not give the path to the destinations as the least-cost tree does; it
gives only the least costs to the destinations.
Note that the name of the distance vector defines the root, the indexes define the
destinations, and the value of each cell defines the least cost from the root to the
destination.
Consider (For example), Node A thinks that it is not connected to node G because the
corresponding cell shows the least cost of infinity.
To improve these vectors, the nodes in the internet need to help each other by exchanging
information. After each node has created its vector, it sends a copy of the vector to all its
immediate neighbors. After a node receives a distance vector from a neighbor, it updates its
distance vector using the Bellman-Ford equation (second case).
The figure (below) shows two asynchronous events, happening one after another with some
time in between.
In the first event, node A has sent its vector to node B. Node B updates its vector using the
cost cBA=2. In the second event, node E has sent its vector to node B. Node B updates its
vector using the cost cEA= 4.
After the first event, node B has one improvement in its vector: its least cost to node D has
changed from infinity to 5 (via node A). After the second event, node B has one more
improvement in its vector; its least cost to node F has changed from infinity to 6 (via node
E).
By exchanging the vectors, we can stabilize the system and allows all nodes to find the
ultimate least cost between themselves and any other node.
After updating a node, it immediately sends its updated vector to all neighbors.
For a routing protocol to work properly, if a link is broken (cost becomes infinity), every other
router should be aware of it immediately, but in distance-vector routing,this takes some time.
The problem is called count to infinity.
Two-Node Loop
Example of count to infinity is the two-node loop problem.
To understand the problem, consider the Figure (below). The figure shows a system with three
nodes.
Initially both nodes A and B know how to reach node X. But suddenly, the link between A and X
fails. Node A changes its table.
If A can send its table to B immediately, everything is fine. However, the system becomes
unstable if B sends its forwarding table to A before receiving A’s forwarding table. Node A
receives the update and, assuming that B has found a way to reach X, immediately updates its
forwarding table. Now A sends its new updateto B.
Now B thinks that something has been changed around A and updates its forwarding table.
The cost of reaching X increases gradually until it reaches infinity. At this moment, both A and B
know that X cannot be reached. However, during this time the system is not stable. Node A thinks
that the route to X is via B; node B thinks that the route to X is via A. If A receives a packet
destined for X, the packet goes to B and then comes back to A. Similarly, if B receives a packet
destined for X, it goes to Aand comes back to B. Packets bounce between A and B, creating a two-
node loop problem.
Split Horizon
o One solution to instability is called split horizon. In this method, instead of flooding the
table through each interface, each node sends only part of its table through each interface.
If, according to its table, node B thinks that the optimum route to reach X is via A, it does not
need to advertise this piece of information to A; the information has come from A (A already
knows).
Taking information from node A, modifying it, and sending it back to node A is what creates the
confusion. In this method, node B eliminates the last line of its forwarding table before it sends it
to A. In this case, node A keeps the value of infinity as the distance to X.
Later, when node A sends its forwarding table to B, node B also corrects its forwardingtable. The
system becomes stable after the first update: both node A and node B know that X is not
reachable.
4. LINK-STATE ROUTING
A routing algorithm that directly creates least-cost trees and forwarding tables is link- state
(LS) routing. This method uses the term link-state to define the characteristic of a link (an edge)
that represents a network in the internet.
Each node can send some greeting messages to all its immediate neighbors (those nodes to
which it is connected directly) to collect two pieces of information for each neighboring
node: the identity of the node and the cost of the link.
The combination of these two pieces of information is called the LS packet (LSP); the LSP
is sent out of each interface, as shown in figure.
When a node receives an LSP from one of its interfaces, it compares the LSP with the copy
it may already have. If the newly arrived LSP is older than the one it has (found by
checking the sequence number), it discards the LSP.
If it is newer or the first one received, the node discards the old LSP (if there is one) and
keeps the received one. It then sends a copy of it out of each interface except the one from
which the packet arrived. This guarantees that flooding stops somewhere in the network
(where a node has only one interface).
After receiving all new LSPs, each node creates the comprehensive LSDB as shown in
Figure (below). This LSDB is the same for each node and shows the whole map of the
internet.
In other words, a node can make the whole map if it needs to, using this LSDB.
Fig: Creation of LSP
Note:
In the distance-vector routing algorithm, each router tells its neighbors what it knows about the
whole internet; in the link-state routing algorithm, each routertells the whole internet what it knows
about its neighbors.
1. The node chooses itself as the root of the tree, creating a tree with a single node, and sets the
total cost of each node based on the information in the LSDB.
2. The node selects one node, among all nodes not in the tree, which is closest to the root, and
adds this to the tree. After this node is added to the tree, the cost of all other nodes not in the tree
needs to be updated because the paths may have been changed.
3. The node repeats step 2 until all nodes are added to the tree.
The Routing Information Protocol (RIP) is one of the most widely used intradomain routing
protocols based on the distance-vector routing algorithm.
Hop Count
A router in this protocol implements the distance-vector routing algorithm. First, since a
router in an AS needs to know how to forward a packet to different networks (subnets) in an
AS, RIP routers advertise the cost of reaching different networks instead of reaching other
nodes in a theoretical graph.
The cost is defined between a router and the network in which the destination host is
located.
Second, to make the implementation of the cost simpler (independent from performance
factors of the routers and links, such as delay, bandwidth, and so on), the cost is defined as
the number of hops, which means the number of networks(subnets)a packet needs to travel
through from the source router to the final destination host.
Note that the network in which the source host is connected is not counted in this
calculation because the source host does not use a forwarding table; the packet is delivered
to the default router.
Figure (below) shows the concept of hop count advertised by three routers from a source
host to a destination host.
In RIP, the maximum cost of a path can be 15, which means 16 is considered as infinity (no
connection).
For this reason, RIP can be used only in autonomous systems in which the diameter ofthe
AS is not more than 15 hops.
Forwarding Table
A forwarding table in RIP is a three-column table in which the first column is the address of the
destination network, the second column is the address of the next router to which the packet should
be forwarded, and the third column is the cost (the number of hops) to reach the destination
network.
Figure shows the three forwarding tables for the routers in Figure (above).
Note that the first and the third columns together convey the same information as does a distance
vector, but the cost shows the number of hops to the destination networks.
RIP Implementation
RIP is implemented as a process that uses the service of UDP on the port number 520.
RIP is a routing protocol to help IP route its datagrams through the AS, the RIP messages are
encapsulated inside UDP user datagrams, which in turn are encapsulated inside IP datagrams.
That is, RIP runs at the application layer, but creates forwarding tables for IP at the network
layer.
RIP Messages
Two RIP processes, a client and a server, need to exchange messages. RIP-2 defines the format
of the message, as shown in Figure.
The message Entry, can be repeated as needed in a message. Each entry carries the information
related to one line in the forwarding table of the router that sends the message.
RIP Algorithm
Instead of sending only distance vectors, a router needs to send the whole contents of its
forwarding table in a response message.
The receiver adds one hop to each cost and changes the next router field to the address of
the sending router.
The received router selects the old routes as the new ones except in the following three
cases:
1. If the received route does not exist in the old forwarding table, it should be added to the
route.
2. If the cost of the received route is lower than the cost of the old one, the received route
should be selected as the new one.
3. If the cost of the received route is higher than the cost of the old one, but the value of the
next router is the same in both routes, the received route should be selected as the new one.
Timers in RIP
RIP uses three timers to support its operation.
The periodic timer controls the advertising of regular update messages. Each router has one
periodic timer that is randomly set to a number between 25 and 35 seconds (to prevent all
routers sending their messages at the same time and creating excess traffic). The timer
counts down; when zero is reached, the update message is sent, and the timer is randomly
set once again.
The expiration timer governs the validity of a route. When a router receives update
information for a route, the expiration timer is set to 180 seconds for that particular route.
Everytime a new update for the route is received, the timer is reset.
If there is a problem on an internet and no update is received within the allotted 180
seconds, the route is considered expired and the hop count of the route is set to 16, which
means the destination is unreachable.
Every route has its own expiration timer. The garbage collection timer isused to purge a
route from the forwarding table.
The garbage collection timer isused to purge a route from the forwarding table. When the
information about a routebecomes invalid, the router does not immediately purge that route
from its table.
Instead, it continues to advertise the route with a metric value of 16. At the same time, a
garbage collection timer is set to 120 seconds for that route. When the count reaches zero,
the route is purged from the table.
Open Shortest Path First (OSPF) is an intradomain routing protocol like RIP. It is based on the
link-state routing protocol.
Metric
In OSPF, like RIP, the cost of reaching a destination from the host is calculated from the
source router to the destination network.
However, each link (network) can be assigned a weight based on the throughput, round-trip
time, reliability, and so on
Figure (below) shows the idea of the cost from a router to the destination host network.
Forwarding Tables
Each OSPF router can create a forwarding table after finding the shortest-path tree between itself
and the destination using Dijkstra’s algorithm.
Fig: Areas in AS
OSPF Implementation
OSPF is implemented as a program in the network layer, using the service of the IP for
propagation. An IP datagram that carries a message from OSPF sets the value of the
protocol field to 89. This means that, the OSPF messages are encapsulated inside
datagrams.
OSPF has two versions: version 1 and version 2.
OSPF Messages
OSPF is a very complex protocol; it has five different types of messages.
Fig: OSPF message format
The hello message (type 1) is used by a router to introduce itself to the neighbors.
The database description message (type 2) is sent in response to the hello message to allow
a newly joined router to acquire the full LSDB.
The link state request message (type 3) is sent by a router that needs information about a
specific LS.
The link-state update message (type 4) is the main OSPF message used for building the
LSDB. This message, has five different versions (router link, network link, summary link
to network, summary link to AS border router, and external link).
The link-state acknowledgment message (type 5) is used to create reliability in OSPF; each
router that receives a link-state update message needs to acknowledge it.
OSPF Algorithm
The Border Gateway Protocol version 4 (BGP4) is the only inter domain routing protocol
used in the Internet today.
Consider an example of an internet with four autonomous systems. AS2, AS3, and AS4 are
stub autonomous systems; AS1 is a transient one.
Here, data exchange between AS2, AS3, and AS4 should pass through AS1.
Each router in each AS knows how to reach a network that is in its own AS, but it does not
know how to reach a network in another AS.
To enable each router to route a packet to any network in the internet, we first install a
variation of BGP4, called external BGP (eBGP), on each border router (the one at the edge
of each AS which is connected to a router at another AS).
We then install the second variation of BGP, called internal BGP (iBGP), on allrouters.
The border routers will be running three routing protocols (intradomain, eBGP, and iBGP),
but other routers are running two protocols (intradomain and iBGP).
BGP is a point-to-point protocol. When the software is installed on two routers, they try to
create a TCP connection using the well-known port 179. The two routers that run the BGP
processes are called BGP peers or BGP speakers.
The eBGP variation of BGP allows two physically connected border routers in two
different ASs to form pairs of eBGP speakers and exchange messages.
The routers that we use in figure has three pairs: R1-R5, R2-R6, and R4-R9.
The connection between these pairs is established over three physical WANs (N5,N6, and
N7). There is a need for a logical TCP connection to be created over the physical
connection to make the exchange of information possible.
Each logical connection in BGP is referred to as a session. This means that we need three
sessions, as shown in Figure (below).
Fig: EBGP operation
Messages
BGP four types of messages for communication between the BGP speakers across the ASs and
inside an AS:
Four messages are
Open
Update
Keepalive
notification .
(Note that BGP can withdraw several destinations that were advertised before, but it can only
advertise one new destination in a single update message)
Keepalive Message: The BGP peers that are running exchange keepalive messages regularly
(before their hold time expires) to tell each other that they are alive.
Notification: A notification message is sent by a router whenever an error condition is detected or
a router wants to close the session.
Performance
BGP performance can be compared with RIP. BGP speakers exchange a lot of messages to
create forwarding tables, but BGP is free from loops and count-to-infinity.
MULTICASTING
MULTICASTING
In multicasting, there is one source and a group of destinations. The relationship is one to
many.
In this type of communication, the source address is a unicast address, but the destination
address is a group address, a group of one or more destination networks inwhich there is at
least one member of the group that is interested in receiving the multicast datagram.
Multicasting starts with a single packet from the source that is duplicated by therouters. The
destination address in each packet is the same for all duplicates.
(Note that only a single copy of the packet travels between any two routers)
The Distance Vector Multicast Routing Protocol (DVMRP) is the extension of the Routing
Information Protocol (RIP) which is used in unicast routing. It uses the source based tree
approach to multicasting.
1. The router uses an algorithm called reverse path forwarding (RPF) to simulate creating
part of the optimal source-based tree between the source and itself.
2. The router uses an algorithm called reverse path broadcasting (RPB) to create a broadcast
(spanning) tree whose root is the router itself and whose leaves are all networks in the internet.
3. The router uses an algorithm called reverse path multicasting (RPM) to create a multicast
tree by cutting some branches of the tree that end in networks with no member in the group.
The first algorithm, reverse path forwarding (RPF), forces the router to forward a multicast
packet from one specific interface: the one which has come through the shortest path from
the source to the router.
The router does not know the shortest path from the source to itself, but it can find which is
the next router in the shortest path from itself to the source (reverse path).
The router simply consults its unicast forwarding table, pretending that it wants to send a
packet to the source; the forwarding table gives the next router and the interface the
message that the packet should be sent out in this reverse direction.
The router uses this information to accept a multicast packet only if it arrives from this
interface. This is needed to prevent looping. In multicasting, a packet may arrive at thesame
router that has forwarded it.
If the router does not drop all arrived packets except the one, multiple copies of the packet
will be circulating in the internet.
The RPF algorithm helps a router to forward only one copy received from a source and
drop the rest.
When we think about broadcasting in the second step, we need to remember that
destinations are all the networks (LANs) in the internet. To be efficient, we need to prevent
each network from receiving more than one copy of the packet.
If a network is connected to more than one router, it may receive a copy of the packet
from each router. RPF cannot help here, because a network does not have the intelligence
to apply the RPF algorithm; we need to allow only one of the routers attached to a network
to pass the packet to the network.
One way to do so is to designate only one router as the parent of a network related to a
specific source. When a router that is not the parent of the attached network receives a
multicast packet, it simply drops the packet.
There are several ways that the parent of the network related to a network can be selected;
one way is to select the router that has the shortest path to the source (using the unicast
forwarding table, again in the reverse direction).
In other words, after this we have a shortest-path tree with the source as the root and all
networks (LANs) as the leaves.
Every packet started from the source reaches all LANs in the internet travelling the shortest
path. Figure shows how RPB can avoid duplicate reception in a network by assigning a
designated parent router, R1, for network N.
Fig: Reverse path broadcasting
To increase efficiency, the multicast packet must reach only those networks that have active
members for that particular group. This is called reverse path multicasting (RPM).
To change the broadcast shortest-path tree to a multicast shortest-path tree, each router
needs to prune (make inactive) the interfaces that do not reach a network with active
members corresponding to a particular source-group combination.
This step can be done bottom-up, from the leaves to the root. At the leaf level, the routers
connected to the network collect the membership information using the IGMP protocol.
The parent router of the network can then disseminate this information upward using the
reverse shortest-path tree from the router to the source, the same way as the distance vector
messages are passed from one neighbor to another.
In multicasting, each router needs to have a database, as with the case of unicast distance-
vector routing, to show which interface has an active member in a particulargroup.
A router follow these steps to forward a multicast packet received from source S and to be
sent to destination G (a group of recipients):
The router uses the Dijkstra algorithm to create a shortest-path tree with S as theroot and all
destinations in the internet as the leaves. Note that this shortest-path tree is different from
the one the router normally uses for unicast forwarding, in which the root of the tree is the
router itself.
Here, the root of the tree is the source of the packet defined in the source address of the
packet. The router finds itself in the shortest-path tree created in the first step. In other
words, the router creates a shortest-path sub tree with itself as the root of the sub tree.
The shortest-path subtree is actually a broadcast subtree with the router as the root and all
networks as the leaves.
The IGMP protocol is used to find the information at the leaf level. The router can now
forward the received packet out of only those interfaces that correspond to the branches of
the multicast tree.
Protocol Independent Multicast (PIM) is the name given to a common protocol that needs a
unicast routing protocol for its operation, but the unicast protocol can be either a distance-
vector protocol or a link-state protocol.
PIM uses the forwarding table of a unicast routing protocol to find the next router in a path
to the destination, but it does not matter how the forwarding table is created.
Feature of PIM:
When the number of routers with attached members is large relative to the number of
routers in the internet, PIM works in the dense mode and is called PIM-DM.
In this mode, the protocol uses a source-based tree approach.
PIM-DM uses only two strategies described in DVMRP: RPF and RPM. The two steps used in
PIM-DM .
1. A router that has received a multicast packet from the source S destined for the group G first
uses the RPF strategy to avoid receiving a duplicate of the packet. It consults the forwarding table
of the unicast protocol to find the next router if it wants to send a message to the source S (in the
reverse direction).
If the packet has not arrived from the next router in the reverse direction, it drops the packet and
sends a prune (remove things which are not needed) message in that direction to prevent receiving
future packets related to (S, G).
2. If the packet in the first step has arrived from the next router in the reverse direction, the
receiving router forwards the packet from all its interfaces except the one from which the packet
has arrived.
Note that this is broadcasting instead of a multicasting if the packet is the first packet from
the source S to group G.
Each router downstream that receives an unwanted packet sends a prune message to the
router upstream, and eventually the broadcasting is changed to multicasting.
Figure (above) PIM-DM. The first packet is broadcast to all networks, which have or do
not have members. After a prune message arrives from a router with no member, the second
packet is only multicast.
When the number of routers with attached members is small relative to the number of
routers in the internet, PIM works in the sparse mode and is called PIM-SM.
In this environment, PIM-SM uses a group-shared tree approach to multicasting.
The core router in PIM-SM is called the rendezvous point (RP). Multicast communication is
achieved in two steps.
Any router that has a multicast packet to send to a group of destinations first encapsulates
the multicast packet in a unicast packet (tunneling) and sends it to the RP. The RP then
decapsulates the unicast packet and sends the multicast packet to its destination.
PIM-SM uses a complex algorithm to select one router among all routers in the internet as
the RP for a specific group. This means that if we have m active groups, we need m RPs,
although a router may serve more than one group.
After the RP for each group is selected, each router creates a database and stores the group
identifier and the IP address of the RP for tunneling multicast packets to it.
PIM-SM uses a spanning multicast tree rooted at the RP with leaves pointing to designated
routers connected to each network with an active member. A very interesting point in PIM-
SM is the formation of the multicast tree for a group.
To create a multicast tree rooted at the RP, PIM-SM uses join and prune messages.
Figure (below) shows the operation of join and prune messages in PIM-SM.
First, three networks join group G1 and form a multicast tree. Later, one of the networks
leaves the group and the tree is pruned.
The join message is used to add possible new branches to the tree; the prune message is
used to cut branches that are not needed.
When a designated router finds out that a network has a new member in the corresponding
group (via IGMP), it sends a join message in a unicast packet destined for the RP.
The packet travels through the unicast shortest-path tree to reach the RP. Any router in the
path receives and forwards the packet, but at the same time, the router adds two pieces of
information to its multicast forwarding table.
The number of the interface through which the join message was sent to the RP is marked (if not
already marked) as the only interface through which the multicast packet destined for the same
group should be received.
In this way, the first join message sent by a designated router creates a path from the RP to one of
the networks with group members.
To avoid sending multicast packets to networks with no members, PIM-SM uses the prune
message.