You are on page 1of 42

Lecture

Data Communication & Networks 11


Routing and Forwarding

Muhammad Yousaf
Routing & Forwarding:
Routing and Forwarding are two different but
complementary functions
Routing:
To acquire topology information of the network
Who is situated where?
What is the cost to reach a node?
A complex learning problem
Forwarding:
Already know all information about network topology
When a packet is received, then select appropriate
outbound network interface for forwarding the packet
Simply a switching problem
myousaf@ymail.com 2
Routing Table @ my system:
C:\Documents and Settings\yousaf>route print
==================================================================
Interface List
0x1 ...................……………..... MS TCP Loopback interface
0x2 ...00 16 d3 03 0a d4 .……. Realtek RTL8139/810x Family Fast Ethernet NIC
0x3 ...00 16 6f 52 f3 8b ..…... Intel(R) PRO/Wireless 2200BG Network Connection
==================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
255.255.255.255 255.255.255.255 255.255.255.255 2 1
255.255.255.255 255.255.255.255 255.255.255.255 3 1
==================================================================
Persistent Routes:
None

myousaf@ymail.com 3
Forwarding:
Every node (Hosts and routers) maintain a
forwarding table
Forwarding table maps network address to the
outbound network interface
Most often there is an entry for Default route too!
Packets with destination address that couldn’t match with
entries of forwarding table, are forwarded to this default
route
For end-systems this table is static and simple
For routers however, this table is dynamic
Complex protocols are used to form these tables

myousaf@ymail.com 4
Forwarding example:
Forwarding Table for a router with three interfaces:
Network # Netmask interface
======== ========= ========
18.0.0.0 255.0.0.0 1
128.32.0.0 255.255.0.0 2
0.0.0.0 0.0.0.0 3

Forwarding Process:

dest: 18.26.10.3 mask with 255.0.0.0 matched! send to interface 1

dest: 128.16.14.10 mask with 255.0.0.0 not matched


mask with 255.255.0.0 not matched
mask with 0.0.0.0 matched! send to interface 3

myousaf@ymail.com 5
Masking:
Netmask indicates the number of bits for network part
Netmask is bitwise ANDed with destination address of
received packet
e.g. for netmask 255.0.0.0
& destination address 18.26.10.3
11111111.00000000.00000000.00000000
00010010.00011010.00001010.00000011 (AND)
================================
00010010.00000000.00000000.00000000
In decimal notation = 18.0.0.0
It is compared with the entry in forwarding table

myousaf@ymail.com 6
Routing:
E

?
?
? D

A ? ?
? ?

? ?
?

C
B

myousaf@ymail.com 7
Routing schemes:
There are number of schemes to help routers in
making routing decisions
Flooding
Random routing
Source routing
Directory-Base routing
Static routing
Dynamic routing

myousaf@ymail.com 8
Flooding:
Packet received on one interface is broadcasted on
all other network interfaces
Network is flooded with a single message
If there is even a single possible path then it is
guaranteed that message will reach the destination
Destination can receive multiple redundant copies
First copy will reach with minimum possible delay
Overhead is high

myousaf@ymail.com 9
Flooding: cont…
E

C
B

myousaf@ymail.com 10
Random routing:
Trying to reduce overhead of flooding
Do not forward packet on all interfaces
Rather, randomly choose a subset of interfaces and
forward only over them
Reduces flooding overhead
It is not guaranteed that packets will either reach
the destination or not
Even if reached, then delays are likely to be high

myousaf@ymail.com 11
Random routing: cont...
E

C
B

myousaf@ymail.com 12
Source routing:
Source node attaches the path to be followed in the
header of packet
Each router reads the header and sees where to
forward the packet
Routing-overhead is small
Header-to-Packet ratio is large
Can’t accommodate dynamics of network
Most users don’t know the path to be followed by
packets, so they can’t give source route
Source routing can be used for QoS or secure
routing of packets

myousaf@ymail.com 13
Source routing: cont…
E
R6-R11-R12-D R11-R12-D
R4 R6 R12-D
R11 D
R4-R6-R11-R12-D D
A R1 R3 R8 R12

R1-R4-R6-R11-R12-D
R2 R10
R9

C
B

myousaf@ymail.com 14
Directory-Based routing
Let’s migrate the intelligence into the routers
Each router maintains a table, that helps to make
the routing decision
Routers can have:
Either static tables
Or dynamic tables

