0% found this document useful (0 votes)
17 views127 pages

Updated CN Module 3

Uploaded by

2022.sahil.ahuja
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)
17 views127 pages

Updated CN Module 3

Uploaded by

2022.sahil.ahuja
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/ 127

Chapter 3- NETWORK LAYER

Mrs Nusrat Ansari


CONTENTS

Network Layer Design Issues


Routing Algorithms
Protocols
Congestion Control Algorithms

2
4.1 Network Layer Design Issues

Issues faced by designers of the network layer are as follows:


Store-and-Forward Packet Switching
Services Provided to the Transport Layer
Implementation of Connectionless Service
Implementation of Connection-Oriented Service
Comparison of Virtual-Circuit and Datagram Subnets

3
4.1.1 Store and Forward Packet Switching

The context in which network layer works can be seen in the next fig.
Major components are ISPs equipment, i.e routers connected by transmission lines, and customer’s
equipment, i.e hardware devices
As seen in the fig, host H1 is connected directly to ISP’s router, whereas host H2 is connected to a
LAN
This LAN is an office internet connected to router F, owned and operated by owner (office managers)
and has leased a line to ISP’s equipment
F is outside the oval as it does not belong to ISP, but algorithm that they run on are the same

4
4.1.1 Store and Forward Packet Switching
5.1.1 Store and Forward Packet Switching

Equipment works as follows:


Host with a packet to send transmits it to the nearest router (through LAN or P2P to ISP)
PAcket is stored there until it arrives fully and link has finished verifying it using checksum
Then it is forwarded to the next router along the path until it reaches its destination
This is known as Store and Forward Packet Switching

6
4.1.2 Services provided to Transport layer

Services are designed with following goals in mind:


Services must be independent of router technology
Transport layer shielded from number, type, topology of routers
Network addresses available to transport layer must use uniform numbering plan

7
4.1.3 Implementation of Connectionless Service

If connectionless service is offered, packets are injected in the network individually and routed
independently of each other
No advance set up is needed
In this context, packets are known as datagram and n/w is called a datagram network

8
5.1.3 Implementation of Connectionless Service

A’s table (initially) A’s table (later) C’s Table E’s Table

Fig. 5.1.3 9
4.1.4 Implementation of Connection Oriented Service

For connection-oriented service, we need a virtual-circuit network. The idea behind virtual circuits is to
avoid having to choose a new route for every packet sent

Instead, when a connection is established, a route from the source machine to the destination machine
is chosen as part of the connection setup and stored in tables inside the routers. That route is used for
all traffic flowing over the connection, exactly the same way that the telephone system works

10
4.1.4 Implementation of Connection Oriented Service

That route is used for all traffic flowing over the connection, exactly the same way that the telephone
system works. When the connection is released, the virtual circuit is also terminated. With
connection-oriented service, each packet carries an identifier telling which virtual circuit it belongs to
Consider the situation shown in Fig. 5.1.4. Here, host H1 has established connection 1 with host H2.
This connection is remembered as the first entry in each of the routing tables .

11
4.1.4 Implementation of Connection Oriented Service

Fig. 5.1.4 12
4.1.4 Implementation of Connection Oriented Service

The first line of A’s table says that if a packet. bearing connection identifier 1 comes in from H1, it is to
be sent to router C and given connection identifier 1. Similarly, the first entry at C routes the packet to E,
also with connection identifier 1

Consider what happens if H3 also wants to establish a connection to H2.

It chooses connection identifier 1 (because it is initiating the connection and this is its only connection)
and tells the network to establish the virtual circuit. This leads to the second row in the tables

13
4.1.4 Implementation of Connection Oriented Service

We have a conflict here because although A can easily distinguish connection 1 packets from H1 from
connection 1 packets from H3, C cannot do this
For this reason, A assigns a different connection identifier to the outgoing traffic for the second
connection. Avoiding conflicts of this kind is why routers need the ability to replace connection
identifiers in outgoing packets
This process is called label switching. An example of a connection-oriented network service is MPLS
(Multi Protocol Label Switching). It is used within ISP networks in the Internet, with IP packets
wrapped in an MPLS header having a 20-bit connection identifier or label

14
4.1.5 Comparison of Virtual-Circuit and Datagram Networks

Both virtual circuits and datagrams have their supporters and their detractors
The major issues are listed in Fig. 5.1.5

Trade offs between Virtual-Circuit and Datagram Networks are:


