Вы находитесь на странице: 1из 31

Chapter 4: Network Layer

Chapter goals:
❒ understand principles behind network layer
services:
❍ network layer service models
❍ forwarding versus routing
❍ how a router works
❍ routing (path selection)
❍ dealing with scale
❍ advanced topics: IPv6, mobility

❒ instantiation, implementation in the Internet

Network Layer 1

Chapter 4: Network Layer


❒ 4.5 Routing algorithms
❍ Link state
❍ Distance Vector
❍ Hierarchical routing

❒ 4.6 Routing in the


Internet
❍ RIP
❍ OSPF
❍ BGP
❒ 4.7 Broadcast and
multicast routing

Network Layer 2
Two Key Network-Layer Functions

❒ forwarding: move analogy:


packets from router’s
❒ routing: process of
input to appropriate
router output planning trip from
source to dest
❒ routing: determine
❒ forwarding: process
route taken by packets
from source to dest. of getting through
single interchange
❍ routing algorithms

Network Layer 3

Interplay between routing and forwarding

routing algorithm

local forwarding table


header value output link
0100 3
0101 2
0111 2
1001 1

value in arriving
packet’s header

0111 1

3 2

Network Layer 4
Virtual circuits: signaling protocols

❒ used to setup, maintain teardown VC


❒ used in ATM, frame-relay, X.25
❒ not used in today’s Internet

application 6. Receive data


5. Data flow begins application
transport 4. Call connected 3. Accept call transport
network 1. Initiate call 2. incoming call network
data link
data link
physical
physical

Network Layer 5

Datagram networks
❒ no call setup at network layer
❒ routers: no state about end-to-end connections
❍ no network-level concept of “connection”

❒ packets forwarded using destination host address


❍ packets between same source-dest pair may take different paths

application application
transport transport
network 1. Send data 2. Receive data network
data link data link
physical physical

Network Layer 6
Forwarding table
4 billion
possible entries

Destination Address Range Link Interface

11001000 00010111 00010000 00000000


through 0
11001000 00010111 00010111 11111111

11001000 00010111 00011000 00000000


through 1
11001000 00010111 00011000 11111111

11001000 00010111 00011001 00000000


through 2
11001000 00010111 00011111 11111111

otherwise 3
Network Layer 7

Longest prefix matching

Prefix Match Link Interface


11001000 00010111 00010 0
11001000 00010111 00011000 1
11001000 00010111 00011 2
otherwise 3

Examples

DA: 11001000 00010111 00010110 10100001 Which interface?

DA: 11001000 00010111 00011000 10101010 Which interface?

Network Layer 8
The Internet Network layer
Host, router network layer functions:

Transport layer: TCP, UDP

Routing protocols IP protocol


•path selection •addressing conventions
Network •RIP, OSPF, BGP •datagram format
layer •packet handling conventions
forwarding
ICMP protocol
table
•error reporting
•router “signaling”

Link layer

physical layer

Network Layer 9

IP datagram format
IP protocol version 32 bits total datagram
number
head. length (bytes)
header length (bytes) ver TOS length
len
for
“Type Of Service” of data 16-bit identifier flgs fragment offset
fragmentation/
TTL - max number of hops time to upper reassembly
live - TTL layer header checksum
(decremented at
each router) 32 bit source IP address
32 bit destination IP address
upper layer protocol
to deliver payload to Options (if any) E.g. timestamp,
record route
how much overhead data
taken, specify
with TCP? (variable length,
list of routers
❒ 20 bytes of TCP typically a TCP to visit.
❒ 20 bytes of IP or UDP segment)
❒ = 40 bytes + app
layer overhead Network Layer 10
Chapter 4: Network Layer
❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing

Network Layer 11

IP Addressing
223.1.1.1
❒ IP address: 32-bit
identifier for host, 223.1.1.2
223.1.2.1

router interface 223.1.1.4 223.1.2.9

❒ interface: connection 223.1.2.2


223.1.1.3 223.1.3.27
between host/router
and physical link
❍ router’s typically have 223.1.3.1 223.1.3.2
multiple interfaces
❍ host typically has one
interface
❍ IP addresses associated 223.1.1.1 = 11011111 00000001 00000001 00000001
with each interface
223 1 1 1

Network Layer 12
Subnets
223.1.1.1
❒ IP address:
❍ subnet part (high order 223.1.2.1
223.1.1.2
bits) 223.1.1.4 223.1.2.9
❍ host part (low order
223.1.2.2
bits) 223.1.1.3 223.1.3.27

