# Routing Algorithms

Networking and Communications

Oct 28, 2013 (4 years and 10 months ago)

168 views

Routing Algorithms

Network Layer

4
-
2

Dynamic Routing

The routing table is updated using the
routing
protocols
. When there is a change in the Internet
such as router breakdown or link failure, the
routing protocols update all the information in the
routing tables.

For the dynamic routing, routers should exchange
routing information

using routing protocols.

routing information

information about network topology, delay, etc.

routing protocol

It specifies the routing messages and procedures to
exchange the routing information to determine routes.

Network Layer

4
-
3

Internet Routing Architecture

Internet architecture from routing’s views

It is unrealistic to apply a single routing protocol to the
worldwide Internet because of its size.

So, the worldwide Internet is divided into many groups,

These independent groups of networks are called the
autonomous systems(AS)

which are assigned 16 bits long AS
number.

AS

“a group of networks and routers controlled by a single

Each AS needs to inform its routing information of other
ASs. For this purpose each AS has more than one
border
routers.

Network Layer

4
-
4

Subnet
1.2

Subnet
1.4

Subnet
2.3

Subnet
2.2

Subnet
2.4

Subnet
2.1

Subnet
1.3

R1

R2

R3

R4

R5

R6

R7

R8

Autonomous System 1

Autonomous System 2

LEGEND:

Interior Gateway Protocol

Exterior Gateway Protocol

Subnet
1.1

Network Layer

4
-
5

Internet Routing Protocols

Interior Gateway Protocol (IGP)

IGP is operated within each AS.

Each AS can operate its own IGP.

Most well
-
known IGPs

RIP(Routing Information Protocol)

OSPF(Open Shortest Path Find)

Exterior Gateway Protocol (EGP)

To exchange packets between AS, the AS border routers
should exchange the routing information.

EGP is the routing protocol between ASs.

BGP(Border Gateway Protocol)

Network Layer

4
-
6

IGPs

Routing

protocol

Shortest path
algorithm

Routing

algorithm

RIP

IGRP

Bellman
-
Ford
algorithm

Distance Vector
algorithm

OSPF

IS
-
IS

Dijstra algorithm

algorithm

Network Layer

4
-
7

Distance Vector Algorithm

(assume that the metric is delay)

Step 1
: Each router exchange ECHO packet to measure the time

to reach each neighboring routers.

Step 2
: Each router send this information to its neighboring routers

periodically.

The information contains the times to reach all other routers.

Step 3
: Each router determines the mim. time to reach all other routers

using step 1 and 2. And update its own routing table.

Network Layer

4
-
8

Example

J

A

C

Echo
패킷

m sec

T
i

sec

E

B

D

(T
AB
, T
AC
, T
, T
AE
)

T
B
= m + T
AB

T
C

= m + T
A
C

T
D

= m + T
A
D

T
E

= m + T
A
E

Network Layer

4
-
9

Example: sample network

A

E

I

B

C

D

F

G

H

J

K

L

Network Layer

4
-
10

new information from A, I, H, K

Network Layer

4
-
11

New information on the
neighboring nodes

Suppose that the delay from J to A, I,H, and K
8,10,12,6 secs respectively.

Then what is the next hop router and the delay to
reach G from J?

J
---
> A
-------
> G

8 + 18 = 26

J
----
> I
-------
> G

10 + 31 = 41

J
----
> H
------
> G

12 + 6 = 18 (best route for JG)

J
----
> K
------
> G

6 + 31 = 37

Network Layer

4
-
12

Updated routing table of J

Network Layer

4
-
13

Overview

Each node collects the topology information of the whole
network, and then computes the shortest paths to reach
each node using the
Dijkstra algorithm
.

The routing protocols such as ISO’s
IS
-
IS
and IETF’s
OSPF

belong to this algorithm, and they will replace the
DVA routing protocol.

Examples

OSPF for TCP/IP

ISO’s IS
-
IS for CLNS and IP

DEC’s DNA Phase V

Network Layer

4
-
14

Discover the neighboring node. (send Hello message
periodically)

Measure the link costs to the neighboring nodes.

Make the
.

After receiving the Link State packets from all other
nodes, make the
.

Compute the
shortest paths

to reach all other nodes
based on the link state database.

Network Layer

4
-
15

Step1
:
Collect the link state information from the
neighboring nodes and make the link state packets.

A

B

D

C

E

F

5

2

3

1

2

1

1

3

3

2

A

seq#

age

B

2

C

5

D

2

D

seq#

age

A

2

B