One trade-off is setup time versus address parsing time. Using virtual circuits requires a setup
phase, which takes time and consumes resources. However, once this price is paid, figuring out
what to do with a data packet in a virtual-circuit network is easy: the router just uses the circuit
number to index into a table to find out where the packet goes. In a datagram network, no setup
is needed but a more complicated lookup procedure is required to locate the entry for the
destination

15
4.1.5 Comparison of Virtual-Circuit and Datagram Networks

Fig. 5.1.5 16
4.1.5 Comparison of Virtual-Circuit and Datagram Networks

A related issue is that the destination addresses used in datagram networks are longer than circuit
numbers used in virtual-circuit networks because they have a global meaning. If the packets tend
to be fairly short, including a full destination address in every packet may represent a significant
amount of overhead, and hence a waste of bandwidth
Another issue is the amount of table space required in router memory. A datagram network needs
to have an entry for every possible destination, whereas a virtual-circuit network just needs an
entry for each virtual circuit.

17
4.1.5 Comparison of Virtual-Circuit and Datagram Networks

However, this advantage is somewhat illusory since connection setup packets have to be routed
too, and they use destination addresses, the same as datagrams do.

Virtual circuits have some advantages in guaranteeing quality of service and avoiding congestion
within the network because resources (e.g., buffers, bandwidth, and CPU cycles) can be reserved
in advance, when the connection is established. Once the packets start arriving, the necessary
bandwidth and router capacity will be there. With a datagram network, congestion avoidance is
more difficult.

18
5.1.5 Comparison of Virtual-Circuit and Datagram Networks

For transaction processing systems (e.g., stores calling up to verify credit card purchases), the overhead
required to set up and clear a virtual circuit may easily dwarf the use of the circuit.

If the majority of the traffic is expected to be of this kind, the use of virtual circuits inside the network
makes little sense. On the other hand, for long-running uses such as VPN traffic between two corporate
offices, permanent virtual circuits (that are set up manually and last for months or years) may be useful.

19
4.1.5 Comparison of Virtual-Circuit and Datagram Networks

Virtual circuits also have a vulnerability problem. If a router crashes and loses its memory, even if it
comes back up a second later, all the virtual circuits passing through it will have to be aborted.

n contrast, if a datagram router goes down, only those users whose packets were queued in the router at
the time need suffer (and probably not even then since the sender is likely to retransmit them shortly).
The loss of a communication line is fatal to virtual circuits using it.

Datagrams also allow the routers to balance the traffic throughout the network, since routes can be
changed partway through a long sequence of packet transmissions.

20
Communication Primitives
▪ Data is transported over a network by three simple methods i.e. Unicast,
Broadcast, and Multicast.

▪ Unicast: from one source to one destination i.e. One-to-One

▪ Broadcast: from one source to all possible destinations i.e. One-to-All

▪ Multicast: from one source to multiple destinations stating an interest in


receiving the traffic i.e. One-to-Many
Communication Primitives

▪ Unicast: traffic, many streams of IP packets that move across networks flow from a
single point, such as a website server, to a single endpoint such as a client PC. This
is the most common form of information transference on networks.

▪ Broadcast: Here, traffic streams from a single point to all possible endpoints
within reach on the network, which is generally a LAN. This is the easiest technique
to ensure traffic reaches its destinations.

▪ This mode is mainly utilized by television networks for video and audio distribution.
Even if the television network is a cable television (CATV) system, the source signal
reaches all possible destinations, which is the key reason that some channels’
content is scrambled. Broadcasting is not practicable on the public Internet due to
the massive amount of unnecessary data that would continually reach each user’s
device, the complications and impact of scrambling, and related privacy issues.
Communication Primitives
▪ Multicast: In this method traffic recline between the boundaries of unicast (one point to one
destination) and broadcast (one point to all destinations). And multicast is a “one source to
many destinations” way of traffic distribution, which means that only the destinations that
openly point to their requisite to accept the data from a specific source to receive the traffic
stream.

▪ On an IP network, destinations (i.e. clients) do not regularly communicate straight to sources


(i.e. servers), because the routers between source and destination must be able to regulate the
topology of the network from unicast or multicast side to avoid disordered routing traffic.
Multicast routers replicate packets received on one input interface and send the replicas out
on multiple output interfaces.

