You are on page 1of 43

Lecture 4:

Routing in the Internet


HEDSPI Project
Hanoi University of Technology
by
Ngo Hong Son

This course materials contains charts and texts provided by Keio University, Japan
Overview
 Last week
 Internet protocol
 IP address and IP packet format
 ICMP
 Today: continue the Internet Layer
 What is routing?
 Static and dynamic routing
 Routing algorithms & protocols
What is routing?
Routing principles
Forwarding mechanism
Longest matching rule
Basic of routing (1)
 When a host sends an IP packet to a certain
address.
 If the destination address is on the same link,
direct forward
 If the destination address is not on the same link,
forwarding through routers
Router Router
Basic of routing (2)

Destination?
( Route searc
h)

Destination?
( Route search )
What is routing?
 Mechanism for host and router to forward the
packet to destination
 Routing elements
 Routing table
 Routing information
 Routing algorithms and protocols
What are routers?
 Equipment that transfers packets among
networks
 Computer with special hardware
 Connect multiple sub-networks
 Forward packet based on routing tables
 Having many interfaces
 Equipment that is suitable with the scale of
network and traffic etc...
Some routers

YAMAHA
RTX-1500 Cisco 2600
BUFFALO PLANEX
BHR-4RV GW-AP54SAG
Edge Router

Cisco CRS-1

Core router
Hitachi
Juniper M10 http://www.cisco.com.vn
GR2000-1B
Foundry Networks
NetIron 800 http://www.juniper.net/
http://www.buffalotech.com
Cisco 3700 Midrange router
Routing table
 List of routes stored in memory of a router
or host
 Elements of routing table
 Destination network address with netmask
 Next hop router
Routing table and forwarding
mechanism (1)

Network Next-hop
10.0.0.0/24 A
172.16.0.0/24 C

Router A Router B Router C

10.0.0.0/24 172.16.0.0/24

10.0.0.0/24 192.168.0.0/24 172.16.0.0/24


Longest matching rule (1)
 Destination : 11.1.2.5
 Which next hop router will be used?

Network Next hop


11.0.0.0/8 A
11.1.0.0/16 B
11.1.2.0/24 C
Longest matching rule (2)
Destination:
11.1.2.5 = 00001011.00000001.00000010.00000101
Route 1:
11.1.2.0/24 = 00001011.00000001.00000010.00000000
Route 2:
11.1.0.0/16 = 00001011.00000001.00000000.00000000
Route 3:
11.0.0.0/8 = 00001011.00000000.00000000.00000000

What is the longest match?


Why longest match is needed?
Routing table and forwarding
Internet
mechanism (2)

Router A Router B Router C

10.0.0.0/24 172.16.0.0/24

10.0.0.0/24 192.168.0.0/24 172.16.0.0/24

Network Next-hop Q. Describe the


routing table on C
10.0.0.0/24 A
If C connects to
172.16.0.0/24 C the Internet?
192.168.0.0/24 Direct No routes, no reachability!
Default route
 When no other routes for the destination are found
in the routing table
 Many cases that default route directs to the upper router
 Many cases that to set only default route on host
 0.0.0.0/0
 It matches every destination
Router A
Internet

For any destination, the next hop is router A


Routing aggregation
 How many networks are there in the Internet?
 Too many entries in a routing table
 Continuous subnets with same destination can be aggregated
into one route to reduce number of routes
200.23.1.0/24
200.23.0.0/23

200.23.2.0/24
200.23.0.0/22

200.23.3.0/24
200.23.2.0/23

200.23.4.0/24
Routing aggregation (2)
 Example of Vietel ISP case
 Large IP address space:
 203.113.128.0-203.113.191.255
 To reach a sub-network in Vietel: routing
aggregation, no need to specify the sub-network
address
 Default route is some kind of route aggregation
 0.0.0.0/0
Example of routing table
C:\Documents and Settings\hongson>netstat -rn
Route Table
===========================================================================
Interface List
0x1 ........................... ………MS TCP Loopback interface
0x2 ...08 00 1f b2 a1 a3 ...... Realtek RTL8139 Family PCI Fast Ethernet NIC -
===========================================================================

Active Routes:
Network Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.34 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.1.0 255.255.255.0 192.168.1.34 192.168.1.34 20
192.168.1.34 255.255.255.255 127.0.0.1 127.0.0.1 20
192.168.1.255 255.255.255.255 192.168.1.34 192.168.1.34 20
224.0.0.0 240.0.0.0 192.168.1.34 192.168.1.34 20
255.255.255.255 255.255.255.255 192.168.1.34 192.168.1.34 1

Default Gateway: 192.168.1.1


===========================================================================
Example of routing table : IPv4
(Extract)
#show ip route
Prefix Next Hop
203.238.37.0/24 via 203.178.136.14
203.238.37.96/27 via 203.178.136.26
203.238.37.128/27 via 203.178.136.26
203.170.97.0/24 via 203.178.136.14
192.68.132.0/24 via 203.178.136.29
203.254.52.0/24 via 203.178.136.14
202.171.96.0/24 via 203.178.136.14
Static & dynamic routing

Static routing
Dynamic routing
Pros & Cons
Updating routing table
 Network structure may change
 New network is added.
 Router failure due to power corruption …
 It’s necessary to update routing table
 of all nodes (theory)
 in pratice: some nodes
Network Next- Network Next- Network Next-
hop hop hop
192.168.0.0/24 B 10.0.0.0/24 A 10.0.0.0/24 B

172.16.0.0/24 B 172.16.0.0/24 C 192.168.0.0/24 B

172.16.1.0/24 B 172.16.1.0/24 C

