2. Network layer
● transport segment from sending to receiving host
● on sending side encapsulates segments into datagrams
● on receiving side, delivers segments to transport layer
● network layer protocols in every host, router
● router examines header fields in all IP datagrams passing through it
3. Two Key Network Layer Functions
forwarding: move packets from router’s input to
appropriate router output
routing: determine route taken by packets from source to
dest. (routing algorithms)
4. Routing Algorithm
● Goal → Determine good paths (equivalently, routes),
from senders to receivers, through the network of
routers.
● “Good” path is one that has the least cost.
5. Abstract graph model
Graphs → Used to formulate routing problem
Nodes → routers
Edges → Physical links between routers
Cost → Physical length, link speed, cost
6. Abstract graph model : Cost
routing algorithm: algorithm that finds that least cost path
cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)
c(x,x’) = cost of link (x,x’) e.g., c(w,z) = 5
key question: what is the least-cost path
between u and z ?
7. Routing algorithm classification (1)
global:
● all routers have complete topology, link cost info
● “link state” algorithms
decentralized:
● router knows physically- connected neighbors, link costs to neighbors
● iterative process of computation, exchange of info with neighbors
● “distance vector” algorithms
8. Routing algorithm classification (2)
static:
● routes change slowly over time
dynamic:
● routes change more quickly
● periodic update (in response to link cost changes)
9. A Link-State Routing Algorithm
Dijkstra’s algorithm
● net topology, link costs known to all nodes
■ accomplished via “link state broadcast”
■ all nodes have same info
● computes least cost paths from one node (‘source”) to all other nodes
■ gives forwarding table for that node
● iterative: after k iterations, know least cost path to k dest.’s
10. Dijkstra’s algorithm (1)
notation:
c(x,y): link cost from node x to y; = ∞ if not direct neighbors
D(v): current value of cost of path from source to dest. v
p(v): predecessor node along path from source to v
N': set of nodes whose least cost path definitively known
11. Dijkstra’s algorithm (2)
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'
15. Bellman-Ford: example
5
u
1
2
v
2
x
3
3
1
w
1
y
5
2
z
clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
B-F equation says:
du(z) = min { c(u,v) + dv(z),c(u,x) + dx(z),c(u,w) + dw(z) }
= min {(2 + 5), (1 + 3), (5 + 3) } = 4
node achieving minimum is next
hop in shortest path, used in forwarding table
16. Distance Vector algorithm
key idea:
● from time-to-time, each node sends its own distance vector estimate
to neighbors
● when 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)
17. Hierarchical routing
Scale (with 600 million destinations)
● can’t store all dest’s in routing tables!
● routing table exchange would swamp links!
Administrative autonomy
● internet = network of networks
● each network admin may want to control routing in its own network
18. Hierarchical routing
● aggregate routers into regions, “autonomous systems” (AS)
● routers in same AS run same routing protocol
■ “intra-AS” routing protocol
■ routers in different AS can run different intra- AS routing protocol
gateway router:
● at “edge” of its own AS
● has link to router in another AS
19. Interconnected ASes
● forwarding table configured by
both intra- and inter-AS routing
algorithm
■ intra-AS sets entries
for internal dests
■ inter-AS & intra-AS
sets entries for
20. Intra-AS Routing
● also known as interior gateway protocols (IGP)
● most common intra-AS routing protocols:
○ RIP: Routing Information Protocol
○ OSPF: Open Shortest Path First
○ IGRP: Interior Gateway Routing Protocol (Cisco
proprietary)
21. RIP ( Routing Information Protocol)
● included in BSD-UNIX distribution in 1982
● distance vector algorithm
○ distance metric: # hops (max = 15 hops), each link has cost 1
○ DVs exchanged with neighbors every 30 sec in response message (aka
advertisement)
○ each advertisement: list of up to 25 destination subnets (in IP addressing sense)
22. RIP: link failure, recovery
if no advertisement heard after 180 sec --> neighbor/ link declared dead
▪ routes via neighbor invalidated
▪ new advertisements sent to neighbors
▪ neighbors in turn send out new advertisements (if tables changed)
▪ link failure info quickly (?) propagates to entire net
▪ poison reverse used to prevent ping-pong loops (infinite distance = 16 hops)
23. OSPF (Open Shortest Path First)
● “open”: publicly available
● uses link state algorithm
○ LS packet dissemination
○ topology map at each node
○ route computation using Dijkstra’s algorithm
24. OSPF (Open Shortest Path First)
● OSPF advertisement carries one entry per neighbor
● advertisements flooded to entire AS
■ carried in OSPF messages directly over IP (rather than
TCP or UDP
● IS-IS routing protocol: nearly identical to OSPF
25. Internet inter-AS routing: BGP
● BGP (Border Gateway Protocol): the de facto inter-domain routing protocol
○ “glue that holds the Internet together”
● BGP provides each AS a means to:
○ eBGP: obtain subnet reachability information from neighboring ASs.
○ iBGP: propagate reachability information to all AS- internal routers.
○ determine “good” routes to other networks based on reachability information and policy.
● allows subnet to advertise its existence to rest of Internet: “I am here”
26. BGP route selection
● router may learn about more than 1 route to destination AS, selects
route based on:
1. local preference value attribute: policy decision
2. shortest AS-PATH
3. closest NEXT-HOP router: hot potato routing
4. additional criteria