❒ What’s a subnet ?
subnet
❍ device interfaces with
223.1.3.1 223.1.3.2
same subnet part of IP
address
❍ can physically reach

each other without network consisting of 3 subnets


intervening router

Network Layer 13

Subnets 223.1.1.0/24
223.1.2.0/24

Recipe
❒ To determine the
subnets, detach each
interface from its host
or router, creating
islands of isolated
networks. Each isolated
223.1.3.0/24
network is called a
subnet. Subnet mask: /24

Network Layer 14
Subnets 223.1.1.2

How many subnets? 223.1.1.1 223.1.1.4

223.1.1.3
223.1.222.2
R1
223.1.222.99
223.1.9.2 223.1.7.2

223.1.9.1 223.1.7.1
223.1.8.1 223.1.8.2
R2 R3
223.1.2.6 223.1.3.27

223.1.2.1 223.1.2.2 223.1.3.1 223.1.3.2

Network Layer 15

IP fragmentation,
IP reassembly
addressing: CIDR
§ CIDR:
network Classless
links have MTUInterDomain Routing
(max.transfer size) -
❍ subnet portion of address of arbitrary length
largest possible link-level fragmentation:
❍ address format: a.b.c.d/x, where x is in:
frame # one
bits indatagram

large
• different
subnetlink types, of address
portion out: 3 smaller datagrams
different MTUs
§ large IP datagram divided
( fragmented ) within net reassembly
• one datagram becomes
several datagrams
subnet host
• reassembled only at

part part
final11001000
destination00010111 00010000 00000000
• IP header bits used to
identify, order related
200.23.16.0/23
fragments
Network
Network Layer
Layer: Data 16
Plane 4-33
IP addresses:
IP fragmentation, reassembly
how to get one?
length ID fragflag offset
Q: How does host get IP address?
example: =4000 =x =0 =0
v 4000 byte datagram
one large datagram becomes
v❒ MTU = 1500 by
hard-coded bytes
system admin in a file
several smaller datagrams
❍ Wintel: control-panel->network->configuration->tcp/ip-
>properties
1480 bytes in length ID fragflag offset
data field
❍ UNIX: /etc/rc.config =1500 =x =1 =0
❒ DHCP: Dynamic Host Configuration Protocol: dynamically get address
offset = length ID fragflag offset
from as1480/8
server =1500 =x =1 =185
❍ “plug-and-play”
length ID fragflag offset
=1040 =x =0 =370

Network
Network Layer
Layer: Data 17
Plane 4-34

Examples:
❒ Ex. a) : Consider sending a 3000 byte datagram into a link that

has a MTU of 500 bytes. Suppose the original datagram is

stamped with the identification number 422. How many

fragments are generated? What are their characteristics?

❒ Ex. b) : Suppose an application generates chunks 40 bytes of

data every 20 msec, and each chunk gets encapsulated in a TCP

segment and then an IP datagram. What percentage of each

datagram will be overhead and what percentage will be

application data?

Network Layer 18
IP addresses: how to get one?
Q: How does network get subnet part of IP addr?
A: gets allocated portion of its provider ISP’s
address space

ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20

Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23


Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23
Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23
... ….. …. ….
Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23

Network Layer 19

Hierarchical addressing: route aggregation


Hierarchical addressing allows efficient advertisement of routing
information:

Organization 0
200.23.16.0/23
Organization 1
“Send me anything
200.23.18.0/23
with addresses
Organization 2 beginning
200.23.20.0/23 . Fly-By-Night-ISP 200.23.16.0/20”
.
. . Internet
Organization 7 ..
200.23.30.0/23
“Send me anything
ISPs-R-Us
with addresses
beginning
199.31.0.0/16”

Network Layer 20
Hierarchical addressing: more specific routes

ISPs-R-Us has a more specific route to Organization 1


Organization 0
200.23.16.0/23

“Send me anything
with addresses
Organization 2 beginning
200.23.20.0/23 . Fly-By-Night-ISP 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
ISPs-R-Us
with addresses
Organization 1 beginning 199.31.0.0/16
200.23.18.0/23 or 200.23.18.0/23”

Network Layer 21

IP addressing: last words...

Q: How does an ISP get block of addresses?


A: At first (before 1998), IANA Internet
Assigned Numbers Authority
A: ICANN (1998): Internet Corporation for Assigned
Names and Numbers
❍ allocates addresses
❍ manages DNS
❍ assigns domain names, resolves disputes

AND
❍ Regional Internet Registries (RIRs)

Network Layer 22
IP addressing: last words...

Regional Internet Registries (RIRs)

