0% found this document useful (0 votes)
18 views105 pages

IP Rout

Uploaded by

rishabh mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views105 pages

IP Rout

Uploaded by

rishabh mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 105

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 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

v Each AS runs an intra-domain routing protocol that


establishes routes within its domain
§ (AS -- region of network under a single administrative entity)
§ Link State, e.g., Open Shortest Path First (OSPF)
§ Distance Vector, e.g., Routing Information Protocol (RIP)

v ASes participate in an inter-domain routing protocol that establishes


routes between domains
§ Path Vector, e.g., Border Gateway Protocol (BGP)

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) }

aside: graph abstraction is useful in other network contexts, e.g.,


P2P, where N is set of peers and E is set of TCP connections

Network Layer 6
Addressing (abstraction)
v Assume each host has a unique ID (address)

v No particular structure to those IDs

v Earlier in course we talked about real IP


addressing

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

cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)

key question: what is the least-cost path between u and z ?


routing algorithm: algorithm that finds that least cost path

Network Layer 8
Quiz: How should link costs be determined?

A: They should all be equal.

B: They should be a function of link capacity.

C: They should take current traffic characteristics


into account (congestion, delay, etc.).

D: They should be manually determined by network


administrators.

E: They should be determined in some other way.


9
Network Layer
Link Cost

v Typically simple: all links are equal

v Least-cost paths => shortest paths (hop count)

v Network operators add policy exceptions


§ Lower operational costs
§ Peering agreements
§ Security concerns

10
Network Layer
Routing algorithm classes
Link State (Global) Distance Vector (Decentralised)

• Routers maintain cost of each • Routers maintain next hop &


link in the network cost of each destination.

• Connectivity/cost changes • Connectivity/cost changes


flooded to all routers iteratively propagate form
neighbour to neighbour
• Converges quickly (less
inconsistency, looping, etc.) • Requires multiple rounds to
converge
• Limited network sizes
• Scales to large networks

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

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 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

v Processing complexity for Dijkstra’s algorithm?


§ O(N2), because we check all nodes w not in S at each iteration
and we have O(N) iterations
§ more efficient implementations: O(N log(N) +E) using min-heap

v How many entries in the LS topology database? O(E)

v How many entries in the forwarding table? O(N)

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

A and D think that this E thinks that this


is the path to C is the path to C
32
Network Layer
Oscillations
oscillations possible:
v e.g., support link cost equals amount of carried traffic:

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

Each router maintains its shortest distance to every


destination via each of its neighbours
35
Network Layer
How Distance-Vector (DV) works

MIN { distB(A,B), distC(A, B) }


A’s distance
From node A vector (DV)

A via via min


B C dist

to B to B
to C to C
to D to D

Each router computes its shortest distance to every


destination via any of its neighbors
36
Network Layer
How Distance-Vector (DV) works

From node A A’s DV

A via via min


B C dist

to B ? ? to B ?
to C ? ? to C ?
to D ? ? to D ?

How does A initialize its dist() table and DV?


37
Network Layer
How Distance-Vector (DV) works
B

A Link costs

How does A initialize its dist() table and DV?


38
Network Layer
How Distance-Vector (DV) works
B

From node A A’s DV


mindist
A via B via C
to B c(A,B) ∞ to B c(A,B)
to C ∞ c(A,C) to C c(A,C)
C to D ∞ ∞ to D ∞

Each router initializes its dist() table based on its immediate


neighbors and link costs
39
Network Layer
How Distance-Vector (DV) works
Assume that A’s DV
B is as follows at
some later time

From node A A’s DV


mindist
A via B via C
to B c(A,B) ∞ to B c(A,B)
5
to C ∞ c(A,C) to C c(A,C)
6
C to D ∞ ∞ to D ∞
2

Each router sends its DV to its immediate neighbors


40
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 15 1 to C 1
A to D 2 to D ∞ ∞ to D ∞

Routers process received DVs

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)

Routers process received DVs


And repeat…
42
Network Layer
Distance Vector Routing
v Each router knows the links to its neighbors

v Each router has provisional “shortest path” to


every other router -- its distance vector (DV)

v Routers exchange this DV with their neighbors

v Routers look over the set of options offered by their


neighbors and select the best one

v Iterative process converges to set of shortest paths


