dynamic routing - kth

58
Dynamic Routing Internetworking Olof Hagsand Literature: Forouzan, TCP/IP Protocol Suite Ch 14 Courses covering the subject: 2D1490 – IP routing in simple computer networks 2D1491 - IP routing in the Internet and other complex networks

Upload: others

Post on 03-Feb-2022

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Dynamic Routing - KTH

Dynamic Routing

Internetworking

Olof Hagsand

Literature:Forouzan, TCP/IP Protocol Suite Ch 14

Courses covering the subject: 2D1490 – IP routing in simple computer networks2D1491 - IP routing in the Internet and other complex

networks

Page 2: Dynamic Routing - KTH

What is a router?

• Host (end-system) • One or many network interfaces• Cannot forward packets between them

• Router• Can forward packets between multiple interfaces• Forwarding on Layer 3

Page 3: Dynamic Routing - KTH

What does a router do?

• Packet forwarding• Not only IPv4:• IPv6, MPLS, Bridging/VLAN, Tunneling,...• Filter packets

• Access lists• Metering/Shaping• Compute routes: build forwarding table• In the background: routing• In real-time: forwarding

Page 4: Dynamic Routing - KTH

Inside a router, 1st Generation

● Late 80s, early 90s● Every packet goes twice over the shared bus● Capacity < 0.5 Gb/s

LineCard

LineCard

LineCard

BufferM em oryCPU RIB

Shared bus backplane

Page 5: Dynamic Routing - KTH

Line Card

BufferM em ory

forw arder

Line Card

BufferM em ory

forw arder

Line Card

BufferM em ory

forw arder

Line Card

BufferM em ory

forw arder

Inside a router, 3rd Generation

● Late 90s● Multiple simultaneous transfers over the backplane● Specialized hardware: ASICs (Application Specific IC)● Capacity 100 Gb/s

CPU

RIB

CPU Card

Sw it ched backplane

Page 6: Dynamic Routing - KTH

Next-hop Routing● How do you hold information about route from A to all other hosts?

– A ->R1->R2->R3->B

● Nodes only store reachability information to closest neighbours– Next hop routing

● Table of host/network address and nexthop● Fundamental principle – but tables need to be updated dynamically

A

C D E F

BR1 R2 R3

R4

N1

N2 N3

N4

N1, -N2, R1N3, R1N4, R1

N1, -N2, R2N3, R2N4, R2

N1, R1N2, R4N3, R4N4, R3

N1, R2N2, R2N3, R2N4, -

N1, R3N2, R3N3, R3N4, -

Page 7: Dynamic Routing - KTH
Page 8: Dynamic Routing - KTH
Page 9: Dynamic Routing - KTH
Page 10: Dynamic Routing - KTH

Levels of abstraction

The Internet is huge

– Necessary to divide the routing problem into sub-problems.

– There are several layers of abstractions

The Internet is partitioned into Autonomous systems (AS)

– An independent administrative domain

– Routing between AS:s is called inter-domain routing / External routing

– Based on commercial agreements – Policies, Service-level-agreements

Routing within an AS

– Routing inside an AS: Intra-domain routing / Internal routing

– Best path based on hop/bw metrics

Page 11: Dynamic Routing - KTH

Autonomous systems - RFC1930

An Autonomous system is generally administered by a single entity.

Operators, ISPs (Internet Service Providers)

An AS contains an arbitrary complex sub-structure.

Each autonomous system selects the routing protocol to be used within the AS.

Policies or updates within an AS are not propagated to other AS:s.

An AS-number is (currently) a 16-bit unique identifier

Interconnection between AS:s

– Service Level Agreements (SLA:s)

– Internet Exchange Points (IX:s)/ Network Access Points (NAPs)

– Direct connections

Page 12: Dynamic Routing - KTH

Internet structure● Ideally, there is a well-defined hierarchy in the Internet –

a tree.

