0% found this document useful (0 votes)
6 views

Routing Algorithms

The network layer's main goal is to route packets from the source to the destination by understanding the communication subnet's topology and selecting appropriate paths while avoiding congestion. It provides two services to the transport layer: connectionless and connection-oriented services, and utilizes routing algorithms to determine the best paths for packet transmission. Routing algorithms can be adaptive or non-adaptive, with metrics such as distance and hops used for optimization.

Uploaded by

richa gairola
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Routing Algorithms

The network layer's main goal is to route packets from the source to the destination by understanding the communication subnet's topology and selecting appropriate paths while avoiding congestion. It provides two services to the transport layer: connectionless and connection-oriented services, and utilizes routing algorithms to determine the best paths for packet transmission. Routing algorithms can be adaptive or non-adaptive, with metrics such as distance and hops used for optimization.

Uploaded by

richa gairola
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 76

Network Layer

COMPUTER NETWORKS
Networking Standards
(Network LAYER)
Network Layer

Question to be answered ?

 What is the main goal of Network


layer?

 How does Network layer achieve


its goal?

Computer Networks 2
Network Layer

Network Layer
- The network layer is concerned with
getting packets from the source all
the way to the destination.
- Therefore, the main function (goal)
of network layer is routing packets
from the source machine to the
destination machine.
Computer Networks 3
Network Layer
To achieve its goal the network layer
must:
1- Know about the topology of the
communication subnet.
2- Choose appropriate paths through the
subnet.
3- Avoid overloaded communication lines
and routers (avoid congestion).

Computer Networks 4
Store-and-Forward Packet Switching

fig 5-1

The environment of the network layer protocols.


Network Layer
Store-and-Forwarding Packet Switching

 In Store-and Forwarding Packet Switching


mechanism, a host transmits a packet to the
nearest router, the packet is stored there
until it has fully arrived so the checksum can
be verified, then it is forwarded to the next
router along the path until it reaches the
destination host.

Computer Networks 6
Network Layer

Services provided to the Transport Layer

 There are two services provided by the


network layer to the transport layer:
1) Connectionless service.
2) Connection-Oriented Service.

Computer Networks 7
Implementation of Connectionless Service

Routing within a diagram subnet.


Implementation of Connection-Oriented Service

Routing within a virtual-circuit subnet.


Comparison of Virtual-Circuit and Datagram
Subnets

5-4
Network Layer
Routing Algorithms

 In most subnets, packets require multiple


hops to reach their destinations.

 The Routing algorithm is the software


part of the network layer responsible for
deciding which output line an incoming
packet should be transmitted on.

Computer Networks 11
Network Layer
Routing Algorithms

 The decision about the best route either


calculated once as the case with
connection-oriented paradigm or for
every arriving data packet in the case of
the subnet uses connectionless
paradigm.

Computer Networks 12
Network Layer
Routing Algorithms

Desirable properties in a routing algorithm:


1) Correctness
2) Simplicity
3) Robustness (hardware or software failures)
4) Stability (to be run for long time)
5) Fairness
6) Optimality
Computer Networks 13
Routing Algorithms

Conflict between fairness and optimality.


The Optimality Principle

(a) A subnet. (b) A sink tree for router B.


Network Layer
Routing Algorithms

Routing Algorithms can be grouped in two


major classes:
1) Non-adaptive algorithms (Static Routing)
2) Adaptive algorithms (Dynamic Routing)

Computer Networks 16
Network Layer
Routing Algorithms

1) Non-adaptive algorithms, they do not


base their routing decision on
measurements or estimates of the
current traffic and topology. Instead the
route is computed in advance, off-line,
and downloaded to the routers when the
network is booted.

Computer Networks 17
Network Layer
Routing Algorithms

2) Adaptive algorithms, they change their


routing decisions to reflect changes in
the topology, and usually the traffic as
well.
- Adaptive algorithms differ in where they
get their information.

Computer Networks 18
Network Layer
Routing Algorithms

- What metric is used for optimization?


- Distance
- number of hops
- estimated transit time
- delay
- bandwidth

Computer Networks 19
Network Layer
Shortest Path Routing
- The technique that is used in many
routing algorithms is simple and easy to
understand.
- The idea is to build a graph of the subnet,
with each node of the graph representing
a router and each arc of the graph
representing a communication line
(link). To choose a route between a given
pair of routers, the algorithm just finds the
shortest path between them on the graph.
Computer Networks 20
Network Layer
Shortest Path Routing

