IP Rout
IP Rout
Network Layer 2
Interplay between routing, forwarding
routing algorithm determines
routing algorithm
end-end-path through network
forwarding table determines
local forwarding table
local forwarding at this router
dest address output link
address-range 1 3
address-range 2 2
address-range 3 2
address-range 4 1
IP destination address in
arriving packet’s header
1
3 2
Network Layer 3
Context and Terminology
“Autonomous System (AS)” or “Domain”
Region of a network under a single administrative entity
“End hosts”
“Clients”, “Users”
“End points”
“Border Routers”
“Route” or “Path”
“Interior Routers”
4
Network Layer
Internet Routing
v Internet Routing works at two levels
5
Network Layer
Graph abstraction
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
graph: G = (N,E)
N = set of routers = { u, v, w, x, y, z }
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
Network Layer 6
Addressing (abstraction)
v Assume each host has a unique ID (address)
7
Network Layer
Graph abstraction: costs
5
c(x,x’) = cost of link (x,x’)
3 e.g., c(w,z) = 5
v w 5
2
u 2 1 z
3
1 2
x 1
y
Network Layer 8
Quiz: How should link costs be determined?
10
Network Layer
Routing algorithm classes
Link State (Global) Distance Vector (Decentralised)
Network Layer 11
Network Layer: outline
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and § link state
datagram networks § distance vector
4.3 what’s inside a router § hierarchical routing
4.4 IP: Internet Protocol 4.6 routing in the Internet
§ datagram format § RIP
§ IPv4 addressing § OSPF
§ BGP
§ ICMP
§ IPv6 4.7 broadcast and multicast
routing
Network Layer 12
Link State Routing
v Each node maintains its local “link state” (LS)
§ i.e., a list of its directly attached links and their costs
(N1,N2)
(N1,N4)
(N1,N5) Host C
Host A Host D
N1 N2
N3
N5
Host B
N4 Host E
N6 N7
13
Network Layer
Link State Routing
v Each node maintains its local “link state” (LS)
v Each node floods its local link state
§ on receiving a new LS message, a router forwards the message
to all its neighbors other than the one it received the message from
Host C
Host A Host D
(N1,N2)
(N1, N4)
(N1, N5)
(N1,N2)
(N1, N4)
(N1, N5)
N1 N2
(N1,N2)
(N1, N4)
(N1, N5)
N3
(N1,N2)
(N1, N4)
(N1, N5)
(N1,N2)
(N1, N4) N5 (N1,N2)
(N1, N4)
(N1,N2)
(N1, N5) (N1, N5)
(N1, N4)
(N1,N2) (N1, N5)
(N1, N4)
(N1, N5)
Host B
N4 Host E
(N1,N2)
(N1, N4)
(N1,N2)
(N1, N4) N6 (N1, N5)
N7
(N1, N5)
14
Network Layer
Flooding LSAs
v Routers transmit Link State Advertisement (LSA)
on links
§ A neighbouring router forwards out on all links except
incoming
§ Keep a copy locally; don’t forward previously-seen
LSAs
v Challenges
§ Packet loss
§ Out of order arrival
v Solutions
§ Acknowledgements and retransmissions
§ Sequence numbers
§ Time-to-live for each packet 15
Network Layer
Link State Routing
v Each node maintains its local “link state” (LS)
v Each node floods its local link state
v Eventually, each node learns the entire network topology
§ Can use Dijkstra’s to compute the shortest paths between nodes
C
A D Host C C
A D
Host A Host D
B
E B
E
C N1 N2
A D C
A D
N3
C
B A
E D
A
C
D
N5 B
E
Host B B
E
N4 B
E A
C
D
Host E
N6 N7
B 16
E Network Layer
A Link-State Routing Algorithm
Dijkstra’s algorithm notation:
v net topology, link costs v c(x,y): link cost from
known to all nodes node x to y; = ∞ if not
§ accomplished via “link state direct neighbors
broadcast” v D(v): current value of
§ all nodes have same info cost of path from source
v computes least cost paths to dest. v
from one node (‘source”) v p(v): predecessor node
to all other nodes along path from source to
§ gives forwarding table for v
that node v N': set of nodes whose
v iterative: after k least cost path definitively
iterations, know least cost known
path to k dest.’s
Network Layer 17
Dijsktra’s Algorithm
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N' :
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'
Network Layer 18
Example: Dijkstra’s Algorithm
5 1 Initialization:
2 N’ = {A};
3 3 for all nodes v
B C
2 5
4 if v adjacent to A
A 2 1 F 5 then D(v) = c(A,v);
3
1 2 6 else D(v) = ∞;
D E …
1
19
Network Layer
Example: Dijkstra’s Algorithm
Step Set N’ 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
2
3
4
5
…
5 8 Loop
3 9 find w not in N’ s.t. D(w) is a minimum;
B C 10 add w to N’;
2 5
11 update D(v) for all v adjacent
A 2 1 F
3 to w and not in N’:
1 2 12 If D(w) + c(w,v) < D(v) then
D E 13 D(v) = D(w) + c(w,v); p(v) = w;
1
14 until all nodes in N’;
Network Layer
Example: Dijkstra’s Algorithm
Step Set N’ 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
3
4
5
…
5 8 Loop
3 9 find w not in N’ s.t. D(w) is a minimum;
B C 10 add w to N’;
2 5
11 update D(v) for all v adjacent
A 2 1 F
3 to w and not in N’:
1 2 12 If D(w) + c(w,v) < D(v) then
D E 13 D(v) = D(w) + c(w,v); p(v) = w;
1
14 until all nodes in N’;
21
Network Layer
Example: Dijkstra’s Algorithm
Step Set N’ 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 4,D 2,D
2
3
4
5
…
5 8 Loop
3 9 find w not in N’ s.t. D(w) is a minimum;
B C 10 add w to N’;
2 5
11 update D(v) for all v adjacent
A 2 1 F
3 to w and not in N’:
1 2 12 If D(w) + c(w,v) < D(v) then
D E 13 D(v) = D(w) + c(w,v); p(v) = w;
1
14 until all nodes in N’;
22
Network Layer
Example: Dijkstra’s Algorithm
Step Set N’ 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 4,D 2,D
2 ADE 3,E 4,E
3
4
5
…
5 8 Loop
3 9 find w not in N’ s.t. D(w) is a minimum;
B C 10 add w to N’;
2 5
11 update D(v) for all v adjacent
A 2 1 F
3 to w and not in N’:
1 2 12 If D(w) + c(w,v) < D(v) then
D E 13 D(v) = D(w) + c(w,v); p(v) = w;
1
14 until all nodes in N’;
23
Network Layer
Example: Dijkstra’s Algorithm
Step Set N’ 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 4,D 2,D
2 ADE 3,E 4,E
3 ADEB
4
5
…
5 8 Loop
3 9 find w not in N’ s.t. D(w) is a minimum;
B C 10 add w to N’;
2 5
11 update D(v) for all v adjacent
A 2 1 F
3 to w and not in N’:
1 2 12 If D(w) + c(w,v) < D(v) then
D E 13 D(v) = D(w) + c(w,v); p(v) = w;
1
14 until all nodes in N’;
24
Network Layer
Example: Dijkstra’s Algorithm
Step Set N’ 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 4,D 2,D
2 ADE 3,E 4,E
3 ADEB
4 ADEBC
5
…
5 8 Loop
3 9 find w not in N’ s.t. D(w) is a minimum;
B C 10 add w to N’;
2 5
11 update D(v) for all v adjacent
A 2 1 F
3 to w and not in N’:
1 2 12 If D(w) + c(w,v) < D(v) then
D E 13 D(v) = D(w) + c(w,v); p(v) = w;
1
14 until all nodes in N’;
25
Network Layer
Example: Dijkstra’s Algorithm
Step Set N’ 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 4,D 2,D
2 ADE 3,E 4,E
3 ADEB
4 ADEBC
5 ADEBCF
…
5 8 Loop
3 9 find w not in N’ s.t. D(w) is a minimum;
B C 10 add w to N’;
2 5
11 update D(v) for all v adjacent
A 2 1 F
3 to w and not in N’:
1 2 12 If D(w) + c(w,v) < D(v) then
D E 13 D(v) = D(w) + c(w,v); p(v) = w;
1
14 until all nodes in N’;
26
Network Layer
Example: Dijkstra’s Algorithm
Step Set N’ 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 4,D 2,D
2 ADE 3,E 4,E
3 ADEB
4 ADEBC
5 ADEBCF
5
3 To determine path A → C (say),
B C
2 5 work backward from C via p(v)
A 2 1 F
3
1 2
D E
1
27
Network Layer
The Forwarding Table
• Running Dijkstra at node A gives the shortest
path from A to all destinations
• We then construct the forwarding table
Destination Link
resulting shortest-path tree from A: B (A,B)
B C C (A,D)
A F D (A,D)
D E E (A,D)
F (A,D)
28
Network Layer
Dijkstra’s algorithm: example
D(v) D(w) D(x) D(y) D(z)
Step N' p(v) p(w) p(x) p(y) p(z) WORK THIS OUT
0 u 7,u 3,u 5,u ∞ ∞ BY YOURSELF
1 uw 6,w 5,u 11,w ∞
2 uwx 6,w 11,w 14,x
3 uwxv 10,v 14,x
4 uwxvy 12,y
5 uwxvyz x
9
notes: 5
4
7
v construct shortest path tree by
tracing predecessor nodes 8
v ties can exist (can be broken u
3 w y z
arbitrarily) 2
3
7 4
v
Network Layer 29
Practice Problem
WORK THIS OUT
BY YOURSELF
http://gaia.cs.umass.edu/kurose_ross/interactive/dij.php
Network Layer 30
Issue #1: Scalability
v How many messages needed to flood link state messages?
§ O(N x E), where N is #nodes; E is #edges in graph
31
Network Layer
Issue#2: Transient Disruptions
v Inconsistent link-state database
§ Some routers know about failure before others
§ The shortest paths are no longer consistent
§ Can cause transient forwarding loops
B C B C
A F A F
D E Loop! D E
1
A 1+e A A A
2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D 1+e 1 B
0 0
0 e 0 0
1
C C 0 1
C 1+e C 0
1
e
given these costs, given these costs, given these costs,
initially find new routing…. find new routing…. find new routing….
resulting in new costs resulting in new costs resulting in new costs
Network Layer 33
Network Layer: outline
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and § link state
datagram networks § distance vector
4.3 what’s inside a router § hierarchical routing
4.4 IP: Internet Protocol 4.6 routing in the Internet
§ datagram format § RIP
§ IPv4 addressing § OSPF
§ BGP
§ ICMP
§ IPv6 4.7 broadcast and multicast
routing
Network Layer 34
How Distance-Vector (DV) works
Neighbour
From node A (next-hop)
A via via
B C
to B
to C
Destinations to D distC(A, D): shortest
distance from A to D via C
to B to B
to C to C
to D to D
to B ? ? to B ?
to C ? ? to C ?
to D ? ? to D ?
A Link costs
41
Network Layer
How Distance-Vector (DV) works
A’s DV From node B B’s DV
B min mindist
via A via C
to B 5 to A 5 ∞ to A 5
to C 6 to C 1115 1 to C 1
A to D 2 to D 7 ∞ ∞ to D 7∞
C
new = c(B,A) + mindist(A, D)
C)
Network Layer 44
v c(i,j): link cost from node i to j
distZ(A,V): shortest dist. from A to V via Z
Distance Vector v
0 At node A
1 Initialization:
2 for all destinations V do
3 if V is neighbor of A
4 distV(A, V) = mindist(A,V) = c(A,V);
5 else
6 distV(A, V) = mindist(A,V) = ∞;
7 send mindist(A, *) to all neighbors
loop:
8 wait (until A sees a link cost change to neighbor V /* case 1 */
9 or until A receives mindist(V,*) from neighbor V) /* case 2 */
10 if (c(A,V) changes by ±d) /* ⇐ case 1 */
11 for all destinations Y do
12 distV(A,Y) = distV(A,Y) ± d
13 else /* ⇐ case 2: */
14 for all destinations Y do
15 distV(A,Y) = c(A,V) + mindist(V, Y);
16 update mindist(A,*)
15 if (there is a change in mindist(A, *))
16 send mindist(A, *) to all neighbors
17 forever
45
Network Layer
v c(i,j): link cost from node i to j
distZ(A,V): shortest dist. from A to V via Z
Distance Vector v
0 At node A
1 Initialization:
2 for all destinations V do
3 if V is neighbor of A
4 distV(A, V) = mindist(A,V) = c(A,V);
5 else
6 distV(A, V) = mindist(A,V) = ∞;
7 send mindist(A, *) to all neighbors
loop:
8 wait (until A sees a link cost change to neighbor V /* case 1 */
9 or until A receives mindist(V,*) from neighbor V) /* case 2 */
10 if (c(A,V) changes by ±d) /* ⇐ case 1 */
11 for all destinations Y do
12 distV(A,Y) = distV(A,Y) ± d
13 else /* ⇐ case 2: */
14 for all destinations Y do
15 distV(A,Y) = c(A,V) + mindist(V, Y);
16 update mindist(A,*)
15 if (there is a change in mindist(A, *))
16 send mindist(A, *) to all neighbors
17 forever
46
Network Layer
Example: Initialization
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 ∞
to A 2 ∞ ∞ to A ∞ ∞
0 3
to B - - - to B 3 ∞
to C ∞ 1 ∞ 1 to C ∞ 1 1
to D ∞ ∞ 3 3 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min min via via via dist
dist dist A B D
B C
to
0A 0 7
to A - - to A 7 ∞ ∞
to
2B 2 to B ∞ 1 ∞ 1
to B 2 ∞
to
7C 7 to C - - - 0
to C ∞ 7
to D ∞ ∞ to
∞D ∞ to D ∞ ∞ 1 1
Example: C sends update to A
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 ∞
to A 2 ∞ ∞ to A ∞ ∞
0 3
to B - - - to B 3 ∞
to C ∞ 1 ∞ 1 to C ∞ 1 1
to D ∞ ∞ 3 3 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 7
to A - - to A 7 ∞ ∞
2 to B ∞ 1 ∞ 1
to B 2 ∞
7 to C - - - 0
to C ∞ 7
to D ∞ ∞ ∞ to D ∞ ∞ 1 1
Example: C sends update to A
B 3 D
2 1
1
A C
from Node A 7
min min
via via dist dist
B C
0 7
to A - -
2 1
to B 2 ∞
7 0
to C ∞ 7
to D ∞ ∞ ∞ 1
Example: C sends update to A
B 3 D
2 1
1
A C
from Node A 7
min min
via via dist dist
B C
0 7
to A - -
2 1
to B 2 8
7 0
to C ∞ 7
to D ∞ 8 ∞ 1
Example: C sends update to A
B 3 D
2 1
1
A C
from Node A 7
min
via via dist
B C
0
to A - -
to B 2 8 2
to C ∞ 7 7
to D ∞ 8 8
Example: now B sends update to A
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 ∞
to A 2 ∞ ∞ to A ∞ ∞
0 3
to B - - - to B 3 ∞
to C ∞ 1 ∞ 1 to C ∞ 1 1
to D ∞ ∞ 3 3 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 7
to A - - to A 7 ∞ ∞
2 to B ∞ 1 ∞ 1
to B 2 8
7 to C - - - 0
to C ∞ 7
to D ∞ 8 8 to D ∞ ∞ 1 1
Example: now B sends update to A
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 ∞
to A 2 ∞ ∞ to A ∞ ∞
0 3
to B - - - to B 3 ∞
to C ∞ 1 ∞ 1 to C ∞ 1 1
to D ∞ ∞ 3 3 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 7
to A - - to A 7 ∞ ∞
2 to B ∞ 1 ∞ 1
to B 2 8
7 to C - - - 0
to C ∞ 7
to D ∞ 8 8 to D ∞ ∞ 1 1
Example: now B sends update to A
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 ∞
to A 2 ∞ ∞ to A ∞ ∞
0 3
to B - - - to B 3 ∞
to C ∞ 1 ∞ 1 to C ∞ 1 1
to D ∞ ∞ 3 3 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 Make sure you
to A know
7 ∞ ∞
7
to A - -
to B 2 8 2 why this isto5,B not
∞ 4!1 ∞ 1
7 to C - - - 0
to C 3 7
to D 5 8 8 to D ∞ ∞ 1 1
Example: now B sends update to A
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 ∞
to A 2 ∞ ∞ to A ∞ ∞
0 3
to B - - - to B 3 ∞
to C ∞ 1 ∞ 1 to C ∞ 1 1
to D ∞ ∞ 3 3 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 7
to A - - to A 7 ∞ ∞
2 to B ∞ 1 ∞ 1
to B 2 8
3 to C - - - 0
to C 3 7
to D 5 8 5 to D ∞ ∞ 1 1
Make
All nodes surethe
know youbest
st understand
two-hop whypaths.
Example: After some
1 Full
entries are
Exchange
still
Make sure you believe this ∞
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 5
to A 2 8 ∞ to A 5 8
0 2
to B - - - to B 3 2
to C 9 1 4 1 to C 4 1 1
to D ∞ 2 3 2 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 3
to A - - to A 7 3 ∞
2 to B 9 1 4 1
to B 2 8
3 to C - - - 0
to C 3 7
to D 5 8 5 to D ∞ 4 1 1
Example: Now A sends update to B
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 5
to A 2 8 ∞ to A 5 8
0 2
to B - - - to B 3 2
to C 9 1 4 1 to C 4 1 1
to D ∞ 2 3 2 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 3
to A - - to A 7 3 ∞
2 to B 9 1 4 1
to B 2 8
3 to C - - - 0
to C 3 7
to D 5 8 5 to D ∞ 4 1 1
Updatedto B
Example: Now A sends update
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 5
to A 2 8 ∞ to A 5 8
0 2
to B - - - to B 3 2
to C 5 1 4 1 to C 4 1 1
to D 7 2 3 2 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 3
to A - - to A 7 3 ∞
2 to B 9 1 4 1
to B 2 8
3 to C - - - 0
to C 3 7
to D 5 8 5 to D ∞ 4 1 1
nd Full Exchange
Check: All nodes know the best three-hop paths.
Example: End of 2
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 4
to A 2 4 8 to A 5 4
0 2
to B - - - to B 3 2
to C 5 1 4 1 to C 4 1 1
to D 7 2 3 2 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 3
to A - - to A 7 3 6
2 to B 9 1 3 1
to B 2 8 Check 0
to C 3 7 3 to C - - -
to D 4 8 4 to D 12 3 1 1
Example: End of 3nd Full Exchange
No further change in DVs à Convergence!
from Node B from Node D
min min
via via via via via dist
dist
A C D B C
2 4
to A 2 4 7 to A 5 4
0 2
to B - - - to B 3 2
to C 5 1 4 1 to C 4 1 1
to D 6 2 3 2 to D - - 0
B 3 D
2 1
1
A C
from Node A from Node C
7 min
via via min via via via dist
dist A B D
B C
0 3
to A - - to A 7 3 5
2 to B 9 1 3 1
to B 2 8
3 to C - - - 0
to C 3 7
to D 4 8 4 to D 11 3 1 1
Intuition
v Initial state: best one-hop paths
v One simultaneous round: best two-hop paths
v Two simultaneous rounds: best three-hop paths
v …
v Kth simultaneous round: best (k+1) hop paths
Node A B C B C B C B C B C
B 4 51 B 1 51 B 1 51 B 1 51 B 1 51
to
C 5 50 C 2 50 Note:
C 2none 50 of B’sC 2 50 C 2 50
deduct 3 from distances
Node B A C A C paths use link
Adist (A,C) A C
C(A,*) A C
B and distA(B,*)
A 4 6 A 1 6 A 1 6 A 1 6 A 1 3
C 9 1 C 6 1 C 3 1 C 3 1 C 3 1
Node C A B A B A B A B A B
A 50 5 A 50 5 A 50 5 A 50 2 A 50 2
B 54 1 B 54 1 B 51 1 B 51 1 B 51 1
Node C A B A B
A 50 5 A 50 5
B 54 1 B 54 1
Node A B C B C B C B C B C
B 4 51 B 60 51 B 60 51 B 60 51 B 60 51
to
C 5 50 C 61 50 C 61 50 C 61 50 C 61 50
Node B A C A C A C A C A C
A 4 6 A 60 6 A 60 6 A 60 6 A 60 8
C 9 1 C 65 1 C 110 1 C 110 1 C 110 1
Node C A B A B A B A B A B
A 50 5 A 50 5 A 50 5 A 50 7 A 50 7
B 54 1 B 54 1 B 101 1 B 101 1 B 101 1
65
Network Layer
DV: Poisoned Reverse 60
4
B
1
If B routes through C to get to A: A C
B tells C its (B’s) distance to A is infinite 50
Node C A B A B
A 50 5 A 50 5
B 54 1 B 54 1
Node A B C B C B C B C
B 4 51 B 60 51 B 60 51 B 60 51
to
C 5 50 C 61 50 C 61 50 C 61 50
Node B A C A C A C A C
A 4 ∞
6 A 60 ∞
6 A 60 ∞
6 A 60 ∞
6
C ∞
9 1 ∞
C 65 1 C 110 1 C 110 1
Node C A B A B A B A B
A 50 5 A 50 5 A 50 5 A 50 7
B 54 1 B 54 1 ∞
B 101 1 ∞
B 101 1
Node A B C B C B C B C
B 4 51 B 60 51 B 60 51 B 60 51
to
C 5 50 C 61 50 C 61 50 C 61 50
Node B A C A C A C A C
A 4 ∞
6 A 60 ∞
6 A 60 ∞
6 A 60 ∞
6
C ∞
9 1 ∞
C 65 1 C 110 1 C 110 1
Node C A B A B A B A B
A 50 5 A 50 5 A 50 5 A 50 61
B 54 1 B 54 1 ∞
B 101 1 ∞
B 101 1
Stable state A-B changed A sends its B sends its C sends its
via DV to B, C DV to A, C DV to A, B
Node A B C B C B C B C B C
B 4 51 B 60 51 B 60 51 B 60 51 B 60 51
to
C 5 50 C 61 50 C 61 50 C 61 50 C 61 50
Node B A C A C A C A C A C
A 4 ∞
6 A 60 ∞
6 A 60 ∞
6 A 60 ∞
6 A 60 51
C ∞
9 1 ∞
C 65 1 C 110 1 C 110 1 C 110 1
Node C A B A B A B A B A B
A 50 5 A 50 5 A 50 5 A 50 61 A 50 ∞
61
B 54 1 B 54 1 ∞
B 101 1 ∞
B 101 1 ∞
B 101 1
1
100
∞
4
B
100
1∞ 14
100
63 1
∞ 1
∞
A 1
C
2
∞ 52
Network Layer 71
Real Protocols
Link State Distance Vector
Border Gateway
Protocol (BGP)
Network Layer 72
Quiz: Routing
v In this link-state routing network running
Dijkstra’s algorithm, the set N’ (the set of nodes
to which the least cost is definitively known) is
initially {u}. After two iterations, which nodes
belong to N’?
A. u 4
B. ux 3
v w 5
C. uw 3
u 5 4 z
D. uvx 1
1
8
E. uwx x 3
y
Network Layer 73
Quiz: Routing
v In link state routing, the time for routing to re-
converge after a link-cost change does NOT
significantly depend on which one of the
following?
A. Number of nodes
B. Diameter of the network
C. Whether the link cost increased or decreased
D. Whether routing is load-dependent or not
Network Layer 74
Network Layer: outline
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and § link state
datagram networks § distance vector
4.3 what’s inside a router § hierarchical routing
4.4 IP: Internet Protocol 4.6 routing in the Internet
§ datagram format § RIP
§ IPv4 addressing § OSPF
§ BGP
§ ICMP
§ IPv6 4.7 broadcast and multicast
routing
Network Layer 75
Hierarchical routing
our routing study thus far - idealization
v all routers identical
v network “flat”
… not true in practice
Network Layer 76
Hierarchical routing
v aggregate routers into gateway router:
regions, “autonomous v at “edge” of its own AS
systems” (AS) v has link to router in
v routers in same AS another AS
run same routing
protocol
§ “intra-AS” routing
protocol
§ routers in different AS
can run different intra-
AS routing protocol
Network Layer 77
Autonomous Systems (AS)
Network Layer 78
Interconnected ASes
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d v forwarding table
configured by both intra-
and inter-AS routing
Intra-AS
Routing
Inter-AS algorithm
Routing
algorithm algorithm § intra-AS sets entries
Forwarding
for internal dests
table § inter-AS & intra-AS
sets entries for
external dests
Network Layer 79
Inter-AS tasks
v suppose router in AS1 AS1 must:
receives datagram 1. learn which dests are
destined outside of AS1: reachable through AS2,
§ router should forward which through AS3
packet to gateway 2. propagate this
router, but which one? reachability info to all
routers in AS1
job of inter-AS routing!
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 80
Example: setting forwarding table in router 1d
v suppose AS1 learns (via inter-AS protocol) that subnet x
reachable via AS3 (gateway 1c), but not via AS2
§ inter-AS protocol propagates reachability info to all internal
routers
v router 1d determines from intra-AS routing info that its
interface I is on the least cost path to 1c
§ installs forwarding table entry (x,I)
3c … x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 81
Example: choosing among multiple ASes
3c … x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
?
Network Layer 82
Example: choosing among multiple ASes
v now suppose AS1 learns from inter-AS protocol that subnet
x is reachable from AS3 and from AS2.
v to configure forwarding table, router 1d must determine
towards which gateway it should forward packets for dest x
§ this is also job of inter-AS routing protocol!
v hot potato routing: send packet towards closest of two
routers.
Network Layer 83
Network Layer: done!
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and § link state, distance vector,
datagram networks hierarchical routing
4.3 what’s inside a router 4.6 routing in the Internet
(NOT COVERED)
4.4 IP: Internet Protocol § RIP, OSPF, BGP
§ datagram format, IPv4
addressing, ICMP, IPv6 4.7 broadcast and multicast
routing (NOT
COVERED)
v understand principles behind network layer services:
§ network layer service models, forwarding versus routing
how a router works, routing (path selection), broadcast,
multicast
v instantiation, implementation in the Internet
Network Layer 84
Link layer, LANs: outline
5.1 introduction, services 5.5 link virtualization:
5.2 error detection, MPLS (EXCLUDED)
correction 5.6 data center
5.3 multiple access networking
protocols (EXCLUDED)
5.4 LANs 5.7 a day in the life of a
§ addressing, ARP web request
§ Ethernet
§ switches
§ VLANS (EXCLUDED)
Link Layer 85
From Macro- to Micro-
From Macro- to Micro-
• Previously, we looked at Internet scale…
Other
Networks
Other
Networks
Destination
Customer’s ISP AS
Customer AS
Link Layer 86
Link layer focus: Within a Subnet
Within a Subnet
Router
Link Layer 87
Link layer: introduction
terminology:
v hosts and routers: nodes
global ISP
v communication channels that
connect adjacent nodes along
communication path: links
§ wired links
§ wireless links
§ LANs
v layer-2 packet: frame,
encapsulates datagram
Link Layer 89
Link layer services
v framing, link access:
§ encapsulate datagram into frame, adding header, trailer
§ channel access if shared medium
§ “MAC” addresses used in frame headers to identify
source, dest
• different from IP address!
v reliable delivery between adjacent nodes
§ we learned how to do this already (chapter 3)!
§ seldom used on low bit-error link (fiber, some twisted
pair)
§ wireless links: high error rates
• Q: why both link-level and end-end reliability?
Link Layer 90
Quiz: Why put a limit on the size of a frame?
A: To make signaling message boundaries easier
Network Layer 91
Link layer services (more)
v flow control:
§ pacing between adjacent sending and receiving nodes
v error detection:
§ errors caused by signal attenuation, noise.
§ receiver detects presence of errors:
• signals sender for retransmission or drops frame
v error correction:
§ receiver identifies and corrects bit error(s) without resorting to
retransmission
v half-duplex and full-duplex
§ with half duplex, nodes at both ends of link can transmit, but not
at same time
Link Layer 92
Where is the link layer implemented?
v in each and every host
v link layer implemented in
“adaptor” (aka network
interface card NIC) or on a
chip application
v combination of hardware,
software, firmware network adapter
card
Link Layer 93
Adaptors communicating
datagram datagram
controller controller
frame
Link Layer 95
Internet checksum (review)
goal: detect “errors” (e.g., flipped bits) in transmitted packet
(note: used at transport layer only)
sender: receiver:
v treat segment contents v compute checksum of
as sequence of 16-bit received segment
integers v check if computed
v checksum: addition (1’s checksum equals checksum
complement sum) of field value:
segment contents § NO - error detected
v sender puts checksum § YES - no error detected.
value into UDP But maybe errors
checksum field nonetheless?
Link Layer 96
Error detection
EDC= Error Detection and Correction bits (redundancy)
D = Data protected by error checking, may include header fields
otherwise
Link Layer 97
Simple Parity
Simple- Sender
Parity - Sender
• Suppose you want to send the message:
– 001011011011000110010
• For every d bits (e.g., d = 7), add a parity bit:
– 1 if the number of one’s is odd
– 0 if the number of one’s is even
– 001011011101100001100101
Link Layer 98
Simple Parity
Simple- Sender
Parity - Sender
• Suppose you want to send the message:
– 0010110 1101100 0110010
• For every d bits (e.g., d = 7), add a parity bit:
– 1 if the number of one’s is odd
– 0 if the number of one’s is even
– 001011011101100001100101
Link Layer 99
Simple Parity - Receiver
Simple Parity - Receiver
• For each block of size d:
– Count the number of 1’s and compare with
following parity bit.
0 0 1 0 1 1 0 1
1 0 1 0 0 0 1 0
1 0 0 1 0 1 1 0
1 1 1 0 1 1 0 1
Parity byte 1 1 1 1 1 1 0 0