1 A few large “Tier 1” backbone providers – the core of the Internet (Sprint, Level3, Telstra, ...)

● Provides transit for everyone else

2 Tier 2 regional ISPs, or NSPs (Network Service Providers)

3 Smaller ISPs

4 Customers

● A well-defined hierarchy is nice for address aggregation –> smaller IP tables

● However, the hierarchy has broken down due to market forces:

– Peering at IXs, direct connections.

● The Internet structure is now more in the form of a graph --> larger routing tables

Page 13: Dynamic Routing - KTH

Routing table size● Number of BGP entries in typical backbone routers

Source: http://www.cidr-report.org

Page 14: Dynamic Routing - KTH

Metrics

● The most fundamental functionality in a dynamic routing protocol:– Find the ”best path” to a destination

● But what is best path?– Interior routing: typically number of hops, or

bandwidth– Exterior routing: business relations – peering

● Metrics– Number of “hops” (most common)– Bandwidth, Delay, Cost, Load, ”Policies”

Page 15: Dynamic Routing - KTH

Load balancing

● The routing protocol gives several routes to a network● Either select the best● Or load-balance between several links

– Unequal-cost multi-path

– Equal-cost multi-path● The forwarding decides how to balance actual traffic:

– random (but this break TCP)

– load balance per flow

– load balance per address pairs

Page 16: Dynamic Routing - KTH

Aggregation

● Also called summarization

● The netid part of IPv4 addresses can be aggregated (summarized) into shorter prefixes.

● Summarization is often done manually

● Leads to smaller routing tables (fewer prefixes)

● Threats: multi-homing and load-balancing

199.1.2.0/24

199.1.1.0/24

199.1.0.0/24

which aggregations can be made?

199.1.3.0/24

199.1.4.0/24

Page 17: Dynamic Routing - KTH

Redistribution of routing information

● If several protocols are running on the same router– E.g., an OSPF as interior and BGP as exterior– E.g. static routes into dynamic routing protocol

● The router can distribute routes from one protocol to another– Interior routes need to be advertized to the Internet

● Typically these routes are aggregated– Exterior routes may need to be injected into the interior

network● But only a subset – the backbone tables are very large● Necessary for domain carrying transit traffic● Not necessary for a domain using only a default route

● Typically, redistributed routes are filtered in different ways due to routing policies

Page 18: Dynamic Routing - KTH

Popular Routing Protocols

Routing Protocols

Interior Exterior

BGPRIP OSPF IS-ISIGRP(cisco)

EGP

Page 19: Dynamic Routing - KTH

Routing Information Protocol - RIP

● RIP-1 (RFC 1058), RIP-2 (RFC 2453)● Metric is hop counts

– 1: directly connected

– 16: infinity

– RIP cannot support networks with diameter > 14.

● RIP uses distance vector● RIP messages are carried via UDP datagrams.

– IP Multicast (RIP-2) or Broadcast (RIP-1)

Page 20: Dynamic Routing - KTH

Routing Information Protocol - RIP

● RIP is a distance-vector protocol ● RIP uses Bellman-Ford to calculate routes● RIP-1 (RFC 1058)● RIP-2 (RFC 2453)● Rip uses UDP as transport

– Multicast (RIP-2) or Broadcast (RIP-1)

● Metric is Hop Counts– 1: directly connected

– 16: infinity

– RIP cannot support networks with diameter > 14.

Page 21: Dynamic Routing - KTH

The Distance-Vector protocol

● Each router sends a list of distance-vectors (route with cost) to each neighbour periodically

● Every router selects the route with smallest metric.● Metric is a positive integer

– The cost to reach a destination: number of hops

– Hop-count is limited to 1-15, 16 is “infinity”

Page 22: Dynamic Routing - KTH

The Distance-Vector protocol (according to the RFC 2453)

If it is possible to get from entity i to entity j directly, then a cost, d(i,j), is associated with the hop between i and j. The cost is infinite if i and j are not immediate neighbors. Let D(i,j) represent the metric of the best route from entity i to entity j.