▪ In the multicast model, the source and destinations are almost every time “Host” and not
“Routers”. The multicast traffic is spread by multicast routers across the network from source
to destination. The multicast routers must find multicast sources on the network, send out
copies of packets on a number of interfaces, avoid loops, connect interested destinations with
accurate sources and keep the flow of unsolicited packets to a minimum. The standard
protocols of multicast routing provide most of these facilities, but some router architecture
cannot send multiple copies of packets and so do not support direct multicasting.
IPV4 addresing (classfull & classless)

Introduction

IP is the transmission mechanism used by TCP/IP protocols at the network layer.


IP is an unreliable and connectionless datagram protocol- best effort delivery service.
Each datagram is handled independently and each datagram can follow a different route to the destination.
this implies that datagram send by the same source to the same destination could arrive out of oder.
Some could be lost or corrupted during transmission.
IP relies on higher level protocol to take care of all these problems.
Position of IP in TCP/IP protocol suite
Datagrams

► Packets in the network layer are called datagram.


► It is a variable length packet consisting of two parts:-
Header
Data

❑ Header:
✔ 20 to 60 bytes in length
✔ contains information essential to routing and delivery.
✔ In TCP/IP it is customary to show header in 4 byte section.
IPv4 datagram format
IPv4 datagram header format

Version(VER):-
4 bit field defines the version [Version 4] of IP software running
If machine is using some other version of IP, the datagram is discarded rather that interpreted incorrectly.

Header Length(HLEN):-
4 bit field defines the total length of the datagram header in 4 byte words.
The length of the header is variable (between 20 and 60 bytes)
When there are no options:-
✔ HLEN is 20 bytes and the value of the field is 5 (5*4=20)
When the options field is at maximum size:
✔ HLEN is 60 bytes value of field is 15 (15*4=60)
IPv4 Addresses

IP Address: identifier used in IP layer to identify each device connected to the internet
It is a 32 bit long address ,unique and universal.
IPv4 addresses has address space.
Address space- is the total number of addresses used by the protocol.
If a protocol uses N bits to define an address, the address space is 2N because each bit can have two different
values (0 and 1) and N bits can have 2N values.
The address space of IPv4 is 232 or 4,294,967,296.
Classful Addrssing

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

Class A: 2 31 = 2,147,483,648 addresses, 50%


Class B: 2 30 = 1,073,741,824 addresses, 25%
Class C: 2 29 = 536,870,912 addresses, 12.5%
Class D: 2 28 = 268,435,456 addresses, 6.25%
Class E: 2 28 = 268,435,456 addresses, 6.25%
Recognizing classes
Example

Find the class of each address:


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 10100111 11011011 10001011 01101111
d. 11110011 10011011 11111011 00001111
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 bit is 0; the second bit is 1. This is a class B address.
d. The first 4 bits are 1s. This is a class E address..
Example
Find the class of each address:
a. 227.12.14.87
b.193.14.56.22
c.14.23.120.8
d. 252.5.15.111
e.134.11.78.56
Solution
a. The first byte is 227 (between 224 and 239); the class is D.

b. The first byte is 193 (between 192 and 223); the class is C.

c. The first byte is 14 (between 0 and 127); the class is A.

d. The first byte is 252 (between 240 and 255); the class is E.

e. The first byte is 134 (between 128 and 191); the class is B.
Netid and Hostid
✔Each address in classful addressing contains two parts: netid and hosted

✔The netid defines the network and hostid defines particular host connected to that network.
Blocks in class A

1 byte=Netid with leftmost bit 0 , Number of blocks=27 = 128 , each block=16,777,216 addresses
Many addresses are wasted
Blocks in class B

2 byte = Netid with leftmosts bit 10 , Number of blocks=214 = 16,384 , each block=65,536 addresses
Many addresses are wasted
Blocks in class C

3 byte = Netid with leftmost bits 110 , Number of blocks=221 = 2,097,152 , each block=256 addresses .
Not so organizations are so small to have a class C block.
The single block in class D

✔ Designed for multicasting


✔ Each address in this class is used to define one group of hosts on the internet.
✔ When a group is assigned an address in this class, every host that is a member
of this group will have a multicast address in addition to its normal (unicast)
address.
The single block in class E

The only block of class E addresses was reserved for future


purposes.
Two Level Addressing
✔ All addresses in a network belonged to a single block
✔ Each address in classful addressing contains two parts: netid and hostid
✔ The netid defines the network and hostid defines particular host
connected to that network.
Example:
Information extraction in classful addressing

1. The number of addresses in the block, N , can be found using N = 232-n