myousaf@ymail.com 15
Static routing tables:
At the time of configuring network devices, tables
are established in each router
Entries are static, can not be updated automatically
Addition or removal of routers/nodes is not easy
Require manual updating of each router

myousaf@ymail.com 16
Dynamic routing tables:
Again each node maintain a routing table
But this time, table is not fix or constant
It can change automatically to accommodate the
network changes
Sophisticated routing protocols are designed for
dynamically updating these tables
All nodes exchange routing advertisements with
each other periodically
Hence nodes remain aware of the network
dynamics

myousaf@ymail.com 17
Routing Protocols:
Most of the modern protocols are dynamic
They can adapt to the current condition of the
network
Well known strategies for adaptive routing are:
Distance Vector routing
Link State routing
These protocols define procedures following which,
routers can acquire information in their
routing/forwarding tables

myousaf@ymail.com 18
Routing Protocols: cont….
Distance Vector
Communicate information to neighbors only
Exchange information about entire network

Link State
Communicate information to entire network
Exchange information about neighbors only
State of own links is exchanged

myousaf@ymail.com 19
Distance Vector routing:
Distributed Bellman-Ford routing algorithm
Also known as Ford-Fulkerson algorithm
Original ARPANET routing protocol
Used in Internet as RIP
RIP = Routing Information Protocol
First dynamic routing protocol
Automatically compute routing tables
Freeing administrators from statically specifying routes

myousaf@ymail.com 20
Distance Vector routing: cont…
Each router maintains a distance vector:
Containing one entry for each router in the network
Each entry also contains the distance (cost) and the next
hop to reach that destination
So, each entry is a set of triplet (Destination, Cost, NextHop)
Cost = number of hops, time delay, etc…
It is assumed that routers know the distance to each of its neighbors
Routing updates are exchanged with directly
connected neighbors by:
periodically (from time period of milliseconds to minutes)
triggered update (whenever significant change occurs)

myousaf@ymail.com 21
Calculating Cost:
Let cost to reach from me to my neighbor is “1”
If my neighbor tells me that he can reach the router
D in cost “3”
Then I can conclude that the cost to reach from me
to router D is “1+3=4”

myousaf@ymail.com 22
Calculating Cost: example…
E

R4 R6
R11 D
R3=(R12, 3, R8)
R1=(R12, 4, R3)
A R1 R3 R8 R12

R2 R10
R9

C
B

myousaf@ymail.com 23
Distance Vector Iterations:
source A B
infinity infinity infinity
infinity 6 infinity 2 1 Dest
infinity 3 B 1 Dest
8 C 3 B 1 Dest
8 C 3 B 1 Dest

1 1 1

C E Destination
infinity infinity
infinity 2 5 Dest 5
7 E 5 Dest
7 E 4 A
6 E 4 A

myousaf@ymail.com 24
Distance Vector Iterations: example

Information in routing table of each node:


Iteration 1
At distance to reach node
node A B C D E F G B
A 0 1 1 x 1 1 x C
A
B 1 0 1 x x x x D
C 1 1 0 1 x x x
E
D x x 1 0 x x 1
E 1 x x x 0 x x
F G
F 1 x x x x 0 1
G x x x 1 x 1 0

myousaf@ymail.com 25
Distance Vector Iterations: example

Information in routing table of each node:


Iteration 2
At distance to reach node
node A B C D E F G B
A 0 1 1 2 1 1 2 C
A
B 1 0 1 2 2 2 x D
C 1 1 0 1 2 2 2
E
D 2 2 1 0 x 2 1
E 1 2 2 x 0 2 x
F G
F 1 2 2 2 2 0 1
G 2 x 2 1 x 1 0

myousaf@ymail.com 26
Distance Vector Iterations: example

Information in routing table of each node:


Iteration 3
At distance to reach node
node A B C D E F G B
A 0 1 1 2 1 1 2 C
A
B 1 0 1 2 2 2 3 D
C 1 1 0 1 2 2 2
E
D 2 2 1 0 3 2 1
E 1 2 2 3 0 2 3
F G
F 1 2 2 2 2 0 1
G 2 3 2 1 3 1 0

myousaf@ymail.com 27
Distance Vector Routing Table:

Routing table at node B:

Destination Cost NextHop B

A 1 A C
C 1 C A
D
D 2 C
E 2 A E
F 2 A
G 3 A F G