2

C

3

E

1

C

seq#

age

A

5

B

3

D

3

E

1

F

1

B

seq#

age

A

2

C

3

D

2

E

seq#

age

C

1

D

1

F

1

F

seq#

age

C

1

E

1

Network Layer

4
-
16

Step 2:

Propagate the link state information to all
other nodes.

Make the

Use the
flooding
.

Step 3:

Compute the shortest path.

Based on the link state information, the node makes the

that represents the whole network
topology.

Compute the shortest path using the
Dijkstra algorithm.

Network Layer

4
-
17

A

B

D

C

E

F

5

2

3

1

2

1

1

3

3

2

Cost

Cost

A
-
B

A
-
C

A
-
D

B
-
A

B
-
C

B
-
D

C
-
A

2

5

2

2

3

2

5

D
-
E

E
-
C

E
-
D

E
-
F

E
-
C

E
-
E

1

1

1

1

1

1

C
-
B

C
-
D

C
-
E

C
-
F

D
-
A

D
-
B

D
-
C

3

3

1

1

2

2

3

Cost

Network Layer

4
-
18

Internet Routing Protocols

Network Layer

4
-
19

Intra
-
AS Routing

Also known as
Interior Gateway Protocols (IGP)

Most common Intra
-
AS routing protocols:

RIP
: Routing Information Protocol

OSPF
: Open Shortest Path First

IGRP: Interior Gateway Routing Protocol (Cisco
proprietary)

Network Layer

4
-
20

RIP

IETF standard routing protocol

Based on the
Distant Vector algorithm

The
hop count

is used as the metric.

The hop count is 1 for an adjacent network.

The hop count 16 means infinity
.(network is not connected.)

Each router exchange routing information
every 30
secs
.

The routing information contains the whole routing table
entries.

within AS

It uses the UDP port number 520.

It was first implemented in the UNIX 4.2 BSD.

Network Layer

4
-
21

Procedure

a

response

RIP

message

1
.

one

hop

to

the

hop

count

for

each

destination

2
.

Repeat

the

following

steps

for

each

destination
:

If

(destination

not

in

the

routing

table)

the

information

to

the

table

else

if

(next
-
hop

field

is

the

same)

replace

entry

in

the

table

with

the

one

else

if

hop

count

smaller

than

one

in

the

table

it

to

the

routing

table

else

do

nothing

3
.

Return

Network Layer

4
-
22

RIP: Example(1)

Network Layer

4
-
23

RIP: Example(2)

Network Layer

4
-
24

RIP: Example(2)

Network Layer

4
-
25

RIP message

Command

version

family

reserved

All

0
s

Network

All

0
s

All

0
s

distance

Command

:

request

(
1
)

or

response

(
2
)

The

unsolicited

response

is

transmitted

periodically

every

30

secs
.

Family
:

TCP/IP

(
2
)

distance

:

hop

count

반복

Network Layer

4
-
26

Problems of DVA(RIP)

Problems

scalability

Slow convergence

In particular, when the shortest paths are changing
rapidly, the inconsistency between routing tables can
happen, since the updated routing information
propagates slowly.

count
-
to
-
infinity problem

Not proper to be expanded to multicast routing
protocol.

Network Layer

4
-
27

Good news go travels quickly!

good news go fast!

When the connection with the network 1 is added, the routing
table can reach the stability after 2 message exchanges.

up

R1

R3

R2

Net 1

Net D R

1 1 R1

Net D R

1

-

Net D R

1

-

Net D R

1 1 R1

Net D R

1 2 R1

Net D R

1

-

Net D R

1 1 R1

Net D R

1 2 R1

Net D R

1 3 R2

(N1,1)

(N1,1)

(N1,2)

(N1,2)

Initial state

time

Note: (x, y) = (destination network, Distance)

distance

next router

destination

Network Layer

4
-
28

Count
-
to
-
infinity Problem(1)

crash

R1

R3

R2

Net 1

Net D R

1

-

Net D R

1 2 1

Net D R

1 3 2

Net D R

1 3 2

Net D R

1 4 3

Net D R

1 3 2

Net D R

1 5 2

Net D R

1 4 3

Net D R

1 5 2

Net D R

1 5 2

Net D R

1 6 1

Net D R

1 5 2

Net D R

1

-

Net D R

1

-

Net D R

1

-

(N1,2)

(N1,

)

(N1,4)

(N1,3)

(N1,4)

(N1,5)

(N1,3)

(N1,2)

(N1,3)

(N1,4)

(N1,5)