Router A Router B Router C New Network

10.0.0.0/24 192.168.0.0/24 172.16.0.0/24 172.16.1.0/24


How to update routing table?
 Static routing
 Entries in routing table are added manually by
administrator

 Dynamic routing
 Automatically update routing table
 By mean of routing protocols
Static routing
Internet
 When there is a failure:
 Problem happens even
there are alternative
routes.
 Network administrator 10.0.0.3 10.0.0.2
needs to change setting
Next-hop 10.0.0.3

Routing table of 10.0.0.1 (extract) 10.0.0.1


Prefix Next-hop
0.0.0.0/0 10.0.0.3 Next-hop 10.0.0.1

Unreachable route
Dynamic Routing
 When there is a failure: Internet

 Alternative route is added


automatically

Routing table of 10.0.0.1 (extract)


10.0.0.3 10.0.0.2
Prefix Next-hop Alternative route
0.0.0.0/0 10.0.0.2 Next-hop 10.0.0.3

0.0.0.0/0 10.0.0.3 Unreachable route


10.0.0.1

Next-hop 10.0.0.1
Static routing
 Pros
 Stable
 Secure
 It won’t be effected by other factor

 Cons
 Very stubborn
 Back up link cannot be used
 Difficult to manage
Dynamic routing
 Pros
 Easy to manage
 Backup link can be utilized

 Cons
 Insecure
 Difficult to understand the routing protocols
 Difficult to manage
Routing algorithms and
protocols
Dijkstra vs. Bellman-Ford algorithm
Link-state vs. distance vector routing
Network as a graph
 Graph with nodes (routers) and edges (links)
 Link “cost” c(x,y)
 Bandwidth, delay, cost, congestion level…
 Determine least cost path from every node to every
other node
5

3
v w
2 5
u 2 1 z
3
1
2
x y
1
Shortest path tree - SPT
5
3
v w 5 v w
2
u 2 1 z u z
3
1 2
x 1
y x y

 A tree that links go out from root to leaves


 The unique path from root to any node v is the
shortest path from the root to v
 Each node has a different SPT
Centralized or distributed
 Centralized
 Collect graph structure in one place (central)
 Use standard graph algorithm
 Disseminate routing tables
 Distributed
 Each node must build routing table by its own
 Routing protocols: Link-state or distance-vector
 Mainly used in the real networks
Global or decentralized
 Routing information is needed for each node to build
routing tables
 Global or decentralized routing information?
 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
 “friend of friend is friend”
A Link-State Routing Algorithm
Dijkstra’s algorithm
 Topology and costs are known to all
 “Link-state” broadcast

 All nodes have same info

 Each router calculates its own SPT

 Computes least cost paths from one node


(‘source”) to all other nodes
 To build forwarding table
Notation
 G = (V,E) : Graph with set of vertex and set of edges
 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
 T: set of nodes whose least cost path definitively
known
Initialization and functions
 Init():
For each node v, d[v] = ∞, p[v] = NIL
d[s] = 0
 update(u,v), where (u,v) is an edge of G
if d[v] > d[u] + c(u,v) then
d[v] = d[u] + c(u,v)
p[v] = u
Dijkstra’s Algorithm
1. Init()
2. T = empty-set
3. Repeat
4. u: a node not in T such that d(u) is minimum
5. T = T ∪ {u}
6. for all v adjacent to u and not in T
7. update(u,v)
8. Until all nodes in T
Dijkstra’s algorithm: example

Step T 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
Forwarding table in u:
v 3 w
2 5 destination link
u 2 1 z
3 v (u,v)
1 2
x y v w x (u,x)
1
u z y (u,x)
w (u,x)
x y
z (u,x)
SPT from u:
Distance Vector Algorithm (1)
Bellman-Ford Equation (dynamic programming)

Define
dx(y) := cost of least-cost path from x to y
Then
dx(y) = minv {c(x,v) + dv(y) }

where min is taken over all neighbors v of x


Bellman-Ford example
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3

5 B-F equation says:


3 du(z) = min { c(u,v) + dv(z),
v w 5
2
u c(u,x) + dx(z),
2
3
1 z
1 c(u,w) + dw(z) }
2
x 1
y = min {2 + 5,
1 + 3,
5 + 3} = 4
Node that achieves minimum is next
hop in shortest path ➜ forwarding table
Distance vector algorithm (2)
Basic idea: Each node:
 Each node periodically sends its
own DV estimate to neighbors wait for (change in local link
cost or msg from neighbor)
 When a node x receives new DV
estimate, it updates its own DV
using B-F equation recompute estimates
 Under minor, natural conditions, the
estimate Dx(y) converge to the if DV to any dest has
actual least cost dx(y) changed, notify neighbors
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
node x table
cost to cost to
x y z x y z
x 0 2 7 x 0 2 3 Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}

from
from

y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0 = min{2+1 , 7+0} = 3
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 7 1 0
time
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 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 x z
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 7 1 0 z 3 1 0 z 3 1 0
time
Comparison of LS and DV algorithms
Message complexity Robustness: what happens if
 LS: with n nodes, E links, router malfunctions?
O(nE) msgs sent LS:
 DV: exchange between  node can advertise incorrect
neighbors only link cost
 convergence time varies  each node computes only its
own table
Speed of Convergence DV:
 LS: O(n2) algorithm requires  DV node can advertise
O(nE) msgs incorrect path cost
 DV: convergence time varies  each node’s table used by
others
 error propagate thru
network
Summary
 Routing principles
 Static vs. dynamic
 Link state vs. distance vector
Next week: Routing in the
Internet
 Hierarchical routing
 RIP
 OSPF
 BGP

You might also like