Then, the best metric must be described by D(i,i) = 0, all i D(i,j) = min [d(i,k) + D(k,j)], otherwise k

The algorithm:Entity i gets its neighbors k to send it their estimates of their distances to the destination j. When i gets the estimates from k, it adds d(i,k) to each of the numbers. This is simply the cost of traversing the network between i and k. Now and then i compares the values from all of its neighbors and picks the smallest.

It can be proven that this algorithm will converge to the correct estimates of D(i,j) in finite time in the absence of topology changes.

Page 23: Dynamic Routing - KTH

Its implementation

● Keep a table with an entry for each destination N in the network.

● Store the distance D and next-hop G for each N in the table.

● Periodically, send the table to all neighbours (the distance-vector).

● For each update that comes in from neighbour G':

– Add the cost of the network to the new distance D'.

– Replace the route if D' < D.

– If G = G', replace the route.

Page 24: Dynamic Routing - KTH

Distance Vector

N1 1 -

N2 1 -

N3 1 -

N2 1 -

N5 1 -

N6 1 -

N3 1 -

N6 1 -

N7 1 -

N8 1 -

N5 1 -

N9 1 -N8 1 -

N10 1 -

N4 1 -

N7 1 -

RIP Response

N5 2 B

N6 2 B

N1

N2 N3

N5N6

N7

N8

N4

N9 N10

A

B C

D

E

F

N1 2 A

N2 2 A

N5 3 A

Page 25: Dynamic Routing - KTH

Distance Vector

N1 1 -

N2 1 -

N3 1 -

N2 1 -

N5 1 -

N6 1 -

N3 1 -

N6 1 -

N7 1 -

N8 1 -

N5 1 -

N9 1 -N8 1 -

N10 1 -

N4 1 -

N7 1 -

RIP Response

N5 2 B

N6 2 B

N1

N2 N3

N5N6

N7

N8

N4

N9 N10

A

B C

D

E

F

N1 2 A

N2 2 A

N5 2 BNote, N2 is not updated: equal cost

Page 26: Dynamic Routing - KTH

Distance Vector – Converged

N1

N2 N3

N5N6

N7

N8

N4

N9 N10

A

B C

D

E

F

N1 1 -

N2 1 -

N3 1 -

N4 3 C

N5 2 B

N6 2 B

N7 2 C

N8 2 C

N9 3 B

N10 3 C

N1 2 A

N2 2 A

N3 1 -

N4 2 E

N5 2 B

N6 1 -

N7 1 -

N8 1 -

N9 3 B

N10 2 F

N1 3 B

N2 2 B

N3 3 B

N4 4 B

N5 1 -

N6 2 B

N7 3 B

N8 3 B

N9 1 -

N10 4 B

N1 3 C

N2 3 C

N3 2 C

N4 1 -

N5 3 C

N6 2 C

N7 1 -

N8 2 C

N9 4 C

N10 3 C

N1 3 C

N2 3 C

N3 2 C

N4 3 C

N5 3 C

N6 2 C

N7 2 C

N8 1 -

N9 4 C

N10 1 -

N1 2 A

N2 1 -

N3 2 A

N4 3 C

N5 1 -

N6 1 -

N7 2 C

N8 2 C

N9 2 D

N10 3 C

Page 27: Dynamic Routing - KTH

RIP Problem: Count to Infinity

Initially, R1 and R2 both have a route to N with metric 1 and 2, respectively.

N 1 -

N

N 2 R1

R1 R2

The link between R1 and N fails. xN 1 - N 2 R1

N

Now R1 removes its route to N, by setting its metric to 16 (infinity).

N 16 N 2 R1

N

Now two things can happen: Either R1 reports its route to R2. Everything is fine.

N 16 N 16

N

N 16

Page 28: Dynamic Routing - KTH

RIP Problem: Count to Infinity

