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

Module 5 - Network Layer 1

Uploaded by

ggcxdfkdm8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Module 5 - Network Layer 1

Uploaded by

ggcxdfkdm8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 138

Module 5

Network Layer
BY:
Maulika Patel

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Network Layer
• It is responsible for the host-to-host delivery
of datagrams.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Duties of Network Layer
1. Packetizing:
• Encapsulating the payload(data received from upper
layer) in a network-layer packet at the source and
decapsulating the payload from the network-layer
packet at the destination.
• The source host adds a header that contains the source
and destination addresses and some other information
that is required by the network-layer protocol.
• If the packet is fragmented at the source or at routers
along the path, the network layer is responsible for
waiting until all fragments arrive, reassembling them,
and delivering them to the upper-la yer protocol.
Mitul Patel B.Tech(Computer Engineering/IT)
SECE3011-Computer Networks
Duties of Network Layer
2. Routing and Forwarding
• The network layer is responsible for finding the best one
among these possible routes.
• Requires Routing Protocols.
• forwarding can be defined as the action applied by each
router when a packet arrives at one of its interfaces.
• The decision-making table a router normally uses for
applying this action is sometimes called the forwarding
table and sometimes the routing table.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Forwarding process

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Other Services
• Error Control(By ICMP)
• Flow Control(By sing Upper Layer Protocols)
• Congestion Control
• Quality of Service
• Security

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
IPv4 ADDRESSES
• The identifier used in the IP layer of the
TCP/IP protocol suite to identify the
connection of each device to the Internet is
called the Internet address or IP address.
• An IPv4 address is a 32-bit address that
uniquely and universally defines the
connection of a host or a router to the
Internet

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Note

An IPv4 address is 32 bits long.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Note

The IPv4 addresses are unique


and universal.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Note

The address space of IPv4 is


232 or 4,294,967,296.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Three different notations in IPv4 addressing

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 1

Change the following IPv4 addresses from binary


notation to dotted-decimal notation.

Solution
We replace each group of 8 bits with its equivalent
decimal number and add dots for separation.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 2

Change the following IPv4 addresses from dotted-decimal


notation to binary notation.

Solution
We replace each decimal number with its binary
equivalent.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 3

Find the error, if any, in the following IPv4 addresses.

Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Hierarchy in Addressing

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Classful Addressing

• When the Internet started, an IPv4 address


was designed with a fixed-length prefix, but
to accommodate both small and large
networks, three fixed-length prefixes were
designed instead of one (n = 8, n = 16, and n =
24).
• The whole address space was divided into
five classes (class A, B, C, D, and E).

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Note

In classful addressing, the address


space is divided into five classes:
A, B, C, D, and E.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Finding the classes in binary and dotted-decimal notation

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Occupation of the address space in classful
addressing

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 4

Find the class of each address.


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111

Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class C
address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Number of blocks and block size in classful IPv4 addressing

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Note

In classful addressing, a large part of the


available addresses were wasted.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Mask
• The mask can help us to find the netid and
the hostid. For example, the mask for a class
A address has eight 1s, which means the first
8 bits of any address in class A define the
netid; the next 24 bits define the hostid.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Default masks for classful addressing

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Subnetting
• During the era of classful addressing,
subnetting was introduced.
• If an organization was granted a large block in
class A or B, it could divide the addresses into
several contiguous groups and assign each
group to smaller networks (called subnets) or,
in rare cases, share part of the addresses with
neighbors.
• Subnetting increases the number of 1s in the
mask, as we will see later when we discuss
Maulika Patel B.Tech(Computer

classless addressing.
Engineering/IT)
SECE3011-Computer Networks
Note:
• Subnetting for classful addressing is
discussed in LAB which is also in the syllabus.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Supernetting
• An organization can combine several class C blocks to create
a larger range of addresses. In other words, several
networks are combined to create a supernetwork or a
supenet.
• An organization can apply for a set of class C blocks instead
of just one.
• For example, an organization that needs 1000 addresses can
be granted four contiguous class C blocks. The organization
can then use these addresses to create one supernetwork.
• Supernetting decreases the number of 1s in the mask. For
example, if an organization is given four class C addresses,
the mask changes from /24 to /22
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Note

