44
1 Computer Networks Routing Algorithms

1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

1

Computer Networks

Routing Algorithms

Page 2: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

2

IP Packet Delivery

• Two Processes are required to accomplish IP packet delivery:– Routing

• discovering and selecting the path to the destination • layer-3 functionality

– Forwarding

Page 3: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

3

Routing Tables

• Routing Tables are built up by the routing algorithms with components:– Destination Network Address: The network portion of

the IP address for the destination network

– Subnet Mask: used to distinguish the network address from the host address

– The IP address of the next hop to which the interface forwards the IP packet for delivery

– The Interface with which the route is associated

Page 4: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

4

Forwarding Tables After the routing lookup is completed and the next

hop is determined, The IP packet is forwarded according to:

• Local delivery model – destination and host are on the same local network

• Remote delivery model – destination and host are on different networks

Page 5: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

5

Static v.s. Dynamic Routing • Static Routing Tables are

entered manually

• Strengths of Static Routing– Ease of use

– Control

– Efficiency

• Weaknesses of Static Routing– Not Scalable

– Not adaptable to link failures

• Dynamic Routing Tables are created through the exchange of information between routers on the availability and status of the networks to which an individual router is connected to. Two Types – Distance Vector Protocols

• RIP: Routing Information Protocol

– Link State Protocols• OSPF: Open Shortest

Path First

Page 6: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

6

Routing Metrics• Used by dynamic routing protocols to establish

preference for a particular route. • Support Route Diversity and Load Balancing • Most Common routing metrics:

– Hop Count (minimum # of hops)– Bandwidth/Throughput (maximum throughput)– Load (actual usage)– Delay (shortest delay)– Cost

Page 7: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

7

Dynamic Routing Protocols (1)

• Distance Vector (DV) Protocols– based on the Bellman-Ford algorithm

– Each router on the network compiles a list of the networks it can reach (in the form of a distance vector)

– exchange this list with its neighboring routers only

– Upon receiving vectors from each of its neighbors, the router computes its own distance to each neighbor.

– for every network X, router finds that neighbor who is closer to X than to any other neighbor. Router updates its cost to X.

Page 8: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

8

Example: Initial Distances

A

B

E

C

D

Info atnode

A

B

C

D

A B C

0 7 ~

7 0 1~ 1 0

~ ~ 2

7

1

1

2

28

Distance to node

D

~

~2

0

E 1 8 ~ 2

1

8~

2

0

E

Page 9: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

9

Router E receives Router D Table

A

B

E

C

D

Info atnode

A

B

C

D

A B C

0 7 ~

7 0 1~ 1 0

~ ~ 2

7

1

1

2

28

Distance to node

D

~

~2

0

E 1 8 ~ 2

1

8~

2

0

E

Page 10: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

10

Router E updates cost to Router C

A

B

E

C

D

Info atnode

A

B

C

D

A B C

0 7 ~

7 0 1~ 1 0

~ ~ 2

7

1

1

2

28

Distance to node

D

~

~2

0

E 1 8 4 2

1

8~

2

0

E

Page 11: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

11

Router A receives Router B Table

A

B

E

C

D

Info atnode

A

B

C

D

A B C

0 7 ~

7 0 1~ 1 0

~ ~ 2

7

1

1

2

28

Distance to node

D

~

~2

0

E 1 8 4 2

1

8~

2

0

E

Page 12: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

12

Router A updates Cost to Router C

A

B

E

C

D

Info atnode

A

B

C

D

A B C

0 7 87 0 1~ 1 0

~ ~ 2

7

1

1

2

28

Distance to node

D

~

~2

0

E 1 8 4 2

1

8~

2

0

E

Page 13: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

13

Router A receives Router E Table

A

B

E

C

D

Info atnode

A

B

C

D

A B C

0 7 8

7 0 1~ 1 0

~ ~ 2

7

1

1

2

28

Distance to node

D

~

~2

0

E 1 8 4 2

1

8~

2

0

E

Page 14: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

14

Router A updates Costs to Routers C&D

A

B

E

C

D

Info atnode

A

B

C

D

A B C

0 7 57 0 1~ 1 0

~ ~ 2

7

1

1

2

28

Distance to node

D

3~2

0

E 1 8 4 2

1

8~

2

0

E

Page 15: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

15

Final Distances

A

B C

D

Info atnode

A

B

C

D

A B C

0 6 5

6 0 15 1 0

3 3 2

7

1

1

2

28

Distance to node

D

3

32

0

E 1 5 4 2

1

54

2

0

E

E

Page 16: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

16

Final Distances after a Link failure

A

B C

D

Info atnode

A

B

C

D

A B C

0 7 8

7 0 1

8 1 0

10 3 2

7

1

1

2

28

Distance to node

D

10

3

2

0

E 1 8 9 11

1

8

9

11

0

E

E

Page 17: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Link Failure Causes “Bouncing” Effect

A

25

1

1

B

C

B

C 21

dest cost

XBB

via

A

C 11

dest cost

CA

via

A

B 12

dest cost

BB

via

Page 18: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

B Notices A-B Link Failure

A

25 1

B

C

B notices failure, resets cost via A toinfinity in distance table (not shown), &knows cost via C is 26

B

C 21

dest cost

BB

via

A

C 126

dest cost

CC

via

A

B 12

dest cost

BB

via

Page 19: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

C Sends Dist. Vector to B

A

25 1

B

C

B

C 21

dest cost

BB

via

A

C 13

dest cost

CC

via

A

B 12

dest cost

BB

via

C sends routing update to B

Page 20: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

B Updates Distance to A

A

25 1

B

C

Packet sent from Cto A bounces between C and B

until TTL=0!

B

C 21

dest cost

BB

via

A

C 13

dest cost

CC

via

A

B 12

dest cost

BB

via

Page 21: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

B Sends Dist. Vector to C

A

25 1

B

C

C adds one to B’sadvertised distanceto A. (Why does C

overrideits storeddistance of 2to A with 4,larger value?)

B

C 21

dest cost

BB

via

A

C 13

dest cost

CC

via

A

B 14

dest cost

BB

via

Page 22: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

C Sends Dist. Vector to B

A

25 1

B

C

B adds one to C’sadvertised distanceto A. (overrides

its storeddistance of 3to A with 5,larger value)

B

C 21

dest cost

BB

via

A

C 15

dest cost

CC

via

A

B 14

dest cost

BB

via

Page 23: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Link Failure: Bad News Travels Slowly

A

25 1

B

C

After 20+ exchanges,routing tables looklike this:

B

C 2526

dest cost

CC

via

A

C 125

dest cost

CC

via

A

B 124

dest cost

BB

viaAssume A has advertisedits link cost of 25 to C during B<->C exchanges.C stores this cost in its distancetable (not shown)

Page 24: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Bad News Travels Slowly (2)

A

25 1

B

C

C increments B’supdate by 1, andchooses 25 via Ato A, instead of 26

Via B to A

B

C 2526

dest cost

CC

via

A

C 125

dest cost

CC

via

A

B 125

dest cost

BA

via

Page 25: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Bad News Travels Slowly (3)

A

25 1

B

C

After 25 B-Cexchanges, finallyconverge tostable routing

B

C 2526

dest cost

CC

via

A

C 126

dest cost

CC

via

A

B 125

dest cost

BA

via

Page 26: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Link Failure Causes “Counting to Infinity” Effect

A

25

1

1

B

C

B

C 21

dest cost

XBB

via

A

C 11

dest cost

CA

via

A

B 12

dest cost

BB

via

Page 27: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

B Notices A-B Link Failure

A

25 1

B

C

B notices failure,resets cost to 26

B

C 21

dest cost

BB

via

A

C 126

dest cost

CC

via

A

B 12

dest cost

BB

via

Page 28: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

C Sends Dist. Vector to B

A

25 1

B

C

B

C 21

dest cost

BB

via

A

C 13

dest cost

CC

via

A

B 12

dest cost

BB

via

C sendsrouting update to B

Page 29: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

A-C Link Fails

A

1

B

C

C detects link to A has failed,but no change in C’srouting table (why?)

A

C 13

dest cost

CC

via

A

B 12

dest cost

BB

via

Page 30: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Now, B and C Count to Infinity

A

1

B

C

A

C 13

dest cost

CC

via

A

B 14

dest cost

BB

via

Page 31: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

B and C Count to Infinity (2)

A

1

B

C

A

C 15

dest cost

CC

via

A

B 14

dest cost

BB

via

Page 32: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

32

Dynamic Routing Protocols (2)

• Link-State (LS) Protocols– Based on an algorithm by Dijkstra

– Each router on the network is assumed to know the state of the links to all its neighbors

– Each router will disseminate (via reliable flooding of link state packets, LSPs) the information about its link states to all routers in the network.

– In this case, every router will have enough information to build a complete map of the network and therefore is able to construct a Shortest Path Spanning Tree from itself to every other router

Page 33: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

33

Link State Packets• The link state packets consist of the following

information:– The address of the node creating the LSP– A list of directly connected neighbors to that node with

the cost of the link to each neighbor– A sequence number to make sure it is the most recent

one– A time-to-live to insure that an LSP doesn’t circulate

indefinitely

• A node (router) will only send an LSP if there is a change of status to some of its links or if a timer expires

Page 34: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

34

SPT algorithm (Dijkstra)

• SPT = {a}• for all nodes v

– if v is adjacent to a then D(v) = cost (a, v)

– else D(v) = infinity

• Loop– find w not in SPT, where D(w) is min

– add w in SPT

– for all v adjacent to w and not in SPT

• D(v) = min (D(v), D(w) + C(w, v))

• until all nodes are in SPT

Page 35: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Dijkstra’s Shortest Path Algorithm (1)

• Initialize shortest path tree SPT = {B}• For each n not in SPT, C(n) = l(s,n)

• C(E) = 1, C(A) = 3, C(C) = 4, C(others) = infinity

• Add closest node to the tree: SPT = SPT U {E} since C(E) is minimum for all w not in SPT.• No shorter path to E can ever be found via some other

roundabout path.

4

3

6

21

9

1

1

D

A

FE

B

C

• Shortest path tree SPT = {B, E}

Page 36: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Dijkstra’s Shortest Path Algorithm (2)

• Recalculate C(n) = MIN (C(n), C(E) + l(E,n)) for all nodes n not yet in SPT• C(A) = MIN( C(A)=3, 1 + 1) = MIN(3,2) = 2

• C(D) = MIN( infinity, 1 + 1) = 2

• C(F) = MIN( infinity, 1 + 2) = 3

• C(C ) = MIN( 4, 1 + infinity) = 4

4

3

6

21

9

1

1

D

A

FE

B

C

• Each new node in tree, could create a lower cost path, so redo costs

Page 37: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Dijkstra’s Shortest Path Algorithm (3)

• Loop again, select node with the lowest cost path:• C(A) = 2, C(D) = 2, C(F) = 3, C(C ) = 4

• SPT = SPT U {A} = {B, E, A}

• No shorter path can be found from B to A, regardless of any new nodes added to tree

4

3

6

21

9

1

1

D

A

FE

B

C

• Recalc: C(n) = MIN (C(n), C(A) + l(A,n)) for all n not yet in SPT• C(D) = MIN(2, 2+inf) = 2

• C(F) = 3, C(C) = 4

Page 38: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

Dijkstra’s Shortest Path Algorithm (4)

• Continue to loop, adding lowest cost node at each step and updating costs

• SPT crawls outward• Remember to store the links in SPT as they are added

(each node’s predecessor is stored)• Each node has to store the entire topology, or database

of link costs

4

3

6

21

9

1

1

D

A

FE

B

C

Page 39: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

39

Example

A F

B

D E

C2

2

2

3

1

1

3

5

5

step SPT D(b), P(b) D(c), P(c) D(d), P(d) D(e), P(e) D(f), P(f)0 A 2, A 5, A 1, A ~ ~

B C D E F

1

Page 40: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

40

Example (Continued)

A F

B

D E

C2

2

2

3

1

1

3

5

5

step SPT D(b), P(b) D(c), P(c) D(d), P(d) D(e), P(e) D(f), P(f)0 A 2, A 5, A 1, A ~ ~1 AD 2, A 4, D 2, D ~

B C D E F

1

Page 41: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

41

Example (Continued)

A F

B

D E

C2

2

2

3

1

1

3

5

step SPT D(b), P(b) D(c), P(c) D(d), P(d) D(e), P(e) D(f), P(f)0 A 2, A 5, A 1, A ~ ~1 AD 2, A 4, D 2, D ~2 ADE 2, A 3, E 4, E

1

B C D E F

5

Page 42: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

42

Example (Continued)

A F

B

D E

C2

2

2

3

1

1

3

5

5

1

step SPT D(b), P(b) D(c), P(c) D(d), P(d) D(e), P(e) D(f), P(f)0 A 2, A 5, A 1, A ~ ~1 AD 2, A 4, D 2, D ~2 ADE 2, A 3, E 4, E3 ADEB 3, E 4, E

B C D E F

Page 43: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

43

Example (Continued)

A F

B

D E

C2

2

2

3

1

1

3

5

1

5

step SPT D(b), P(b) D(c), P(c) D(d), P(d) D(e), P(e) D(f), P(f)0 A 2, A 5, A 1, A ~ ~1 AD 2, A 4, D 2, D ~2 ADE 2, A 3, E 4, E3 ADEB 3, E 4, E4 ADEBC 4, E

B C D E F

Page 44: 1 Computer Networks Routing Algorithms. 2 IP Packet Delivery Two Processes are required to accomplish IP packet delivery: –Routing discovering and selecting

44

Example (Continued)

A F

B

D E

C2

2

2

3

1

1

3

5

5

1

step SPT D(b), P(b) D(c), P(c) D(d), P(d) D(e), P(e) D(f), P(f)0 A 2, A 5, A 1, A ~ ~1 AD 2, A 4, D 2, D ~2 ADE 2, A 3, E 4, E3 ADEB 3, E 4, E4 ADEBC 4, E5 ADEBCF

B C D E F