2. To find the first address, we keep the n leftmost bits and set the (32-n) rightmost bits
all to 0s.
3. To find the last address, we keep the n leftmost bits and set the (32-n) rightmost bits
all to 1s.
Example

An address in a block is given as 73.22.17.25.Find


the number of addresses in the block, the first
address, and the last address.

Solution
As 73 is in between 0 & 127, its Class=A , n=8
Solution

1. The number of addresses in the block, N , can be found using N = 232-n = 224 =16,777,216
2. To find the first address, we keep the n leftmost bits and set the (32-n = 24) rightmost bits all to 0s. The
first address (called as network address) is 73.0.0.0/8 in which 8 is the value of n and not assigned to any
host.
3. To find the last address, we keep the n leftmost bits as it is and set the (32-n=24) rightmost bits all to 1s.
The last address is 73.255.255.255. the last address is normally used for a special purpose.
Example

An address in a block is given as 180.8.17.9. Find the


number of addresses in the block, the first address, and the
last address.

Solution
As 180 is in between 128 & 191, its Class=B,
n=16
Solution

1. The number of addresses in the block, N , can be found using N = 232-n = 216
=65,536
2. To find the first address, we keep the leftmost 16 bits and set the (32-n=16)
rightmost 16 bits all to 0s. The first address(network address) is 18.8.0.0/16
3. To find the last address, we keep the leftmost 16 bits and rightmost 16 bits to 1s.
The last address is 18.8.255.255
Example

An address in a block is given as 200.11.8.45. Find the


number of addresses in the block, the first address, and the
last address.

Solution
As 200 is in between 192 & 223, its Class=C,
n=24
Solution

1. The number of addresses in the block, N , can be found using N = 232-n = 28 =256
2. To find the first address, we keep the leftmost 24 bits and set the (32-n=16)
rightmost 8 bits all to 0s. The first address(network address) is 200.11.8.o/24
3. To find the last address, we keep the leftmost 24 bits and all to 1s. The last
address is 200.11.8.255
Sample Internet

Example: A hypothetical part of an internet with three network.


1.A LAN with the network address 220.3.6.0 (class C)
2.A LAN with the internet address 134.18.0.0 (class B)
3.A switched WAN (class C) such as Frame Relay or ATM, can be connected to many routers. (here 3 routers- 1 for
WAN to left LAN, 2nd WAN to right LAN and 3rd WAN to rest of the internet.)
Network Address
✔ The network address is the identifier of a network.
✔ It is the first address, used in routing a packet to its destination
address.
Network Mask

✔ A network mask or default mask in classful addressing 32 bit number with n


leftmost bits all set to 1s and (32-n) rightmost bits all set to 0s.
✔ Since n is different for each class in classful addressing, we have 3 default masks in
classful addressing as shown in above diagram.
Finding a network address using the default mask

✔ To
extract the network address from destination address of a packet, a router uses the
AND operation.
Example 1
Solution
Since the class of the address is A, we assume that the router applies the default mask for
class B, 255.0.0.0 to find the network address

Decimal Binary
IP 93.12.5.3 01011101 00001100 00000101 00000011
Default 255.0.0.0 11111111 00000000 00000000 00000000
Mask
Network ID 93.0.0.0 01011101 00000000 00000000 00000000
after
ANDing

128 64 32 16 8 4 2 1 ---> 01011101


64+16+8+4+1🡪 93
Example 2
A router receives a packet with the destination address 201.24.67.32. Show
how the router finds the network address of the packet.

Solution
Since the class of the address is C, we assume that the router applies the
default mask for class C, 255.255.255.0 to find the network address.
Subnetting
✔ Splitting a block to smaller blocks is subnetting
✔ In Subnetting, a network is divided into several smaller subnetworks (subnets) with each
subnetworking having its own subnetwork address.

✔ Three level Addressing:


✔ Three-level addressing can be found in the telephone system

✔ 626 is the area code, 358 is the exchange, and 1301 is the subscriber connection.
Example
Figure (next) shows class B addresses before subnetting.
one network with almost 216 hosts. The whole network is connected, through one single
connection, to one of the routers in the Internet.
/16 to show the length of the netid (class B).
same network after subnetting