Classful addressing, which is almost


obsolete, is replaced with classless
addressing.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Classless Addressing
• To overcome address depletion and give
more organizations access to the Internet,
classless addressing was designed and
implemented.
• In this scheme, there are no classes, but the
addresses are still granted in blocks.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Address Blocks
• In classless addressing, when an entity, small or
large, needs to be connected to the Internet, it
is granted a block (range) of addresses.
• The size of the block (the number of addresses)
varies based on the nature and size of the
entity.
• For example, a household may be given only
two addresses; a large organization may be
given thousands of addresses.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Restrictions
• To simplify the handling of addresses, the
Internet authorities impose three restrictions
on classless address blocks:
1. The addresses in a block must be contiguous,

one after another.


2. The number of addresses in a block must be

a power of 2 (I, 2, 4, 8, ... ).


3. The first address must be evenly divisible by

the number of addresses.


Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Example 5

Figure on next slide shows a block of addresses, in both


binary and dotted-decimal notation, granted to a small
business that needs 16 addresses.

We can see that the restrictions are applied to this block.


The addresses are contiguous. The number of addresses
is a power of 2 (16 = 24), and the first address is divisible
by 16. The first address, when converted to a decimal
number, is 3,440,387,360, which when divided by 16
results in 215,024,210.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Figure 3 A block of 16 addresses granted to a small
organization

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Mask
• A better way to define a block of addresses is
to select any address in the block and the
mask.
• As we discussed before, a mask is a 32-bit
number in which the n leftmost bits are 1s
and the 32 - n rightmost bits are 0s.
• However, in classless addressing the mask for
a block can take any value from 0 to 32. It is
very convenient to give just the value of n
preceded by a slash (CIDR notation).
M itul Patel B.Tech(Computer Engineering/IT)
SECE3011-Computer Networks
Note

In IPv4 addressing, a block of


addresses can be defined as
x.y.z.t /n
in which x.y.z.t defines one of the
addresses and the /n defines the mask.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Note

The first address in the block can be


found by setting the rightmost
32 − n bits to 0s.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 6

A block of addresses is granted to a small organization.


We know that one of the addresses is 205.16.37.39/28.
What is the first address in the block?

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightm ostbits to 0, we get
11001101 00010000 00100101 0010000
or
205.16.37.32.
This is actually the block shown in Figure 3.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Note

The last address in the block can be


found by setting the rightmost
32 − n bits to 1s.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 7

Find the last address for the block in Example 6.

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32 − 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111
or
205.16.37.47
This is actually the block shown in Figure 3.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Note

The number of addresses in the block


can be found by using the formula
232−n.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 8

Find the number of addresses in Example 6.

Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 9

Another way to find the first address, the last address,


and the number of addresses is to represent the mask as
a 32-bit binary (or 8-digit hexadecimal) number. This is
particularly useful when we are writing a program to find
these pieces of information. In Example 5 the /28 can be
represented as
11111111 11111111 11111111 11110000
(twenty-eight 1s and four 0s).

Find
a. The first address
b. The last address
c. The number of addresses.
Maulika Patel B.Tech(Computer
Engineering/IT)
SECE3011-Computer Networks
Example 9 (continued)

Solution
a. The first address can be found by ANDing the given
addresses with the mask. ANDing here is done bit by
bit. The result of ANDing 2 bits is 1 if both bits are 1s;
the result is 0 otherwise.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 9 (continued)

b. The last address can be found by ORing the given


addresses with the complement of the mask. ORing
here is done bit by bit. The result of ORing 2 bits is 0 if
both bits are 0s; the result is 1 otherwise. The
complement of a number is found by changing each 1
to 0 and each 0 to 1.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example 9 (continued)

c. The number of addresses can be found by