B 7 C
Metric is number of hops
2
- The path ABC is equal to
3
2 E 2 F 3 path ABE.
A D
1 2
Metric is the distance in km
6 4
2 - the path ABC is longer than
H the path ABE
G

Computer Networks 21
Network Layer
Shortest Path Routing

There are several algorithms to compute the


shortest path between two nodes of a
graph. The most popular is Dijkstra
algorithm.

In this algorithm each node is labeled (in


parentheses) with its distance from the
source node along the best known path.

Computer Networks 22
Network Layer
Shortest Path Routing

- In Flooding Algorithm every packet is sent


out on every outgoing line except the one it
arrived on.
- Timer is used to stop (limit) this flooding
which can be a hop counter.
- A practical selective flooding algorithm is
used where the packets are sent only to
the approximately in the right direction.
- It is suitable for military applications.

Computer Networks 24
Collection of Subnetworks

The Internet is an interconnected collection of many networks.


3 Distance Vector Routing (1)

(a) A subnet. (b) Input from A, I, H, K, and the new


routing table for J.
3 Distance Vector Routing (2)

The count-to-infinity problem.


3 Distance Vector Routing (3): Loop-
Breaking Heuristics
Set infinity to a limited number, e.g. 16.
Split horizon
Split horizon with poison reverse
A
3 Example: B
C
A 0
B D0
C D E
A 1 A
D 2 B
E C
2
10 E D
2 E 0
A B C A
B 0
B
C C 0 Initialization
D D
E
E
A1
A 0 B
B 10 C 2
C D0
D 1 E 2
A 1 D A
E 2 B
C 2
2
10 E D 2
2 E 0
A 10 B C A
B 0
B
C C 0 Direct
D D 2 Neighbours
E
E2
A1
A 0 B 11
B 10 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B
C 2
2
10 E D 2
2 E 0
A 10 B C A 3
B 0 Neighbours
B
C C 0 of neighbours
D 11 D 2
E
E2
A1
A 0 B 11
B 10 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B 13
C 2
2
10 E D 2
2 E 0
A 10 B C A 3 Neighbours
B 0
B 13 of neighbours
C 13 C 0
D 11 of neighbours
D 2
E 13
E2
A1
A 0 B 11
B 10 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B 13
C 2
2
10 E D 2
2 E 0
A 10 B C A 3
B 0 Stable
B 13
C 13 C 0 convergence
D 11 D 2
E 13
E2
A1
A 0 B 11
B 10 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B 13
C 2
2
10 E D 2
2 E 0
B 1
A 10 C A 3
B 0 Good news:
B 13
C 13 C 0
A new link!
D 11 D 2
E 13
E2
A1
A 0 B 11
B 10 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B 13
C 2
2
10 E D 2
2 E 0
A 10 B 1 C A 3
B 0 Direct
B1
C 1 C 0 endpoints
D 11 D 2 know
E 13
E2
A1
A 0 B3
B 10 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B3
C 2
2
10 E D 2
2 E 0
A4 B 1 C A 3
B 0 Neighbours
B1
C 1 C 0 know
D3 D 2
E3
E2
A1
A 0 B3
B4 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B3
C 2
2
10 E D 2
2 E 0
A4 B 1 C A 3
B 0 Neighbours
B1
C 1 C 0
of neighbours
D3 D 2
know
E3
E2
A1
A 0 B3
B4 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B3
C 2
2
10 E D 2
2 E 0
A4 B 1 C A 3
B 0
B1
A happy and
C 1 C 0 stable network
D3 D 2
E3
E2
A1
A 0 B3
B4 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B3
C 2
2
10 E D 2
2 E 0
A4 B C A 3 Bad news:
B 0
B1 Link crash!!
C 1 C 0
D3 D 2
E3
E2
A1
A 0 B3
B4 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B3
C 2
2
10 E D 2
2 E 0
A B C A 3
B 0 Direct
B
C C 0
endpoints
D D 2
know
E
E2
A1
A 0 B3
B4 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B3
C 2
2
10 E D 2
2 E 0
A 10 B C A 3
B 0
B
C C 0
D D 2
E
E2
A1
A 0 B3
B4 C 2
C 3 D0
D 1 E 2
A 1 D A3
E 3 2 B3
C 2
2
10 E D 2
2 E 0
A 10 B C A 3 Get help
B 0
B5 from
C 13 C 0
D 11 neighbours
D 2
E 13
E2
A 1
A 0 B 7
B 4 C 2
C 3 D 0
D 1 E 2
E 3 A 1 D A 3
2 B 7
C 2
2
10 E D 2
E 0
2
A 10 B C A 3
B 0 Routing loop
B 5
C 13
C 0
(due to
D 11
D 2
inconsistent
E 13
E 2
state info)
A 1
A 0 B 7
B 8 C 2
C 3 D 0
D 1 E 2
E 3 A 1 D A 3
2 B 7
C 2
2
10 E D 2
E 0
2
A 10 B C A 3
B 0
B 9
C 13
C 0
D 11
D 2
E 13
E 2
A 1
A 0 B 11
B 8 C 2
C 3 D 0
D 1 E 2
E 3 A 1 D A 3
2 B 11
C 2
2
10 E D 2
E 0
2
A 10 B C A 3
B 0
B 9 Counting
C 13
C 0 to infinity…
D 11
D 2
E 13
E 2
A 1
A 0 B 11
B 10 C 2
C 3 D 0
D 1 E 2
E 3 A 1 D A 3
2 B 11
C 2
2
10 E D 2
E 0
2
A 10 B C A 3
B 0
B 13
C 13
C 0
D 11
D 2
E 13
E 2
A 1
A 0 B 11
B 10 C 2
C 3 D 0
D 1 E 2
E 3 A 1 D A 3
2 B 13
C 2
2
10 E D 2
E 0
2
A 10 B C A 3
B 0
B 13
C 13
C 0
D 11
D 2
E 13
E 2
A 1
A 0 B 11
B 10 C 2
C 3 D 0
D 1 E 2
E 3 A 1 D A 3
2 B 13
C 2
2
10 E D 2
E 0
2
A 10 B C A 3
B 0
B 13 Stability
C 13
C 0 again
D 11
D 2
E 13
E 2
4 Link State Routing (1)
Each router must do the following:
• Discover its neighbors, learn their network
address.
• Measure the delay or cost to each of its
neighbors.
• Construct a packet telling all it has just
learned.
• Send this packet to all other routers.
• Compute the shortest path to every other
router.
4 Link State Routing (2): Learning
about the Neighbors

