Transcript Document
An Introduction
to
Computer Networks
Lecture 9: Routing
University of Tehran
Dept. of EE and Computer Engineering
By:
Dr. Nasser Yazdani
Univ. of Tehran
Introduction to Computer Network
1
Outline
Routing process
Routing Algorithms
Scalability
Univ. of Tehran
Introduction to Computer Network
2
Routing Process
Question? How to populate the lookup table?
Forwarding vs Routing
forwarding: to select an output port based on destination
address from the lookup table.
routing: process by which the routing table is built.
Minimize the lookup time.
Optimize the calculating paths in case of changing topology.
Primery solutions:
Build the lookup table Manually? Is it practical? The
answer is no.
Flooding- Broadcast to all node except the one we
have received the packet.
Waste the bandwidth
Not scale well- Broadcast storm.
Univ. of Tehran
Introduction to Computer Network
3
Overview
Network as a Graph
A
6
1
3
4
C
2
1
B
9
E
F
1
D
Problem: Find lowest cost, or shortest, path between
two nodes
The process is distributed and this makes it
complicated, I.e, it may create loop.
Factors
static: topology
dynamic: load
Univ. of Tehran
Introduction to Computer Network
4
Distance Vector
Each node maintains a set of triples
(Destination, Cost, NextHop)
Exchange updates directly connected neighbors
periodically ( on the order of several seconds)
whenever its table changes (called triggered update)
Each update is a list of pairs:
(Destination, Cost)
Update local table if receive a “better” route
smaller cost
came from next-hop
Refresh existing routes; delete if they time out
Univ. of Tehran
Introduction to Computer Network
5
The Bellman-Ford Algorithm
•Bellman-Ford algorithm solve the distance Vector
problem in general case.
1. Set: Xo = (
,
,
,…,
).
2. Send updates of components of Xn to neighbors
3. Calculate: Xn+1 = F(Xn)
4. If Xn+1
Xn then go to (2)
5. Stop
Univ. of Tehran
Introduction to Computer Network
6
Distance Vector: Control
Traffic
By changing the routing table, a node sends its
table to its neighbors
A node updates its table with information received
from its neighbors
Host C
Host D
Host A
N1
N2
N3
N5
Host B
Host E
N4
Univ. of Tehran
N6
Introduction to Computer Network
N7
7
Example: Distance Vector
Algorithm
Node B
Node A
Dest. Cost NextHop
2
A
B
7
3
1
C
D
1
B
2
B
C
7
C
A
2
A
D
∞
-
C
1
C
D
3
D
Node C
1 Initialization:
2 for all neighbors V do
3
if V adjacent to A
4
D(A, V) = c(A,V);
5 else
6
D(A, V) = ∞;
…
Univ. of Tehran
Dest. Cost NextHo
p
Node D
Dest Cost NextHo
.
p
Dest. Cost
NextHo
p
A
7
A
A
∞
-
B
1
B
B
3
B
D
1
D
C
1
C
Introduction to Computer Network
8
Example: 1st Iteration (C A)
Node A
2
A
B
7
3
1
C
D
1
Node B
Dest.
Cost
NextHop
B
2
B
C
7
C
A
2
A
D
∞
-
C
1
C
D
3
D
Dest. Cos
t
…
7 loop:
Node C (D(C,A), D(C,B), D(C,D))
…
12 else if (update D(V, Y) received from V)
13
for all destinations Y do
Dest
Dest Cos NextHo
14
if (destination Y through V)
15
D(A,Y) = D(A,V) + D(V, Y);
t
p
16
else
A
17
D(A, Y) = min(D(A, Y),
A
7
A
D(A, V) + D(V, Y));
B
18 if (there is a new minimum for dest. Y)
B
1
B
19 send D(A, Y) to all neighbors
C
D
1
D
20 forever
Univ. of Tehran
Introduction to Computer Network
NextH
op
Node D
Cost NextHo
p
∞
-
3
B
1
C
9
Example: 1st Iteration (C A)
Node A
Node B
Dest. Cost NextHo
p
2
A
B
7
3
1
C
D
1
B
2
B
C
7
C
D
8
C
Des Cos
t.
t
NextH
op
A
2
A
C
1
C
D
3
D
D(A, D) = min(D(A, D), D(A, C) + D(C,D)
= min(∞ , 7 + 1) = 8
…
7 loop:
(D(C,A), D(C,B), D(C,D))
…
Node D
12 else if (update D(V, Y) received from V) Node C
13
for all destinations Y do
Des Cos NextH
Des
14
if (destination Y through V)
15
D(A,Y) = D(A,V) + D(V, Y);
t.
t
op
t.
16
else
17
D(A, Y) = min(D(A, Y),
A
7
A
A
D(A, V) + D(V, Y));
18 if (there is a new minimum for dest. Y)
B
1
B
B
19 send D(A, Y) to all neighbors
D
1
D
C
20 forever
Univ. of Tehran
Introduction to Computer Network
Cos
t
NextH
op
∞
-
3
B
1
C
10
Example: 1st Iteration (B A)
Node B
Node A
2
A
B
7
Dest. Cost NextHo
p
3
1
C
D
1
Des Cos
t.
t
NextH
op
B
2
B
A
2
A
C
7
C
C
1
C
D
8
C
D
3
D
…
7 loop:
Node C
…
12 else if (update D(V, Y) received from V)
Dest Cost NextHo
13
for all destinations Y do
p
14
if (destination Y through V)
15
D(A,Y) = D(A,V) + D(V, Y);
A
7
A
16
else
17
D(A, Y) = min(D(A, Y),
B
1
B
D(A, V) + D(V, Y));
18 if (there is a new minimum for dest. Y)
D
1
D
19 send D(A, Y) to all neighbors
20 forever
Univ. of Tehran
Introduction to Computer Network
Node D
Dest. Cost
NextHo
p
A
∞
-
B
3
B
C
1
C
11
Example: 1st Iteration (BA,
CA)
Node A
Node B
Dest. Cost NextHo
p
2
A
B
7
3
1
C
D
1
B
2
B
C
3
B
D
5
B
Des Cos
t.
t
NextH
op
A
2
A
C
1
C
D
3
D
…
D(A,D) = min(D(A,D), D(A,B) + D(B,D)) D(A,C) = min(D(A,C), D(A,B) + D(B,C))
7 loop:
= min(8, 2 + 3) = 5
= min(7, 2 + 1) = 3
…
Node D
12 else if (update D(V, Y) received from V) Node C
13
for all destinations Y do
Dest. Cost NextHo
Dest. Cos NextH
14
if (destination Y through V)
15
D(A,Y) = D(A,V) + D(V, Y);
p
t
op
16
else
17
D(A, Y) = min(D(A, Y),
A
7
A
A
∞
D(A, V) + D(V, Y));
18 if (there is a new minimum for dest. Y)
B
1
B
B
3
B
19 send D(A, Y) to all neighbors
D
1
D
C
1
C
20 forever
Univ. of Tehran
Introduction to Computer Network
12
Example: End of
st
1
Iteration
Node B
Node A
Dest. Cost NextHo
p
2
A
B
7
3
1
C
D
1
Des Cos
t.
t
NextH
op
B
2
B
A
2
A
C
3
B
C
1
C
D
5
B
D
2
C
…
7 loop:
Node C
…
12 else if (update D(V, Y) received from V)
13
for all destinations Y do
Des Cos NextH
14
if (destination Y through V)
t.
t
op
15
D(A,Y) = D(A,V) + D(V, Y);
16
else
A
3
B
17
D(A, Y) = min(D(A, Y),
D(A, V) + D(V, Y));
B
1
B
18 if (there is a new minimum for dest. Y)
19 send D(A, Y) to all neighbors
D
1
D
20 forever
Univ. of Tehran
Introduction to Computer Network
Node D
Des Cos
t.
t
NextH
op
A
2
B
B
3
B
C
1
C
13
Example: End of
nd
3
Iteration
Node A
Dest. Cost NextHo
p
2
A
B
7
3
1
C
D
1
…
7 loop:
…
12 else if (update D(V, Y) received from V)
13
for all destinations Y do
14
if (destination Y through V)
15
D(A,Y) = D(A,V) + D(V, Y);
16
else
17
D(A, Y) = min(D(A, Y),
D(A, V) + D(V, Y));
18 if (there is a new minimum for dest. Y)
19 send D(A, Y) to all neighbors
20 forever
B
2
B
C
3
B
D
4
B
Des Cos
t.
t
NextH
op
A
2
A
C
1
C
D
2
C
Node D
Node C
Dest Cos NextHo
.
t
p
A
3
B
B
1
B
D
1
D
Nothing changes algorithm terminates
Univ. of Tehran
Node B
Introduction to Computer Network
Dest. Cost
NextHo
p
A
4
C
B
2
C
C
1
C
14
Link Cost Changes
7 loop:
8 wait (link cost update or update message)
9 if (c(A,V) changes by d)
10
for all destinations Y through V do
11
D(A,Y) = D(A,Y) + d
12 else if (update D(V, Y) received from V)
13
for all destinations Y do
14
if (destination Y through V)
15
D(A,Y) = D(A,V) + D(V, Y);
16
else
17
D(A, Y) = min(D(A, Y), D(A, V) + D(V, Y));
18 if (there is a new minimum for destination Y)
19 send D(A, Y) to all neighbors
20 forever
Node B
Node C
1
4
A
D C N
D C N
D C N
D C N
A 4 A
A 1 A
A 1 A
A 1 A
C 1 B
D C N
C 1 B
D C N
C 1 B
D C N
C 1 B
D C N
A 5 B
A 5 B
A 2 B
A 2 B
B 1 B
B 1 B
B 1 B
B 1 B
B
1
50
time
cost changes here
Algorithm
terminates
Univ.Link
of Tehran
Introduction to Computer
Network
C
“good
news
travels
fast”
15
Example
B
C
A
D
E
G
F
Destination Cost
A
1
C
1
D
2
E
2
F
2
G
3
NextHop
A
C
C
A
A
A
•Distance of other nodes from Node B.
• The cost between two nodes has been assumed 1.
•All nodes keep a routing table from themselves.
Univ. of Tehran
Introduction to Computer Network
16
Routing Loops
Example
link from A to E fails
A advertises distance of infinity to E
B and C advertise a distance of 2 to E
B decides it can reach E in 3 hops; advertises this to A
A decides it can read E in 4 hops; advertises this to C
C decides that it can reach E in 5 hops…
Univ. of Tehran
Introduction to Computer Network
17
Loop-Breaking Heuristics
Set infinity to a reasonably small number.
For instance, RIP sets to 16
Split horizon: Don’t announce the distance
to the node the distance has been gotten
from.
Split horizon with poison reverse: Instead of
not announcing the distance put negative
numbers.
Univ. of Tehran
Introduction to Computer Network
18
Link State
Strategy
send to all nodes (not just neighbors) information
about directly connected links (not entire routing
table)
Link State Packet (LSP)
id of the node that created the LSP
cost of the link to each directly connected
neighbor
sequence number (SEQNO)
time-to-live (TTL) for this packet
Univ. of Tehran
Introduction to Computer Network
19
Link State (cont)
Reliable flooding
store most recent LSP from each node
forward LSP to all nodes but one that sent it
generate new LSP periodically
increment SEQNO
start SEQNO at 0 when reboot
decrement TTL of each stored LSP
discard when TTL=0
Univ. of Tehran
Introduction to Computer Network
20
Route Calculation
Dijkstra’s shortest path algorithm
Let
N denotes set of nodes in the graph
l (i, j) denotes non-negative cost (weight) for edge (i, j)
s denotes this node
M denotes the set of nodes incorporated so far
C(n) denotes cost of the path from s to node n
M = {s}
for each n in N - {s}
C(n) = l(s, n)
while (N != M)
M = M union {w} such that C(w)
is the minimum for all w in (N - M)
for each n in (N - M)
C(n) = MIN(C(n), C (w) + l(w, n ))
Univ. of Tehran
Introduction to Computer Network
21
Link state (Example)
•Two list confirmed and tentative
•Always, select the one with
minimum distance from the
tentative list.
B
5
A
10
3
C
11
D
2
Step
Confirmed
1
(D,0,-)
2
(D,0,-)
(B,11,B), (C,2,C)
3
(D,0,-), (C,2,C)
(B,5,C), (A, 13,C)
Univ. of Tehran
Tentative
Introduction to Computer Network
22
Interior Gateway Protocols
RIP: Route Information Protocol
developed for XNS
distributed with Unix
distance-vector algorithm
based on hop-count
OSPF: Open Shortest Path First
recent Internet standard
uses link-state algorithm
supports load balancing
supports authentication
Univ. of Tehran
Introduction to Computer Network
23
Metrics
Original ARPANET metric
measures number of packets enqueued on each link
took neither latency or bandwidth into consideration
New ARPANET metric
stamp each incoming packet with its arrival time (AT)
record departure time (DT)
when link-level ACK arrives, compute
Delay = (DT - AT) + Transmit + Latency
if timeout, reset DT to departure time for retransmission
link cost = average delay over some time period
Fine Tuning
compressed dynamic range
replaced dynamic with link utilization
Univ. of Tehran
Introduction to Computer Network
24
How to Make Routing Scale
Flat versus Hierarchical Addresses
Inefficient use of Hierarchical Address Space
class C with 2 hosts (2/255 = 0.78% efficient)
class B with 256 hosts (256/65535 = 0.39%
efficient)
Still Too Many Networks
routing tables do not scale
route propagation protocols do not scale
Univ. of Tehran
Introduction to Computer Network
25
Subnetting
Add another level to address/routing hierarchy:
subnet
Subnet masks define variable partition of host part
Subnets visible only within site
Network number
Host number
Class B address
1111111111111111111
0000000000000000
Subnet mask (255.255.0.0)
Network number
Univ. of Tehran
Subnet ID
Subnetted address
Host ID
Introduction to Computer Network
26
Subnet Example
Subnet
Net
host
Subnet mask: 255.255.255.128.
Subnet number: 128.96.34.0
128.96.34.15
H1
111….1.0xxx….x
128.96.34.1
R1
Subnet mask: 255.255.255.128
Subnet number: 128.96.34.128
128.96.34.130
128.96.34.139
128.96.34.129
H3
128.96.33.14
H2
R2
128.96.33.1 Forwarding
Subnet mask: 255.255.255.0
Subnet number: 128.96.33.0
Univ. of Tehran
table at router R1
Subnet #
128.96.34.0
128.96.34.128
128.96.33.0
Subnet Mask
255.255.255.128
255.255.255.128
255.255.255.0
Introduction to Computer Network
Next Hop
interface 0
interface 1
R2
27
Forwarding Algorithm
D = destination IP address
for each entry (SubnetNum, SubnetMask, NextHop)
D1 = SubnetMask & D
if D1 = SubnetNum
if NextHop is an interface
deliver datagram directly to D
else
deliver datagram to NextHop
Use a default router if nothing matches
Not necessary for all 1s in subnet mask to be
contiguous
Can put multiple subnets on one physical network
Subnets
not visible
fromtothe
rest
of the Internet 28
Univ. of Tehran
Introduction
Computer
Network
Supernetting
Assign block of contiguous network numbers to
nearby networks
Called CIDR: Classless Inter-Domain Routing
Represent blocks with a single pair
(first_network_address, count)
Restrict block sizes to powers of 2
Use a bit mask (CIDR mask) to identify block size
All routers must understand CIDR addressing
Univ. of Tehran
Introduction to Computer Network
29
Route Propagation
Know a smarter router
Autonomous System (AS)
hosts know local router
local routers know site routers
site routers know core router
core routers know everything
corresponds to an administrative domain
examples: University, company, backbone network
assign each AS a 16-bit number
Two-level route propagation hierarchy
interior gateway protocol (each AS selects its own)
exterior gateway protocol (Internet-wide standard)
Univ. of Tehran
Introduction to Computer Network
30
EGP: Exterior Gateway Protocol
Overview
Designed for tree-structured Internet
Concerned with reachability, not optimal routes
Protocol messages
neighbor acquisition: one router requests that another be
its peer; peers exchange reachability information
neighbor reachability: one router periodically tests if the
another is still reachable; exchange HELLO/ACK
messages;
routing updates: peers periodically exchange their routing
tables (distance-vector)
Univ. of Tehran
Introduction to Computer Network
31
BGP-4: Border Gateway Protocol
AS Types
stub AS: has a single connection to one other AS
multihomed AS: has connections to more than one AS
refuses to carry transit traffic
transit AS: has connections to more than one AS
carries local traffic only
carries both transit and local traffic
Each AS has:
one or more border routers
one BGP speaker that advertises:
local networks
other reachable networks (transit AS only)
gives path information
Univ. of Tehran
Introduction to Computer Network
32
BGP Example
Speaker for AS2 advertises reachability to P and Q
network 128.96, 192.4.153, 192.4.32, and 192.4.3, can
be reached directly from AS2
Customer P
(AS 4)
128.96
192.4.153
Customer Q
(AS 5)
192.4.32
192.4.3
Customer R
(AS 6)
192.12.69
Customer S
192.4.54
192.4.23
Regional provider A
(AS 2)
Backbone network
(AS
1)
Regional provider B
(AS 3)
(AS 7)
Speaker for backbone advertises
networks 128.96, 192.4.153, 192.4.32, and 192.4.3 can be reached
along the path (AS1, AS2).
Speaker
can cancelIntroduction
previously
advertised
paths
Univ. of Tehran
to Computer
Network
33
Internet Structure
Recent Past
NSFNET backbone
Stanford
ISU
BARRNET
MidNet
regional
regional
Westnet
regional
Berkeley
PARC
UNM
NCAR
UNL
KU
UA
Univ. of Tehran
Introduction to Computer Network
34
Internet Structure
Today
Large corporation
“Consumer
” ISP
Peering
point
Backbone service provider
Peering
point
“ Consumer ” ISP
Large corporation
“Consumer ”ISP
Small
corporation
Univ. of Tehran
Introduction to Computer Network
35