complementing the mask, interpreting it as a decimal
number, and adding 1 to it.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Figure 4 A network configuration for the block
205.16.37.32/28

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Note

The first address in a block is


normally not assigned to any device;
it is used as the network address that
represents the organization
to the rest of the world.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Network Address
• For the moment, let us assume that an internet is
made of m networks and a router with m interfaces.
• When a packet arrives at the router from any
source host, the router needs to know to which
network the packet should be sent: from which
interface the packet should be sent out.
• After the network address has been found, the
router consults its forwarding table to find the
corresponding interface from which the packet
should be sent out

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Network Address

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Note

Each address in the block can be


considered as a two-level
hierarchical structure:
the leftmost n bits (prefix) define
the network;
the rightmost 32 − n bits define
the host.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Designing Subnets
• We assume the total number of addresses granted to the
organization is N, the network mask is n, the assigned number
of addresses to each subnetwork is Nsub, and the subnet mask
is nsub
1. The number of addresses in each subnetwork should be a
power of 2.
2. The subnet mask for each subnetwork should be found
using the following formula:
nsub = 32 − log2Nsub
3. The starting address in each subnetwork should be
divisible by the number of addresses in that subnetwork.
4. Always start the assignment from larger blocks
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Subnetting
• More levels of hierarchy can be created using
subnetting. An organization (or an ISP) that is
granted a range of addresses may divide the
range into several subranges and assign each
subrange to a subnetwork (or subnet).
• Note that nothing stops the organization
from creating more levels.
• A subnetwork can be divided into several
sub-subnetworks.A sub-subnetwork can be
divided into several sub-sub-subnetworks,
and so on. Maulika Patel B.Tech(Computer
Engineering/IT)
SECE3011-Computer Networks
Designing Subnets
Example 5
• An organization is granted a block of
addresses with the beginning address
14.24.74.0/24.
• The organization needs to have 3 subblocks
of addresses to use in its three subnets:
– one subblock of 10 addresses
– one subblock of 60 addresses, and
– one subblock of 120 addresses.
Design the subblocks.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Solution
• There are 232 – 24 = 256 addresses in this
block. The first address is 14.24.74.0/24; the
last address is 14.24.74.255/24. To satisfy the
third requirement, we assign addresses to
subblocks, starting with the largest and
ending with the smallest one.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• The number of addresses in the largest subblock,
which requires 120 addresses, is not a power of
2. We allocate 128 addresses. The subnet mask
for this subnet can be found as
n1 = 32 − log2128 = 25.
The first address in this block is
14.24.74.0/25; the last address is 14.24.74.127/25.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• The number of addresses in the second
largest subblock, which requires 60
addresses, is not a power of 2 either. We
allocate 64 addresses.
• The subnet mask for this subnet can be found
as n2 = 32 − log264 = 26. The first address in
this block is 14.24.74.128/26; the last address
is 14.24.74.191/26.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• The number of addresses in the smallest
subblock, which requires 10 addresses, is not
a power of 2 either. We allocate 16
addresses.
• The subnet mask for this subnet can be found
as n3 = 32 − log216 = 28.
• The first address in this block is
14.24.74.192/28; the last address is
14.24.74.207/28.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
• If we add all addresses in the previous
subblocks, the result is 208 addresses, which
means 48 addresses are left in reserve.
• The first address in this range is 14.24.74.208.
The last address is 14.24.74.255.
• Figure shows the configuration of blocks.
We have shown the first address in each block.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Exercise
• An ISP is granted the block 16.12.64.0/20.
The ISP needs to allocate addresses for 8
organizations, each with 256 addresses.
a. Find the number and range of addresses
in the ISP block.
b. Find the range of addresses for each
organization and the range of
unallocated addresses.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Address Aggregation

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Special Addresses
• This-host Address
• The only address in the block 0.0.0.0/32 is
called the this-host address. It is used
whenever a host needs to send an IP
datagram but it does not know its own
address to use as the source address.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Special Addresses
• Limited-broadcast Address
• The only address in the block
255.255.255.255/32 is called the limited-
broadcast address.
• It is used whenever a router or a host needs to
send a datagram to all devices in a network.
• The routers in the network, however, block the
packet having this address as the destination;
the packet cannot travel outside the network.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Special Addresses
• Private Addresses
• Four blocks are assigned as private
addresses: 10.0.0.0/8, 172.16.0.0/12,
192.168.0.0/16.
• Applications of these addresses in NAT

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Special Addresses
• Loopback Address
• The block 127.0.0.0/8 is called the loopback
address. A packet with one of the addresses in this
block as the destination address never leaves the
host; it will remain in the host.
• Any address in the block is used to test a piece of
software in the machine. For example, we can write
a client and a server program in which one of the
addresses in the block is used as the server address.
We can test the programs using the same host to
see if they work before running them on different
computers Maulika Patel B.Tech(Computer
Engineering/IT)
SECE3011-Computer Networks
Network Address Resolution (NAT)

