Download Dijkstra`s algorithm

Document related concepts
no text concepts found
Transcript
application
transport
network
data link
physical
The Routing &
the IP
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
application
transport
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
application
transport
network
data link
physical
The network layer moves transport layer segments
from host to host in the network, to deliver them to
their destination. This layer involves each and every
host and router in the network.
Network layer functions
 transport packet from
sending to receiving hosts
 network layer protocols in
every host, router
three important functions:
 path determination: route
taken by packets from source
to destination - routing
algorithms
 switching: move packets from
router’s input to appropriate
router output
 call setup: some network
architectures require router
call setup along path before
data flows (connection
oriented networks)
application
transport
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
application
transport
network
data link
physical
Datagram networks:
the Internet model
 no call setup at network layer
 routers: do not maintain state for the end-to-end
connections

no network-level concept of a “connection”
 packets are typically routed using only destination
host ID which is carried in the packet

packets between same source-destination pair may take
different paths
application
transport
network
data link 1. Send data
physical
application
transport
network
2. Receive data
data link
physical
Routing
Routing protocol
Goal: determine a “good” path
(sequence of routers) thru
the network from the source
to the destination
Graph abstraction for
routing algorithms:
 graph nodes are routers
 graph edges are physical
links


link cost: delay, distance,
# of hops, rate structure
or congestion level = $$
Other costs??
5
2
A
B
2
1
D
3
C
3
1
5
F
1
E
2
 “good” path:
 typically means minimum
cost path
 other definitions also
possible
Hierarchical Routing
Our routing study thus far – an idealization
 all routers are identical
 the network is “flat”
… not true in practice
Why?
scale: with 55 million+
destination hosts:
 can’t store all destinations
in routing tables!
 routing table exchange
would swamp links!
administrative autonomy
 internet = network of
networks
 each network admin may
want to control routing in its
own network
Hierarchical Architecture of
the Internet
Legend
router
border router
Inter-AS level
connection
host
LAN
Intra Domain
level (AS)
intra domain
network (AS)
inter AS
network
LAN level
Hierarchical Routing
 aggregate routers into
regions, called
“autonomous systems”
(AS)
 routers in same AS run
same routing protocol


“intra-AS” routing
protocol
routers in different AS
can run different intraAS routing protocol
gateway routers
 special routers in AS
 run intra-AS routing
protocol with all other
routers in AS
 also responsible for
routing to destinations
outside AS
 run inter-AS routing
protocol with other
gateway routers
Internet AS Hierarchy
Inter-AS border (exterior gateway) routers
Intra-AS interior (gateway) routers
Internet inter-AS routing: BGP
 BGP (Border Gateway Protocol): the de facto
standard
 Path Vector protocol:
 similar to Distance Vector protocol
 each Border Gateway broadcasts to neighbors
(peers) the entire path (I.e, sequence of ASs)
to destination
Intra-AS and Inter-AS routing
C.b
a
C
Gateways:
B.a
A.a
b
A.c
d
A
a
b
c
a
c
B
b
•perform inter-AS
routing amongst
themselves
•perform intra-AS
routers with other
routers in their
AS
network layer
inter-AS, intra-AS
routing in
gateway A.c
data link layer
physical layer
Intra-AS and Inter-AS routing
C.b
a
Host
h1
C
b
A.a
Inter-AS
routing
between
A and B
A.c
a
d
c
b
A
Intra-AS routing
within AS A
B.a
a
c
B
Host
h2
b
Intra-AS routing
within AS B
 We’ll examine specific inter-AS and intra-AS
Internet routing protocols shortly
IP Addressing: introduction
 IP address: 32-bit
identifier for host or
router interface
 interface: connection
between host or
router and the
physical link



routers typically have
multiple interfaces
hosts typically have
only one
IP addresses are
associated with the
interface, not the
host or the router
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
223.1.3.2
223.1.3.1
dotted-decimal notation:
223.1.1.1 = 11011111 00000001 00000001 00000001
223
1
1
1
IP Addressing
 IP address:
 network part (high
order bits)
 host part (low order
bits)
 What’s a network ?
(from the IP address
perspective)
 device interfaces with
the same network part
of their IP address
 hosts can physically
reach each other
without an intervening
router
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
LAN
223.1.3.1
223.1.3.2
Example: network consisting of 3 IP
networks (for IP addresses starting
with 223, the first 24 bits are the
network address – more later)
IP Addresses
Given the notion of a “network”, let’s look closer at IP
addresses:
“classful” addressing class
A
0 network
host (24 bits)
27 = 127 networks
B
10
224 = 16.8 million+ hosts
network
host (16 bits)
214 = 16,384 networks
C
110
216 = 65,536 hosts
network
221 = 2 million+ networks
D
1110
multicast address
host (8 bits)
28 = 256 hosts
(28 bits)
228 = 268.4 million+ hosts
1.0.0.0 to
127.255.255.255
128.0.0.0 to
191.255.255.255
192.0.0.0 to
223.255.255.255
224.0.0.0 to
239.255.255.255
32 bits
What is the address space size (number of hosts) for each class?
Map of
the Internet
Abbreviated Format of the Address
Ranges
224.0.0.0 - 239.255.255.255
224/4
 The minimum & maximum values of the range:
 11100000.00000000.00000000.000000002
11101111.11111111.11111111.111111112
 E0.00.00.0016 … EF.FF.FF.FF16
 The first part of the abbreviation is the common byte(s)
in the range
 The second part of the abbreviation is the number of
bits, which are common for the all members of the range
The private address ranges
 Used locally
Never used in the Internet
 Gateways do not forward the packets addressed to
private addresses

 The network, which uses the private address
range can be connected to the Internet by the
NAT (Network Address Translation)
Name
Start of the range
End of the range
Subnet mask
Class A
10.0.0.0
10.255.255.255
255.0.0.0
Class B
172.16.0.0
172.31.255.255
255.255.0.0
Class C
192.168.0.0
192.168.255.255
255.255.255.0
IP addressing: CIDR
 classful addressing:


inefficient use of address space, address space exhaustion
e.g., class B network is allocated enough addresses for 65K
hosts, even if only 2K hosts exist in that network
 CIDR: Classless InterDomain Routing


network portion of address of arbitrary length
address format: a.b.c.d/x, where x is # bits in the network
portion of an address
network
part
host
part
11001000 00010111 00010000 00000000
200.23.16.0/23
IP addresses: how to get one?
Hosts (host portion):
 hard-coded by system admin in a file
 DHCP: Dynamic Host Configuration Protocol:
dynamically get address (RFC 2131): “plug-and-play”
 host broadcasts “DHCP discover” msg
 DHCP server responds with “DHCP offer” msg
 host requests IP address: “DHCP request” msg
 DHCP server sends address: “DHCP ack” msg
Why different Intra- and Inter-AS routing ?
Policy:
 Inter-AS: admin wants control over how its traffic is
routed, who routes through its net.
 Intra-AS: single admin, so no policy decisions needed
Scale:
 hierarchical routing saves table size, reduces update
traffic
Performance:
 Intra-AS: can focus on performance
 Inter-AS: policy may dominate over performance
Intra-AS Routing
 Also known as Interior Gateway Protocols (IGP)
 Most common IGPs:

RIP: Routing Information Protocol (legacy)

OSPF: Open Shortest Path First (common)

EIGRP: Enhanced Interior Gateway Routing
Protocol (proprietary – Cisco Systems)
Distance-vector routing algorithm
(DVR)
 The different names of the background
mathematical algorithm:
Backward search algorithm
 Bellman-Ford algorithm

 Goal: search the smallest delay paths for the
traffic
 For this reason in each router a table is created,
which contains:
The interface to the smallest delay path to every node
 The estimated delay of each path

 This table is called distance vector
The link state tables of an
example network
A
1
2
5
B
4
router
D
3
C
1
6
G
1
Legend
1
physical link
1
E
F
4
A
B
C
D
E
F
G
A
B
0
2
2
0
5
4
1
C
D
5
1
4


6


1

0
3


1
1

E
F




1
6

0
4

4
0
G


1


1
0

3
0
1

1
Routing tables (Step 1)
A
Router
Destination CA,j
B
C
D
Bellman-Ford algorithm
E
F
G
Inter
Inter
Inter
Inter
Inter
Inter
Inter
C
C
C
C
C
C
B,j face
C,j face
D,j face
E,j face
F,j face
G,j face
face
2
A
A
5
A
1
A

-

-

-
4
B

3
C
C
-

1
D
C
D

6
3

1
1
C
-
E

1
B
C
D
2
5
1
B
C
D

C
-
E

-

-
1
E
1
E
F

-

-
6
F

-
4
F
G

-

-
1
G

-

-
4
Distance
vector
Modified
entry

4
1

F
G
Unmodified
entry
Step 1
Shortest paths in
the routing table of
the router A
Bellman-Ford algorithm
A
Legend
CA,D=1
CA,B=2
CA,C =5
B
Router
Physical link
D
C
Temporarily step
of the algorithm
E
CA,G =
Least
cost path
F
G
h CA,B Path CA,C
1
2
3

2
2
2
4
5
0
A-B
A-B
A-B

5
4
3
2
A-B
2
A-B
-
h=1
CA,F=
Path
CA,E=
CA,D Path CA,E Path CA,F
CA,G
Path
-

-
A-C-F
A-D-E-F

6
5
A-C-G
A-D-C-G
A-D-E-CG
A-D-E-CG
-

A-C
A-D-C
A-D-E-C

1
1
1
A-D
A-D
A-D

2
2

A-D-E 11
A-D-E 6
3
A-D-E-C
1
A-D
2
A-D-E
5
A-D-E C-G-F
4
3
A-D-E-C
1
A-D
2
A-D-E
5
A-D-E-C-G-F
4
-
-

Path
Routing tables (Step 2)
Router
A
B
C
Bellman-Ford algorithm
D
E
F
G
Destination CA,j Path CB,j Path CC,j Path CD,j Path CE,j Path CF,j Path CG,j Path
A
B
C
D
E
F
G
2
4
1
2
11
6
B
D
D
D
C
C
2
A
4
3
5
10
5
C
A
C
C
C
4
4
D
B
2
1
5
1
E
E
E
G
A
Router
Routing tables
resulted from
the previous
step
Destination CA,j
1
3
2
A
A
E
1
5
4
E
E
C
B
2
5
1
1
D
C
C
D
4
2
F
C
C
D
11
10
2
5
4
C
C
G
E
E
1
G
E
6
5
1
4
2
1
F
C
C
C
C
C
F
G
Inter
Inter
Inter
Inter
Inter
Inter
Inter
CB,j face CC,j face CD,j face CE,j face CF,j face CG,j face
face
2
A
A
5
A
1
A

-

-

-
4
B

3
C
C
-

1
D
C
D

6
3

1
1
C
-
E

1
B
C
D
2
5
1
B
C
D

C
-
E

-

-
1
E
1
E
F

-

-
6
F

-
4
F
G

-

-
1
G

-

-
4

4
1
G

F
Step 2
Bellman-Ford algorithm
A
Shortest paths in
the routing table of
the router A
CA,D=1
CA,B=2
CA,C =4
C
B
D
E
CA,G =6
F
G
CA,F=11
h=2
h CA,B Path CA,C
1
2
3

2
2
2
4
5
0
A-B
A-B
A-B

5
4
3
2
A-B
2
A-B
-
CA,E=2
Path
CA,D Path CA,E Path CA,F
CA,G
Path
-

-
A-C-F
A-D-E-F

6
5
A-C-G
A-D-C-G
A-D-E-CG
A-D-E-CG
-

A-C
A-D-C
A-D-E-C

1
1
1
A-D
A-D
A-D

2
2

A-D-E 11
A-D-E 6
3
A-D-E-C
1
A-D
2
A-D-E
5
A-D-E C-G-F
4
3
A-D-E-C
1
A-D
2
A-D-E
5
A-D-E-C-G-F
4
-
-

Path
Bellman-Ford algorithm
Routing tables (Step 3)
Router
A
B
C
D
E
F
G
Destination CA,j Path CB,j Path CC,j Path CD,j Path CE,j Path CF,j Path CG,j Path
A
B
C
D
E
F
G
2
3
1
2
6
5
B
D
D
D
D
D
2
A
4
3
4
9
5
C
A
A
C
C
3
4
E
B
2
1
2
1
E
E
G
G
Router
A
1
3
2
A
A
E
1
5
3
E
E
E
B
2
4
1
1
D
D
C
D
3
2
C
C
C
D
6
6
2
4
3
G
G
G
G
G
1
G
E
5
5
1
3
2
1
F
C
C
C
C
C
F
G
Destination CA,j Path CB,j Path CC,j Path CD,j Path CE,j Path CF,j Path CG,j Path
Routing tables
resulted from
the previous
step
A
B
C
D
E
F
G
2
4
1
2
11
6
B
D
D
D
C
C
2
A
4
3
5
10
5
C
A
C
C
C
4
4
D
B
2
1
5
1
E
E
E
G
1
3
2
A
A
E
1
5
4
E
E
C
2
5
1
1
D
C
C
D
4
2
F
C
11
10
2
5
4
C
C
G
E
E
1
G
6
5
1
4
2
1
C
C
C
C
C
F
Bellman-Ford algorithm
Routing tables (Step 4)
Router
A
B
C
D
E
F
G
Destination CA,j Path CB,j Path CC,j Path CD,j Path CE,j Path CF,j Path CG,j Path
A
B
C
D
E
F
G
2
3
1
2
5
4
B
D
D
D
D
D
2
A
4
3
4
6
5
C
A
A
C
C
3
4
E
B
2
1
2
1
E
E
G
G
Router
1
3
2
A
A
E
1
4
3
E
E
E
A
B
2
4
1
1
D
D
C
D
3
2
C
C
C
5
6
2
4
3
G
G
G
G
G
1
G
D
4
5
1
3
2
1
E
C
C
C
C
C
F
F
G
Destination CA,j Path CB,j Path CC,j Path CD,j Path CE,j Path CF,j Path CG,j Path
Routing tables
resulted from
the previous
step
A
B
C
D
E
F
G
2
3
1
2
6
5
B
D
D
D
D
D
2
A
4
3
4
9
5
C
A
A
C
C
3
4
E
B
2
1
2
1
E
E
G
G
1
3
2
A
A
E
1
5
3
E
E
E
2
4
1
1
D
D
C
D
3
2
C
C
6
6
2
4
3
G
G
G
G
G
1
G
5
5
1
3
2
1
C
C
C
C
C
F
Step 3-4
Bellman-Ford algorithm
Shortest paths in
the routing table of
the router A
CA,D =1
A
A
CA,D =1
B CA,B =2
B CA,B =2
CA,C =3
D
C
CA,C =5
CA,C =3
CA,E=2
CA,C =4
D
C
E
F
G
CA,F =6
h CA,B Path CA,C
1
2
3

2
2
2
4
5
0
A-B
A-B
A-B

5
4
3
2
A-B
2
A-B
-
F
E
h=3
Path
G
CA,D Path CA,E Path CA,F
h=4
Path
CA,G
Path
-

-
A-C-F
A-D-E-F

6
5
A-C-G
A-D-C-G
A-D-E-CG
A-D-E-CG
-

A-C
A-D-C
A-D-E-C

1
1
1
A-D
A-D
A-D

2
2

A-D-E 11
A-D-E 6
3
A-D-E-C
1
A-D
2
A-D-E
5
A-D-E C-G-F
4
3
A-D-E-C
1
A-D
2
A-D-E
5
A-D-E-C-G-F
4
-
-

CA,F =5
CA,E=2
Bellman-Ford algorithm
Routing tables (Step 5)
Inter
Inter
Inter
Inter
Inter
Inter
Inter
G
F
E
D
C
B
A
Router
Destination CA,j face CB,j face CC,j face CD,j face CE,j face CF,j face CG,j face
A
B
C
D
E
F
G
2
3
1
2
5
4
B
D
D
D
D
D
2
A
4
3
4
6
5
C
A
A
C
C
3
4
E
B
2
1
2
1
E
E
G
G
Router
Routing tables
resulted from
the previous
step
A
1
3
2
A
A
E
1
4
3
E
E
E
B
2
4
1
1
D
D
C
D
3
2
C
C
C
D
5
6
2
4
3
G
G
G
G
G
1
G
E
C
C
C
C
C
F
4
5
1
3
2
1
F
G
Destination CA,j Path CB,j Path CC,j Path CD,j Path CE,j Path CF,j Path CG,j Path
A
B
C
D
E
F
G
2
3
1
2
5
4
B
D
D
D
D
D
2
A
4
3
4
6
5
C
A
A
C
C
3
4
E
B
2
1
2
1
E
E
G
G
1
3
2
A
A
E
1
4
3
E
E
E
2
4
1
1
D
D
C
D
3
2
C
C
5
6
2
4
3
G
G
G
G
G
1
G
4
5
1
3
2
1
C
C
C
C
C
F
Bellman-Ford algorithm
Step 5 and the final result
A
Shortest paths in
the routing table of
the router A CA,C =3
A
CA,D =1
B CA,B =2
B CA,B =2
CA,C =3
D
CA,E=2
C
CA,G =4
CA,D =1
CA,G =4
F
G
CA,F =5
h CA,B Path CA,C
1
2
3

2
2
2
4
5
0
A-B
A-B
A-B

5
4
3
2
A-B
2
A-B
-
Path
E
h=5
G
CA,D Path CA,E Path CA,F
C
E
F
h=6
CA,F =5
Path
CA,G
Path
-

-
A-C-F
A-D-E-F

6
5
A-C-G
A-D-C-G
A-D-E-CG
A-D-E-CG
-

A-C
A-D-C
A-D-E-C

1
1
1
A-D
A-D
A-D

2
2

A-D-E 11
A-D-E 6
3
A-D-E-C
1
A-D
2
A-D-E
5
A-D-E C-G-F
4
3
A-D-E-C
1
A-D
2
A-D-E
5
A-D-E-C-G-F
4
-
-

D
CA,E =2
Link-state routing algorithm
 The different names of the background
mathematical algorithm:



Forward search
Dijkstra algorithm
Shortest path (SP)
 The SP is the optimal path, however, this is not
obviously the geometrically shortest path
 Other factor, which can be taken into account:





Number of routers in the path
delay
cost
Average traffic
Reliability of the links in a certain path
Dijkstra’s algorithm
 Dijkstra's algorithm, named after its inventor the Dutch
computer scientist Edsger Dijkstra , solves a shortest
path problem for a directed and connected graph G(V,E)
which has nonnegative (>=0) edge weights
 Dijkstra's algorithm is known to be a good algorithm to
find a shortest path
The method…
Dijkstra’s algorithm
 Finds the shortest path between a source node
and the rest
 Finds routes between nodes by cost precedence
 Assumes every cost is a positive number
 Supports directed or bidirectional communication
Dijkstra’s algorithm
Initialisation – Example network
A
CA,B=2
CA,D=1
B
CA,C=5
D
G
C
E
F
M={A}
Step 1
Dijkstra’s algorithm
Node
B
C
D
E
F
G
Cost of the least cost path
Path
2
5
1
A-B
A-C
A-D

-

-

-
Node
Expression
Value
Evaluation
Resulted action
B
CA,D+LD,B
CA,D+LD,C
CA,D+LD,E
>2
4<5
No change
C
E
1+=
1+3=4
1+1=2
2<
New path
New path
F
CA,D+LD,F
1+=
=
No change
G
CA,D+LD,G
1+=
=
No change
A
CA,B=2 CA,D=1
B
CA,C=4
G
D
C
F
M={A,D}
E CA,E=2
Least cost
new node: D
Step 2
Dijkstra’s algorithm
Node
B
C
D
E
F
G
Cost of the least cost path
Path
2
4
1
2

-

-
A-B A-D-C A-D A-D-E
Node
Expression
Value
Evaluation
Resulted action
C
E
CA,B+LB,C
CA,B+LB,E
2+4=6
6>4
2+=
>2
No change
No change
F
CA,B+LB,F
2+=
=
No change
G
CA,B+LB,G
2+=
=
No change
A
B
CA,C=4
G
A
CA,B=2 CA,D=1
B
F
E CA,E=2
M={A,B,D}
CA,B=2 CA,D=1
CA,C=3
D
C
Least cost
new node
(with smaller
IP address) : B
G
D
C
CA,F=6
F
E CA,E=2
M={A,B,D,E}
Step 3
Dijkstra’s algorithm
Node
B
C
D
E
F
G
Cost of the least cost path
Path
2
4
1
2

-

-
A-B A-D-C A-D A-D-E
Node
Expression
Value
Evaluation
Resulted action
C
F
CA,E+LE,C
CA,E+LE,F
2+1=3
2+4=6
3<4
6<
New path
New path
G
CA,E+LE,G
2+=
=
No change
A
B
CA,C=4
CA,B=2 CA,D=1
B
F
E CA,E=2
M={A,B,D}
CA,B=2 CA,D=1
CA,C=3
D
C
G
A
G
D
C
CA,F=6
F
E CA,E=2
M={A,B,D,E}
Least cost
new node: E
Step 4
Dijkstra’s algorithm
Node
B
C
D
E
F
G
3
6
1
2
Cost of the least cost path 2
A-B A-D-E-C A-D A-D-E A-D-E-F
Path

-
Node
Expression
Value
Evaluation
Resulted action
F
G
CA,C+LC,F
CA,C+LC,G
3+6=9
3+1=4
9>6
No change
New path
4<
A
A
B CA,B=2 CA,D=1
CA,C=3
B CA,B=2 CA,D=1
CA,C=3
D
C
CA,F=4
G
F
Least cost
new node: C
E CA,E=2
M={A,B,C,D,E}
D
C
G
CA,F=4
F
E CA,E=2
M={A,B,C,D,E,G}
Step 5
Dijkstra’s algorithm
Node
B
Cost of the least cost path
Path
2
A-B
C
D
E
F
G
6
4
3
1
2
A-D-E-C A-D A-D-E A-D-E-F A-D-E-C-G
Least cost
new node: G
Node
Expression
Value
Evaluation
Resulted action
F
CA,G+LF,G
4+1=5
5<6
New path
A
B
CA,C=3
A
CA,B=2 CA,D=1
B
CA,C=3
D
C
CA,F=4
G
F
E CA,E=2
M={A,B,C,D,E}
CA,B=2 CA,D=1
D
C
G
CA,F=4
F
E CA,E=2
M={A,B,C,D,E,G}
Dijkstra’s algorithm
Step 6 (final result)
Node
Cost of the least cost
path
Path
B
C
D
E
F
G
2
3
1
2
5
4
A-B
A-D-E-C A-D A-D-E A-D-E-C-G-F A-D-E-C-G
A
B
CA,B=2 CA,D=1
CA,C=3
D
C
G
CA,F=4
F
E CA,E=2
M={A,B,C,D,E,F,G}
Second example
Step 1
Dijkstra’s algorithm
Second example
Step 2
Dijkstra’s algorithm
Second example
Step 3
Dijkstra’s algorithm
Second example
Step 4
Dijkstra’s algorithm
Second example
Step 5
Dijkstra’s algorithm
Second example
Step 6
Dijkstra’s algorithm
Second example
Step 7
Dijkstra’s algorithm
Second example
Step 8
Dijkstra’s algorithm
Second example
Step 9
Dijkstra’s algorithm
Second example
Step 10
Dijkstra’s algorithm
Second example
Step 11
Dijkstra’s algorithm
Second example
Step 12
Dijkstra’s algorithm
Differences between the forward
and the backward search algorithms
 Forward search (Dijkstra algorithm)
 It increases the scope of the search in each
step with including new node
 Backward search (Bellman-Ford algorithm)
 It increases the scope of the search in each
step with including new hop
Comparison of the distance-vector
and the link-state algorithms
 Distance vector:
 Each router sends distance-vector, but to its neighbours
 The distance-vector contains the estimated distance to all other
nodes
 Older method
 Problem of the ”count-to-infinity” due to the fact, that the bad
news are distributed too slowly
 Link-state:
 Each router sends link-state distance-vector to all others
 The link-state distance-vector contains the distance to the
neighbours, only
 The distance value to the neighbour (called link-state) is accurate
 Recent method
Related documents