The whole network is still connected to the Internet through the same router. However, the
network has used a private router to divide the network into four subnetworks. The rest of
the Internet still sees only one network; internally the network is made of four subnetworks.
Each subnetwork can now have almost 214 hosts. The network can belong to a university
campus with four different schools (buildings). After subnetting, each school has its own
subnetworks, but still the whole campus is one network for the rest of the Internet. Note that
/16 and /18 show the length of the netid and subnetids.
Network mask and subnetwork mask

✔ Network Mask- is used when a network is not subnetted.


✔ Subnetwork Mask- when we divide a network to several subnetworks.
✔ Subnetting increase the length of netid and decreases the length of hostid.
✔ calculation of subnetid for each subnetwork (s): nsub= n+ log 2 S
✔ where n= lenth of netid, nsub is the length of each subnetid and s= number of
subnets which must be a power of 2
Example

In previous example, we divided a class B network into four


subnetworks.
The value of n = 16 and the value of
n1 = n2 = n3 = n4 = 16 + log24 = 18.

This means that the subnet mask has eighteen 1s and fourteen 0s.
In other words, the subnet mask is 255.255.192.0 which is
different from the network mask for class B (255.255.0.0).
Example

In previous Example we show that a network is divided into four subnets. Since one of
the addresses in subnet 2 is 141.14.120.77, we can find the subnet address as:

The values of the first, second, and fourth bytes are calculated using the first
short cut for AND operation. The value of the third byte is calculated using the
second short cut for the AND operation.
Supernetting
As most organizations did not want to share their granted blocks with others, subnetting could
not completely solve address depletion problem.
When size of block did not meet the requirement of new organization, option of supernetting
can be used.
Organization can combine several class C blocks to create a large range of addresses
Several networks are combined to create a Supernetwork.
By doing this an organization can apply for several class C blocks instead of just one.

Supernet Mask: is the reverse of subnet mask.


► A subnet mask for class C has more 1s than the default mask for this class.
► A supernet mask for class C has less 1s than the default mask for this class.
Comparison of Subnet, default and Supernet mask:
✔ A subnet mask that divides a block into 8 subblocks has 3 more 1s (23 = 8) than
default mask.
✔ A supernet mask that combines 8 blocks into one superblock has 3 less 1s than the
default mask.

nsub= 24+3=27

n = 24

Nsuper =24- 3=21

calculation of supernetid for each subnetwork (s): nsubper= n- log 2 c


Supernetting

In supernetting, number of class C addresses that can be combined to


make a supernet needs to be a power of 2.
calculation of supernetid for each subnetwork (s): nsubper= n - log 2 C
where nsubper = length of the supernetid in bits
C = number of C blocks that are combined.

Two problems associated with supernetting:


The number of blocks to combine needs to be a power of 2
Supernetting and subnetting really complicated the routing of packets in
the internet.
A supernetwork
Example 1 ( subnetting
)
A company is granted the site address 201.70.64.0 (class
C). The company needs six subnets. Design the subnets.

Solutio
n
The number of 1s in the default mask is 24 (class C).
Solution
(Continued)
The company needs six subnets. This number 6 is not a power of 2. The next
number that is a power of 2 is 8 (23). We need 3 more 1s in the subnet mask.
The total number of 1s in the subnet mask is 27 (24 + 3).
The total number of 0s is 5 (32 - 27). The mask is
11111111 11111111 11111111 11100000
or
255.255.255.224
The number of subnets is 8.The number of addresses in each subnet is 25 (5
is the number of 0s) or 32. Refer Next Figure
Example 1
Example 2
(Subnet)
A company is granted the site address 181.56.0.0 (class B).
The company needs 1000 subnets. Design the subnets.

Solution

The number of 1s in the default mask is 16 (class B).


Solution
(Continued)
The company needs 1000 subnets.
This number is not a power of 2.
10
The next number that is a power of 2 is 1024 (2 ).
We need 10 more 1s in the subnet mask.
The total number of 1s in the subnet mask is 26 (16 + 10).
The total number of 0s is 6 (32 - 26).
Solution
(Continued)
The mask is
11111111 11111111 11111111 11000000
or
255.255.255.192.
The number of subnets is 1024.
The number of addresses in each subnet is 26 (6 is the
number of 0s) or 64.
Refer Next Figure
Example 2
Variable-length subnetting
Rules for designing blocks
1.The number of blocks must be a power of 2 (1, 2, 4, 8, 16, . . .).
2.The blocks must be contiguous in the address space (no gaps
between the blocks).
3.The third byte of the first address in the superblock must be evenly
divisible by the number of blocks.
4.In other words, if the number of blocks is N, the third byte must be
divisible by N.
Example 1
(Supernet)
A company needs 600 addresses. Which of the following set
of class C blocks can be used to form a supernet for this
company?
198.47.32.0 198.47.33.0 198.47.34.0
198.47.32.0 198.47.42.0 198.47.52.0 198.47.62.0
198.47.31.0 198.47.32.0 198.47.33.0 198.47.52.0
198.47.32.0 198.47.33.0 198.47.34.0 198.47.35.0
Solutio
n
1: No, there are only three blocks.
2: No, the blocks are not contiguous.
3: No, 31 in the first block is not divisible by 4.
4: Yes, all three requirements are fulfilled.
In subnetting, we need the first address of the
subnet and the subnet mask to define the range of
addresses.