• The distribution of addresses through ISPs


has created a new problem. Assume that an
ISP has granted a small range of addresses to
a small business or a household.
• If the business grows or the household needs
a larger range, the ISP may not be able to
grant the demand because the addresses
before and after the range may have already
been allocated to other networks
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Network Address Resolution (NAT)
• A quick solution to this problem is called
network address translation (NAT).
• NAT enables a user to have a large set of
addresses internally and one address, or a
small set of addresses, externally. The traffic
inside can use the large set; the traffic
outside, the small set.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Addresses for private networks

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
A NAT implementation

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
NAT address translation

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Addresses in a NAT

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Five-column translation table

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Forwarding of IP Packets

Maulika Patel B.Tech(Computer

McGraw-Hill ©The McGraw-Hill Companies, Inc., 2000


Engineering/IT) SECE3011-Computer
Networks
Forwarding Based on Destination Address
• forwarding means to place the packet in its route to its
destination.
• In Forwarding Based on Destination Address, it requires
a host or a router to have a forwarding table.
• When a host has a packet to send or when a router has
received a packet to be forwarded, it looks at this table
to find the next hop to deliver the packet to.
• A classless forwarding table needs to include four
pieces of information: the mask, the network address,
the interface number, and the IP address of the next
router
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Simplified forwarding module in classless
address
Figure 1

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Example : Make a forwarding table for router R1
using the configuration in Figure 1.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Solution 1
Forwarding table for router R1

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Solution 2
Forwarding table for router R1
using prefix bits

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Exercise 3
• Show the forwarding process if a packet arrives at R1 in
Figure 1 with the destination address 180.70.65.140.
Solution
• The router performs the following steps:
1. The first mask (/26) is applied to the destination address.
The result is 180.70.65.128, which does not match the
corresponding network address.
2. The second mask (/25) is applied to the destination address.
The result is 180.70.65.128,which matches the
corresponding network address. The next-hop address and
the interface number m0 are extracted for forwarding the
packet.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Exercises
• Each of the following addresses belongs to a
block. Find the first and the last address in
each block.
a. 14.12.72.8/24
b. b. 200.107.16.17/18
c. c. 70.110.19.17/16

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Exercises
• Show the n leftmost bits of the following
network-addresses/masks that can be used
in a forwarding table.
a. 170.40.11.0/24
b. 110.40.240.0/22
c. 70.14.0.0./18

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Exercises
• Assume we have an internet with an 8-bit
address space. The addresses are equally
divided between four networks (N0 to N3).
The internetwork communication is done
through a router with four interfaces (m0 to
m3). Show the internet outline and the
forwarding table (with two columns: prefix in
binary and the interface number) for the only
router that connects the networks. Assign a
network address to each network.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Exercises
• An ISP is granted the block 80.70.56.0/21. The ISP
needs to allocate addresses for two organizations
each with 500 addresses, two organizations each
with 250 addresses, and three organizations each
with 50 addresses.
a. Find the number and range of addresses in the ISP

