Network Layer
Routing
Routing
Routing algorithm
Network Layer responsible for deciding on which output
line to transmit an incoming packet.
Remember:
For virtual circuit subnets the routing decision is made
ONLY at set up.
Routing Algorithms
Goal: determine good path (sequence of routers)
through network from source to destination
Routing algorithms for both datagrams and virtual
circuits should satisfy:
- Correctness
- Simplicity
- Stability
- Optimality
- Simplicity
- Robustness
- Fairness
Impossible to satisfy everything at the same time
Routing Algorithm: Graph Abstraction
Graph abstraction for routing algorithms:
graph nodes are routers
graph edges are physical links
Link cost: delay, $cost, or congestion level
good path:
minimum cost path
Forwarding vs. Routing
Forwarding: data plane
Directing a data packet to an outgoing link
Individual router using a forwarding table
Routing: control plane
Computing paths the packets will follow
Routers talking amongst themselves
Individual router creating a forwarding table
Router Architecture Overview
Two key router functions:
Run routing algorithms/protocol (RIP, OSPF, BGP)
Forwarding datagrams from incoming to outgoing
link
switching
fabric
router input ports
routing
processor
router output ports
6
Input Port Functions
line
termination
link
layer
protocol
(receive)
lookup,
forwarding
queueing
physical layer:
bit-level reception
data link layer:
e.g., Ethernet
decentralized switching:
given datagram destination, lookup output port
using forwarding table in input port memory
goal: complete input port processing at line
speed
queuing: if datagrams arrive faster than
forwarding rate into switch fabric
7
Switching Fabrics
Transfer packet from input buffer to appropriate output buffer
Switching rate: rate at which packets can be transfer from inputs
to outputs
Often measured as multiple of input/output line rate
N inputs: switching rate N times line rate desirable
Three types of switching fabrics
memory
memory
bus
crossbar
Routing Design Parameters
Performance Criteria: cost, delay, hops, throughput,
distance, bandwidth, traffic, queue length, ...
Decision Time: packet-wise, session-wise
Decision Place: each node, central node, originated
node
Network information source: none, local, adjacent
node, all nodes
Network information update time: continuous,
periodic, major load change, topology change
Routing Classification
Static vs Dynamic
Adaptive vs Non-Adaptive
Single path vs Multi path
Flat vs Hierarchical
Inter-Domain vs Intra-Domain
Link-state vs Distance-vector
Host intelligent vs Router intelligent
Shortest Path Routing
1. Bellman-Ford Algorithm [Distance Vector]
2. Dijkstras Algorithm [Link State]
What does it mean to be the shortest (or optimal)
route?
1. Minimize mean packet delay
2. Maximize the network throughput
3. Mininize the number of hops along the path
Shortest-Path Problem
Given: network topology with link costs
c(x, y): link cost from node x to node y
Infinity if x and y are not direct neighbors
Compute: least-cost paths to all nodes
From a given source u to all other nodes
p(v): predecessor node along path from source to v
Routing: Link-State Algorithm
Dijkstras Shortest-Path Algorithm
Each node has entire map of network.
Iterative algorithm
After k iterations, know least-cost path to k nodes
S: nodes whose least-cost path definitively known
Initially, S = {u} where u is the source node
Add one node to S in each iteration
D(v): current cost of path from source to node v
Initially, D(v) = c(u,v) for all nodes v adjacent to u
and D(v) = for all other nodes v
Continually update D(v) as shorter paths are learned
Dijsktras Algorithm
1 Initialization:
2 S = {u}
3 for all nodes v
4 if v adjacent to u {
5
D(v) = c(u,v)
6 else D(v) =
7
8 Loop
9 find w not in S with the smallest D(w)
10 add w to S
11 update D(v) for all v adjacent to w and not in S:
12
D(v) = min{D(v), D(w) + c(w,v)}
13 until all nodes in S
15
Dijkstra Algorithm: Example
16
Dijkstra Algorithm: Example
17
Dijkstra Algorithm: Example
18
Dijkstra Algorithm: Example
19
Dijkstra Algorithm: Example
20
Dijkstra Algorithm: Example
21
Dijkstra Algorithm: Example
22
Dijkstra Algorithm: Example
23
Dijkstra Algorithm: Example
24
Dijkstra Algorithm: Example
25
Link-State Routing
Dijkstras algorithm nice and well
But how to obtain centralized view of the entire
network to be able to apply Dijkstras algorithm?
Assumption: only direct neighbors know the (current)
cost of a link or know whether a link has failed/been
restored/upgraded/...
Solution: Have each node distribute this
information state of all its links in the entire
network
Link-State Routing
Each router keeps track of its incident links
Whether the link is up or down
The cost on the link
Each router broadcasts the link state
To give every router a complete view of the graph
Each router runs Dijkstras algorithm
To compute the shortest paths
and construct the forwarding table
Example protocols
Open Shortest Path First (OSPF)
Intermediate System Intermediate System (IS-IS)
Link State Routing - Concept
28
Link State Knowledge
29
Link State Routing
Strategy
send to all nodes (not just neighbors)
information about directly connected links (not entire
routing table)
Link State Packet (LSP)
id of the node that created the LSP
cost of link to each directly connected neighbor
sequence number
time-to-live (TTL) for this packet
Link State Routing
Reliable flooding
store most recent LSP from each node
forward LSP to all nodes but the one that sent it
generate new LSP periodically (in 1-2 hours)
increment sequence number
Start sequence number at 0 when reboot
Route Calculation
Dijkstras shortest path algorithm
Link State Routing
Reaction to Failure
Router sets link distance to infinity & floods the network
with an update packet
All routers immediately update their link database &
recalculate their shortest paths
Recovery very quick
Open Shortest Path First (OSPF)
OSPF divides an autonomous system into areas.
Each area is a collection of networks, hosts and
routers.
Every router in the same area has the same link state
database
Special routers called autonomous system boundary
routers are responsible for dissipate information about
other autonomous systems into the current system.
Metric based on type of service
Administrator can assign the cost to each route based on
type of service (minimum delay, maximum throughput...etc)
OSPF: Areas in an autonomous system
34
OSPF: type of links
OSPF: link state advertisement
Network Link
Router Link
OSPF: LSA cont.
Summary link to Network
Summary link to AS boundary router
External Link
Example of an AS and its graphical
representation in OSPF
Shortest Path Calculation
Types of OSPF packets and header
format
Neighbor Discovery and Maintenance
OSPF Hello Protocol
Hello packets sent out every 10 seconds
Helps to detect failed neighbors
RouterDeadInterval (default 40 seconds)
Also ensures that link is bidirectional
Neighboring routers agree on interval
Summary
Why OSPF is needed in the Internet?
The basics of the protocol
The Link state Advertisements
Neighbor Discovery (Hello Protocol)
Database Synchronization and reliable flooding
Hierarchical Routing in OSPF
OSPF Areas and Area Organization
Interaction with External Routing Information
Routing: Distance-Vector Algorithm
Basic Approaches
Static
Type in the right answers and hope they are always true
...So far
Link state
Tell everyone what you know about your neighbors
Distance vector
Tell your neighbors when you know about everyone
Distance vector algorithm
Base assumption
Each router knows its own address and the cost to reach
each of its directly connected neighbors
Bellman-Ford algorithm
Distributed route computation using only neighbors
info
Mitigating loops
Split horizon and posion reverse
Bellman-Ford Algorithm
Define distances at each node X
dx(y) = cost of least-cost path from X to Y
Update distances based on neighbors
dx(y) = min {c(x,v) + dv(y)} over all neighbors V
Distance Vector Algorithm
Basic Idea
Each network node maintains a Distance Vector table
containing the distance between itself and ALL possible
destination nodes.
Iterative, asynchronous: each local iteration caused by:
Local link cost change
Distance vector update message from neighbor
Distributed
Each node notifies neighbors only when its DV changes
Neighbors then notify their neighbors if necessary
Distance Vector Routing Table
48
Distance Vector Routing Table
In distance vector routing, each node
shares its routing table with its
immediate neighbors periodically and
when there is a change.
The chosen route is with minimum
distance.
Initialization of tables in distance vector
routing
50
Updating in distance vector routing
Process:
Initialization
Each node can know only distance with its immediate
neighbors.
Not neighbor; entry in table is mark as infinite(unreachable)
Sharing
Sharing table with neighbors.
Updating
Update the routing table: calculate the distance, add new
node, modify the existing record if needed.
Updating in distance vector routing
Characteristics of Distance Vector Routing
Periodic Updates: Updates to the routing tables are sent at
the end of a certain time period. A typical value is 90
seconds.
Triggered Updates: If a metric changes on a link, a router
immediately sends out an update without waiting for the end
of the update period.
Full Routing Table Update: Most distance vector routing
protocol send their neighbors the entire routing table (not
only entries which change).
Route invalidation timers: Routing table entries are invalid if
they are not refreshed. A typical value is to invalidate an
entry if no update is received after 3-6 update periods.
53
Network Discovery
Router initial start up (Cold Starts)
Initial network discovery
Directly connected networks are initially placed in the routing
table
Initial Exchange of Routing Information
If a routing protocol is configured then
Routers will exchange routing information
Network Discovery cont.
Routing updates received from other routers
Router checks update for new information
If there is new information:
Metric is updated
New information is stored in routing table
Exchange of Routing Information
Router convergence is reached when
All routing tables in the network contain the same network
information
Routers continue to exchange routing information
If no new information is found then Convergence is reached
Convergence must be reached before a network is
considered completely operable
Routing Loops
Routing loops are
A condition in which a packet is continuously
transmitted within a series of routers without ever
reaching its destination.
Two-node instability
Three-node Instability
Count-to-Infinity
The reason for the count-to-infinity problem is that
each node only has a next-hop-view
For example, in the first step, B did not realize that
its route (with cost 6) to X went through node A
How can the Count-to-Infinity problem be solved?
59
Solution: Count-to-Infinity
Solution 1: Loop avoidance:
Always advertise the entire path in an update message
(Path vectors)
If routing tables are large, the routing messages require
substantial bandwidth
BGP uses this solution
60
Solution: Count-to-Infinity
Solution 2: Split Horizon
Split Horizon: A router should not advertise a network
through the interface from which the update came.
Example: A would not send the first routing update to B, since
B is the next hop on As current route to C
Split Horizon does not solve count-to-infinity in all cases!
Split horizon with poison reverse
The rule states that once a router learns of an unreachable
route through an interface, advertise it as unreachable back
through the same interface
61
In practice
RIP: Routing Information Protocol
DV protocol with hop count as metric
Infinity value is 16 hops; limits network size
Includes split horizon with poison reverse
Routers send vectors every 30 seconds
With triggered updates for link failures
Time-out in 180 seconds to detect failures
Destination network identified by IP address
Netmasks in RIPv2
Encapsulated as UDP packets, port 520
Largely implemented (routed on Unix)
Authentication in RIPv2 by MD5 (shared secret)
Summary
Distance Vector shortest-path routing
Each node sends list of its shortest distance to each
destination to its neighbors
Neighbors update their lists; iterate
Weak at adapting to changes out of the box
Problems include loops and count to infinity
Link-state vs. Distance-vector
Message complexity
LS: with n nodes, E links,
O(nE) messages sent
DV: exchange between
neighbors only
Speed of Convergence
LS: relatively fast
DV: convergence time varies
May be routing loops
Count-to-infinity problem
Robustness: what happens
if router malfunctions?
LS:
Node can advertise incorrect
link cost
Each node computes only its
own table
DV:
Node can advertise incorrect
path cost
Each nodes table used by
others (error propagates)