The other alternative is that R2, which still has a route to N, advertises it to R1. Now things start to go wrong: packets to N are looped until their TTL expires!

N 3 R2 N 2 R1

N

N 2

R1 R2

Loop!

Eventually (~10-20s), R1 sends an update to R2. The cost to N increases, but the loop remains.

N 3 R2 N 4 R1

NN 3

Loop!

Yet some time later, R2 sends an update to R1.

N 5 R2 N 4 R1

NN 4

Loop!...

Finally, the cost reaches infinity at 16, and N is unreachable. The loop is broken!

N 16 N 16

N

Page 29: Dynamic Routing - KTH

Split Horizon

● Do not send routes back over the same interface from which the route arrived.

● This helps in avoiding “mutual deception”: two routers tell each other they can reach a destination via each other.

● Split Horizon MUST be supported on all RIP routers

R2, does not announce the route to N to R1 since that is where it came from. N 16 N 2 R1

N

R1 R2

Eventually, R1 reports its route to R2 and everything is fine.

N 16 N 16

N

N 16

Page 30: Dynamic Routing - KTH

Split Horizon + Poison Reverse● Advertise reverse routes with a metric of 16 (i.e.,

unreachable).● Does not add information but breaks loops faster● Adds protocol overhead● RIP SHOULD be supported by all RIP implementations, but it

is OK to be able to turn it off.

Eventually, R1 reports its route to R2 and everything is fine.

N 16 N 16

N

N 16

R2 always announces an unreachable route to N to R1.

N 16 N 2 R1

N

R1 R2

N 16

Page 31: Dynamic Routing - KTH

Remaining problems

● More than two routers involved in mutual deception– A may believe it has a route through B, B through C, and C through A

● In this case, split horizon with poison reverse does not help

AB

C

Page 32: Dynamic Routing - KTH

Triggered Update● Send out update immediately when metric changes● But only the changed route, not the complete table● This may lead to a cascade of updates

– RIP filters these updates by not allowing more than one every 1-5 seconds.

● CISCO also implements “flash updates”: on boot, broadcast a request -> all neighbours answer with updates.

R1 Immediately announces the broken link when it happens.

N 16 N 16

N

R1 R2

N 16

Page 33: Dynamic Routing - KTH

Hold Down

● When a route is removed, no update of this route is accepted for some period of time (hold-down time)- to give everyone a chance to remove the route.

● Holddown is not in the RIP RFC, but some vendors (eg CISCO) implements it

R1 ignores updates to N from R2 for some period of time.

N 16 N 1 R1

N

N 2

R1 R2

N 16 N 16

N

N 16Eventually, R1 sends the update to R2.

Page 34: Dynamic Routing - KTH

RIPv2 header

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Command | Version | Routing domain | +---------------+---------------+-------------------------------+ | Address family | Route tag | +-------------------------------+-------------------------------+ | IP address | +---------------------------------------------------------------+ | Netmask | +---------------------------------------------------------------+ | Next Hop | +---------------------------------------------------------------+ | Metric | +---------------------------------------------------------------+

rep

eate

d

● Command: request/ response

● Family: 2 (IPv4)

● Address/mask

● Distance: 1-16

● Version: 2

● Route tag: AS number

● Nexthop

Page 35: Dynamic Routing - KTH

Disadvantages with RIP

● Slow convergence

– Changes propagate slowly

– Each neighbor only speaks ~every 30 seconds; information propagation time over several hops is long

● Instability

– After a router or link failure RIP takes minutes to stabilize.

● Hops count may not be the best indication for which is the best route.

● The maximum useful metric value is 15

– Network diameter must be less than or equal to 15.

● RIP uses lots of bandwidth

– It sends the whole routing table in updates.

Page 36: Dynamic Routing - KTH

Why would anyone use RIP?● After all these problems you might ask

this question.● Answer

– It is easy to implement– It is generally available – Implementations have been rigorously tested– It is simple to configure.– It has little overhead (for small networks)