block.
b.Find the range of addresses for each organization
and the range of unallocated addresses.
c. Show the outline of the address distribution and
Maulika Patel B.Tech(Computer

the forwarding table.


Engineering/IT)
SECE3011-Computer Networks
Exercises
• An organization is granted the block
130.56.0.0/16. The administrator wants to
create 1024 subnets.
a. Find the number of addresses in each

subnet.
b. Find the subnet prefix.
c. Find the first and the last address in the first
subnet.
d. Find the first and the last address in the last
Maulika Patel B.Tech(Computer

subnet. Engineering/IT) SECE3011-Computer


Networks
Forwarding vs. Routing
• Forwarding: the process of moving packets
from input to output
– The forwarding table
– Information in the packet
• Routing: process by which the forwarding
table is built and maintained
– One or more routing protocols
– Procedures(algorithms) to convert routing info to
forwarding table.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Routing Algorithms
• Routing algorithms are meant for determining the
routing of packets in a node.
• Best route(least cost path) to send the packets is
determined by the routing algorithm.
• Routing algorithms are classified as-

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Static Routing Algorithms
• Also known as Non Adaptive routing
algorithm.
• When booting up the network, the routing
information stores to the routers.
• Non Adaptive routing algorithms do not take
the routing decision based on the network
topology or network traffic.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Static Routing Algorithms
Two Types:
• Flooding: In case of flooding, every incoming
packet is sent to all the outgoing links except
the one from it has been reached. The
disadvantage of flooding is that node may
contain several copies of a particular packet.
• Random walks: In case of random walks, a
packet sent by the node to one of its
neighbors randomly. An advantage of using
random walks is that it uses the alternative
routes very efficien tly.
M itul Patel B.Tech(Computer Engineering/IT)
SECE3011-Computer Networks
Dynamic Routing Algorithm
• Dynamic routing algorithm is also known as
an adaptive routing algorithm .
• This algorithm makes the routing decisions
based on the topology and network traffic.
• The main parameters related to this
algorithm are hop count, distance and
estimated transit time.

Maulika Patel B.Tech(Computer


Engineering/IT)
SECE3011-Computer Networks
Comparisons
Basis Of Adaptive Routing algorithm Non-Adaptive Routing algorithm
Comparison
Define Adaptive Routing algorithm is an The Non-Adaptive Routing
algorithm that constructs the algorithm is an algorithm that
routing table based on the constructs the static table to
network conditions. determine which node to send the
packet.

Usage Adaptive routing algorithm is The Non-Adaptive Routing


used by dynamic routing. algorithm is used by static routing.

Routing Routing decisions are made Routing decisions are the static
decision based on topology and network tables.
traffic.
Categorization The types of adaptive routing The types of Non Adaptive routing
algorithm, are Centralized, algorithm are flooding and random
isolation and distributed walks.
algorithm.
Complexity Adaptive Routing algorithms are
Maulika Patel B.Tech(Computer
Non-Adaptive Routing algorithms
eering/IT)
are simple.
Engin
more complex. SECE3011-Computer Network
s
Distance Vector Routing Algorithm

• Distance Vector Routing is a dynamic distributed


routing algorithm.
• It works in the following steps-

• Step-01:
• Each router prepares its routing table. By their local
knowledge. each router knows about-
• All the routers present in the network
• Distance to its neighboring routers
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
• Step-02:
– Each router exchanges its distance vector with its
neighboring routers.
– Each router prepares a new routing table using
the distance vectors it has obtained from its
neighbors.
– This step is repeated for (n-2) times if there are n
routers in the network.
– After this, routing tables converge / become
stable
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Distance Vector Routing Example-
Consider-
• There is a network consisting of 4 routers.
• The weights are mentioned on the edges.
• Weights could be distances or costs or delays.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• Step-01:
• Each router prepares its routing table using
its local knowledge.
• Routing table prepared by each router is
shown below:

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
At Router A

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
At Router B

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
At Router C

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
At Router D

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Step-02:
• Each router exchanges its distance vector
obtained in Step-01 with its neighbors.
• After exchanging the distance vectors, each
router prepares a new routing table.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
At Router A