In supernetting, we need the first address of the


supernet and the supernet mask to define the range of
addresses.
Example 2
(supernet)
We need to make a supernetwork out of 16 class C
blocks. What is the supernet mask?
Solutio
n
We need 16 blocks. For 16 blocks, which is 2 to the power 4 so
we need to change four 1s to 0s in the default mask. So the mask
is
11111111 11111111 11110000 00000000
or
255.255.240.0
Example 3
A supernet has a first address of 205.16.32.0 and a supernet mask of
255.255.248.0. A router receives three packets with the following destination
addresses:
205.16.37.44
205.16.42.56
205.17.33.76
Which packet belongs to the supernet?
Solutio
n
We apply the supernet mask to see if we can find the beginning
address.
205.16.37.44 AND 255.255.248.0 🡺 205.16.32.0
205.16.42.56 AND 255.255.248.0 🡺 205.16.40.0
205.17.33.76 AND 255.255.248.0 🡺 205.17.32.0
Only the first address belongs to this supernet.
Example 4
A supernet has a first address of 205.16.32.0 and a supernet
mask of 255.255.248.0. How many blocks are in this supernet
and what is the range of addresses?

Solution

The supernet has 21 1s. The default mask has 24 1s. Since the
difference is 3, there are 23 or 8 blocks in this supernet. The blocks
are 205.16.32.0 to 205.16.39.0. The first address is 205.16.32.0.
The last address is 205.16.39.255.
Routing Header
Types
Routing Algorithm

► Shortest Path (Dijkastra‘s),


► Link state routing,
► Distance Vector Routing
4.2.1. Optimality principle

A general statement about optimality is called as optimality.

It states that if router J is on the optimal path from router I to


router K, then the optimal path from Jto K will also be along
the same route.
4.2 Shortest Path Algorithm

► The idea is to build graph of the network, with each node of


the graph representing a router and each edge of the graph
representing a communication
► To choose a route between a given pair of routers, the algorithm just
finds the shortest path between them on graph.
► There are many Algorithms for computing the shortest path
► One of them is Dijkstra
Shortest Algorithm

► The Dijkstra’s algorithm finds the shortest path from a particular node, called
the source node to every other node in a connected graph. It produces a
shortest path tree with the source node as the root. It is profoundly used in
computer networks to generate optimal routes with the aim of minimizing
routing costs.
► Input − A graph representing the network; and a source node, s
► Output − A shortest path tree, spt[], with s as the root node.
Shortest Path Algorithm
► An array of distances dist[] of size |V| (number of nodes), where dist[s] = 0 and dist[u] = ∞ (infinite), where u
represents a node in the graph except s.
► An array, Q, containing all nodes in the graph. When the algorithm runs into completion, Q will become
empty.
► An empty set, S, to which the visited nodes will be added. When the algorithm runs into completion, S will
contain all the nodes in the graph.
► Repeat while Q is not empty −
► Remove from Q, the node, u having the smallest dist[u] and which is not in S. In the first run, dist[s] is
removed.
► Add u to S, marking u as visited.
► For each node v which is adjacent to u, update dist[v] as −
► If (dist[u] + weight of edge u-v) < dist[v], Then
► Update dist[v] = dist[u] + weight of edge u-v
► The array dist[] contains the shortest path from s to every other node.
Shortest Path Algorithm (1)

94
1. The first five steps used in computing the shortest path from A to D. The arrows indicate the
working node
4.2 Flooding
► In this every incoming packets is sent out on every outgoing line except the one it arrived
► It produces infinite number of duplicate packets unless some measure is used to damp the
process
► Process for Damping:
1. hop counter
2.To keep track of which packets have been flooded
3.selective flooding

