Unicast Routing Protocols
Unicast Routing Protocols
Lecture No. 15
Network layer protocols
• Unicast Routing Protocols (RIP, OSPF, and BGP):
Unicast communication means communication
between one sender and one receiver, a one-to-one
communication.
In this lecture, we discuss how the routers create their
routing tables to support unicast communication.
The Internet is divided into administrative areas
known as autonomous systems to efficiently handle
the exchange of routing information.
We will study one dominant routing protocols used
inside an autonomous system and one routing
protocol used for exchange of routing information
between autonomous systems.
2
• Static versus Dynamic Routing Tables:
A routing table can be either static or dynamic.
A static table is one with manual entries.
A dynamic table, on the other hand, is one that is
updated automatically when there is a change
somewhere in the internet.
Today, an internet needs dynamic routing tables.
The tables need to be updated as soon as there is a
change in the internet.
For instance, they need to be updated when a link
is down, and they need to be updated whenever a
better route has been found.
3
• Routing Protocol:
Routing protocols have been created in response to the
demand for dynamic routing tables.
A routing protocol is a combination of rules and
procedures that lets routers in the internet inform each
other of changes. It allows routers to share whatever
they know about the internet or their neighborhood.
The routing protocols also include procedures for
combining information received from other routers.
Routing protocols can be either an interior protocol or
an exterior protocol.
An interior protocol handles intradomain routing ; an
exterior protocol handles interdomain routing.
4
• Intra- and Inter-domain Routing:
• Today, an internet can be so large that one routing
protocol cannot handle the task of updating the
routing tables of all routers.
• For this reason, an internet is divided into
autonomous systems.
• An autonomous system (AS) is a group of networks
and routers under the authority of a single
administration. Routing inside an autonomous
system is referred to as intra-domain routing.
• Routing between autonomous systems is referred to
as inter-domain routing.
5
• Each autonomous system can choose one or more intradomain
routing protocols to handle routing inside the autonomous
system.
• However, only one interdomain routing protocol handles
routing between autonomous systems. See Figure below.
6
Several intra-domain and inter-domain routing
protocols are in use.
In this lecture, we cover only the most popular ones.
We discuss one intra-domain routing protocols:
distance vector.
We also introduce one inter-domain routing protocol:
path vector routing (see Figure below).
Routing Information Protocol (RIP) is the
implementation of the distance vector protocol.
Border Gateway Protocol (BGP) is the implementation
of the path vector protocol.
RIP is interior routing protocols; BGP is an exterior
routing protocol.
7
8
• A distance-vector routing protocol in data networks determines
the best route for data packets based on distance. Distance-
vector routing protocols measure the distance by the number of
routers a packet has to pass, one router counts as one hop.
• Some distance-vector protocols also take into account network
latency and other factors that influence traffic on a given route.
• To determine the best route across a network, routers, on which
a distance-vector protocol is implemented, exchange information
with one another, usually routing tables plus hop counts for
destination networks and possibly other traffic information.
• Distance-vector routing protocols also require that a router
informs its neighbours of network topology changes periodically.
• Distance-vector routing protocols use the Bellman–Ford
algorithm to calculate the best route.
• Another way of calculating the best route across a network is based on
link cost, and is implemented through link-state routing protocols.
9
• Bellman-Ford Algorithm:
• Let us briefly discuss the Bellman-Ford algorithm.
• The algorithm can be used in many applications in graph theory.
• If we know the cost between each pair of nodes, we can use the
algorithm to find the least cost (shortest path) between any two
nodes.
• Figure below shows a map with nodes and lines.
10
• Distance vector algorithm
• 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.
11
• Example
• Figure below shows the initial routing table for an AS. Note that
the figure does not mean that all routing tables have been created
at the same time; each router creates its own routing table when it
is booted.
12
• Example
• Now assume router A sends four records to its neighbors, routers
B, D, and C.
• Figure below shows the changes in B’s routing table when it
receives these records.
• We leave the changes in the routing tables of other neighbors as
exercise.
13
Example
Figure below shows the final routing tables for routers in
Figure in slide 12.
14
• Routing Information Protocol (RIP):
• The Routing Information Protocol (RIP) is an intradomain
(interior) routing protocol used inside an autonomous system. It is a
very simple protocol based on distance vector routing. RIP
implements distance vector routing directly with some considerations:
• 1. In an autonomous system, we are dealing with routers and
networks (links), what was described as a node.
• 2. The destination in a routing table is a network, which means the
first column defines a network address.
• 3. The metric used by RIP is very simple; the distance is defined as
the number of links (networks) that have to be used to reach the
destination. For this reason, the metric in RIP is called a hop count.
• 4. Infinity is defined as 16, which means that any route in an
autonomous system using RIP cannot have more than 15 hops.
• 5. The next node column defines the address of the router to which
the packet is to be sent to reach its destination.
15
• Figure below shows an autonomous system with seven
networks and four routers.
16
RIP Message Format:
The format of the RIP message is shown in Figure below.
❑Command.
This 8-bit field specifies the type of message: request (1) or
response (2).
❑Version.
This 8-bit field defines the version. 17
❑Family.
This 16-bit field defines the family of the protocol used. For
TCP/IP the value is 2.
❑Network address.
The address field defines the address of the destination
network.
RIP has allocated 14 bytes for this field to be applicable to
any protocol.
However, IP currently uses only 4 bytes. The rest of the
address is filled with 0s.
❑Distance.
This 32-bit field defines the hop count (cost) from the
advertising router to the destination network.
18
Requests and Responses:
RIP has two types of messages: request and response.
1- Request
A request message is sent by a router that has just come up or
by a router that has some time-out entries. A request can ask
about specific entries or all entries (see Figure below).
19
2- Response
A response can be either solicited or unsolicited.
• A solicited response is sent only in answer to a request. It contains
information about the destination specified in the corresponding
request.
• An unsolicited response, on the other hand, is sent periodically,
every 30 seconds or when there is a change in the routing table.
The response is sometimes called an update packet. Figure shows the
response message format.
Response
message
format
20
Timers in RIP:
RIP uses three timers to support its operation (see
Figure below).
The periodic timer controls the sending of messages,
the expiration timer governs the validity of a route,
and the garbage collection timer advertises the failure
of a route.
21
• Path vector routing
• Distance vector and link state routing are both interior
routing protocols.
• They can be used inside an autonomous system as intra-domain
or intra-AS (as sometimes are called), but not between
autonomous systems.
• Both of these routing protocols become intractableص==عبا==لمع=ا==لجة
when the domain of operation becomes large.
• Distance vector routing is subject to instability if there is more
than a few hops in the domain of operation.
• Link state routing needs a huge amount of resources to
calculate routing tables. It also creates heavy traffic because of
flooding.
• There is a need for a third routing protocol which we call path
vector routing.
22
• Path vector routing is exterior routing protocol proved
to be useful for inter-domain or inter-AS routing as it is
sometimes called.
• In distance vector routing, a router has a list of networks
that can be reached in the same AS with the corresponding
• cost (number of hops).
• In path vector routing, a router has a list of networks that
can be reached with the path (list of ASs to pass) to reach
each one.
• In other words, the domain of operation of the distance
vector routing is a single AS; the domain of operation of
the path vector routing is the whole Internet.
• The distance vector routing tells us the distance to each
network; the path vector routing tells us the path.
23
• In Figure, router R1 in AS1 can send its reachability list to router R2.
• Router R2, after combining its reachability list, can send the result to both R1
and R3. Router R3 can send its reachability list to R2, which in turn improves
its routing table, and so on.
24
25
• Border Gateway Protocol (BGP):
• Border Gateway Protocol (BGP) is an inter-domain routing
protocol using path vector routing.
• It first appeared in 1989 and has gone through four versions.
• Stub AS
• A stub AS has only one connection to another AS.
• The inter-domain data traffic in a stub AS can be either
created or terminated in the AS.
• The hosts in the AS can send data traffic to other ASs.
• The hosts in the AS can receive data coming from hosts in
other ASs.
• Data traffic, however, cannot pass through a stub AS.
• A stub AS is either a source or a sink.
• A good example of a stub AS is a small corporation or a
small local ISP.
27
• Multi-homed AS
• A multi-homed AS has more than one connection to other ASs,
but it is still only a source or sink for data traffic.
• It can receive data traffic from more than one AS.
• It can send data traffic to more than one AS, but there is no
transient traffic.
• It does not allow data coming from one AS and going to another
AS to pass through.
• A good example of a multi-homed AS is a large corporation that is
connected to more than one regional or national AS that does not
allow transient traffic.
• Transit AS
• A transit AS is a multi-homed AS that also allows transient traffic.
Good examples of transit ASs are national and international ISPs
(Internet backbones).
28
• Path Attributes
• The path was presented as a list of autonomous
systems, but is, in fact, a list of attributes.
• Each attribute gives some information about the
path.
• The list of attributes helps the receiving router
make a better decision when applying its policy.
• Attributes are divided into two broad categories:
well-known and optional.
29
• A wellknown attribute is one that every BGP router must
recognize.
• An optional attribute is one that needs not be recognized by
every router.
• Well-known attributes are themselves divided into two
categories: mandatory and discretionary.
• Well-known mandatory: Attributes of this type must be
understood by all BGP implementations and must EXIST in the
BGP update messages.
• Well-known discretionary: Attributes of this type must be
understood by all BGP implementations but they don’t have to
exist in all BGP updates to all neighbors.
• One well-known mandatory attribute is ORIGIN. This defines
the source of the routing information (RIP, OSPF, and so on).
• Another well-known mandatory attribute is AS_PATH.
30
• This defines the list of autonomous systems through
which the destination can be reached.
• Still another well-known mandatory attribute is NEXT-
HOP, which defines the next router to which the data
packet should be sent.
• The optional attributes can also be subdivided into two
categories: transitive and non-transitive.
• An optional transitive attribute is one that must be
passed to the next router by the router that has not
implemented this attribute.
• An optional non-transitive attribute is one that must be
discarded if the receiving router has not implemented it.
• Table below shows some BGP attributes:
31
32
• BGP Sessions
• The exchange of routing information between two routers
using BGP takes place in a session.
• A session is a connection that is established between two BGP
routers only for the sake of exchanging routing information. To
create a reliable environment, BGP uses the services of TCP.
• In other words, a session at the BGP level, as an application
program, is a connection at the TCP level.
• However, there is a subtle difference between a connection in
TCP made for BGP and other application programs.
• When a TCP connection is created for BGP, it can last for a long
timeفترة طويلةCCستمر لCCنيCمكنأCCي, until something unusual happens.
• For this reason, BGP sessions are sometimes referred to as semi-
permanent connections.
33
• External and Internal BGP
• BGP can have two types of sessions: external BGP (E-
BGP) and internal BGP (I-BGP) sessions.
• The E-BGP session is used to exchange information
between two speaker nodes belonging to two different
autonomous systems.
• The I-BGP session, on the other hand, is used to exchange
routing information between two routers inside an
autonomous system.
• Figure below shows the idea.
• The session established between AS1 and AS2 is an E-BGP
session.
• The two speaker routers exchange information they know
about networks in the Internet.
34
35
• Types of Packets in BGP:
• BGP uses four different types of messages:
• open, update, keepalive, and notification (see
Figure below).
36
• Packet Format
• All BGP packets share the same common header. Before studying the
different types of packets, let us talk about this common header (see next
Figure). The fields of this
• header are as follows:
• ❑Marker.
• The 16-byte marker field is reserved for authentication.
• ❑Length.
• This 2-byte field defines the length of the total message including the header.
• ❑Type.
• This 1-byte field defines the type of the packet. As we said before, we have
four types, and the values 1 to 4 define those types.
37
• Open Message
• To create a neighborhood relationship, a router running
BGP opens a TCP connection with a neighbor and sends an
open message.
• If the neighbor accepts the neighborhood relationship, it
responds with a keepalive message, which means that a
relationship has been established between the two routers.
• Update Message
• The update message is the heart of the BGP protocol.
• It is used by a router to
withdraw destinations that have been advertised
previously,
announce a route to a new destination, or both.
38
• Keepalive Message
• The routers (called peers in BGP parlance) running the BGP
protocols exchange keepalive messages regularly (before their
hold time expires) to tell each other that they are alive. The
keepalive message consists of only the common header.
39