(N1,4)

.

.

.

.

.

.

.

.

.

Initial state

time

Network Layer

4
-
29

Count
-
to
-
infinity Problem(2)

In the previous picture, when the connection between R1 and
network 1 is broken, the cost (distance) to network 1 grows to

When the cost reaches to 16, the router knows that the
connection is broken.

When the bad news occur, it takes a long time to be aware of
that.(slow convergence)

Solutions

Split Horizon

Hold down

Poison reverse

Network Layer

4
-
30

Solutions to the Count
-
to
-
infinity Problem

Split horizon update

(
with

Poison Reverse
)

a certain network should send information about that
network to other routers as infinity (distance=16)

It cannot be applied to all kinds of topologies.

Route poisoning

If a router receives the information that the hop count
to a certain network increases, it sets the hop count=16,
and send it to other routers, suspecting a loop might
occur.

Network Layer

4
-
31

Split Horizon

A router should never send the routing update
information to the interface through which it

Net
1

Net
2

Net
3

Net
2

1

Net
3

2

Net
3

1

A

B

Net
1

1

Net
1

2

Net
2

1

routing

message

routing

message

Network Layer

4
-
32

Poison reverse

When a router sends the routing update message
to all routers, it says to the interface from which
that the cost to the network is infinity (cost=16).

Net
1

Net
2

Net
3

Net
1

16

Net
2

1

Net
3

2

A

B

routing

message

Net
1

1

Net
2

16

Net
3

16

Net
1

16

Net
2

16

Net
3

1

routing

message

Net
1

2

Net
2

1

Net
3

16

Network Layer

4
-
33

--
>

routes via neighbor invalidated

tables changed)

link failure info quickly propagates to entire net

poison reverse used to prevent ping
-
pong loops
(infinite distance = 16 hops)

Network Layer

4
-
34

RIP Table processing

RIP routing tables managed by
application
-
level

process called route
-
d (daemon)

repeated

physical

network forwarding

(IP) table

Transprt

(UDP)

routed

physical

network

(IP)

Transprt

(UDP)

routed

forwarding

table

Network Layer

4
-
35

OSPF (Open Shortest Path First)

open”: publicly available

LS packet dissemination

Topology map at each node

Route computation using Dijkstra’s algorithm

router

entire

AS (via
flooding)

