Unit 3 Routing Algorithms Computer Networks
Unit 3 Routing Algorithms Computer Networks
Network layer
Dr. Pushpendra Singh Sisodia
1
Network Layer
• Design issues
• Routing
• Congestion
• Internetworking
• Internet Protocols
• Multimedia or QoS
2
Design Issues
• The network layer or layer 3 of the OSI model is
concerned delivery of data packets from the
source to the destination across multiple hops or
links. The design issues can be elaborated under
four heads −
• Store − and − Forward Packet Switching
• Services to Transport Layer
• Providing Connection Oriented Service
• Providing Connectionless Service
3
Store − and − Forward Packet Switching
• The network layer operates in an environment that uses
store and forward packet switching. The node which has a
packet to send, delivers it to the nearest router.
• The packet is stored in the router until it has fully arrived
and its checksum is verified for error detection.
• Once, this is done, the packet is forwarded to the next
router. Since, each router needs to store the entire packet
before it can forward it to the next hop, the mechanism is
called store − and − forward switching
4
Services to Transport Layer
• The network layer provides service to its
immediate upper layer, namely transport layer,
through the network − transport layer interface.
The two types of services provided are −
• Connection − Oriented Service − In this service, a
path is setup between the source and the
destination, and all the data packets belonging to
a message are routed along this path.
5
Services to Transport Layer
6
Services to Transport Layer
8
Virtual circuits
– Routes chosen at connection time
– Connection identified by a virtual circuit number (VCn)
– Primary service of subnet is connection-oriented
4
Transport 7 Transport
Network Network
Data Link Data Link
Physical Physical
9
Providing Connectionless Service
• In connectionless service, since each packet is transmitted
independently, each packet contains its routing information
and is termed as datagram.
• The network using datagrams for transmission is called
datagram networks or datagram subnets.
• No prior setup of routes are needed before transmitting a
message.
• Each datagram belong to the message follows its own
individual route from the source to the destination.
• An example of connectionless service is Internet Protocol or
IP.
10
Network Layer
• Design issues
• Routing
• Congestion
• Internetworking
• Internet Protocols
• Multimedia or Qos
11
Routing Algorithms
• Properties
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State routing
• Hierarchical routing
• Broadcast routing
• Multicast routing
• Routing for mobile hosts
• Routing in Ad Hoc Networks
• Node Lookup in Peer-to-Peer Networks
12
Routing algorithms
• Desirable properties
– Correctness } all algorithms
– Simplicity
– Robustness: able to cope with hard to achieve
• changes in topology, load
• hardware and software failures
– Stability
• Converge to equilibrium
– Fairness } conflicting
– Optimality
13
Routing algorithms
• Desirable properties (cont.) Conflict!
– Fairness
– Optimality
14
Routing algorithms
• Taxonomy
– Non adaptive
• Routing decisions computed in advance, off-line and
downloaded
– Adaptive
• To changes in
– Topology
– Load
• Get information
– Locally
– From adjacent routers
– From all routers
15
Routing algorithms
Optimal path from I to K over J
• Optimality principle
I d1 distance
K
d2
d1 + d2 is minimal
J d3
Other path from J to K
d3 > d 2
Set of all optimal routes as
• from all sources to a given d1 + d3 > d 1 + d 2
destination is a tree: sink tree
16
Routing algorithms
• Optimality principle: sink tree
Destination
17
Routing: shortest path
• Algorithm of Dijkstra: shortest path in graph
– Graph
• Node = router
• Arc = communication line
– Metric
• Number of hops
• Geographic distance
• Mean queueing and transmission delay
18
Routing: shortest path
Initial node
Elements of algorithm:
• Mark all nodes as free:
• Mark initial node as selected:
• repeat till destination is selected:
• Label all free nodes reachable from selected nodes with shortest
distance to a selected node
• Select free node with shortest distance to a selected node and
mark it as selected
19
Routing: shortest path
20
Routing: flooding
• Every packet is sent out on every outgoing line except the one
it arrived at
21
Routing: flooding
• Every packet is sent out on every outgoing line
except the one it arrived at
22
Routing: flooding
• Every packet is sent out on every outgoing line
except the one it arrived at
23
Routing: flooding
• Every packet is sent out on every outgoing line
except the one it arrived at
24
Routing: flooding
• Every packet is sent out on every outgoing line
except the one it arrived at
• Duplicates!! How to limit?
– Hop counter
• Decrement in each router
• Discard packet if counter is 0
• Initialisation?
– Sequence number in packet
• Avoid sending the same packet a second time
• Keep in each router per source a list of packets already seen
• Useful?
25
Routing: flooding
• Every packet is sent out on every outgoing line
except the one it arrived at
• Sometimes useful
– Robust algorithm: e.g. military applications
– Broadcast
– Comparison purposes: always shortest path
• Selective flooding
– Use only those lines that are going approximately in
right direction
– Still working?
26
Routing Algorithms
• Properties
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State routing
• Hierarchical routing
• Broadcast routing
• Multicast routing
• Routing for mobile hosts
• Routing in Ad Hoc Networks
• Node Lookup in Peer-to-Peer Networks
27
Routing: distance vector
• Adaptive algorithm
– Exchange of info only with neighbours
• Data to be available in each router
– Routing table: per destination
• Distance
• Outgoing line
– Distance to all neighbours
28
Routing: distance vector
• Algorithm
– At each step within a router:
• Get routing tables from neighbours
• Compute distance to neighbours
• Compute new routing table
– Characteristics:
• Iterative
• Asynchronous
• Distributed
29
30
31
32
Routing: link state
• Learning about neighbours:
– Upon boot of router
• Send HELLO packet on each point-to-point line
• Routers are supposed to send reply with a globally
unique name
33
Routing: link state
Algorithm:
34
Routing: link state
Algorithm:
35
Routing: link state
Algorithm:
• Distributing link state packets
– Trickiest part of algorithm
• Arrival time for packets different
• How to keep consistent routing tables
– Basic algorithm
• Flooding +
• Sequence number (in each packet) to limit duplicates
– Manageable problems
• Wrap around of sequence numbers:
• Wrong sequence number used:
– lost in case of crash
– Corruption
36
Routing: link state
Algorithm:
37
Network Layer
Packet buffer for router B
o ACK flag: ACK to send
o Send flag: packet to forward
38
Routing: link state
Algorithm:
39
Routing: link state
• Usage:
– IS-IS protocol
• Designed for DECnet, adopted by ISO
• In use also in Internet
• Supports multiple network layer protocols
– OSPF protocol used in Internet
– Common features:
• Self-stabilizing method of flooding link state updates
• Concept of a designated router on a LAN
• Method of computing and supporting path splitting and multiple metrics
40
41
42
43
44
45
Routing Algorithms
• Properties
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State routing
• Hierarchical routing
• Broadcast routing
• Multicast routing
• Routing for mobile hosts
• Routing in Ad Hoc Networks
• Node Lookup in Peer-to-Peer Networks
46
Hierarchical routing
• When network size increases…
– Larger stables
– More CPU time needed to
compute …
– More bandwidth needed
47
Hierarchical routing
• Solution?
48
Hierarchical routing
49
Routing Algorithms
• Properties
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State routing
• Hierarchical routing
• Broadcast routing
• Multicast routing
• Routing for mobile hosts
• Routing in Ad Hoc Networks
• Node Lookup in Peer-to-Peer Networks
50
Broadcast routing
• Send message to all other hosts:
– Update distributed database
– Distribute weather reports
– Distribute live radio/TV programs
• Poor methods:
– Send a distinct packet to each destination
• List of addresses needed
• High usage of bandwidth
– Flooding
• Too many packets
– Multidestination routing
• Each packet contains a list of destination
• On each line a single packet
51
Broadcast routing
• Best method: use sink tree
o Broadcast source =
root of sink tree
o Forwarding on sink tree
lines
o Excellent use of bandwidth
o Source tree must be
known at each
intermediate node
Which sink tree?
How many sink trees?
52
Broadcast routing
• Sink tree approximation: reverse path
forwarding
53
Routing Algorithms
• Properties
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State routing
• Hierarchical routing
• Broadcast routing
• Multicast routing
• Routing for mobile hosts
• Routing in Ad Hoc Networks
• Node Lookup in Peer-to-Peer Networks
54
Multicast routing
• Send a message to a well-
defined group
– Large in size
– Small compared to network
as a whole
• Group management
– Create and destroy groups
– Process can leave and join
a group
How will routers know
about groups? • algorithm
55
Multicast routing
source
• Algorithm • Pruning:
– Source computes spanning – Link state routing
• Each router knows full topology
tree
– Distance vector routing
– Remove lines that do not
• Reverse path forwarding +
lead to hosts of group
• PRUNE messages to remove
( = pruning) arcs
56
Multicast routing
source
• Pruning:
– Link state routing
• Each router knows full topology
– Distance vector routing
• Reverse path forwarding +
• PRUNE messages to remove
arcs
57
Routing Algorithms
• Properties
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State routing
• Hierarchical routing
• Broadcast routing
• Multicast routing
• Routing for mobile hosts
• Routing in Ad Hoc Networks
• Node Lookup in Peer-to-Peer Networks
58
Routing for Mobile Hosts
• Model of world: WAN + LANs, wireless cells
o Move from time to time
o Use network when connected
• Migratory users
• Roaming users
o Compute on the run
o Maintain connections as they
move around
59
Routing for Mobile Hosts
• Foreign agent: keeps track of • Home agent: keeps track of users
users: – whose home is in the area
– who are currently visiting the – who are currently visiting
area another area
60
Routing for Mobile Hosts
• How does it work?
– Registration procedure with foreign agents
– Sending packets
– Leaving an area
• Registration procedure with foreign agent
– Announcing existence of foreign agent
• Broadcast by foreign agent
• Broadcast query by arriving mobile user
– Mobile user gives to foreign agent
• Home address
• Current data link address
• Security information
– Foreign agent contacts home agent of user
61
Routing for Mobile Hosts
• Registration procedure with foreign agent (cont.)
– Announcing existence of foreign agent
– Mobile user gives to foreign agent
– Foreign agent contacts home agent of user
• Identity of user
• Security info
• Network address of foreign agent
– Home agent
• Checks security info
• Sends ack to foreign agent
– Foreign agent
• Stores state
• Informs mobile user
62
Routing for Mobile Hosts
• Sending a packet to a mobile user
– Home address is used packet routed to home LAN
– Packet intercepted by home agent
address of user address of home agent!
– Packet forwarded to the foreign agent
• Encapsulation – tunneling
– Foreign agent forwards packet to mobile user
• Which protocol, address used?
– Sender is given address of foreign agent
• Encapsulation – tunneling used, required?
63
Routing for Mobile Hosts
Home agent
Foreign agent
64
Routing for Mobile Hosts
• Leaving an area
– Announced by user deregistration
– Automatic detection by foreign agent
• Various different schemes:
– Protocol carried out by routers or hosts
– Routers along the way intercept and redirect traffic
– Visitor gets temporary address to off-load foreign agent
– Modify original packet instead of encapsulation
– Security aspects: authentication?
65
Routing Algorithms
• Properties
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State routing
• Hierarchical routing
• Broadcast routing
• Multicast routing
• Routing for mobile hosts
• Routing in Ad Hoc Networks
• Node Lookup in Peer-to-Peer Networks
66
Routing in Ad Hoc Networks
• Ad Hoc Network = routers are mobile
– No fixed topologies
– No fixed or known neighbors
– Valid paths can disappear at any time
– Node = router + host
– Routing quite different from routing in wired networks
• Examples
– Military vehicles on a battlefield
– Fleet of ships at see
– People with notebooks (lacking 802.11)
• AODV = Ad hoc On-demand distance vector routing
– On-demand: route computed when needed
– Distance vector for mobile world
– Taking into account limited bandwidth + low battery life
67
Routing in Ad Hoc Networks
• Graph presentation
– Node
– Arc = nodes connected
can communicate directly by radio
• Routing table:
– Line for known routes
– Can be valid or invalid
• A wants to send a packet
– To H: forward to D Dest Next Distance Other
– To I: start route discovery broadcasting hop fields
a route request packet B B 1 …
C B 2 …
H D 3 …
68
Routing in Ad Hoc Networks
• Route request packet:
69
Routing in Ad Hoc Networks
• Processing a route request packet
– duplicate request?
• Yes: discard
– Fresh route to destination known?
• Fresh = local destination sequence # >= destination sequence # in
request
• Yes: send route reply packet
– No fresh route to destination is known!
• Store info from route request in reverse route table; to enable the
forwarding of route reply packets
• Increment hop count
• Rebroadcast route request
70
Routing in Ad Hoc Networks
• Processing a route request packet
– Duplicate request?
– Fresh route to destination known?
– No fresh route to destination is known!
71
Routing in Ad Hoc Networks
• Processing a route request packet
– Duplicate request?
– Fresh route to destination known?
– No fresh route to destination is known!
72
Routing in Ad Hoc Networks
• Route reply packet
– Returned by
• Intermediate node knowing a fresh route
• Destination node
Destination sequence#
– Number known by sender of reply packet
Hop count
– Set to length of path known by sender of reply packet
– For destination = 0
73
Routing in Ad Hoc Networks
• Route maintenance
– Detect that neighbors are not reachable anymore
• Broadcast Hello packet periodically
• Failure to send packet
– Cleanup routing table
74
Routing in Ad Hoc Networks
• Route maintenance
75
Routing in Ad Hoc Networks
• Route maintenance
76
Routing Algorithms
• Properties
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State routing
• Hierarchical routing
• Broadcast routing
• Multicast routing
• Routing for mobile hosts
• Routing in Ad Hoc Networks
• Node Lookup in Peer-to-Peer Networks
77
Peer-to-Peer Networks
• Peer-to-Peer
How can a user networkfind a node that
– Large number
contains theof users
info he is looking for,
in– Usually permanent wired
the absence of connections
a centralized
– In contact to
database orshare resources
even a centralized index?
• Interesting features
–Totally distributed storage system!
Distributed
– Symmetric
– No central control or hierarchy
Routing?
– Users will not know each other
– Users will not know where to find what they are looking for
78