0% found this document useful (0 votes)
15 views82 pages

Network Layer (Classless Addressing, Routing Algorithms)

Uploaded by

anu1529ravina
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)
15 views82 pages

Network Layer (Classless Addressing, Routing Algorithms)

Uploaded by

anu1529ravina
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/ 82

Network Layer

1
Classless Addressing
 To overcome address depletion and give more organizations access to
the Internet, classless addressing was designed and implemented.

 There are no classes here, but the addresses are still granted in blocks.

Address Blocks

 When a network, 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 network. For example,
 Households may be given only two addresses;
 Large organizations may be given thousands of addresses.
 The ISP, may be given thousands or hundreds of thousands based on the
number of customers it may serve.
Classless Addressing: 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.


 Example: A block of 16 addresses granted to a small organization starting
from 205.16.37.32
The first address, when converted to a decimal number, is 3,440,387,360,
which when divided by 16 results in 215,024,210.

3
11001101 00010000 00100101 00100000

231 + 230 + 227 + 226 + 224 + 220 + 213 + 210 + 28 + 25

= 3,440,387,360

4
Mask
 A better way to define a block of addresses is to select any address in the
block and the mask.

 A mask is a 32-bit number in which the n leftmost bits are 1s and the 32 - n
rightmost bits are 0s.

 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:


Classless Interdomain Routing notation).

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.

 Example: 205.16.37.39/28

5
Mask
 The address and the /n notation completely define the whole block
(the first address, the last address, and the number of addresses).
 First Address: The first address in the block can be found by setting the
(32 - n) rightmost bits in the binary notation of the address to 0s.

 Example: A block of addresses is granted to a small organization with IP


address: 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 or 205.16.37.39

 If we set (32 - 28) = 4 rightmost bits to 0, we get


11001101 00010000 00100101 00100000 or 205.16.37.32

 This is the first address of the block.


6
Mask
 Last Address: The last address in the block can be found by setting the
(32- n) rightmost bits in the binary notation of the address to 1s.

 Example: Same example; IP address: 205.16.37.39/28. What is the last


address in the block?

 Solution: 11001101 00010000 00100101 00100111 or 205.16.37.39

 If we set (32 - 28) = 4 rightmost bits to 1, we get the last address of the block
11001101 00010000 00100101 00011111 or 205.16.37.47

 Number of Addresses: The number of addresses in the block is the


difference between the last and first address. It can easily be found using the
formula 232-n. For the above example it is 232-28 = 24 = 16

 There are 16 addresses in the block (from 205.16.37.32 to 205.16.37.47)

7
Another way to find first, last and number of
addresses in the block
 By representing the mask as a 32-bit binary number.

 The number
This of addresses
is particularly usefulcan be found
when by complementing
we write a program tothe mask,
find interpreting
these pieces ofit
as a decimal number,
information. and adding
In Example, 1 to
already it.
discussed, the /28 can be represented as
Mask complement: 000000000 00000000 00000000 00001111
11111111 11111111
Number 11111111
of addresses: 11110000 (twenty-eight 1s and four 0s)
15 + 1 =16

 The first address can be found by ANDing the given addresses with the mask

205.16.37.32

 The last address can be found by ORing the given addresses with the
complement of the mask.

 205.16.37.47
8
Network Addresses
 When an organization is given a block of addresses, the organization is free to
allocate the addresses to the devices that need to be connected to the
Internet.

 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.

 Mostly it is used by routers to direct the message sent to the organization from
the outside world. The organization network is connected to the Internet via a
router.

9
Hierarchy
 Like our telephone network, IP addresses also have levels of Hierarchy.

 The total length of all phone numbers is constant at 10 digits.

 022-27771000 (area code, operator code, exchange office code and phone
number)

 An IP address can define only two levels of hierarchy when not subnetted

 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 (suffix) define the host.

 The prefix is common to all addresses in the network; the suffix changes
from one device to another.