43
Network Layer
Distance vector routing
iterative, asynchronous: each node:
each local iteration
caused by:
v local link cost change wait for (change in local link
cost or msg from neighbor)
v DV update message from
neighbor
distributed: recompute estimates
v each node notifies
neighbors only when its
DV changes if DV to any dest has
§ neighbors then notify their changed, notify neighbors
neighbors if necessary

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

v mindist(A,V): shortest dist. from A to 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

v mindist(A,V): shortest dist. from A to 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

v Must eventually converge


§ as soon as it reaches longest best path
v …..but how does it respond to changes in cost?
The key here is that the starting point is
not the initialization, but some other set of
entries. Convergence could be different! 61
Network Layer
1 B
DV: Link Cost Changes A
4 1
C
50
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 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

Link cost changes here “good news travels fast”


62
Network Layer
60 B
DV: Link Cost Changes A
4 1
C
50
Stable state A-B changed
via
Node A B C B C
B 4 51 B 60 51
to
C 5 50 C 61 50
Node B A C A C add 56 to distances
A 4 6 A 60 6 distB(A,*) and distA(B,*)
C 9 1 C 65 1

Node C A B A B
A 50 5 A 50 5
B 54 1 B 54 1

Link cost changes here


63
Network Layer
60 B
DV: Link Cost Changes A
4 1
C
50
This is the “Counting to Infinity” Problem
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 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

Link cost changes here


“bad news travels slowly”
(not yet converged) Network Layer
64
The “Poisoned Reverse” Rule
v Heuristic to avoid count-to-infinity

v If B routes via C to get to A:


§ B tells C its (B’s) distance to A is infinite
(so C won’t route to A via B)

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

Stable state A-B changed


via
Node A B C B C
B 4 51 B 60 51
to
C 5 50 C 61 50
Node B A C A C
A 4 ∞
6 A 60 6
C ∞
9 1 C 65 1

Node C A B A B
A 50 5 A 50 5
B 54 1 B 54 1

Link cost changes here


66
Network Layer
DV: Poisoned Reverse 60 B
4 1
If B routes through C to get to A: A C
B tells C its (B’s) distance to A is infinite 50

Stable state A-B changed A sends its B sends its


via DV to B, C DV to A, C

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

Link cost changes here


67
Network Layer
DV: Poisoned Reverse 60 B
4 1
If B routes through C to get to A: A C
B tells C its (B’s) distance to A is infinite 50

Stable state A-B changed A sends its B sends its


via DV to B, C DV to A, C

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

Link cost changes here


68
Network Layer
DV: Poisoned Reverse 60 B
4 1
If B routes through C to get to A: A C
B tells C its (B’s) distance to A is infinite 50

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

Converges after C receives


Link cost changes here
another update from B 69
Will Poison-Reverse Completely Solve
the Count-to-Infinity Problem?

1
100

4
B
100
1∞ 14
100
63 1
∞ 1

A 1
C
2
∞ 52

Numbers in blue denote the best cost


to destination D advertised along the link
70
Network Layer
Comparison of LS and DV algorithms
message complexity robustness: what happens if
v LS: with n nodes, E links, O(nE) router malfunctions?
msgs sent LS:
v DV: exchange between neighbors § node can advertise incorrect
only link cost
§ convergence time varies § each node computes only its
own table
speed of convergence
DV:
v LS:O(n2) algorithm requires
O(nE) msgs § DV node can advertise
incorrect path cost
§ may have oscillations
§ each node’s table used by
v DV: convergence time varies others
§ may be routing loops • error propagate thru
§ count-to-infinity problem network

Network Layer 71
Real Protocols
Link State Distance Vector

Open Shortest Path Routing Information


First (OSPF) Protocol (RIP)

Intermediate system to Interior Gateway


intermediate system (IS- Routing Protocol
IS) (IGRP-Cisco)

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

scale: with 600 million administrative autonomy


destinations: v internet = network of
v can’t store all dest’s in networks
routing tables! v each network admin may
v routing table exchange want to control routing in
would swamp links! its own network

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)

v AS is a network under a single administrative control


§ currently over 30,000 ASes
§ Think AT&T, France Telecom, UNSW, IBM, etc.

v ASes are sometimes called “domains”.


§ Hence, “interdomain routing”

v Each AS is assigned a unique identifier


§ 16 bit AS Number (ASN)

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

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
which gateway it should forward packets towards for dest x
§ this is also job of inter-AS routing protocol!

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.

use routing info determine from