(a) Nine routers and a LAN.


(b)A graph model of (a).
4 Link State Routing (3):
Measuring Line Cost
A subnet in which the East and West parts are
connected by two lines.
4 Link State Routing (4): Building
Link State Packets

(a) A subnet. (b) The link state packets for this


subnet.
4 Link State Routing (5):
Distributing the Link State Packets
The packet buffer for router B in the previous slide
(Fig. 5-13).
5 Hierarchical Routing
Hierarchical routing.
6. Routing in Ad Hoc Networks (1)
Possibilities when the routers are mobile:
Military vehicles on battlefield.
• No infrastructure.

A fleet of ships at sea.


• All moving all the time

Emergency works at earthquake .


• The infrastructure destroyed.

A gathering of people with notebook


computers.
• In an area lacking 802.11.
6. Routing in Ad Hoc Networks (2):
Route Discovery

(a) Range of A's broadcast.


(b) After B and D have received A's broadcast.
(c) After C, F, and G have received A's broadcast.
(d) After E, H, and I have received A's broadcast.
Shaded nodes are new recipients. Arrows show possible reverse routes.
6. Routing in Ad Hoc Networks (3):
Route Discovery

Format of a ROUTE REQUEST packet.


6. Routing in Ad Hoc Networks (4):
Route Discovery

Format of a ROUTE REPLY packet.


6. Routing in Ad Hoc Networks (5):
Route Maintenance
(a) D's routing table before G goes down.
(b) The graph after G has gone down.
4. RIP ( Routing Information Protocol)
(1)

Distance vector algorithm


Included in BSD-UNIX Distribution in 1982
Distance metric: # of hops (max = 15 hops)
From router A to subsets:
u v
destination hops
u 1
A B w
v 2
w 2
x 3
x
y 3
z C D
y z 2
4. RIP (2): advertisements
•Distance vectors: exchanged among neighbors every
30 sec via Response Message (also called
advertisement)
•Each advertisement: list of up to 25 destination nets
within AS
4. RIP (3): Example

z
w x y
A D B