► To choose a route between a given pair of routers, the algorithm just finds the shortest path
between them on graph.
► There are many Algorithms for computing the shortest path
► One of them is Dijkstra 95
4.2 Distance Vector Routings
► Distance vector routing algorithms operate by having each router
maintain a table (i.e, a vector) giving the best known distance to each
destination and which line to use to get there.
► These tables are updated by exchanging information with the
neighbors.
► The distance vector routing algorithm is sometimes called by other
names, Bellman-Ford routing algorithm and the Ford-Fulkerson
algorithm,.
96
Distance Vector Routings
► In this, each router maintains a routing table containing one entry for each
router in the subnet. This entry contains two parts:
► the preferred outgoing line to use for that destination and an estimate of the
time or distance to that destination.
► The metric used might be number of hops, time delay in milliseconds, total
number of packets queued along the path, or something similar.
► The router is assumed to know the ''distance'' to each of its neighbors.
► If the metric is hops, the distance is just one hop. If the metric is queue length,
the router simply examines each queue.
► If the metric is delay, the router can measure it directly with special ECHO
packets that the receiver just timestamps and sends back as fast as it can.
Distance Vector Routings
► Example: Assume that delay is used as a metric and the router knows the
delay of each of its neighbors.
► Once every T msec, each router sends to each neighbor a list of its estimated
delays to each destination.
► It also receives a similar list from each neighbor.
► Imagine that one of these tables has just come in from neighbor X, with Xi
being X’s estimate of how long it takes to get to router i. If the router knows
that the delay to X is msec, it also knows that it can reach router I via X Xi+
m msec.
► By performing this calculation for each neighbor, a router can find out which
estimate seems the best and use that estimate and the corresponding link in
its new routing table. Old routing table is not used in the calculations.
Distance Vector Routings
Explanation
► I am at N1 router so its dist=0 and nxt is N1 itself
► from N2->N1 dist is 1 & nxt is N2
► Note: N2 is the neighbour of N1
N3 is the neighbour of N2 but N1 is not the neigbour of N3 n so on
► So N1 doesn’t know anything about N3 so N1->N3 cost is ∞ ( infinite) so nxt dest also
remain unknown
► Similarly N1->N4 cost is ∞ ( infinite) so nxt dest also remain unknown
► Similarly N1->N5 cost is ∞ ( infinite) so nxt dest also remain unknown
► So this is the local routing table of Router N1

Note: Similarly all the routing table will be updated parallely

local routing table of Router N1


Complete local routing table
► So we are sharing the details only with neighbour
► So we are sharing only distance vector
► That means Router N1 will share only column of distance or array of
distance with its neighbour N1->N2
► Similarly N2->N1, N2->N5 & N2->N6
► Similarly the rest of the router will share its distance vector to only its
neighbour

Complete New Routing table for N1 Complete New Routing table for N5
New Routing table for N1
Note: Similarly all the new routing table will be updated parallely
Distance Vector Routing

Part (a) shows a subnet. The first four columns of part (b) show the delay vectors received
from the neighbors of router J. A claims to have a 12-msec delay to B, a 25-msec delay to
C, a 40-msec delay to D, etc. 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.
103
Distance Vector Routing
Ex1. How J computes its new route to
router G
1. It knows that it can get to A in 8 msec
furthermore A claims to be able to get
to G in 18 msec
So J knows it can count on a delay of
26msec to G if it forwards packet bound
for G to A.

Ex 2. How it computes delay to G via I


1. = 31+10 = 41msec

Ex 3. How it computes delay to G via H


= 6 + 12 = 18msec

Ex4. How it computes delay to G via K


= 31+6=37msec
Advantages of Distance Vector routing
•Shortest Path: Distance Vector Routing finds the shortest path for data to travel in
a network.
•Usage: It is used in local, metropolitan, and wide-area networks.
•Easy Implementation: The method is simple to set up and doesn’t require many
resources.
Disadvantages of Distance Vector Routing Algorithm
•It is slower to converge than link state.
•It is at risk from the count-to-infinity problem.
•It creates more traffic than link state since a hop count change must be propagated
to all routers and processed on each router. Hop count updates take place on a
periodic basis, even if there are no changes in the network topology,
so bandwidth-wasting broadcasts still occur.
•For larger networks, distance vector routing results in larger routing tables than link
state since each router must know about all other routers. This can also lead to
congestion on WAN links.
The Count-to-Infinity Problem