10
Three-Levels of Hierarchy: Subnetting
 An organization that is granted a large block of addresses may want to
create clusters of networks (called subnets) and divide the addresses
between the different subnets.

 The rest of the world still sees the organization as one entity; however,
internally there are several subnets.

 All messages are sent to the router address that connects the organization
to the rest of the Internet; the router routes the message to the
appropriate subnets.

 The organization needs to create small subblocks of addresses, each


assigned to specific subnets.

 Network Address, Subnet Address and Host Addresses

 The organization has its own mask; each subnet must also have its own.

11
Example: subnet
 Suppose an organization is given the block 17.12.40.0/26, which
contains 64 addresses. The organization has three offices and needs to
divide the addresses into three subblocks of 32, 16, and 16 addresses.

 17.12.40.0/26 gives us 64 addresses; i.e. 26 = 64; (since 32 – 6 = 26)


 i.e. : 17.12.40.0 to 17.12.40.63
 The organization has three offices and divides these addresses into
three subblocks of 32, 16, and 16 addresses
 1st office with 32 addresses: 17.12.40.0 to 17.12.40.31
 2nd office with 16 addresses: 17.12.40.32 to 17.12.40.47
 3rd office with 16 addresses: 17.12.40.48 to 17.12.40.63

12
Example: subnet
 We can find the new masks by using the following rules:
1. Suppose the mask for the first subnet is n1, then 232- n1 must be 32,
i.e. 25 = 32; which means that n1 = 32 - 5 = 27.
2. Suppose the mask for the second subnet is n2, then 232- n2 must be 16,
i.e. 24 = 16; which means that n2 = 32 – 4 = 28.
3. Suppose the mask for the third subnet is n3, then 232- n3 must be 16,
i.e. 24 = 16; which means that n3 = 32 – 4 = 28.

 This means that we have the masks 27, 28, 28 with the
organization mask being 26.
 Figure shows one configuration for the above scenario.

13
Configuration and addresses in a subnetted network

14
Example with 3 level hierarchy

15
Example 1
 An organization is granted the block 211.17.180.0/24.The administrator
wants to create 32 subnets.
a. Find the subnet mask.
b. Find the number of addresses in each subnet.
c. Find the first and last addresses in subnet 1.
d. Find the first and last addresses in subnet 32.

 Total Addresses: 232 - 24 = 28 = 256


 256 addresses need to be divided into 32 subnets of equal size.
 Therefore 256/32 = 8 addresses per subnet.

16
211.17.180.0/24
a. Possible subnets: 32;
25 = 32; Extra 1s = 5; Mask: /29 (24 + 5)

b. 232− 29 = 8 Addresses per subnet.

c. Subnet 1: The first address is the beginning address of the block or


211.17.180.0. To find the last address, we need to write 7 (one less than the
number of addresses in each subnet) in base 256 (0.0.0.7) and add it to the first
address (in base 256).
First address in subnet 1: 211 . 17 . 180 . 0
Number of addresses: 0 . 0 . 0 . 7
Last address in subnet 1: 211 . 17 . 180 . 7

d. Subnet 32: To find the first address in subnet 32, we need to add 248 (31 × 8) in
base 256 (0.0.0.248) to the first address in subnet 1. We have 211.17.180.0 +
0.0.0.248 or 211.17.180.248. Now we can calculate the last address in subnet 32
as we did for the first address.
First address in subnet 32: 211 . 17 . 180 . 248
Number of addresses: 0 . 0 . 0 . 7
17 Last address in subnet 32: 211 . 17 . 180 . 255
Example 2
 An organization is granted the block 130.56.0.0/16. The administrator
wants to create 1024 subnets.
a. Find the subnet mask.
b. Find the number of addresses in each subnet.
c. Find the first and last addresses in subnet 1.
d. Find the first and last addresses in subnet 1024.

a. Possible subnets: 1024;


Log2 1024 = 10 or 210 = 1024; Extra 1s = 10; Mask: /26 (16 + 10)