• A receives distance vectors from its neighbors B and D.


• Router A prepares a new routing table as

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• Cost of reaching destination B from router A
= min { 2+0 , 1+7 } = 2 via B.
• Cost of reaching destination C from router A
= min { 2+3 , 1+11 } = 5 via B.
• Cost of reaching destination D from router A
= min { 2+7 , 1+0 } = 1 via D.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Explanation For Destination B
• Router A can reach the destination router B via its neighbor
B or neighbor D.
• It chooses the path which gives the minimum cost.
• Cost of reaching router B from router A via neighbor B = Cost
(A→ B)+ Cost (B→ B)= 2 + 0 = 2
• Cost of reaching router B from router A via neighbor D = Cost
(A→ D)+ Cost (D→ B)= 1 + 7 = 8
• Since the cost is minimum via neighbor B, so router A
chooses the path via B.
• It creates an entry (2, B) for destination B in its new routing
table.
• Similarly, we calculate the shortest path distance to each
Maulika Patel B.Tech(Computer
Engineering/IT)

destination router at every router.


SECE3011-Computer Networks
• Thus, the new routing table at router A is-

Maulika Patel B.Tech(Computer


Engineering/IT)
SECE3011-Computer Networks
At Router B
• Router B receives distance vectors from its neighbors A, C and D.
• Router B prepares a new routing table as

• Cost of reaching destination A from router B = min { 2+0 , 3+∞ , 7+1 } = 2


via A.
• Cost of reaching destination C from router B = min { 2+∞ , 3+0 , 7+11 } =
3 via C.
• Dl Bf.Treoch(m
Cost of reaching destinatMiiotulnPateSECE3011-ComputerroNetworks
uter B = min { 2+1 , 3+11 , 7+0 } = 3
Computer Engineering/IT)
• Thus, the new routing table at router B is-

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
At Router C
• Router C receives distance vectors from its
neighbors B and D.
• Router C prepares a new routing table as

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• Cost of reaching destination A from router C = min { 3+2 , 11+1 } = 5 via
B.
• Cost of reaching destination B from router C = min { 3+0 , 11+7 } = 3 via B.
• Cost of reaching destination D from router C = min { 3+7 , 11+0 } = 10 via
B.
• Thus, the new routing table at router C is-

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
At Router D
• Router D receives distance vectors from its
neighbors A, B and C.
• Router D prepares a new routing table as

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• Cost of reaching destination A from router D = min { 1+0 , 7+2 , 11+∞ } =
1 via A.
• Cost of reaching destination B from router D = min { 1+2 , 7+0 , 11+3 } = 3
via A.
• Cost of reaching destination C from router D = min { 1+∞ , 7+3 , 11+0 } =
10 via B.
• Thus, the new routing table at router D is-

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Step-03:
• Each router exchanges its distance vector
obtained in Step-02 with its neighboring
routers.
• After exchanging the distance vectors, each
router prepares a new routing table.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
At Router A
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
At Router B

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
At Router C
• Router C receives distance vectors from its neighbors B and D.
• Router C prepares a new routing table as

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
At Router D
• Router D receives distance vectors from its neighbors A, B and C.
• Router D prepares a new routing table as

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Identifying Unused Links-

• After routing tables converge (becomes stable),