learn from inter-AS from intra-AS hot potato routing: forwarding table the
protocol that subnet choose the gateway interface I that leads
protocol to determine
x is reachable via that has the to least-cost gateway.
costs of least-cost
multiple gateways smallest least cost Enter (x,I) in
paths to each
of the gateways forwarding table

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

data-link layer has responsibility of


transferring datagram from one node
to physically adjacent node over a link
Link Layer 88
Link layer: context
v datagram transferred by transportation analogy:
different link protocols over v trip from Princeton to Lausanne
different links: § limo: Princeton to JFK
§ e.g., Ethernet on first link, § plane: JFK to Geneva
frame relay on § train: Geneva to Lausanne
intermediate links, 802.11 v tourist = datagram
on last link v transport segment =
v each link protocol provides communication link
different services v transportation mode = link
§ e.g., may or may not layer protocol
provide rdt over link v travel agent = routing
algorithm

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

B: To keep one user from hogging the channel

C: To achieve higher performance

D: Some other reason

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

§ Ethernet card, 802.11 transport


network cpu memory
card; Ethernet chipset link

§ implements link, physical host


layer controller
bus
(e.g., PCI)
link
v attaches into host’s system physical
physical
buses transmission

v combination of hardware,
software, firmware network adapter
card

Link Layer 93
Adaptors communicating

datagram datagram

controller controller

sending host receiving host


datagram

frame

v sending side: v receiving side


§ encapsulates datagram in § looks for errors, rdt,
frame flow control, etc
§ adds error checking bits, § extracts datagram, passes
rdt, flow control, etc. to upper layer at
receiving side
Link Layer 94
Link layer, LANs: outline
5.1 introduction, services 5.5 link virtualization:
5.2 error detection, MPLS
correction 5.6 data center
5.3 multiple access networking
protocols 5.7 a day in the life of a
5.4 LANs web request
§ addressing, ARP
§ Ethernet
§ switches
§ VLANS

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

• Error detection not 100% reliable!


• protocol may miss some errors, but rarely
• larger EDC field yields better detection and correction

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

Message chunk Parity bit


0010110 1
1101100 0
0110010 1

– 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

Message chunk Parity bit


0010110 1
1101100 0
0110010 1

– 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.

• If an odd number of bits get flipped, we’ll


detect it (can’t do much to correct it).

• Cost: One extra bit for every d


– In this example, 21 -> 24 bits.
Link Layer 100
Two-Dimensional ParityParity
Two-Dimensional
• Suppose you want to send the same message:
– 001011011011000110010
• Add an extra parity byte, compute parity on
“columns” too.
• Can detect 1, 2, 3-bit (and some 4-bit) errors
Message chunk Parity bit
0010110 1
1101100 0
0110010 1
Parity byte: 1001000 0

Link Layer 101


Forward Error Correction
Forward Error Correction
• With two-dimensional parity, we can even
correct single-bit errors. Parity
bits

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

Exactly one bit has been flipped. Which is it?

Link Layer 102


In practice In practice…

• Bit errors occur in bursts.

• We’re willing to trade computational


complexity for space efficiency.
– Make the detection routine more complex, to
detect error bursts, without tons of extra data

• Insight: We need hardware to interface with


the network, do the computation there!
Link Layer 103
Cyclic redundancy check
v more powerful error-detection coding
v view data bits, D, as a binary number
v choose r+1 bit pattern (generator), G
v goal: choose r CRC bits, R, such that
§ <D,R> exactly divisible by G (modulo 2)
§ receiver knows G, divides <D,R> by G. If non-zero remainder:
error detected!
§ can detect all burst errors less than r+1 bits
v widely used in practice (Ethernet, 802.11 WiFi, ATM)

Link Layer 104


CRC example
want: G D r=3
D.2r XOR R = nG 101011
equivalently: 1001 101110000
1001
D.2r = nG XOR R 101
equivalently: 000
if we divide D.2r by 1010
G, want remainder R 1001
to satisfy: 110
000
1100
D.2r R 1001
R = remainder[ ]
1010
G
1001
011

Link Layer 105


Modulo-2 Arithmetic
• All calculations are modulo-2 arithmetic
• No carries or borrows in subtraction
• Addition and subtraction are identical and both are equivalent to XOR
• 1011 XOR 0101 = 1110
• 1011 - 0101 = 1110
• 1011 + 0101 = 1110
• Multiplication by 2k is essentially a left shift by k bits
• 1011 x 22 = 101100

Link Layer 106

You might also like