Page 37: Dynamic Routing - KTH

Original OSPF requirements

● A more descriptive routing metric

– Link metric: 1-65535

● Equal-cost multipath

– Multiple best paths: load balance

● Routing hierarchy

– Two-level routing scheme: areas

● Separate internal and external routes

– External routes

● Security

– Cryptographic authentication

--> OSPF version 2 in RFC 2328

Page 38: Dynamic Routing - KTH

Link-state routing

● Each router spreads information about its links to its neighbours.

● This information is flooded to every router in the routing domain so that every router has knowledge of the entire network topology.

● Using Dijkstra's algorithm, the shortest path to each prefix in the network is calculated

Page 39: Dynamic Routing - KTH

Comparison with Distance-vector

● Link-state uses a distributed database model

● Distance-vector uses a distributed processing model

● Link-state pros:

– More functionality due to distribution of original data, no dependency on intermediate routers

● Easier to troubleshoot

– Fast convergence: when the network changes, new routes are computed quickly

– Less bandwidth consuming

● Distance-vector pros:

– Less complex – easier to implement and administrate

– Needs less memory

Page 40: Dynamic Routing - KTH

The OSPF protocol

1. The hello protocol

– Is there anybody out there?

– Detection of neighboring routers

– Election of designated routers

2. The exchange protocol

• Exchange database between neighbours

3. Reliable flooding

• When links change/age send: update to neighbours and flood recursively.

4. Shortest path calculation

• Dijkstra's algorithm

• Compute shortest path tree to all destinations

Page 41: Dynamic Routing - KTH

OSPF Encapsulation

● OSPF runs directly on IP (protocol = 89)

● Needs its own reliable protocol

– The flooding protocol

● No port numbers

– Need to run as root – raw sockets

● No checksum

– Computes its own checksum or digest

● Since it runs on IP (IS-IS runs on the link-level)

– OSPF messages can be routed – tunneled or routed by some other protocol

Page 42: Dynamic Routing - KTH

Link-State Advertisements

● LSAs are the elements of the distributed database

● The router describes its environment in the form of networks that it is connected to

● Fundamental task in OSPF:

– Distribute the LSAs to all nodes in a reliable way

● Then, each node can compute Dijkstra on the same database

Page 43: Dynamic Routing - KTH

Router link LSA

Which neighbors do a ”true” router have?

Page 44: Dynamic Routing - KTH

Network Link LSA

● Links of a transit network distributed from a designated router

● The designated router distributes the information on behalf of the connected routers

● Cost to enter network.

● Zero cost to leave

● Example: An Ethernet with four routers:

DR

Ethernet (transit) networkwith three links.

Designated router advertizesthe links.

Page 45: Dynamic Routing - KTH

Dijkstra Algorithm

From link-state database, compute a shortest path delivery tree:

1 Define the root of the tree: the router

2 Assign a cost of 0 to this node and make it the first permanent node.

3 Examine each neighbor node of the last permanent node.

4 Assign a cumulative cost to each node and make it tentative.

5 Among the list of tentative nodes:

● Find the node with the smallest cumulative cost and make it permanent.

● If a node can be reached from more than one direction, select the direction with the smallest cumulative cost.

6 Repeat steps 3 to 5 until every node is permanent.

Page 46: Dynamic Routing - KTH

OSPF Example

N1

N6

N4

N9 N10

N2 N3

N5

N7

N8

A

B C

D

E

F

1

13

21

2

1 2

2

3

5

Metric (may be assymmetric)

Page 47: Dynamic Routing - KTH

Flooding LSPs (from A)

N1

N2 N3

A

B C

D

E

F

Router A dist ributes one router-link LSA (containg N1, N2, N3)

Page 48: Dynamic Routing - KTH

A creates link state database

N2 N3

N5

N7

N8

A

B C

D

E

F

N1

N6’s DesignatedRouter

N6

N9

N4

N10

1

13

2 1

2

1 2