Network Layer 23

Example
Q: Proponha um esquema que
lhe permita endereçar os
computadores das redes
locais associadas aos
diferentes
encaminhadores a partir
dos seguintes endereços:
193.213.168.0/23 (ou
Net: 193.213.168.0 Mask:
255.255.254.0).

Network Layer 24
TP9 - Routing (submit via elearning platform)
Q: A tabela seguinte
constitui uma parte da
tabela de encaminhamento
do Router R1. Complete-a
de forma a conseguir que
os computadores destas
redes tenham
conectividade IP entre si e
acesso à Internet.

Network Layer 25

How many hosts?


172.16.4.0/24
Internet
I0 - 172.16.4.254

R1
I2 - 192.168.1.252 I1 - 192.168.2.249

I1 - 192.168.1.254
192.168.2.250 - Ix IA - 192.168.111.254

R2 R3

I0 - 172.16.2.254 IB - 172.16.192.2

172.16.2.0/24 172.16.192.0/20
How many hosts? How many hosts?

26
NAT: Network Address Translation

❒ Motivation: local network uses just one IP address as far


as outside world is concerned:
❍ range of addresses not needed from ISP: just one IP
address for all devices
❍ can change addresses of devices in local network
without notifying outside world
❍ can change ISP without changing addresses of devices
in local network
❍ devices inside local net not explicitly addressable,
visible by outside world (a security plus).

Network Layer 27

NAT: Network Address Translation


Implementation: NAT router must:


❍ outgoing datagrams: replace (source IP address, port #) of


every outgoing datagram to (NAT IP address, new port #)
. . . remote clients/servers will respond using (NAT IP
address, new port #) as destination addr.


❍ remember (in NAT translation table) every (source IP


address, port #) to (NAT IP address, new port #)
translation pair


❍ incoming datagrams: replace (NAT IP address, new port #) in


dest fields of every incoming datagram with corresponding
(source IP address, port #) stored in NAT table

Network Layer 28
NAT: Network Address Translation
NAT translation table 1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
changes datagram sends datagram to
138.76.29.7, 5001 10.0.0.1, 3345
source addr from 128.119.40.186, 80
…… ……
10.0.0.1, 3345 to
S: 10.0.0.1, 3345
138.76.29.7, 5001, D: 128.119.40.186, 80
updates table 10.0.0.1
1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
4
D: 10.0.0.1, 3345
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: Reply arrives
changes datagram
dest. address:
dest addr from
138.76.29.7, 5001
138.76.29.7, 5001 to 10.0.0.1, 3345
Network Layer 29

NAT: Network Address Translation

❒ 16-bit port-number field:


❍ 60,000 simultaneous connections with a single
LAN-side address!
❒ NAT is controversial:
❍ routers should only process up to layer 3
❍ violates end-to-end argument
• NAT possibility must be taken into account by app
designers, eg, P2P applications
❍ address shortage should instead be solved by
IPv6

Network Layer 30
NAT traversal problem
❒ client want to connect to
server with address 10.0.0.1 10.0.0.1
❍ server address 10.0.0.1 local to Client
LAN (client can’t use it as ?
destination addr) 10.0.0.4
❍ only one externally visible
NATted address: 138.76.29.7 138.76.29.7 NAT
❒ solution 1: statically router
configure NAT to forward
incoming connection requests
at given port to server
❍ e.g., (123.76.29.7, port 2500)
always forwarded to 10.0.0.1
port 25000
Network Layer 31

NAT traversal problem


❒ solution 2: Universal Plug and Play
(UPnP) Internet Gateway Device
10.0.0.1
(IGD) Protocol. Allows NATted
host to: IGD
❖ learn public IP address 10.0.0.4

(138.76.29.7) 138.76.29.7 NAT


❖ enumerate existing port
router
mappings
❖ add/remove port mappings
(with lease times)

i.e., automate static NAT port


map configuration
Network Layer 32
NAT traversal problem
❒ solution 3: relaying (used in Skype)
❍ NATed server establishes connection to relay
❍ External client connects to relay
❍ relay bridges packets between to connections

2. connection to
relay initiated 1. connection to
by client relay initiated
10.0.0.1
3. relaying by NATted host
Client
established
138.76.29.7 NAT
router

Network Layer 33

Chapter 4: Network Layer


❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing

Network Layer 34
ICMP: Internet Control Message Protocol

❒ used by hosts & routers to Type Code description


communicate network-level 0 0 echo reply (ping)
information 3 0 dest. network unreachable
❍ error reporting: 3 1 dest host unreachable
unreachable host, network, 3 2 dest protocol unreachable
3 3 dest port unreachable
port, protocol
3 6 dest network unknown
❍ echo request/reply (used
3 7 dest host unknown
by ping) 4 0 source quench (congestion
❒ network-layer “above” IP: control - not used)
❍ ICMP msgs carried in IP
8 0 echo request (ping)
9 0 route advertisement
datagrams 10 0 router discovery
❒ ICMP message: type, code plus 11 0 TTL expired
first 8 bytes of IP datagram 12 0 bad IP header
causing error

Network Layer 35

Traceroute and ICMP


❒ Source sends series of UDP ❒ When ICMP message
segments to dest arrives, source calculates
❍ First has TTL =1 RTT
❍ Second has TTL=2, etc. ❒ Traceroute does this 3
❍ Unlikely port number
times
❒ When nth datagram arrives
Stopping criterion
to nth router:
❒ UDP segment eventually
❍ Router discards datagram
❍ And sends to source an arrives at destination host
ICMP message (type 11, ❒ Destination returns ICMP
code 0) “host unreachable” packet
❍ Message includes name of (type 3, code 3)
router& IP address
❒ When source gets this
ICMP, stops.
Network Layer 36
Chapter 4: Network Layer
❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing

Network Layer 37

IPv6
❒ Initial motivation: 32-bit address space soon
to be completely allocated.
❒ Additional motivation:
❍ header format helps speed processing/forwarding
❍ header changes to facilitate QoS
IPv6 datagram format:
❍ fixed-length 40 byte header
❍ no fragmentation allowed

Network Layer 38
IPv6 Header (Cont)
Priority: identify priority among datagrams in flow
Flow Label: identify datagrams in same “flow.”
(concept of“flow” not well defined).
Next header: identify upper layer protocol for data

Network Layer 39

Other Changes from IPv4


❒ Checksum: removed entirely to reduce
processing time at each hop
❒ Options: allowed, but outside of header,
indicated by “Next Header” field
❒ ICMPv6: new version of ICMP
❍ additional message types, e.g. “Packet Too Big”
❍ multicast group management functions

Network Layer 40
Transition From IPv4 To IPv6
❒ Not all routers can be upgraded simultaneous
❍ no “flag days”
❍ How will the network operate with mixed IPv4 and
IPv6 routers?
❒ Tunneling: IPv6 carried as payload in IPv4
datagram among IPv4 routers

Network Layer 41

Tunneling
A B E F
Logical view: tunnel

IPv6 IPv6 IPv6 IPv6

A B E F
Physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6

Network Layer 42
Tunneling
A B tunnel
E F
Logical view:
IPv6 IPv6 IPv6 IPv6

A B C D E F
Physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
Flow: X Src:B Src:B Flow: X
Src: A Src: A
Dest: E Dest: E
Dest: F Dest: F
Flow: X Flow: X
Src: A Src: A
Dest: F Dest: F
data data

data data

A-to-B: E-to-F:
B-to-C: B-to-C:
IPv6 IPv6
IPv6 inside IPv6 inside
IPv4 IPv4 Network Layer 43

Chapter 4: Network Layer


❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing

Network Layer 44
Interplay between routing, forwarding

routing algorithm

local forwarding table


header value output link
0100 3
0101 2
0111 2
1001 1

value in arriving
packet’s header

0111 1

3 2

Network Layer 45

Graph abstraction
5

v 3 w
2 5
u 2 1 z
3
1 2
x y
Graph: G = (N,E) 1

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

Remark: Graph abstraction is useful in other network contexts

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

Network Layer 46
Graph abstraction: costs
5
• c(x,x’) = cost of link (x,x’)
3
v w 5
2 - e.g., c(w,z) = 5
u 2 1 z
3
1 • cost could always be 1, or
x y 2
1 inversely related to bandwidth,
or inversely related to
congestion
Cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)

Question: What’s the least-cost path between u and z ?

Routing algorithm: algorithm that finds least-cost path

Network Layer 47

Routing Algorithm classification


Global or decentralized Static or dynamic?
information?
Global:
Static:
❒ all routers have complete ❒ routes change slowly
topology, link cost info
over time
❒ “link state” algorithms

Decentralized: Dynamic:
❒ router knows physically- ❒ routes change more
connected neighbors, link costs
to neighbors
quickly
❒ iterative process of computation,
❍ periodic update
exchange of info with neighbors ❍ in response to link
❒ “distance vector” algorithms
cost changes

Network Layer 48
Chapter 4: Network Layer
❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing

Network Layer 49

A Link-State Routing Algorithm

Dijkstra’s algorithm Notation:


❒ net topology, link costs known
❒ c(x,y): link cost from node
to all nodes
x to y; = ∞ if not direct
❍ accomplished via “link state
neighbors
broadcast”
❍ all nodes have same info ❒ D(v): current value of cost
❒ computes least cost paths from of path from source to
one node (‘source”) to all other dest. v
nodes ❒ p(v): predecessor node
❍ gives forwarding table for
along path from source to v
that node
❒ iterative: after k iterations, ❒ N': set of nodes whose least
know least cost path to k dest.’s cost path definitively known

Network Layer 50
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 51

Dijkstra’s algorithm: example


Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u ∞ ∞
1 ux 2,u 4,x 2,x ∞
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz

5
3
v w 5
2
u 2 1 z
3
1 2
x y
1
Network Layer 52
Dijkstra’s algorithm: example (2)
Resulting shortest-path tree from u:

v w
u z

x y

Resulting forwarding table in u:


destination link
v (u,v)
x (u,x)
y (u,x)
w (u,x)
z (u,x)
Network Layer 53

Dijkstra’s algorithm, discussion


Algorithm complexity: n nodes
❒ each iteration: need to check all nodes, w, not in N
❒ n(n+1)/2 comparisons: O(n2)
❒ more efficient implementations possible: O(nlogn)

Oscillations possible:
❒ e.g., link cost = amount of carried traffic

1 A A A A
1+e 2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D B
0 0 1+e 1
0 e 0 0 1 1+e 0 e
1 C C C C
1
e
… recompute … recompute … recompute
initially
routing
Network Layer 54
Chapter 4: Network Layer
❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing

Network Layer 55

Distance Vector Algorithm


Bellman-Ford Equation (dynamic programming)
Define
dx(y) := cost of least-cost path from x to y

Then

dx(y) = min {c(x,v) + dv(y) }


v

where min is taken over all neighbors v of x


Network Layer 56
Bellman-Ford example
5
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
3
v w 5
2
u z B-F equation says:
2 1
3
1 2 du(z) = min { c(u,v) + dv(z),
x y
1 c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4

Node that achieves minimum is next


hop in shortest path ➜ forwarding table

Network Layer 57

Distance Vector Algorithm

❒ Dx(y) = estimate of least cost from x to y

❒ Node x knows cost to each neighbor v: c(x,v)

❒ Node x maintains distance vector Dx =


[Dx(y): y є N ]
❒ Node x also maintains its neighbors’
distance vectors
❍ For each neighbor v, x maintains 

Dv = [Dv(y): y є N ]

Network Layer 58
Distance vector algorithm (4)
Basic idea:
❒ Each node periodically sends its own distance
vector estimate to neighbors
❒ When a node x receives new DV estimate from
neighbor, it updates its own DV using B-F equation:
Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N

❒ Under minor, natural conditions, the estimate Dx(y) converge to the


actual least cost dx(y)

Network Layer 59

Distance Vector Algorithm (5)


Iterative, asynchronous: Each node:
each local iteration caused
by: wait for (change in local link
❒ local link cost change cost or msg from neighbor)

❒ DV update message from


neighbor recompute estimates

Distributed:
❒ each node notifies neighbors if DV to any dest has
only when its DV changes changed, notify neighbors
❍ neighbors then notify their
neighbors if necessary

Network Layer 60
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} 
 Dx(z) = min{c(x,y) + 


= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}


node x table = min{2+1 , 7+0} = 3
cost to cost to
x y z x y z
x 0 2 7 x 0 2 3
from

from
y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
node y table
cost to
x y z y
2 1
x ∞ ∞ ∞ x z
y 2 0 1 7
from

z ∞∞ ∞
node z table
cost to
x y z
x ∞∞ ∞
from

y ∞∞ ∞
z 71 0
time
Network Layer 61

Dx(z) = min{c(x,y) + 

Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} 

= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
node x table = min{2+1 , 7+0} = 3
cost to cost to cost to
x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from

from

y ∞∞ ∞ y 2 0 1
from

y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y table
cost to cost to cost to
x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 z
x
from

y 2 0 1 y 2 0 1 7
from

from

y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node z table
cost to cost to cost to
x y z x y z x y z
x ∞∞ ∞ x 0 2 7 x 0 2 3
from

from

y 2 0 1 y 2 0 1
from

y ∞∞ ∞
z 71 0 z 3 1 0 z 3 1 0
time
Network Layer 62