myousaf@ymail.com 28
Distance Vector: (Link Failure)
F detects that link to G has failed
F sets distance to G as infinity and B

sends update to A C
A
A sets distance to G as infinity since it D

was using F to reach G E

A receives periodic update from C with F G


2-hop path to G
A sets distance to G to 3 and sends
update to F
F decides it can reach G in 4 hops via
A

myousaf@ymail.com 29
Count to Infinity Problem:
A game of mutual deception
Suppose, link from A to E fails
B
A advertises distance of infinity to E,
C
B and C advertise a distance of 2 to E A
D
B decides it can reach E in 3 hops;
E
advertises this to all
A decides it can read E in 4 hops; F G
advertises this to all
C decides that it can reach E in 5 hops…
We are counting to infinity …

myousaf@ymail.com 30
Problems with Distance Vector:
One iteration per hop for new routes
Information propagates slowly
Can’t scale well for large network
Count to infinity for lost routes

myousaf@ymail.com 31
Link State Routing:
Send to all nodes (not just neighbors) information of
directly connected nodes (links)
Most widely used dynamic routing scheme
Best example is OSPF protocol
OSPF = Open Shortest Path First
Work began in 1980s as a replacement for RIP
Uses Dijkstra’s algorithm for shortest path calculation
OPEN means, it is freely available open standard
While IGRP & EIGRP are CISCO proprietary protocols

myousaf@ymail.com 32
OSPF:
OSPF is well supported by:
CISCO’s Internetwork Operating System (IOS)
Routing & Remote Access Service (RRAS) of Microsoft
Windows 2000 & .NET plateforms
So far, there are three versions:
OSPF (RFC-1131), experimental, not widely used
OSPFv2 (RFC-2328), most widely deployed routing
protocol since 1990
OSPFv3, recent development, support for IPv6, with
enhanced security

myousaf@ymail.com 33
OSPF: cont…
Routers discover its neighbors by Hello messages
Hello messages are sent every 10 to 15 seconds
These messages indicate the liveliness of the routers
If hello is not received from some router in specified time,
then it is assumed that the router is down
Each router then transmit Link State Advertisement
(LSA) messages
LSA contains the information about changes in network
topology
Routers maintains a list of all the LSAs from all the
routers and then run Dijkstra’s algorithm on this list

myousaf@ymail.com 34
OSPF message format:
OSPF operates above the network layer
There are five types of OSPF messages
All OSPF messages include the OSPF header

myousaf@ymail.com 35
OSPF header:

myousaf@ymail.com 36
OSPF header: cont…
Version:
OSPF version, current version is v2
Type:
Type-1 = Hello message
Type-2 = Database Description message
Type-3 = Link State (LS) request message
Type-4 = LS update message
Type-5 = LS Acknowledgement message
Packet Length:
Length of entire packet, including header

myousaf@ymail.com 37
OSPF header: cont…
Router ID:
ID of the message generating router
Area ID:
Area ID of network on which this packet is being sent
Checksum:
Checksum of entire packet, including header

myousaf@ymail.com 38
OSPF header: cont…
Au Type:
Authentication Type
0 = no authentication
1 = password authentication
2 = MD5 checksum
Authentication Data:
Data that is to be used for authentication

myousaf@ymail.com 39
Dijkstra’s Algorithm:
Calculates the shortest path between nodes
Relies on the information received in LSAs
For calculation each router maintains two lists:
Tentative list
Confirmed list
How algorithm works:
Initialize confirmed list & tentative list with your own entry
Pick the entry of shortest cost from tentative list
Include that entry in confirmed list
Include LSA of most recently picked entry in tentative list
Repeat procedure until tentative list is empty

myousaf@ymail.com 40
Dijkstra’s Algorithm: (example)
At node D:
Confirmed list Tentative list
1. (D,0,-)
2. (D,0,-) (C,2,C), (B,11,B) B
3. (D,0,-), (C,2,C) (B,11,B)
4. (D,0,-), (C,2,C) (B,5,C), (A,12,C) 5 3
5. (D,0,-), (C,2,C), (B,5,C) (A,12,C)
(D,0,-), (C,2,C), (B,5,C) (A,10,C) 10 C
6. A
7. (D,0,-), (C,2,C), (B,5,C), (A,10,C)
11
2

myousaf@ymail.com 41
To be continued…

myousaf@ymail.com 42

You might also like