Carried in OSPF messages directly over IP (rather than TCP
or UDP

Network Layer

4
-
36

OSPF “advanced” features (not in RIP)

Security:

all OSPF messages authenticated (to
prevent malicious intrusion)

Multi
ple same
-
cost
path
s allowed (only one path in
RIP)

For each link, multiple cost metrics for different
TOS
(e.g., satellite link cost set “low” for best effort;
high for real time)

Integrated uni
-

and
multicast

support:

Multicast OSPF (MOSPF) uses same topology data
base as OSPF

Hierarchical

OSPF in large domains.

Network Layer

4
-
37

Hierarchical OSPF

Network Layer

4
-
38

Hierarchical OSPF

Two
-
level hierarchy:

local area, backbone.

-

each nodes has detailed area topology; only know
direction (shortest path) to nets in other areas.

Area border routers:

“summarize” distances to nets
in own area, advertise to other Area Border routers.

Backbone routers:

run OSPF routing limited to
backbone.

Boundary routers:

connect to other AS’s.

Network Layer

4
-
39

Internet inter
-
AS routing: BGP

BGP (Border Gateway Protocol):

the

de
facto standard

BGP provides each AS a means to:

1.
Obtain subnet reachability information from
neighboring ASs.

2.
Propagate the reachability information to all
routers internal to the AS.

3.
Determine “good” routes to subnets based on
reachability information and policy.

Allows a subnet to advertise its existence
to rest of the Internet:
“I am here”

Network Layer

4
-
40

Anonymous System(AS)

Subnet
1.2

Subnet
1.4

Subnet
2.3

Subnet
2.2

Subnet
2.4

Subnet
2.1

Subnet
1.3

R1

R2

R3

R4

R5

R6

R7

R8

Autonomous System 1

Autonomous System 2

LEGEND:

Interior gateway protocol

Exterior gateway protocol

Subnet
1.1

Network Layer

4
-
41

Autonomous System (AS)

AS

“ a set of routers under a single technical
Protocol and common metrics to route packets
within the AS and using an Exterior Gateway
Protocol to route packets to other ASs”

(RFC
1771)

Today AS may use more than one IGP, with
potentially several sets of metrics.

The autonomous system designator is a 16
-
bit
number, with a range of 1 to 65535. A range of AS
numbers, 64512 through 65530, is reserved for
private use, much like the private IP addresses.

Network Layer

4
-
42

Path attributes & BGP routes

attributes.

prefix + attributes = “route”

Two important attributes:

AS
-
PATH:

contains the ASs through which the advert
for the prefix passed: AS 67 AS 17

NEXT
-
HOP:

Indicates the specific internal
-
AS router to
next
-
hop AS. (There may be multiple links from current
AS to next
-
hop
-
AS.)

import policy

to accept/decline.

Network Layer

4
-
43

BGP messages

BGP messages exchanged using TCP.

BGP messages:

OPEN:

opens TCP connection to peer and
authenticates sender

UPDATE:

advertises new path (or withdraws old)

KEEPALIVE

keeps connection alive in absence of

reports errors in previous msg;
also used to close connection

Network Layer

4
-
44

AS 1

AS 5

AS 2

AS 3

1

1

BGP Example

R1

R2

R3

R51

R52

AS 4

R4

N3

N2

N1

Network Layer

4
-
45

BGP Example

R1

Obtain the network information in AS1 by
exchanging the IGP routing messages between
routers in AS1.

R1 sends BGP UPDATE message to all BGP
neighbors.

The UPDATE message includes:

AS_Path
: {AS1}

Next_Hop

NLRI:

{N1, N2, N3}

R2, R3

R2 and R3 that received the UPDATE message
can know that the networks in AS1 can be
reached via R1.

Network Layer

4
-
46

AS 1

AS 5

AS 2

AS 3

2

2

BGP Example

R1

R2

R3

R51

R52

AS 4

R4

N3

N2

N1

Network Layer

4
-
47

BGP Example

R2 sends to R51 the
UPDATE message

that
includes the following:

AS_Path
: {AS1, AS2}

Next_Hop

NLRI
: {N1, N2, N3}

R3 sends to R4 the
UPDATE message

that
includes the following:

AS_Path
: {AS1, AS3}

Next_Hop

NLRI
: {N1, N2, N3}

Network Layer

4
-
48

AS 1

AS 5

AS 2

AS 3

3

BGP Example

R1

R2

R3

R51

R52

AS 4

R4

N3

N2

N1

Network Layer

4
-
49

BGP Example

R4 sends to R52 the
UPDATE message

that
includes the following:

AS_Path
: {AS1, AS3, AS4}

Next_Hop

NLRI
: {N1, N2, N3}

Network Layer

4
-
50

AS 1

AS 5

AS 2

AS 3

BGP Example

R1

R2

R3

R51

R52

AS 4

R4

N3

N2

N1

Network Layer

4
-
51

BGP Example

R51 and R52

R51 that received the UPDATE message from R2 can know:

The networks in AS1 can be reached via R2

The path is {AS2, AS1}.

R52 that received the UPDATE message from R4 can know:

The networks in AS1 can be reached via R4

The path is {AS4, AS3, AS1}.

R51 and R52 exchange BGP UPDATE messages. They will
choose the better path.

Choosing the path, they refer to AS
-
path list in the UPDATE
message to find out:

Route loop(loop prevention)

Path selection based on the shortest path(shortest path vector)

Path selection based on AS policy(policy routing)

Network Layer

4
-
52

BGP route selection

Router may learn about more than 1 route
to some prefix. Router must select route.

Elimination rules:

1.
Local preference value attribute: policy
decision

2.
Shortest AS
-
PATH

3.
Closest NEXT
-
HOP router: hot potato routing

4.

Network Layer

4
-
53

BGP routing policy

A,B,C are
provider networks

X,W,Y are customer (of provider networks)

X is
dual
-
homed:

attached to two networks

X does not want to route from B via X to C

.. so X will not advertise to B a route to C

Network Layer

4
-
54

BGP routing policy (2)

A advertises to B the path AW

B advertises to X the path BAW

Should B advertise to C the path BAW?

No way! B gets no “revenue” for routing CBAW since neither
W nor C are B’s customers

B wants to force C to route to w via A

B wants to route
only
to/from its customers!

Network Layer

4
-
55

Why different Intra
-

and Inter
-
AS routing ?

Policy:

Inter
-
AS: admin wants control over how its traffic
routed, who routes through its net.

Intra
-
AS: single admin, so no policy decisions needed

Scale:

hierarchical routing saves table size, reduced update
traffic

Performance
:

Intra
-
AS: can focus on performance

Inter
-
AS: policy may dominate over performance