b. 232− 26 = 64 Addresses per subnet.

c. First address in subnet 1: 130 . 56 . 0 . 0


Number of addresses: 0 . 0 . 0 . 63
Last address in subnet 1: 130 . 56 . 0 . 63
18
 Subnet 1024: To find the first address in subnet 1024, we need to add 65472
(1023 × 64) in base 256 (0.0.255.192) to the first address in subnet 1. We
have 130.56.0.0 + 0.0.255.192 or 130.56.255.192. Now we can calculate the
last address in subnet 1024
First address in subnet 1024: 130.56.255.192
Number of addresses: 0 . 0 . 0 . 63
Last address in subnet 1024: 130.56.255.255

 Subnet 1: 130 . 56 . 0 . 0  130 . 56 . 0 . 63


 Subnet 2: 130 . 56 . 0 . 64  130 . 56 . 0 . 127
 Subnet 3: 130 . 56 . 0 . 128  130 . 56 . 0 . 191
 Subnet 4: 130 . 56 . 0 . 192  130 . 56 . 0 . 255
 Subnet 5: 130 . 56 . 1 . 0  130 . 56 . 1 . 63
.
.
 Subnet 1024: 130 . 56 . 255 . 192  130 . 56 . 255 . 255

19
More Levels of Hierarchy
 The structure of classless addressing does not restrict the number of
hierarchical levels.

 An organization can divide the granted block of addresses into subblocks.


Each subblock can in turn be divided into smaller subblocks and so on.

 One example of this is the ISPs structure.

 A national ISP can divide a granted large block into smaller blocks and
assign each of them to a regional ISP.

 A regional ISP can divide the block received from the national ISP into
smaller blocks and assign each one to a local ISP.

 A local ISP can divide the block received from the regional ISP into smaller
blocks and assign each one to a different organization.

 Finally, an organization can divide the received block and make several
subnets out of it.
Address Allocation
 How are the blocks allocated?

 The ultimate responsibility of address allocation is given to a global


authority called the Internet Corporation for Assigned Names and
Addresses (ICANN).

 However, ICANN does not normally allocate addresses to individual


organizations.

 It assigns a large block of addresses to an ISP.

 Each ISP, in turn, divides its assigned block into smaller subblocks and grants
the subblocks to its customers.

 In other words, an ISP receives one large block to be distributed to its


Internet users. This is called address aggregation: many blocks of addresses
are aggregated in one block and granted to one ISP.
Example 1
 An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536
addresses). The ISP needs to distribute these addresses to three groups of
customers as follows:

a. The first group has 64 customers; each needs 256 addresses.

b. The second group has 128 customers; each needs 128 addresses.

c. The third group has 128 customers; each needs 64 addresses.

 Design the subblocks and find out how many addresses are still available
after these allocations.

22
 Group 1
 For this group, each customer needs 256 addresses. This means that 8 (log2
256) bits are needed to define each host. The prefix length is then 32 − 8 =
24. The addresses are
 1st Customer: 190.100.0.0/24 190.100.0.255/24
 2nd Customer: 190.100.1.0/24 190.100.1.255/24
. . .
. . .
 64th Customer: 190.100.63.0/24 190.100.63.255/24

 Total = 64 X 256 =16,384

23
Group 2
 For this group, each customer needs 128 addresses. This means that 7 (log2
128) bits are needed to define each host. The prefix length is then 32 − 7 =
25. The addresses are

Group 3
 For this group, each customer needs 64 addresses. This means that 6 (log2
64) bits are needed to each host. The prefix length is then 32 − 6 = 26. The
addresses are

 Number of granted addresses to the ISP: 65,536


 Number of allocated addresses by the ISP: 40,960
 Number of available addresses: 24,576
An example of address allocation and distribution by an ISP

25
IPV4 Protocol: Packet Structure
 Internet Protocol being a layer-3 protocol (OSI) takes data Segments from