► Distance vector routing works in theory but has a serious drawback in


practice: although it converges to the correct answer, it may do so slowly.
► In particular, it reacts rapidly to good news, but leisurely to bad news.
Consider a router whose best route to destination X is large.
► If on the next exchange neighbor A suddenly reports a short delay to X,
the router just switches over to using the line to A to send traffic to X.
► In one vector exchange, the good news is processed.

106
The Count-to-Infinity Problem
► To see how fast good news propagates, consider the five-node (linear) subnet
of Fig. where the delay metric is the number of hops. Suppose A is down
initially and all the other routers know this. In other words, they have all
recorded the delay to A as infinity..

107
4.2.5 Link State Routing
► Distance vector routing was used in the ARPANET until 1979, when it was
replaced by link state routing.
► Variants of link state routing are now widely used.
► The idea behind link state routing is simple and can be stated as five parts.
► Each router must do the following:
1. Discover its neighbors and learn their network addresses.
2. Measure the delay or cost to each of its neighbors.
3. Construct a packet telling all it has just learned.
4. Send this packet to all other routers.
5. Compute the shortest path to every other router. ..
108
Learning about the Neighbors

► When a router is booted, its first task is to learn who its neighbors are. 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 telling who it is.
► These names must be globally unique because when a distant router later
hears that three routers are all connected to F, it is essential that it can
determine whether all three mean the same F.
► When two or more routers are connected by a LAN, the situation is slightly
more complicated.

109
► Fig. 5-11(a) illustrates a LAN to which three routers, A, C, and F, are
directly connected. Each of these routers is connected to one or more
additional routers, as shown

110
► Fig. 5-11(a) illustrates a LAN to which three routers, A, C, and F, are
directly connected. Each of these routers is connected to one or more
additional routers, as shown

111
Building Link State Packets

► The information needed for the exchange has been collected, the next step is
for each router to build a packet containing all the data.
► The packet starts with the identity of the sender, followed by a sequence
number and age (to be described later), and a list of neighbors.
► For each neighbor, the delay to that neighbor is given.
► An example subnet is given in Fig. 5-13(a) with delays shown as labels on the
lines. The corresponding link state packets for all six routers are shown in Fig.
5-13(b).

112
Building Link State Packets

113
Distributing the Link State Packets

The difficult part of the algorithm is distributing the link state packets
reliably.
As the packets are distributed and installed, the routers getting the first
ones will change their routes.
The different routers may be using different versions of the topology,
which can lead to inconsistencies, loops, unreachable machines, and other
problems.
First we will describe the basic distribution algorithm. Later we will give
some refinements.
The fundamental idea is to use flooding to distribute the link state
packets.
114
Distributing the Link State Packets

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 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 rejected as being obsolete since the router has more recent
data.

115
Disadvantages

This algorithm has a few problems, but they are manageable.


First, if the sequence numbers wrap around, confusion will reign.
The Second, if a router ever crashes, it will lose track of its sequence
number. If it starts again at 0, the next packet 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 is thought to be 65,540.
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.

116
Distributing the Link State Packets

The packet buffer for router B in previous slide


117
Popular Routing Protocols

RIP: Routing Information protocol


OSPF: Open Shortest Path First BGP: Border Gateway protocol
1. OSPF
► The Open Shortest Path First (OSPF) protocol is an
intra-domain routing protocol based on link state routing. Its
domain is also an autonomous system.
Area in OSPF

• A collection of networks with area ID


• Routers inside an area flood the area with routing information
• Area border routers summarize the information about the area and
send it to other areas
• Backbone area and backbone routers
– All of the area inside an AS must be connected to the backbone
Types of Links
Stub Links
Example of an Autonomous system and its graph Representation
Types of OSPF packets
Border Gateway Protocol (BGP)
Border Gateway Protocol (BGP) is an inter-domain routing protocol using path vector
routing.
It first appeared in 1989 and has gone through four versions.

A speaker node advertises the path, not the metric of the nodes, in its AS or
other ASs.
Types of AS in BGP
• Stub AS
– Only one connection to another AS (only a source or sink for data traffic)
– E g small corporation or a small local ISP
• Multihomed AS
– More than one connection to other AS, but it is still only a source or sink
for data traffic
– E g Large corporation connected to more than one regional or national
AS
• Transit AS
– Multihomed AS that also allows transient traffic
– E g national or international ISP
Types of BGP messages

BGP uses the services of TCP on port 179.

You might also like