2

3

5

00

Page 49: Dynamic Routing - KTH

Dijkstra’s algorithm computed

N2 N3

N5

N7

N8

A

B C

D

E

F

N1

N6

N9

N4

N10

1

13

01

2

1 2

2

3

5

Final shortest path delivery tree from A

Page 50: Dynamic Routing - KTH

OSPF Areas● Divides the OSPF domain into smaller zones

– Smaller link-state database in each zone

– Also decreases signaling traffic

● Routers have limits on processing power and memory

– Router CPUs are typically much slower than PCs

● CISCO nowadays recommends ~80 routers as a limit in a single area

● You need a large network to benefit from areas

– Typical large companies

● Example: KTHLAN using OSPF with 15-20 routers used to have areas – but now only uses area 0.

Page 51: Dynamic Routing - KTH

OSPF Network Topology

● Area 0 is the backbone area. All traffic goes via the backbone.● All other areas are connected to the backbone (1-level hierarchy)● A Border area router has one interface in each area.● An AS Boundary Router – attaches to other AS:s

AS2Area 0

Area 1 Area 2 Area 3

Area Border Router:one interface in each

area

AS boundary router:External routing,

in the backbone area

All areas connected tobackbone area

Page 52: Dynamic Routing - KTH

Alternative to OSPF: IS-IS

● Link-State Routing

● Originally designed for Decnet and then CLNP (OSI)

● Has been stable for a longer time than OSPF

– Large deployed base

– Many backbones runs IS-IS, but OSPF supported by more vendours

– Example: SUNET runs IS-IS● Better scalability in many respects

● Areas easier to configure and manage

Page 53: Dynamic Routing - KTH

Border Gateway Protocol - BGP

● Inter-domain routing

● Simple cases: use static routing

● Main purpose: Network reachability between autonomous systems

● BGP version 4 is the exterior routing protocol used in the Internet today.

● BGP uses TCP

● TCP is reliable: reduces the protocol complexity

● BGP uses path-vector - enhancent of distance-vector.

● BGP implements policies – chosen by the local administrator.

Page 54: Dynamic Routing - KTH

Motivation for Path-Vector

● Distance-vector– Hop-count too limited– Unstable

● Link-State– Link state database would be enormous

● Path-vector extends distance-vector – Instead of a simple cost, assign an AS-Path to every route– There may be many paths to the same destination (network prefix)– AS-Path used to implement policies and loop prevention

Page 55: Dynamic Routing - KTH

BGP Architecture

● BGP interacts with the Internal routing (OSPF/IS-IS/RIP/...)– Redistributes routes between the two domains

● BGP really consists of two protocols:– E-BGP: coordinates between border routers between AS:s– I-BGP : coordinates between BGP peers within an AS

AS2

AS1 AS3E-BGP E-BGP

I-BGP

Page 56: Dynamic Routing - KTH

BGP Example

● N is an IP address prefix (a network) that is announced by AS1 (Origin AS)

● Every AS adds its own AS to the AS-PATH and sends BGP Updates to next AS

● In the example, AS5 can choose which path to select based on policies.

AS1

AS5

N

AS2

AS3AS4

N

N: AS1

N: AS3; AS1

N: AS2; AS1

N: AS4; AS3; AS1

N: AS1

Page 57: Dynamic Routing - KTH

BGP scaling

● Currently , the problems BGP faces have to do with large and changing routing tables

● Routing tables are large because of the many subnetworks (~150000)

● Aggregation does not always work

– E.g., Multihoming often breaks aggregation

● When networks change, BGP peers advertise changes, and these may have problems to converge

– Especially in the presence of faults

● Valid BGP implementations are few, and it is difficult to configure BGP

Page 58: Dynamic Routing - KTH

Summary

● Routers vs Routing

● Autonomus systems

● Routing issues:

– Reachability, metrics, load balancing, aggregation, redistribution

● Protocols

– RIP

– OSPF

– BGP