C
Destination Network Next Router Num. of hops to dest.
w A 2
y B 2
z B 7
x -- 1
…. …. ....
Routing table in D
4. RIP (4) : Example
Dest Next hops Advertisement
w - 1 from A to D
x - 1
z C 4 z
…. … ...
w x y
A D B

C
Destination Network Next Router Num. of hops to dest.
w A 2
y B 2
z BA 75
x -- 1
…. …. ....
Routing table in D
4. RIP (5): Link Failure and 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)
4. RIP (6): Table processing

RIP routing tables managed by application-level process called


route-d (daemon)
advertisements sent in UDP packets, periodically repeated

routed routed

Transport Transport
(UDP) (UDP)
network forwarding network
forwarding table (IP)
(IP)
link table link
physical physical
4. OSPF (1) (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

•OSPF advertisement carries one entry per neighbor router


•Advertisements disseminated to entire AS (via flooding)
• Carried in OSPF messages directly over IP (rather than TCP or
UDP
4. Hierarchical OSPF (2)
4. Hierarchical OSPF (3)

• Two-level hierarchy: local area, backbone.


– Link-state advertisements only in area
– each nodes has detailed area topology; only know
direction (shortest path) to nets in other areas.
• Area border routers: “summarize” distances to nets in own
area, advertise to other Area Border routers.
• Backbone routers: run OSPF routing limited to backbone.
• Boundary routers: connect to other AS’s.
5. BGP (1)
• BGP (Border Gateway Protocol): the de facto standard
• BGP provides each AS a means to:
– Obtain subnet reachability information from
neighboring ASs.
– Propagate the reachability information to all routers
internal to the AS.
– Determine “good” routes to subnets based on
reachability information and policy.
• Allows a subnet to advertise its existence to rest of the
Internet: “I am here”
5. BGP (2): basics
• Pairs of routers (BGP peers) exchange routing info over semi-
permanent TCP connections: BGP sessions
• Note that BGP sessions do not correspond to physical links.
• When AS2 advertises a prefix to AS1, AS2 is promising it will forward
any datagrams destined to that prefix towards the prefix.
– AS2 can aggregate prefixes in its advertisement

3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
AS1 1d
eBGP session
iBGP session
5. BGP (3): Distributing reachability info
•With eBGP session between 3a and 1c, AS3 sends prefix reachability info to
AS1.
•1c can then use iBGP do distribute this new prefix reach info to all routers in
AS1.
•1b can then re-advertise the new reach info to AS2 over the 1b-to-2a eBGP
session.
•When router learns about a new prefix, it creates an entry for the prefix in its
forwarding table.

3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
AS1 1d
eBGP session
iBGP session
5. BGP (4): Path attributes & BGP routes
• When advertising a prefix, advert includes BGP attributes.
– prefix + attributes = “route”
• Two important attributes:
– AS-PATH: contains the ASs through which the advert
for the prefix passed: AS 67 AS 17
– NEXT-HOP: Indicates the specific internal-AS router
to next-hop AS. (There may be multiple links from
current AS to next-hop-AS.)
• When gateway router receives route advert, uses import
policy to accept/decline.
5. BGP (5): route selection
• Router may learn about more than 1 route to some prefix.
Router must select route.
• Elimination rules:
1. Local preference value attribute: policy decision
2. Shortest AS-PATH
3. Closest NEXT-HOP router: hot potato routing
4. Additional criteria
5. BGP (6): messages

•BGP messages exchanged using TCP.


•BGP messages:
– OPEN: opens TCP connection to peer and authenticates sender
– UPDATE: advertises new path (or withdraws old)
– KEEPALIVE keeps connection alive in absence of UPDATES;
also ACKs OPEN request
– NOTIFICATION: reports errors in previous msg; also used to
close connection
5. BGP (7): routing policy
legend: provider
B network
X
W A
customer
C network:

Figure 4.5-BGPnew: a simple BGP scenario


•A,B,C are provider networks

•X,W,Y are customer (of provider networks)

•X is dual-homed: attached to two networks


– X does not want to route from B via X to C
– .. so X will not advertise to B a route to C
5. BGP (8): routing policy
legend: provider
B network
X
W A
customer
C network:

Figure 4.5-BGPnew: a simple BGP scenario


•A advertises to B the path AW
•B advertises to X the path BAW
•Should B advertise to C the path BAW?
– No way! B gets no “revenue” for routing CBAW since neither W nor C
are B’s customers
– B wants to force C to route to w via A
– B wants to route only to/from its customers!

You might also like