– Some of the links connecting the routers may never be used.
– In the above example, we can identify the unused links as
• We have-
– The value of next hop in the final routing table of router A suggests
that only edges AB and AD are used.
– The value of next hop in the final routing table of router B suggests
that only edges BA and BC are used.
– The value of next hop in the final routing table of router C suggests
that only edge CB is used.
– The value of next hop in the final routing table of router D suggests
that only edge DA is used.
– Thus, edges BD and CD are never used.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Important Notes-
• Note-01:
• In Distance Vector Routing,
• Only distance vectors are exchanged.
• “Next hop” values are not exchanged.
• This is because it results in exchanging the
large amount of data which consumes more
bandwidth.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Important Notes-
• Note-02:
• While preparing a new routing table-
• A router takes into consideration only the
distance vectors it has obtained from its
neighboring routers.
• It does not take into consideration its old
routing table.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Important Notes-
• Note-03:
• The algorithm is called so because-
• It involves exchanging of distance vectors
between the routers.
• Distance vector is nothing but an array of
distances.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Important Notes-
• Note-04:
• The algorithm keeps on repeating
periodically and never stops.
• This is to update the shortest path in case any
link goes down or topology changes.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Important Notes-
• Note-05:
• Distance Vector Routing suffers from count to
infinity problem.
• Distance Vector Routing uses UDP at
transport layer.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Exercises

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Counting to infinity problem
• A problem with distance-vector routing is that any
decrease in cost (good news) propagates quickly,
but any increase in cost (bad news) will propagate
slowly.
• For a routing protocol to work properly, if a link is
broken (cost becomes infinity), every other router
should be aware of it immediately, but in distance-
vector routing, this takes some time.
• The problem is referred to as count to infinity. It
sometimes takes several updates before the cost for
a broken link is recorded as infinity by all routers
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Counting to infinity problem:

• B will know that it can get to C at a cost of 1,


and A will know that it can get to C via B at a
cost of 2.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Counting to infinity problem:

• If the link between B and C is disconnected, then B will know that


it can no longer get to C via that link and will remove it from it’s
table. Before it can send any updates it’s possible that it will
receive an update from A which will be advertising that it can get
to C at a cost of 2. B can get to A at a cost of 1, so it will update a
route to C via A at a cost of 3. A will then receive updates from B
later and update its cost to 4. They will then go on feeding each
other bad information toward infinity which is called as Count to
Infinity problem.
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Link-State Routing
• Observation: loop can be prevented if each node
knows the actual network topology
In link-state routing, each node:
•floods the network with the state (up, down) of its
links
•uses Dijkstra’s Shortest Path First (SPF) algorithm to
compute a shortest-path tree

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Link-State Database (LSDB)
• To create a least-cost tree with this method, each
node needs to have a complete map of the
network, which means it needs to know the state of
each link. The collection of states for all links is
called the link-state database (LSDB)

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• Now the question is how each node can create this
LSDB that contains information about the whole
internet. This can be done by a process called
flooding.
• Each node can send some greeting messages to all
its immediate neighbors (those nodes to which it is
connected directly) to collect two pieces of
information for each neighboring node: the identity
of the node and the cost of the link. The
combination of these two pieces of information is
called the LS packet (LSP); the LSP is sent out of
each interface, as shown in Figure.
Maulika Patel B.Tech(Computer
SECE3011-Computer Networks
Engineering/IT)
LSPs created and sent out by each
node to build LSDB

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• When a node receives an LSP from one of its
interfaces, it compares the LSP with the copy
it may already have. If the newly arrived LSP
is older than the one it has (found by
checking the sequence number),it discards
the LSP.

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Formation of Least-Cost Trees
• To create a least-cost tree for itself, using the shared LSDB, each
node needs to run the famous Dijkstra Algorithm. This iterative
algorithm uses the following steps:
1. The node chooses itself as the root of the tree, creating a tree with
a single node,and sets the total cost of each node based on the
information in the LSDB.
2. The node selects one node, among all nodes not in the tree, which
is closest to the root, and adds this to the tree. After this node is
added to the tree, the cost of all other nodes not in the tree needs
to be updated because the paths may have been changed.
3. The node repeats step 2 until all nodes are added to the tree

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Least Cost Trees

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
Maulika Patel B.Tech(Computer
Engineering/IT) SECE3011-Computer
Networks
Exercise

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks
• To be continued in Part 2……

Maulika Patel B.Tech(Computer


Engineering/IT) SECE3011-Computer
Networks

You might also like