Title: Network Layer
1Network Layer
- goals
- understand principles behind network layer
services - routing (path selection)
- how a router works
- instantiation and implementation in the Internet
- Overview
- network layer services
- routing principle path selection
- hierarchical routing
- IP
- whats inside a router?
2Network layer functions
HOST A
- transport packet from sending to receiving hosts
- network layer protocols in every host, router
- Important functions
- Forwarding/switching move packets from router's
input to appropriate router output (router-local
action) - Routing/Path determination route taken by
packets from source to dest (network-wide
process). Routing algorithms
HOST B
3DATAGRAM ROUTING (The internet model)
- routers no state about end-to-end connections
- no network-level concept of 'connection'
- packets are typically routed using destination
host ID - packets between same source-destination pair may
take different paths
Each router has a forwarding table that maps
destination addresses to link interfaces
application transport network data link physical
application transport network data link physical
1. Send data
2. Receive data
4Routing
Physical distance, link speed, monetary cost, etc.
Goal determine good path (sequence of routers)
through network from source to destination.
- Graph abstraction for routing algorithms
- nodes represent routers
- Lines/graph edges are physical links
- link cost delay, cost of sending a packet across
link, or congestion level
5Routing Algorithm classification
- Global or decentralized information?
- Global
- Least-cost path is computed using complete,
global knowledge of the network - topology, link cost info
- Link State (LS) algorithms
- Decentralized
- Least-cost path is calculated in an iterative,
distributed manner - router only knows physically-connected
neighbours, link costs to neighbours - Involves iterative process of calculation
exchange of info with neighbours - Distance Vector (DV) algorithms
- Static or dynamic?
- Static
- routes change slowly over time
- Dynamic
- routes change more quickly
- periodic update
- in response to topology or link cost changes
6Distance Vector Routing Algorithm
- iterative
- continues until no nodes exchange info.
- self-terminating no signal to stop
- asynchronous
- nodes need not exchange info/iterate in lock
step! - distributed
- each node communicates only with
directly-attached neighbours
7Distance Vector Routing Algorithm
- Distance Table data structure
- each node has its own
- row for each possible destination
- column for each directly-attached neighbor to
node - example Node X, routing for destination Y via
directly attached neighbor Z
Currently known minimum-cost path from Z to Y
8DISTANCE TABLE Example
ENTRIES IN THE DATA TABLE for NODE E (after DV
converges)
loop!
loop!
9Distance table gives routing table
Outgoing link to use, cost
A B C D
A,1 D,5 D,4 D,2
destination
Routing table
Distance table
10Distance Vector Routing Overview
BELLMAN-FORD ALGORITHM Internet RIP, BGP, IDRP,
Novell IPX, ARPANet
Each node
wait for (change in local link cost or msg from
neighbor) recompute distance table if a
least-cost path to any destination has changed,
notify neighbors
- Iterative, asynchronous
- Each local iteration (Distance Table update)
caused by - Change of cost of an attached link
- Receipt of message update from neighbour
- Distributed
- each node notifies neighbours only when its
least-cost path to any destination changes
11Distance Vector Algorithm
At all nodes, X
1 Initialization 2 for all adjacent nodes
v 3 D (,v) infinite (
the operator means "for all rows" ) 4 D
(v,v) c(X,v) 5 for all destinations, y 6
send min D (y,w) to each neighbor (w over
all X's neighbors )
X
X
X
w
12Distance Vector Algorithm (cont.)
8 loop 9 wait (until I see a link cost
change to neighbor V 10 or until I
receive update from neighbor V) 11 12 if
(c(X,V) changes by d) 13 / change cost to
all dest's via neighbor v by d / 14 /
note d could be positive or negative / 15
for all destinations y D (y,V) D (y,V) d
16 17 else if (update received from V wrt
destination Y) 18 / shortest path from V to
some Y has changed / 19 / V has sent a
new value for its min DV(Y,w) / 20 /
call this received new value as newval / 21
for the single destination y D (Y,V)
c(X,V) newval 22 23 if we have a new min
D (Y,w) for any destination Y 24 send new
value of min D (Y,w) to all neighbors 25 26
forever
X
X
w
X
X
w
X
w
13Distance Vector Algorithm example
14Distance Vector Algorithm example
15Distance Vector link cost changes
algorithm terminates
good news travels fast
16Distance Vector link cost changes
Routing loop bet. Y Z will persist after 44
iterations
algorithm continues on!
17Distance Vector link cost changes
algorithm continues on!
Routing Table for Node Y
Routing Table for Node Z
Node Z computes the new least-cost to X, then
updates its Routing Table
Sometime after t0 Node Y calculates the new
least-cost path, and finds that passing through Z
is more cost effective to reach Node X
Sometime after t1 Node Z receives the new
least-cost to Node X from Y, then computes a new
least-cost to X
t2 Node Z informs y of its new least-cost to X,
since it has changed (increased)
At time t1 Node Y broadcasts the new least-cost
path to Z (neighbor)
And so on, and so forth
Link-cost change the new link-cost to X changes
from 4 to 60.
ROUTING LOOP! Node Y doesnt know that Z would
pass through Y itself to get to X (at this point
in time, Z is still using the old least-cost path
(from Node Y to X is equal to 4)
18Distance Vector poisoned reverse
It does not. Loops with nodes gt 3 will not be
detected!
algorithm terminates
19Assignment 2
DATA STRUCTURES
DISTANCE TABLE for NODE 0 int costs44
Neighbors (consider directly connected Nodes only)
via
destination
Each Node must have its own DISTANCE TABLE
20Assignment 2
DATA STRUCTURES
ROUTING TABLE SRTPKT 0
Source ID
Destination ID
Packets will have to be sent strictly using a
function named tolayer2() defined in the routing
engine provided.
int mincost4
Each Node must have its own structure for PACKET
to send
21Assignment 2
FUNCTIONS
Void rtinit0()
Initialize link costs using the given values in
the diagram for direct links 999 (infinite)
otherwise
Send the minimum cost (as packets) to all
immediate neighbors using tolayer2() function
Each Node will have its corresponding rtinit?()
function
22Assignment 2
FUNCTIONS
Void rtupdate0( rcvdpkt)
Update the nodes Distance table (Update all link
costs involving the Node X from which the packet
came from Link-cost from Node X to destination
Cost of direct connection mincost to reach
destination node(extracted from the packet)
For each destination node, find the least-cost
path
Apply Poisoned Reverse algorithm
If theres a new least-cost found (different from
previous least-cost path, in any of the
destinations), inform all neighbors of the new
values by sending the routing table in a packet
Each Node will have its corresponding rtupdate?()
function
23Assignment 2
Example
How to apply the Poisoned Reverse Algorithm?
Eventually, the value 8 would become 999 because
it is not a direct link, and it is not the
least-cost path for destination C
via
destination
999
Inspect each row,
If the link is NOT a direct link and if the
link-cost is NOT equal to the minimum cost for a
given destination node, then set the link-cost
999 (infinite)
24Assignment 2
FUNCTIONS
Void linkhandler0( linkID, newcost)
Update the nodes Distance table to reflect the
new link-cost (Update the link cost involving the
direct connection to Node linkID)
Find mincost of Nodes directly connected to Node 0
If theres a new least-cost found (different from
previous least-cost path, in any of the
destinations), inform all neighbors of the new
values by sending the routing table in a packet
Only Nodes 0 and 1 will have a linkhandler (as
indicated in the diagram)