F07 Lecture10 Routing
F07 Lecture10 Routing
Computer Networks
Aditya Akella
Lecture 10 -
Intra-Domain Routing
System Bus
1
Switching Via a Bus
• Datagram from input port
memory to output port
memory via a shared bus
Routing
• Past two lectures
– IP addresses are structured
– IP packet headers carry these
addresses
– When packet arrives at router
• Examine header for intended
destination Router
• Look up next hop in table
• Send packet out appropriate
port
• This lecture:
– How these forwarding tables
are built?
– Routing algorithms
2
A Model of the Problem
• Network as a Graph:
– Represent each router as node
– Direct link between routers
represented by edge
– Symmetric links ⇒ undirected E 3 C
1
graph
1
2 F
• Edge “cost” c(x,y) denotes
6
measure of difficulty of using link
1
– delay, $ cost, or congestion level 3 D
A 4
• Task B
– Determine least cost path from
every node to every other node
• Path cost d(x,y) = sum of link costs
• Distributed
– Routers perform local computation
– Converge to a globally consistent routing state
– “Global”: Link-state
• Every node collects complete graph structure
• Each computes shortest paths from it
• Each generates own routing table
– Local: Distance-vector
• No one has copy of graph
• Nodes construct their own tables iteratively
• Each sends information about its table to neighbors
8
Distance-Vector Method
E 3 C
1
Initial Table for
A F 1
2
Dest Cost Nex 6
t 1
Hop 3 D
A 4
A 0 A B
B 4 B
C –
• Idea
∞
– At any time, have cost/next
D ∞ –
hop of best known path to
E 2 E destination
F 6 F – Use cost ∞ when no path known
• Initially
– Only have entries for directly 9
connected nodes
3
Algorithm
Each node x stores:
– c(x,v) for each neighbor v
– Distance vector of node x: estimate of d(x,y) for all y
– Distance vectors heard from each neighbor
Initialization:
1. d(x,y) = c(x,y) for all y.
2. Send distance vector to each neighbor
Repeat:
Whenever link cost to neighbor changes or distance
vector received from neighbor
For every neighbor z
For every destination y
d(x,y) ← Update(x,y,z)
If d(x,y) changed for any y, send distance vector to all 10
neighbors
Distance-Vector Update
z
d(z,y)
c(x,z)
y
x
d(x,y)
Update(x,y,z)
d ← c(x,z) + d(z,y) /* Cost of path from x to y with first hop z */
if d < d(x,y)
/* Found better path */
return d,z /* Updated cost / next hop */
else
return d(x,y), nexthop(x,y) /* Existing cost / next hop */
11
Start
Optimum 1-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A 1
2 F
B 4 B B 0 B
6
C ∞ – C ∞ – 1
D ∞ – D 3 D 3 D
A 4
E 2 E E ∞ –
B
F 6 F F 1 F
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A ∞ – A ∞ – A 2 A A 6 A
B ∞ – B 3 B B ∞ – B 1 B
C 0 C C 1 C C ∞ – C 1 C
D 1 D D 0 D D ∞ – D ∞ –
E ∞ – E ∞ – E 0 E E 3 E
F 1 F F ∞ – F 3 F F 0 F 12
4
Iteration #1
Optimum 2-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A 1
2 F
B 4 B B 0 B
6
C 7 F C 2 F 1
D 7 B D 3 D 3 D
A 4
E 2 E E 4 F
B
F 5 E F 1 F
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A 7 F A 7 B A 2 A A 5 B
B 2 F B 3 B B 4 F B 1 B
C 0 C C 1 C C 4 F C 1 C
D 1 D D 0 D D ∞ – D 2 C
E 4 F E ∞ – E 0 E E 3 E
F 1 F F 2 C F 3 F F 0 F 13
Iteration #2
Optimum 3-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A 1
2 F
B 4 B B 0 B
6
C 6 E C 2 F 1
D 7 B D 3 D 3 D
A 4
E 2 E E 4 F
B
F 5 E F 1 F
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A 6 F A 7 B A 2 A A 5 B
B 2 F B 3 B B 4 F B 1 B
C 0 C C 1 C C 4 F C 1 C
D 1 D D 0 D D 5 F D 2 C
E 4 F E 5 C E 0 E E 3 E
F 1 F F 2 C F 3 F F 0 F 14
algorithm
continues
on!
15
5
Distance Vector: Poison Reverse
If Z routes through Y to get to X : 60
• Z tells Y its (Z’s) distance to X is infinite (so Y Y
4 1
won’t route to X via Z)
• Will this completely solve count to infinity X Z
50
problem?
algorithm
terminates
16
• Features
– Every link has cost 1 Hop count
– “Infinity” = 16
• Limits to networks where everything reachable within 15 hops
• Sending Updates
– Every router listens for updates on UDP port 520
– Triggered
• When every entry changes, send copy of entry to neighbors
– Except for one causing update (split horizon rule)
– Periodic
• Every 30 seconds, router sends copy of its table to each neighbor
18
6
Link State Protocol Concept
• Every node gets complete copy of graph
– Every node “floods” network with data about its
outgoing links
19
20
Dijkstra’s Algorithm
• Given
– Graph with source node s and edge costs
c(u,v)
– Determine least cost path from s to every
node v
21
7
Dijkstra’s Algorithm
∞
2 E 3 C
5 1
Current Path Costs
F 2
2
6
1
Source 0 ∞
3 3 D
Node A 3
B
Done
Unseen
Horizon
•Node Sets
– Done • Label
• Already have least cost path to it – d(v) = path cost
– Horizon: • From s to v
• Reachable in 1 hop from node in
Done • Path
– Unseen: – Keep track of last link in
• Cannot reach directly from node path 22
in Done
• No nodes “done”
• Source in “horizon”
23
24
8
Dijkstra’s Algorithm
∞
2 E 3 C
5 1
Current Path Costs
F 2
2
6
1
Source 0 ∞
3 3 D
Node A 3
B
Done
Unseen
Horizon
Dijkstra’s Algorithm
Horizon ∞
2 E 3 C
5 1
Current Path Costs
F 2
2
6
1
Source 0 ∞
3 3 D
Node A 3
B
Done
Unseen
• Repeat…
26
Dijkstra’s Algorithm
∞ Unseen
2 E 3 C
4 1
Current Path Costs
F 2
2
6
1
Source 0 6
3 3 D
Node A 3
B Horizon
Done
27
9
Dijkstra’s Algorithm
5
2 E 3 C
4 1
F 2
2
6
1
Source 0 6
3 3 D
Node A 3
B
28
6 2
• Can still have D
29
30
10
OSPF Messages
• Transmit link state advertisements
– Originating router
• Typically, IP address for router
– Link ID
• ID of router at other end of link
– Metric
• Cost of link
– Sequence number
• Incremented each time sending new link information
31
• Cases
– No entry present
• Add entry, propagate to all neighbors other than Y
– Entry present with sequence number p < q
• Update entry, propagate to all neighbors other than Y
– Entry present with sequence number p > q
• Send entry back to Y
• To tell Y that it has out-of-date information
– Entry present with sequence number p = q
• Ignore it
32
Flooding Issues
• When should it be performed
– Periodically
– When status of link changes
• Detected by connected node
• Congestion, lack of electric or optical signal
33
11
Adoption of OSPF
• RIP viewed as outmoded
– Good when networks small and routers had
limited memory & computational power
• OSPF Advantages
– Fast convergence when configuration
changes
– Full topology map helps
34
35
36
12