layer-4 (Transport) and divides it into packets.

 IP packet encapsulates data unit received from above layer and add to its
own header information.

 The encapsulated data is referred to as IP Payload.

 IP header contains all the necessary information to deliver the packet at


the other end.

26
IPV4 Protocol: Header

27
IPV4 Protocol: Header
 Version: It is a 4 bit field that indicates the IP version used. It is 4.
 Header length: It is a 4 bit field that contains the length of the IP header. It
helps in knowing from where the actual data begins. [20 bytes, 60 bytes]. The
value lies in the range [5, 15]
 Type of service: is a 8 bit field that is used for Quality of Service (QoS). It
provides 3 bits to signal priority and 3 bits to signal whether a host cared
more about delay, throughput, or reliability. 2 bits are used to carry
explicit congestion notification information.
 Total length: It is a 16 bit field that contains the total length of the datagram
(in bytes). Total length = Header length + Payload length. Maximum total
length of datagram = Maximum value of 16 bit word = 65535 bytes
 Identification field: It is needed to allow the destination host to determine
which packet a newly arrived fragment belongs to. All the fragments of a
packet contain the same Identification value.
28
IPV4 Protocol: Header
 Flags − As required by the network resources, if IP Packet is too large to
handle, these ‘flags’ tells if they can be fragmented or not. The first bit is always
set to 0. The second bit is called the DF (Don't Fragment) bit and indicates that
this packet should not be fragmented. The third bit is called the MF (More
Fragments) bit and is set on all fragmented packets except the last one.

 Fragment Offset − This offset tells the exact position of the fragment in the
original IP Packet.

 Time to Live − To avoid looping in the network, every packet is sent with
some TTL value set, which tells the network how many routers (hops) this
packet can cross. At each hop, its value is decremented by one and when the
value reaches zero, the packet is discarded.

 Protocol − Tells the Network layer at the destination host, to which Protocol
this packet belongs to, i.e. the next level Protocol. For example protocol
number of ICMP is 1,TCP is 6 and UDP is 17.
29
IPV4 Protocol: Header
 Header Checksum − This field is used to keep checksum value of entire
header which is then used to check if the packet is received error-free.

 Source Address − 32-bit address of the Sender (or source) of the packet.

 Destination Address − 32-bit address of the Receiver (or destination) of


the packet.

 Options − This is optional field, which is used if the value of IHL is greater
than 5. These options may contain values for options such as Security,
Record Route,Time Stamp, etc.

30
Network Address Translation (NAT)
 To access the Internet, one public IP address is needed, but we can use a
private IP address in our private network.
 The idea of NAT is to allow multiple devices to access the Internet through
a single public address.
 To achieve this, the translation of a private IP address to a public IP address
is required.
 Network Address Translation (NAT) is a process in which one or more
local IP address is translated into one or more Global IP address and vice
versa in order to provide Internet access to the local hosts.
 Also, it does the translation of port numbers i.e. masks the port number of
the host with another port number, in the packet that will be routed to the
destination.
 It then makes the corresponding entries of IP address and port number in
the NAT table. NAT generally operates on a router or firewall.
31
Private IP Addresses
 Every class of IP, (A, B & C) has some addresses reserved as Private IP
addresses.
 These IPs can be used within a network, campus, company and are private
to it.
 These addresses cannot be routed on the Internet, so packets containing
these private addresses are dropped by the Routers.

IP Range Mask
= 224
= 220
= 216

 In order to communicate with the outside world, these IP addresses must


have to be translated to some public IP addresses using NAT (Network
address translation) process, or Web Proxy server can be used.
32
NAT
 Any organization can use an address out of this set without permission
from the Internet authorities.
 Everyone knows that these reserved addresses are for private networks.
 They are unique inside the organization, but they are not unique globally.
 No router will forward a packet that has one of these addresses as the
destination address.
 The site must have only one single connection to the global Internet
through a router that runs the NAT software.
 Figure shows a simple implementation of NAT.

33
Address Translation
 All the outgoing packets go through the NAT router, which replaces the
source address in the packet with the global NAT address.

 All incoming packets also pass through the NAT router, which replaces the
destination address in the packet (the NAT router global address) with the
appropriate private address.

 Figure shows an example of address translation.

34
IPV6
 Despite all short-term solutions, address depletion is still a long-term
problem for the Internet. This and other problems in the IP protocol itself
have been the motivation for IPv6.
 An IPv6 address is 128 bits long.

35
IPv6 address in binary and hexadecimal colon notation

 Abbreviated IPv6 addresses

36
Example
 Expand the address 0:15::1:12:1213 to its original.

0:15:0:0:0:1:12:1213

37
Features of IPV6
 Larger address space: 128 bits and 32 bits in IPv4

 Multicasting: is part of the base specification in IPv6. In IPv4 this is an


optional

 Stateless address autoconfiguration (SLAAC): IPv6 hosts configure


themselves automatically. Every interface has a self-generated link-local
address and, when connected to a network, conflict resolution is
performed and routers provide network prefixes via router advertisements

 Ipsec: a mandatory part of all IPv6 protocol implementations

 Extension headers: The IPv6 packet header has a minimum size of 40


octets (320 bits).

38
Features of IPV6
 No more NAT (Network Address Translation)

 Auto-configuration

 No more private address collisions

 Better multicast routing

 Simpler header format

 Simplified, more efficient routing

 True quality of service (QoS), also called "flow labeling"

 Built-in authentication and privacy support

 Flexible options and extensions

39
40
Ipv4 Ipv6

Address length IPv4 is a 32-bit address. IPv6 is a 128-bit address.


Fields IPv4 consists of 4 fields (each byte/field IPv6 consists of 8 fields (each with 4
represents decimal no, or binary bits) hexadecimal digits), which are separated
which are separated by dot (.) by colon (:)
Classes IPv4 has 5 different classes of IP address IPv6 does not contain classes of IP
that includes Class A, Class B, Class C, addresses.
Class D, and Class E.
Number of IP IPv4 has a limited number of IP IPv6 has a large number of IP addresses.
address addresses.
VLSM It supports VLSM (Virtual Length Subnet It does not support VLSM.
Mask). Here,VLSM means that IPv4
converts IP addresses into a subnet of
different sizes.
Address It supports manual and DHCP It supports manual, DHCP, auto-
configuration configuration. configuration, and renumbering.
Address space It generates 4 billion unique addresses It generates 340 undecillion unique
addresses. (3.4 x 1038 )
End-to-end In IPv4, end-to-end connection integrity In the case of IPv6, end-to-end
connection is unachievable. connection integrity is achievable.
integrity
Security In IPv4, security depends on the In IPv6, IPSEC is developed for security
features application. This IP address is not purposes.
developed in keeping the security feature
in mind.
IPV4 IPV6
Address In IPv4, the IP address is In IPv6, the representation of the
representation represented in decimal. IP address in hexadecimal.
Fragmentation Fragmentation is done by the Fragmentation is done by the
senders and the forwarding senders only.
routers.
Packet flow It does not provide any It uses flow label field in the
identification mechanism for packet flow header for the packet flow
identification. identification.
Checksum field The checksum field is available in The checksum field is not
IPv4. available in IPv6.
Transmission IPv4 is broadcasting. On the other hand, IPv6 is
scheme multicasting, which provides
efficient network operations.
Encryption and It does not provide encryption It provides encryption and
Authentication and authentication. authentication.
Number of It consists of 4 octets. It consists of 8 fields, and each
octets field contains 2 octets. Therefore,
the total number of octets in IPv6
is 16.
42
Routing algorithms
 A routing algorithm is a procedure that lays down the route or path to
transfer data packets from source to the destination.

 They help in directing Internet traffic efficiently.

 After a data packet leaves its source, it can choose among the many
different paths to reach its destination.

 Routing algorithm mathematically computes the best path, i.e. “least – cost
path” that the packet can be routed through.

43
Types of Routing algorithms
 Static or Non-adaptive Routing:
 Construct a static routing table to determine the path through which packets
are to be sent. The static routing table is constructed based upon the routing
information stored in the routers when the network is booted up.
 Shortest path routing (Dijkstra’s Algorithm [dike-strah])
 Simple and easy to understand.
 Metric for a shortest path: distance, bandwidth, average traffic, communication cost,
mean queue length, measured delay, ….
 Dynamic or Adaptive Routing
 Makes routing decisions dynamically depending on the network conditions. It
constructs the routing table depending upon the network traffic and topology.
They try to compute the optimized route depending upon the hop count,
transit time and distance.
 Distance Vector Routing.
44
Dijkstra’s Algorithm
 An algorithm that is used for finding the shortest distance, or path, from
starting node to target node in a weighted graph is known as Dijkstra’s
Algorithm.

 Dijkstra's algorithm makes use of weights of the edges for finding the path
that minimizes the total distance (weight) among the source node and all
other nodes.

45
Dijkstra’s Algorithm
1. Mark the source node with a current distance of 0 and the rest nodes
with infinity.
2. Now, fix the source node as the current node
3. For the current node, analyse all of its unvisited neighbours and measure
their distances by adding the current distance of its own to the weight of
the edge that connects to its neighbour node.
4. Compare the recently measured distance with the current distance
assigned to the neighbouring node and make it as the new current
distance of the neighbouring node,
5. After that, consider all of the unvisited neighbours of the current node,
mark the current node as visited,
6. If the destination node has been marked visited then stop, an algorithm
has ended
7. Else, choose the unvisited node that is marked with the least distance, fix
it as the new current node, and repeat the process again from step 3.
46
(∞, - ) (∞, - )

(∞, - ) (∞, - )
(0) (∞, - )

(∞, - ) (∞, - )

47
48
49
50
51
52
53
54
55
Distance Vector Routing
 Operates by having each router maintain a table (i.e., a vector) giving the
best known distance to each destination and which link to use to get there.

 These tables are updated by exchanging information with the neighbors.

 So every router knows the best link to reach each destination.

 Also called distributed Bellman-Ford routing algorithm.

 It was the original ARPANET routing algorithm and was also used in the
Internet under the name RIP.

 Each node shares its routing table with its immediate neighbors periodically
and when there is a change.

56
Distance Vector Routing
 Information kept by DV router -
 Each router has an ID
 Link cost associated with each link connected to a router (static or dynamic).
 Intermediate hops

 Distance Vector Table Initialization -


 Distance to itself = 0
 Distance to ALL other routers = infinity number.

 Distance Vector Algorithm –


 A router transmits its distance vector to each of its neighbors in a routing packet.
 Each router receives and saves the most recently received distance vector from
each of its neighbors.
 A router recalculates its distance vector when:
 It receives a distance vector from a neighbor containing different information than
before.
 It discovers that a link to a neighbor has gone down. (or any change occurred)
 Initially each node can know only the distance between itself and its immediate
neighbors, those directly connected to it.

 For this each node can send a message to the immediate neighbors and find
the distance between itself and these neighbors.

 Figure shows the initial tables for each node. The distance for any entry that is
not a neighbor is marked as infinite (unreachable).

58
Updating
 When a node receives a two-column table from a neighbor, it needs to
update its routing table. Updating takes in three steps:
1. The receiving node needs to add the cost between itself and the sending node
to each value in the second column. Example, if node C claims that its distance
to E is x, and the distance between A and C is y, then the distance between A
and E, via C, is (x + y).

2. The receiving node needs to add the name of the sending node to each row as
the third column if the receiving node uses information from any row. The
sending node is the next node in the route.

3. The receiving node needs to compare each row of its old table with the
corresponding row of the modified version of the received table.
a. If the next-node entry is different, the receiving node chooses the row with the
smaller cost.

59
Distance Vector Routing
 The table for node A shows how we can reach any node from this node. For
example, the least cost to reach node E is 6. The route passes through C.

60
 In this example, delay is used as a metric.
 Suppose that J has measured or estimated its delay to its neighbors, A, I, H,
and K, as 8, 10, 12, and 6 msec, respectively. What is the J’s new table?

 J to A  Min(8+0, 10+24,
12+20, 6+21) = 8 (A)
 J to B  Min(8+12, 10+36,
12+31, 6+28)
= 20 that is through A
 J to G  Min(8+18, 10+31,
12+6, 6+31)
= 18 that is through H
Two-Node Loop Instability or count to infinity
 Instability is the major problem,
which means that a network
using this protocol can become
unstable.

62
Three-Node Instability

63
Distance Vector routing
Advantages
 It is simpler to configure and maintain than link state routing.

Disadvantages of
 It is slower to converge.
 It is at risk from the count-to-infinity problem.
 It creates more traffic since updates take place on a periodic basis and if
there are changes in the network topology, so bandwidth-wasting
broadcasts occur.
 For larger networks, distance vector routing results in larger routing tables
since each router must know about all other routers. This can also lead to
congestion on WAN links.

64
Link State Routing
 Link state routing is a technique in which each router shares the
knowledge of its neighborhood with every other router in the
internetwork.

 The three keys to understand the Link State Routing algorithm:


 Knowledge about the neighborhood: Instead of sending its routing table, a
router sends the information about its neighborhood only. A router broadcast
its identities and cost of the directly attached links to other routers.

 Flooding: Each router sends the information to every other router on the
internetwork except its neighbors. This process is known as Flooding. Every
router that receives the packet sends the copies to all its neighbors. Finally, each
and every router receives a copy of the same information.

 Information sharing: A router sends the information to every other router


only when the change occurs in the information.

65
Link State Routing
 The idea behind link state routing is fairly simple and can be stated as five
parts. Each router must do the following things to make it work:

1. Discover its neighbors and learn their network addresses.

2. Set the distance or cost metric to each of its neighbors.

3. Construct a packet telling all it has just learned.

4. Send this packet to and receive packets from all other routers.

5. Compute the shortest path to every other router.


 In effect, the complete topology is distributed to every router.

 Then Dijkstra’s algorithm can be run at each router to find the shortest
path to every other router.

66
Link State Routing
 Learning about the Neighbors

 When a router is booted, its first task is to learn who are its neighbors.

 It accomplishes this goal by sending a special HELLO packet on each point-to-


point line.

 The router on the other end is expected to send back a reply giving its name.

 These names must be globally unique.

67
Link State Routing
 Setting Link Costs

 The link state routing algorithm requires each link to have a distance or
cost metric for finding shortest paths.

 The cost to reach neighbors can be set automatically, or configured by the


network operator.

 If the network is geographically spread out, the delay of the links may be
factored into the cost so that paths over shorter links are better choices.

 The most direct way to determine this delay is to send over the line a
special ECHO packet that the other side is required to send back
immediately.

 By measuring the round-trip time and dividing it by two, the sending router
can get a reasonable estimate of the delay.

68
Link State Routing
 Building Link State Packets

 Each router needs to build a packet containing all the data.

 The packet starts with the identity of the sender, followed by a sequence
number, age of the packet, a list of neighbors and the cost to each neighbor.

 Example:

69
Link State Routing
 Building the link state packets is easy. The hard part is determining when to
build them.

 One possibility is to build them periodically, that is, at regular intervals.

 Another possibility is to build them when some significant event occurs,


such as a line or neighbor going down or coming back up again or changing
its properties appreciably.

70
Link State Routing
Distributing the Link State Packets
 It is the trickiest part of the algorithm. All of the routers must get all of the
link state packets quickly and reliably.
 If different routers are using different versions of the topology, the routes they
compute can have inconsistencies such as loops, unreachable machines…
 Use flooding to distribute the link state packets to all routers.
 To keep the flood in check, each packet contains a sequence number that is
incremented for each new packet sent.
 Routers keep track of all the (source router, sequence) pairs they see.
 When a new link state packet comes in, it is checked against the list of packets
already seen.
 If it is new, it is forwarded on all lines except the one it arrived on.
 If it is a duplicate, it is discarded.
 If a packet with a sequence number lower than the highest one seen so far ever arrives, it is
71 rejected as being outdated.
Link State Routing
 This algorithm has a few problems, but they are manageable.

 First, if the sequence numbers wrap around, confusion will reign. The
solution here is to use a 32-bit sequence number. With one link state
packet per second, it would take 137 years to wrap around, so this
possibility can be ignored.

 Second, if a router ever crashes, it will lose track of its sequence number. If
it starts again at 0, the next packet it sends will be rejected as a duplicate.

 Third, if a sequence number is ever corrupted and 65,540 is received


instead of 4 (a 1-bit error), packets 5 through 65,540 will be rejected as
obsolete, since the current sequence number will be thought to be 65,540.

 0000000000000100  4 100000000000100  65536 + 4

72
Link State Routing
 The solution to all these problems is to include the age of each packet after
the sequence number and decrement it once per second.

 When the age hits zero, the information from that router is discarded.

 Normally, a new packet comes in, say, every 10 sec, so router information
only times out when a router is down (or six consecutive packets have
been lost, an unlikely event).

 The Age field is also decremented by each router during the initial flooding
process, to make sure no packet can get lost and live for an indefinite
period of time (a packet whose age is zero is discarded).

73
Link State Routing
 Some refinements to this algorithm make it more robust.

 When a link state packet comes in to a router for flooding, it is not queued
for transmission immediately.

 Instead, it is put in a holding area to wait a short while in case more links
are coming up or going down.

 If another link state packet from the same source comes in before the first
packet is transmitted, their sequence numbers are compared.

 If they are equal, the duplicate is discarded.

 If they are different, the older one is thrown out.

 To guard against errors on the links, all link state packets are acknowledged.

74
Fig. (b) the packet buffer for router B in Fig.(a).

75
Link State Routing
 Computing the New Routes

 Once a router has accumulated a full set of link state packets, it can
construct the entire network graph because every link is represented.

 Every link is represented twice, once for each direction.

 The different directions may even have different costs.

 The shortest-path computations may then find different paths from router
A to B than from router B to A.

 Now Dijkstra’s algorithm can be run locally to construct the shortest paths
to all possible destinations.

 The results of this algorithm tell the router which link to use to reach each
destination.This information is installed in the routing tables, and normal
operation is resumed.
76
Link state routing concept

77
78
Link State Routing has two phases:
 Reliable Flooding
 Initial state: Each node knows the cost of its neighbors.
 Final state: Each node knows the entire graph.
 Route Calculation
 Each node uses Dijkstra's algorithm on the graph to calculate
the optimal routes to all nodes.
 The Link state routing algorithm uses Dijkstra's algorithm
which is used to find the shortest path from one node to every
other node in the network.

79
In this figure, source vertex is A.

Step Node B C D E F
1 A 2, A 5, A 1, A ∞ ∞
2 AD 2, A 4, D 2, D ∞
3 ADE 2, A 3, E 4, E
4 ADEB 3, E 4, E
5 ADEBC 4, E
6 ADEBCF

80
Derive the routing table for router 3

81
 Consider the network of the given figure. Distance vector
routing is used, and the following vectors have just come
in to router C: from B: (5, 0, 8, 12, 6, 2); from D: (16, 12, 6,
0, 9, 10); and from E: (7, 6, 3, 9, 0, 4). The cost of the links
from C to B, D, and E, are 6, 3, and 5, respectively. What is
C’s new routing table? Give both the outgoing line to use
and the cost.

82

You might also like