0% found this document useful (0 votes)
24 views41 pages

Module 3

The document provides an overview of the Network Layer, the third layer in the OSI model, detailing its functions such as packetizing, routing, and forwarding. It explains key protocols like IPv4 and IPv6, their addressing schemes, and the differences between classful and classless addressing. Additionally, it discusses the limitations of IPv4 and introduces concepts such as Network Address Translation (NAT) and the transition to IPv6.

Uploaded by

sohamparab38
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)
24 views41 pages

Module 3

The document provides an overview of the Network Layer, the third layer in the OSI model, detailing its functions such as packetizing, routing, and forwarding. It explains key protocols like IPv4 and IPv6, their addressing schemes, and the differences between classful and classless addressing. Additionally, it discusses the limitations of IPv4 and introduces concepts such as Network Address Translation (NAT) and the transition to IPv6.

Uploaded by

sohamparab38
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/ 41

COMPUTER NETWORK

MODULE 3

NETWORK LAYER

INTRODUCTION:

The network Layer is the third layer in the OSI model of computer networks. Its main function
is to transfer network packets from the source to the destination. It involves both the source host
and the destination host.
these services are packetizing, routing, and forwarding.
In the 7-layer OSI model, the network layer is layer 3. The Internet Protocol (IP) is a key
protocol used at this layer, along with other protocols for routing, testing, and encryption.
Features of Network Layer
• The main responsibility of the Network layer is to carry the data packets from the source to
the destination without changing or using them.
• If the packets are too large for delivery, they are fragmented i.e., broken down into smaller
packets.
• It decides the route to be taken by the packets to travel from the source to the destination
among the multiple routes available in a network (also called routing).
• The source and destination addresses are added to the data packets inside the network layer.
Services Offered by Network Layer
The services which are offered by the network layer protocol are as follows:
• Packetizing
• Routing
• Forwarding
1. Packetizing
The process of encapsulating the data received from the upper layers of the network (also called
payload) in a network layer packet at the source and decapsulating the payload from the network
layer packet at the destination is known as packetizing.
The source host adds a header that contains the source and destination address and some other
relevant information required by the network layer protocol to the payload received from the
upper layer protocol and delivers the packet to the data link layer.
2.Routing
Routing is the process of moving data from one device to another device. These are two other
services offered by the network layer. In a network, there are a number of routes available from
the source to the destination. The network layer specifies some strategies which find out the best
possible route. This process is referred to as routing. There are a number of routing protocols
that are used in this process and they should be run to help the routers coordinate with each other
and help in establishing communication throughout the network

3.Forwarding
Forwarding is simply defined as the action applied by each router when a packet arrives at one
of its interfaces. When a router receives a packet from one of its attached networks, it needs to
forward the packet to another attached network (unicast routing) or to some attached networks
(in the case of multicast routing). Routers are used on the network for forwarding a packet from
the local network to the remote network. So, the process of routing involves packet forwarding
from an entry interface out to an exit interface.
Differences Between Routing and Forwarding

Routing Forwarding

Forwarding is simply defined as the


Routing is the process of moving data from one
action applied by each router when a
device to another device.
packet arrives at one of its interfaces.

Operates on the Network Layer. Operates on the Network Layer.

Checks the forwarding table and work


Work is based on Forwarding Table.
according to that.

Works on protocols like Routing Information Works on protocols like UDP


Protocol (RIP) for Routing. Encapsulating Security Payload

**Network Layer Protocols**


Internet Protocol Version 4 (IPv4)

IPv4 is 32-bit addressing scheme used as TCP/IP host addressing mechanism. IP addressing
enables every host on the TCP/IP network to be uniquely identifiable.
IPv4 provides hierarchical addressing scheme which enables it to divide the network into sub-
networks, each with well-defined number of hosts.

Classful vs Classless Addressing


• Classful and classless addressing are methods used in networking to manage IP
addresses. Classful addressing divides IP addresses into fixed classes (A, B, C, D, E),
each with predefined ranges. In contrast, classless addressing, also known as CIDR
(Classless Inter-Domain Routing), offers more flexibility by allowing addresses to be
subdivided into smaller blocks called subnets. This flexibility helps optimize address
allocation and supports the growth of the internet by efficiently managing IP address
resources.

IP addresses are divided into many categories:

• Class A - it uses first octet for network addresses and last three octets for host addressing
• Class B - it uses first two octets for network addresses and last two for host addressing
• Class C - it uses first three octets for network addresses and last one for host addressing
.
Example: 192.168.1.1
Class D
Class D is used for multicast addressing and in a class D address the first octet would always
start with ‘1110’. Thus, class D addresses range from 224.0.0.0 to 239.255.255.255. Its Subnet
mask is not defined.
Example: 239.2.2.2
Class D addresses are used by routing protocols like OSPF, RIP, etc.
Class E
Class E addresses are reserved for research purposes and future use. The first octet in a class E
address starts with ‘1111’. Thus, class E addresses range from 240.0.0.0 to 255.255.255.255. Its
Subnet mask is not defined.
Disadvantage of Classful Addressing
• Class A with a mask of 255.0.0.0 can support 128 Network, 16,777,216 addresses per
network and a total of 2,147,483,648 addresses.
• Class B with a mask of 255.255.0.0 can support 16,384 Network, 65,536 addresses per
network and a total of 1,073,741,824 addresses.
• Class C with a mask of 255.255.255.0 can support 2,097,152 Network, 256 addresses per
network and a total of 536,870,912 addresses.

IPv4 also has well-defined address spaces to be used as private addresses (not routable on internet),
and public addresses (provided by ISPs and are routable on internet

Classless Inter-Domain Routing (CIDR)


CIDR or Class Inter-Domain Routing was introduced in 1993 to replace classful addressing.
Classless Inter-Domain Routing (CIDR) is a method for efficiently allocating IP addresses and
routing Internet Protocol (IP) packets. Unlike classful addressing, which divides IP addresses
into fixed classes (A, B, C, etc.), CIDR allows for variable-length subnet masks (VLSM). This
means that networks can be divided into smaller, more flexible subnets according to their specific
needs, rather than being constrained by predefined class boundaries.

Parameter Classful Addressing Classless Addressing

In Classful addressing IP addresses Classless addressing came


Basics are allocated according to the to replace the classful
classes- A to E. addressing and to handle the
Parameter Classful Addressing Classless Addressing

issue of rapid exhaustion of


IP addresses.

Practical It is less practical. It is more practical.

There is no such restriction


Network ID and The changes in the Network ID and
of class in classless
Host ID Host ID depend on the class.
addressing.

It supports the Variable


It does not support the Variable
VLSM Length Subnet Mask
Length Subnet Mask (VLSM).
(VLSM).

Classful addressing requires more It requires less bandwidth.


bandwidth. As a result, it becomes Thus, fast and less
Bandwidth
slower and more expensive as expensive as compared to
compared to classless addressing. classful addressing.

It does not support Classless Inter- It supports Classless Inter-


CIDR
Domain Routing (CIDR). Domain Routing (CIDR).

Updates Regular or periodic updates Triggered Updates


Parameter Classful Addressing Classless Addressing

Troubleshooting and problem


Troubleshooting detection are easy than classless
It is not as easy compared to
and Problem addressing because of the division of
classful addressing.
detection network, host and subnet parts in the
address.

• Network
• Host
Division of Address • Host
• Subnet
• Subnet

Internet Protocol Version 6 (IPv6)

Exhaustion of IPv4 addresses gave birth to a next generation Internet Protocol version 6. IPv6
addresses its nodes with 128-bit wide address providing plenty of address space for future to be
used on entire planet or beyond.

IPv6 has introduced Anycast addressing but has removed the concept of broadcasting. IPv6
enables devices to self-acquire an IPv6 address and communicate within that subnet. This auto-
configuration removes the dependability of Dynamic Host Configuration Protocol (DHCP)
servers. This way, even if the DHCP server on that subnet is down, the hosts can communicate
with each other.

IPv6 provides new feature of IPv6 mobility. Mobile IPv6 equipped machines can roam around
without the need of changing their IP addresses.

IPv6 is still in transition phase and is expected to replace IPv4 completely in coming years. At
present, there are few networks which are running on IPv6. There are some transition mechanisms
available for IPv6 enabled networks to speak and roam around different networks easily on IPv4.
These are:

• Dual stack implementation


• Tunneling
• NAT-PT

**Internet Protocol Version 4 (Ipv4) Frame Format**

Internet Protocol is one of the major protocols in the TCP/IP protocols suite. This protocol works
at the network layer of the OSI model and at the Internet layer of the TCP/IP model. Thus this
protocol has the responsibility of identifying hosts based upon their logical addresses and to route
data among them over the underlying network.

IP provides a mechanism to uniquely identify hosts by an IP addressing scheme. IP uses best effort
delivery, i.e. it does not guarantee that packets would be delivered to the destined host, but it will
do its best to reach the destination. Internet Protocol version 4 uses 32-bit logical address.

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.
needs to be identified

uniIP header includes many relevant information including Version Number, which, in this
context, is 4. Other details are as follows −

• Version − Version no. of Internet Protocol used (e.g. IPv4).


• IHL − Internet Header Length; Length of entire IP header.
• DSCP − Differentiated Services Code Point; this is Type of Service.
• ECN − Explicit Congestion Notification; It carries information about the congestion seen
in the route.
• Total Length − Length of entire IP Packet (including IP header and IP Payload).
• Identification − If IP packet is fragmented during the transmission, all the fragments
contain same identification number. to identify original IP packet they belong to.
• 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. In this 3-bit flag, the MSB is always set to
‘0’.
• 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.
• 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,

The IPv4 supports three different types of addressing modes

Unicast Addressing Mode

In this mode, data is sent only to one destined host. The Destination Address field contains 32- bit
IP address of the destination host. Here the client sends data to the targeted server −

Broadcast Addressing Mode


In this mode, the packet is addressed to all the hosts in a network segment. The Destination Address
field contains a special broadcast address, i.e. 255.255.255.255. When a host sees this packet on
the network, it is bound to process it. Here the client sends a packet, which is entertained by all the
Servers −

Multicast Addressing Mode

This mode is a mix of the previous two modes, i.e. the packet sent is neither destined to a single
host nor all the hosts on the segment. In this packet, the Destination Address contains a special
address which starts with 224.x.x.x and can be entertained by more than one host.

Here a server sends packets which are entertained by more than one servers. Every network has
one IP address reserved for the Network Number which represents the network and one IP address
reserved for the Broadcast Address, which represents all the hosts in that network.

Hierarchical Addressing Scheme


IPv4 uses hierarchical addressing scheme. An IP address, which is 32-bits in length, is divided into
two or three parts as depicted −

A single IP address can contain information about the network and its sub-network and ultimately
the host. This scheme enables the IP Address to be hierarchical where a network can have many
sub-networks which in turn can have many hosts.

**Subnetting**

The 32-bit IP address contains information about the host and its network. It is very necessary to
distinguish both. For this, routers use Subnet Mask, which is as long as the size of the network
address in the IP address. Subnet Mask is also 32 bits long. If the IP address in binary is ANDed
with its Subnet Mask, the result yields the Network address. For example, say the IP Address is
192.168.1.152 and the Subnet Mask is 255.255.255.0 then −

This way the Subnet Mask helps extract the Network ID and the Host from an IP Address. It can
be identified now that 192.168.1.0 is the Network number and 192.168.1.152 is the host on that
network.

Binary Representation

The positional value method is the simplest form of converting binary from decimal value. IP
address is 32 bit value which is divided into 4 octets. A binary octet contains 8 bits and the value
of each bit can be determined by the position of bit value '1' in the octet.
Positional value of bits is determined by 2 raised to power (position – 1), that is the value of a bit
1 at position 6 is 2^(6-1) that is 2^5 that is 32. The total value of the octet is determined by adding
up the positional value of bits. The value of 11000000 is 128+64 = 192. Some examples are shown
in the table below −

Drawback of IPv4

• Limited Address Space: IPv4 has a limited number of addresses, which is not enough for
the growing number of devices connecting to the internet.
• Complex Configuration: IPv4 often requires manual configuration or DHCP to assign
addresses, which can be time-consuming and prone to errors.
• Less Efficient Routing: The IPv4 header is more complex, which can slow down data
processing and routing.
• Security Issues: IPv4 does not have built-in security features, making it more vulnerable to
attacks unless extra security measures are added.
• Limited Support for Quality of Service (QoS): IPv4 has limited capabilities for
prioritizing certain types of data, which can affect the performance of real-time applications
like video streaming and VoIP.
• Fragmentation: IPv4 allows routers to fragment packets, which can lead to inefficiencies
and increased chances of data being lost or corrupted.
• Broadcasting Overhead: IPv4 uses broadcasting to communicate with multiple devices on
a network, which can create unnecessary network traffic and reduce performancerols the
congestion of data packets in the network.

**Network Address Translation (NAT)**


for 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.
Network Address Translation (NAT) working –
Generally, the border router is configured for NAT i.e the router which has one interface in the
local (inside) network and one interface in the global (outside) network. When a packet
traverse outside the local (inside) network, then NAT converts that local (private) IP address to
a global (public) IP address. When a packet enters the local network, the global (public) IP
address is converted to a local (private) IP address.
If NAT runs out of addresses, i.e., no address is left in the pool configured then the packets
will be dropped and an Internet Control Message Protocol (ICMP) host unreachable packet to
the destination is sent.
Why mask port numbers ?
Suppose, in a network, two hosts A and B are connected. Now, both of them request for the
same destination, on the same port number, say 1000, on the host side, at the same time. If
NAT does only translation of IP addresses, then when their packets will arrive at the NAT,
both of their IP addresses would be masked by the public IP address of the network and sent to
the destination. Destination will send replies to the public IP address of the router. Thus, on
receiving a reply, it will be unclear to NAT as to which reply belongs to which host (because
source port numbers for both A and B are the same). Hence, to avoid such a problem, NAT
masks the source port number as well and makes an entry in the NAT table.
NAT inside and outside addresses –
Inside refers to the addresses which must be translated. Outside refers to the addresses which
are not in control of an organization. These are the network Addresses in which the translation
of the addresses will be done.

• Inside local address – An IP address that is assigned to a host on the Inside (local)
network. The address is probably not an IP address assigned by the service provider i.e.,
these are private IP addresses. This is the inside host seen from the inside network.

• Inside global address – IP address that represents one or more inside local IP addresses to
the outside world. This is the inside host as seen from the outside network.

• Outside local address – This is the actual IP address of the destination host in the local
network after translation.
• Outside global address – This is the outside host as seen from the outside network. It is
the IP address of the outside destination host before translation.

Network Address Translation (NAT) Types –


There are 3 ways to configure NAT:

1. Static NAT – In this, a single unregistered (Private) IP address is mapped with a legally
registered (Public) IP address i.e one-to-one mapping between local and global addresses.
This is generally used for Web hosting. These are not used in organizations as there are
many devices that will need Internet access and to provide Internet access, a public IP
address is needed.
Suppose, if there are 3000 devices that need access to the Internet, the organization has to
buy 3000 public addresses that will be very costly.

2. Dynamic NAT – In this type of NAT, an unregistered IP address is translated into a


registered (Public) IP address from a pool of public IP addresses. If the IP address of the
pool is not free, then the packet will be dropped as only a fixed number of private IP
addresses can be translated to public addresses.
Suppose, if there is a pool of 2 public IP addresses then only 2 private IP addresses can be
translated at a given time. If 3rd private IP address wants to access the Internet then the
packet will be dropped therefore many private IP addresses are mapped to a pool of public
IP addresses. NAT is used when the number of users who want to access the Internet is
fixed. This is also very costly as the organization has to buy many global IP addresses to
make a pool.

3. Port Address Translation (PAT) – This is also known as NAT overload. In this, many
local (private) IP addresses can be translated to a single registered IP address. Port numbers
are used to distinguish the traffic i.e., which traffic belongs to which IP address. This is
most frequently used as it is cost-effective as thousands of users can be connected to the
Internet by using only one real global (public) IP address.

Advantages of NAT –

• NAT conserves legally registered IP addresses.

• It provides privacy as the device’s IP address, sending and receiving the traffic, will be
hidden.

• Eliminates address renumbering when a network evolves.

Disadvantage of NAT –

• Translation results in switching path delays.

• Certain applications will not function while NAT is enabled.

• Complicates tunneling protocols such as IPsec.

• Also, the router being a network layer device, should not tamper with port
numbers(transport layer) but it has to do so because of NAT.

** Internet Protocol version 6 (IPv6)**


The Internet Protocol version 6, or IPv6, is the latest version of the Internet Protocol (IP), which
is the system used for identifying and locating computers on the Internet. IPv6 was developed by
the Internet Engineering Task Force (IETF) to deal with the problem of IPv4 exhaustion. IPv6 is
a 128-bit address having an address space of 2128, which is way bigger than IPv4. IPv6 uses a
Hexa-Decimal format separated by a colon (:).
IP
An IP address, which stands for Internet Protocol address, is like a home address for your computer
or any device connected to the internet. Just as your home address lets mail find its way to your
house, an IP address helps information find its way to your device.
Components in Address Format
• There are 8 groups and each group represents 2 Bytes (16-bits).
• Each Hex-Digit is of 4 bits (1 nibble)
• Delimiter used – colon (:)

Need For IPv6


The Main reason of IPv6 was the address depletion as the need for electronic devices rose quickly
when Internet Of Things (IOT) came into picture after the 1980s & other reasons are related to the
slowness of the process due to some unnecessary processing, the need for new options, support for
multimedia, and the desperate need for security. IPv6 protocol responds to the above issues using
the following main changes in the protocol:
• Large Address Space: An IPv6 address is 128 bits long .compared with the 32 bit address of
IPv4, this is a huge(2 raised 96 times) increases in the address space.
• Better Header Format: IPv6 uses a new header format in which options are separated from
the base header and inserted, when needed, between the base header and the upper layer data .
This simplifies and speeds up the routing process because most of the options do not need to
be checked by routers.
• New Options: IPv6 has new options to allow for additional functionalities.
• Allowance for extension: IPv6 is designed to allow the extension of the protocol if required
by new technologies or applications.
• Support For Resource Allocation: In IPv6,the type of service field has been removed, but
two new fields , traffic class and flow label have been added to enables the source to request
special handling of the packet . this mechanism can be used to support traffic such as real-time
audio and video.
• Support For More Security: The encryption and authentication options in IPv6 provide
confidentiality and integrity of the packet. In IPv6 representation, we have three addressing
methods :
o Unicast
o Multicast
o Anycast
Addressing Methods
• Unicast Address : Unicast Address identifies a single network interface. A packet sent to a
unicast address is delivered to the interface identified by that address.
• Multicast Address : Multicast Address is used by multiple hosts, called as groups, acquires
a multicast destination address. These hosts need not be geographically together. If any packet
is sent to this multicast address, it will be distributed to all interfaces corresponding to that
multicast address. And every node is configured in the same way. In simple words, one data
packet is sent to multiple destinations simultaneously.
• Anycast Address: Anycast Address is assigned to a group of interfaces. Any packet sent to
an anycast address will be delivered to only one member interface (mostly nearest host
possible).

1111 1110 10 Link-Local Unicast Addresses 1/1024

1111 1110 11 Site-Local Unicast Addresses 1/1024

1111 1111 Multicast Address 1/256

Provider Id: Depending on the number of service providers that operate under a region, certain
bits will be allocated to the Provider Id field.
Subscriber Id: After Provider Id is fixed, the remaining part can be used by ISP as a normal IP
address.
Intra Subscriber: This part can be modified as per the need of the organization that is using the
service
Global Routing Prefix: Global routing prefix contains all the details of Latitude and Longitude.
In Geography-based Unicast address routing will be based on location.
Interface Id: In IPv6, instead of using Host Id, we use the term Interface Id.

Local Unicast
Addresses
These are of two types: Link-local and Site-Local
1. Link-Local Address

A link-local address is used for addressing a single link. It can also be used to communicate with
nodes on the same link. The link-local address always begins with 1111111010 (i.e. FE80). The
router will not forward any packet with Link-local address.
2. Site Local Address

Site local addresses are equivalent to a private IP address in IPv4. Likely, some address space is
reserved, which can only be routed within an organization. The first 10-bits are set to 1111111011,
which is why Site local addresses always begin with FEC0. The following 32 bits are Subnet IDs,
which can be used to create a subnet within the organization. The node address is used to uniquely
identify the link; therefore, we use a 48-bits MAC address here.
**Advantages of IPv6**
1. Realtime Data Transmission : Realtime data transmission refers to the process of
transmitting data in a very fast manner or immediately. Example : Live streaming services
such as cricket matches, or other tournament that are streamed on web exactly as soon as it
happens with a maximum delay of 5-6 seconds.
• 2. IPv6 supports authentication: Verifying that the data received by the receiver from the
sender is exactly what the sender sent and came through the sender only not from any third
party. Example : Matching the hash value of both the messages for verification is also done by
IPv6.
• 3. IPv6 performs Encryption: Ipv6 can encrypt the message at network layer even if the
protocols of application layer at user level didn’t encrypt the message which is a major
advantage as it takes care of encryption.
• 4. Faster processing at Router: Routers are able to process data packets of Ipv6 much faster
due to smaller Base header of fixed size – 40 bytes which helps in decreasing processing time
resulting in more efficient packet transmission. Whereas in Ipv4, we have to calculate the
length of header which lies between 20-60 bytes.
Disadvantages of IPV6
• Transition Period: Due to widespread use of IPv4, shifting completely to IPv6 will take a
long time.
• Communication Barrier: IPv4 and IPv6 machines cannot communicate directly with each
other.
• No Backward Compatibility: IPv6 cannot run on IPv4-capable computers because it’s not
supported by IPv4 systems.
• Conversion Challenges: IPv6’s inability to uniquely identify each device on the network
makes the transition from IPv4 time-consuming.
• Protocol Isolation: IPv4 and IPv6 cannot communicate with each other directly, preventing
cross-protocol communication

**Difference Between IPv4 and IPv6**

IPv4 IPv6

IPv4 has a 32-bit address length IPv6 has a 128-bit address length
IPv4 IPv6

It Supports Manual It supports Auto and renumbering address


and DHCP address configuration configuration

In IPv4 end to end, connection In IPv6 end-to-end, connection integrity is


integrity is Unachievable Achievable

It can generate 4.29×109 address The address space of IPv6 is quite large it can
space produce 3.4×1038 address space

The Security feature is dependent on IPSEC is an inbuilt security feature in the IPv6
the application protocol

Address representation of IPv4 is in


Address representation of IPv6 is in hexadecimal
decimal

Fragmentation performed by Sender In IPv6 fragmentation is performed only by the


and forwarding routers sender

In IPv4 Packet flow identification is In IPv6 packet flow identification are Available and
not available uses the flow label field in the header

In IPv4 checksum field is available In IPv6 checksum field is not available


IPv4 IPv6

It has a broadcast Message In IPv6 multicast and anycast message transmission


Transmission Scheme scheme is available

In IPv4 Encryption and In IPv6 Encryption and Authentication are provided


Authentication facility not provided

IPv6 has a header of 40 bytes fixed


IPv4 has a header of 20-60 bytes.

IPv4 can be converted to IPv6 Not all IPv6 can be converted to IPv4

IPv4 consists of 4 fields which are IPv6 consists of 8 fields, which are separated by a
separated by addresses dot (.) colon (:)

IPv4’s IP addresses are divided into


five different classes. Class A , Class IPv6 does not have any classes of the IP address.
B, Class C, Class D , Class E.

IPv4 supports VLSM IPv6 does not support VLSM.

Example of IPv6:
Example of IPv4: 66.94.29.13
2001:0000:3238:DFE1:0063:0000:0000:FEFB
**Benefits of IPv6 over IPv4**
The recent Version of IP IPv6 has a greater advantage over IPv4. Here are some of the mentioned
benefits:
• Larger Address Space: IPv6 has a greater address space than IPv4, which is required for
expanding the IP Connected Devices. IPv6 has 128 bit IP Address rather and IPv4 has a 32-
bit Address.
• Improved Security: IPv6 has some improved security which is built in with it. IPv6 offers
security like Data Authentication, Data Encryption, etc. Here, an Internet Connection is more
Secure.
• Simplified Header Format: As compared to IPv4, IPv6 has a simpler and more effective
header Structure, which is more cost-effective and also increases the speed of Internet
Connection.
• Prioritize: IPv6 contains stronger and more reliable support for QoS features, which helps
in increasing traffic over websites and increases audio and video quality on pages.
• Improved Support for Mobile Devices: IPv6 has increased and better support for Mobile
Devices. It helps in making quick connections over other Mobile Devices and in a safer way
than IPv4.

Link State Routing


dUnicast means the transmission from a single sender to a single receiver. It is a
point-to-point communication between the sender and receiver. There are various
unicast protocols such as TCP, HTTP, etc.
• TCP is the most commonly used unicast protocol. It is a connection-oriented protocol that
relies on acknowledgment from the receiver side.
• HTTP stands for HyperText Transfer Protocol. It is an object-oriented protocol for
communication.
Unicast Routing

Major Protocols of Unicast Routing


1. Distance Vector Routing: Distance-Vector routers use a distributed algorithm to compute
their routing tables.
2. Link-State Routing: Link-State routing uses link-state routers to exchange messages that
allow each router to learn the entire network topology.
3. Path-Vector Routing: It is a routing protocol that maintains the path that is updated
dynamically.
Link State Routing
Link state routing is the second family of routing protocols. While distance-vector routers use a
distributed algorithm to compute their routing tables, link-state routing uses link-state routers to
exchange messages that allow each router to learn the entire network topology. Based on this
learned topology, each router is then able to compute its routing table by using the shortest path
computation.
Link state routing is a technique in which each router shares the knowledge of its neighborhood
with every other router i.e. the internet work. The three keys to understand the link state routing
algorithm.
1. 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.
2. 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 the neighbors. Finally each and every router receives a copy of the
same information.
3. Information Sharing: A router send the information to every other router only when the
change occurs in the information.
Link state routing has two phase:
1. Reliable Flooding: Initial state– Each node knows the cost of its neighbors. Final state-
Each node knows the entire graph.
2. Route Calculation: Each node uses Dijkstra’ s algorithm on the graph to calculate the
optimal routes to all nodes. The link state routing algorithm is also known as Dijkstra’s
algorithm which is used to find the shortest path from one node to every other node in the
network.
Features of Link State Routing Protocols
• Link State Packet: A small packet that contains routing information.
• Link-State Database: A collection of information gathered from the link-state packet.
• Shortest Path First Algorithm (Dijkstra algorithm): A calculation performed on the
database results in the shortest path
• Routing Table: A list of known paths and interfaces.
Distance Vector Routing (DVR) Protocol
The distance vector routing algorithm is one of the most commonly used routing algorithms.
It is a distributed algorithm, meaning that it is run on each router in the network. The algorithm
works by each router sending updates to its neighbors about the best path to each destination.er

Distance Vector Routing Algorithm

Distance vector routing is a routing protocol that uses distance as a metric to determine the best
path between two nodes. It is also known as the Bellman-Ford algorithm.

Distance vector routing is used in simple network topologies where the number of hops between
two nodes is the primary metric used to determine the best path. In more complex network
topologies, other factors such as link bandwidth and latency can be taken into account when
determining the best path.
Advantages of Distance Vector Routing Algorithm

There major advantages to the distance vector routing algorithm are as follows:

• Distance vector routing is a routing protocol that uses the shortest path to a destination as
its primary criterion. This algorithm is used in local-area networks, metropolitan-area
networks, and wide-area networks.

• The main advantage of this algorithm is that it is easy to implement and does not require
many resources.

• Additionally, distance vector routing converges quickly; it means that it can find an optimal
route to a destination quickly after a change in network conditions.

Disadvantages of Distance Vector Routing Algorithm

There are a few disadvantages to the distance vector routing algorithm, as detailed below:

• First, it is not very scalable. This algorithm doesn’t work well in large networks because
the amount of information that needs to be exchanged between nodes can become too great.

• Additionally, this algorithm can suffer from routing loops. This occurs when there is a
change in the network, and incorrect information is propagated between nodes, causing a
loop.

• Also, this algorithm can be slow to converge on a new route after a change in the network.

Applications of Distance Vector Routing Algorithm

There are a number of different applications for the Distance Vector Routing Algorithm. One
common application is in computer networking, specifically in routing data packets. This
algorithm is also used in some types of telephone switching systems. Additionally, it has been used
in military applications to route missiles.

. This header consists of the network ID and host ID of the network.


• Host-to-host Delivery of Data: The network layer ensures that th


• Routing Protocols

A routing protocol is a set of policies or algorithms routers use to exchange information about the
networks they are connected to. This information helps routers decide the best route to transmit
packets to their destination. Routing protocols function on the network layer of the OSI reference
model and use route update packets to communicate with each other.

Routers run various routing protocols to exchange updates and assist in finding the best paths to a
destination in a network. When a new network is added, routing protocols can learn about it and
recognize when a network is unavailable.

We now have a basic understanding of what routing protocols really are. Let’s move on to the
types of routing protocols.

Types of Routing Protocols

Mainly, there are two types of routing protocols. These are:

Static Routing

In static routing, the routes are manually configured by means of the network administrator and do
not change based on network conditions. This type of routing is simple, stable, and rapid, but it
isn’t scalable or adaptable to network modifications. Static routing is best suited for small networks
with a fixed topology.

Dynamic Routing

In dynamic routing, the routes are automatically updated based on modifications inside the
network topology or metrics, including hop count number, bandwidth, delay, and so on. This sort
of routing is complex and efficient, but it consumes greater resources and bandwidth. Dynamic
routing is best suited for big, complicated networks with a variable topology.
Examples of Routing Protocols

Below, we have discussed various examples of routing protocols with their characteristics.

• RIP: Routing Information Protocol is a distance vector IGP that uses hop count as its
metric. It is one of the oldest and is also known to be the simplest routing protocol. Still, it
has many limitations, which include a maximum hop count of 15, slow convergence, and
high bandwidth consumption.
• EIGRP: Enhanced Interior Gateway Routing Protocol is a distance vector IGP that uses a
composite metric based totally on bandwidth, delay, reliability, load, and MTU. It is a
Cisco proprietary protocol that improves upon RIP with the aid of the usage of capabilities
that include partial updates, triggered updates, hello packets, and a DUAL set of rules or
algorithms.
• OSPF: Open Shortest Path First is a link state IGP that makes use of cost as its metric. It
is an open standard protocol that uses functions including areas, LSAs, SPF rules or
algorithms, DR/BDR election, and authentication. It has fast convergence, low bandwidth
intake, and high scalability.
• BGP: Border Gateway Protocol is a path vector EGP that uses attributes that include AS
path, next hop, MED, origin, and community to pick the best routes. It is an open standard
protocol that is used to change routing information among ASes on the Internet. It has slow
convergence, high CPU intake, and complex configuration.
• IS-IS: Intermediate System to Intermediate System is a link state IGP/EGP that uses cost
as its metric. It is an ISO standard protocol that makes use of features such as areas, LSPs,
SPF set of rules, DIS election, and authentication. It has fast convergence, low bandwidth
consumption, and high scalability.

Advantages of Routing Protocols

Some of the advantages of routing protocols are:

• They make it possible for routers to automatically and dynamically learn about distant
networks.
• By locating alternative channels, they let routers adjust to network changes and outages.
• By choosing the optimum path based on multiple variables, they enhance network
performance.
• By doing away with manual route setting, they lower administrative burden.

Disadvantages of Routing Protocols

Some of the disadvantages of routing protocols are:

• Routing protocols can lead to routing loops and sometimes inconsistency if not configured
properly.
• Complexity and security issues in the network design are some of the drawbacks that
routing protocols can generate.
• Sometimes, compatibility issues arise because different versions of routing protocols are
used for different purposes.

Difference between Routing and Routed Protocol

Below, we have compared Routing Protocol vs Routed Protocol in a tabular form to explain the
difference between the two.

Factors Routing Protocol Routed Protocol

To determine the best routes for To carry data packets between


Purpose
data packets end devices

Provide logical addresses (such


Use logical addresses (such as IP
Addressing as IP addresses) to identify end
addresses) to identify networks
devices

Operate at the network layer of the Operate at the network layer or


Operation
OSI model higher layers of the OSI model
Factors Routing Protocol Routed Protocol

Types It can be static or dynamic Can be routable or non-routable

Example RIP, EIGRP, OSPF, BGP, etc. IP, IPX, AppleTalk, etc.

Typically implemented in end


Implemented in network devices,
Hardware/Software systems or hosts (e.g.,
primarily routers.
computers, servers).

The choice of routing protocol can The scale of the network is


Scalability impact network scalability and mostly independent of the routed
routing efficiency. protocol in use.

These are the main differences between Routing and Routed Protocols. In summary, routed
protocols deal with the content and structure of data packets, while routing protocols deal with the
rules and algorithms that routers use to decide how to forward these data packets from one network
segment to another. Routing protocols ensure that data packets from one network can traverse
multiple networks to reach their destination by determining the most efficient path.

Classification of Routing algorithm


Routing is the process of establishing the routes that data packets must follow to reach the
destination. In this process, a routing table is created which contains information regarding
routes that data packets follow. Various routing algorithms are used for the purpose of deciding
which route an incoming data packet needs to be transmitted on to reach the destination
efficiently.
Classification of Routing Algorithms
The routing algorithms can be classified as follows:
1. Adaptive Algorithms
2. Non-Adaptive Algorithms
3. Hybrid Algorithms

Types of Routing Algorithm


1. Adaptive Algorithms
These are the algorithms that change their routing decisions whenever network topology or
traffic load changes. The changes in routing decisions are reflected in the topology as well as the
traffic of the network. Also known as dynamic routing, these make use of dynamic information
such as current topology, load, delay, etc. to select routes. Optimization parameters are distance,
number of hops, and estimated transit time.
Further, these are classified as follows:
• Isolated: In this method each, node makes its routing decisions using the information it has
without seeking information from other nodes. The sending nodes don’t have information
about the status of a particular link. The disadvantage is that packets may be sent through a
congested network which may result in delay. Examples: Hot potato routing, and backward
learning.

• Centralized: In this method, a centralized node has entire information about the network
and makes all the routing decisions. The advantage of this is only one node is required to
keep the information of the entire network and the disadvantage is that if the central node
goes down the entire network is done.
• Distributed: In this method, the node receives information from its neighbors and then
takes the decision about routing the packets. A disadvantage is that the packet may be delayed
if there is a change in between intervals in which it receives information and sends packets.
It is also known as a decentralized algorithm as it computes the least-cost path between
source and destination.
2. Non-Adaptive Algorithms
These are the algorithms that do not change their routing decisions once they have been selected.
This is also known as static routing as a route to be taken is computed in advance and
downloaded to routers when a router is booted.
Further, these are classified as follows:
• Flooding: This adapts the technique in which every incoming packet is sent on every
outgoing line except from which it arrived. One problem with this is that packets may go in
a loop and as a result of which a node may receive duplicate packets. These problems can be
overcome with the help of sequence numbers, hop count, and spanning trees.
• Random walk: In this method, packets are sent host by host or node by node to one of its
neighbors randomly. This is a highly robust method that is usually implemented by sending
packets onto the link which is least queued.

Random Walk

3. Hybrid Algorithms
As the name suggests, these algorithms are a combination of both adaptive and non-adaptive
algorithms. algorithm.
Further, these are classified as follows:
• Link-state: In this method, each router creates a detailed and complete map of the network
which is then shared with all other routers. This allows for more accurate and efficient routing
decisions to be made.
• Distance vector: In this method, each router maintains a table that contains information
about the distance and direction to every other node in the network. This table is then shared
with other routers in the network. The disadvantage of this method is that it may lead to
routing loops

Introduction to Graphs

Graphs are non-linear data structures representing the "connections" between the elements. These
elements are known as the Vertices, and the lines or arcs that connect any two vertices in the graph
are known as the Edges. More formally, a Graph comprises a set of Vertices (V) and a set of
Edges (E). The Graph is denoted by G(V, E).

Components of a Graph
1. Vertices: Vertices are the basic units of the graph used to represent real-life objects,
persons, or entities. Sometimes, vertices are also known as Nodes.
2. Edges:Edges are drawn or used to connect two vertices of the graph. Sometimes, edges are
also known as Arcs.

The following figure shows a graphical representation of a Graph:

Graphical Representation of a Graph

In the above figure, the Vertices/Nodes are denoted with Colored Circles, and the Edges are
denoted with the lines connecting the nodes.
Types of Graphs

The Graphs can be categorized into two types:

1. Undirected Graph
2. Directed Graph

Undirected Graph: A Graph with edges that do not have a direction is termed an Undirected
Graph. The edges of this graph imply a two-way relationship in which each edge can be traversed
in both directions. The following figure displays a simple undirected graph with four nodes and
five edges.

A Simple Undirected Graph

Directed Graph: A Graph with edges with direction is termed a Directed Graph. The edges of
this graph imply a one-way relationship in which each edge can only be traversed in a single
direction. The following figure displays a simple directed graph with four nodes and five edges.

A Simple Directed Graph

The absolute length, position, or orientation of the edges in a graph illustration characteristically
does not have meaning. In other words, we can visualize the same graph in different ways by
rearranging the vertices or distorting the edges if the underlying structure of the graph does not
alter.

Weighted Graphs

A Graph is said to be Weighted if each edge is assigned a 'weight'. The weight of an edge can
denote distance, time, or anything that models the 'connection' between the pair of vertices it
connects.

Weighted Graph

Dijkstra's Algorithm

• Dijkstra's algorithm finds the shortest path from one vertex to all other vertices.It does so
by repeatedly selecting the nearest unvisited vertex and calculating the distance to all the
unvisited neighbouring vertices.

• Dijkstra's algorithm is often considered to be the most straightforward algorithm for


solving the shortest path problem.

• Dijkstra's algorithm is used for solving single-source shortest path problems for directed
or undirected paths. Single-source means that one vertex is chosen to be the start, and the
algorithm will find the shortest path from that vertex to all other vertices.

• Dijkstra's algorithm does not work for graphs with negative edges. For graphs with
negative edges, the Bellman-Ford algorithm that is described on the next page, can be used
instead.
• To find the shortest path, Dijkstra's algorithm needs to know which vertex is the source, it
needs a way to mark vertices as visited, and it needs an overview of the current shortest
distance to each vertex as it works its way through the graph, updating these distances when
a shorter distance is found.

It is a type of Greedy Algorithm that only works on Weighted Graphs having positive weights.
The time complexity of Dijkstra's Algorithm is O(V2) with the help of the adjacency matrix
representation of the graph. This time complexity can be reduced to O((V + E) log V) with the
help of an adjacency list representation of the graph, where V is the number of vertices and E is
the number of edges in the graph.

Fundamentals of Dijkstra's Algorithm

The following are the basic concepts of Dijkstra's Algorithm:

1. Dijkstra's Algorithm begins at the node we select (the source node), and it examines the
graph to find the shortest path between that node and all the other nodes in the graph.
2. The Algorithm keeps records of the presently acknowledged shortest distance from each
node to the source node, and it updates these values if it finds any shorter path.
3. Once the Algorithm has retrieved the shortest path between the source and another node,
that node is marked as 'visited' and included in the path.
4. The procedure continues until all the nodes in the graph have been included in the path. In
this manner, we have a path connecting the source node to all other nodes, following the
shortest possible path to reach each node.

Understanding the Working of Dijkstra's Algorithm

A graph and source vertex are requirements for Dijkstra's Algorithm. This Algorithm is
established on Greedy Approach and thus finds the locally optimal choice (local minima in this
case) at each step of the Algorithm.

Each Vertex in this Algorithm will have two properties defined for it:
1. Visited Property
2. Path Property

Let us understand these properties in brief.

Visited Property:
1. The 'visited' property signifies whether or not the node has been visited.
2. We are using this property so that we do not revisit any node.
3. A node is marked visited only when the shortest path has been found.

Path Property:
1. The 'path' property stores the value of the current minimum path to the node.
2. The current minimum path implies the shortest way we have reached this node till now.
3. This property is revised when any neighbor of the node is visited.
4. This property is significant because it will store the final answer for each node.

Initially, we mark all the vertices, or nodes, unvisited as they have yet to be visited. The path to all
the nodes is also set to infinity apart from the source node. Moreover, the path to the source node
is set to zero (0).

We then select the source node and mark it as visited. After that, we access all the neighbouring
nodes of the source node and perform relaxation on every node. Relaxation is the process of
lowering the cost of reaching a node with the help of another node.

In the process of relaxation, the path of each node is revised to the minimum value amongst the
node's current path, the sum of the path to the previous node, and the path from the previous node
to the current node.

Let us suppose that p[n] is the value of the current path for node n, p[m] is the value of the path up
to the previously visited node m, and w is the weight of the edge between the current node and
previously visited one (edge weight between n and m).

In the mathematical sense, relaxation can be exemplified as:


p[n] = minimum(p[n], p[m] + w)

We then mark an unvisited node with the least path as visited in every subsequent step and update
its neighbor's paths.

We repeat this procedure until all the nodes in the graph are marked visited.

Whenever we add a node to the visited set, the path to all its neighboring nodes also changes
accordingly.

If any node is left unreachable (disconnected component), its path remains 'infinity'. In case the
source itself is a separate component, then the path to all other nodes remains 'infinity'.

Understanding Dijkstra's Algorithm with an Example

The following is the step that we will follow to implement Dijkstra's Algorithm:

Step 1: First, we will mark the source node with a current distance of 0 and set the rest of the nodes
to INFINITY.

Step 2: We will then set the unvisited node with the smallest current distance as the current node,
suppose X.

Step 3: For each neighbor N of the current node X: We will then add the current distance of X
with the weight of the edge joining X-N. If it is smaller than the current distance of N, set it as the
new current distance of N.

Step 4: We will then mark the current node X as visited.

Step 5: We will repeat the process from 'Step 2' if there is any node unvisited left in the graph.

Let us now understand the implementation of the algorithm with the help of an example:
Graph

1. We will use the above graph as the input, with node A as the source.
2. First, we will mark all the nodes as unvisited.
3. We will set the path to 0 at node A and INFINITY for all the other nodes.
4. We will now mark source node A as visited and access its neighboring nodes.
Note: We have only accessed the neighboring nodes, not visited them.
5. We will now update the path to node B by 4 with the help of relaxation because the path to
node A is 0 and the path from node A to B is 4, and the minimum((0 + 4),
INFINITY) is 4.
6. We will also update the path to node C by 5 with the help of relaxation because the path to
node A is 0 and the path from node A to C is 5, and the minimum((0 + 5),
INFINITY) is 5. Both the neighbors of node A are now relaxed; therefore, we can move
ahead.
7. We will now select the next unvisited node with the least path and visit it. Hence, we will
visit node B and perform relaxation on its unvisited neighbors. After performing
relaxation, the path to node C will remain 5, whereas the path to node E will become 11,
and the path to node D will become 13.
8. We will now visit node E and perform relaxation on its neighboring nodes B, D, and F.
Since only node F is unvisited, it will be relaxed. Thus, the path to node B will remain as
it is, i.e., 4, the path to node D will also remain 13, and the path to node F will become 14
(8 + 6).
9. Now we will visit node D, and only node F will be relaxed. However, the path to
node F will remain unchanged, i.e., 14.
10. Since only node F is remaining, we will visit it but not perform any relaxation as all its
neighboring nodes are already visited.
11. Once all the nodes of the graphs are visited, the program will end.

Hence, the final paths we concluded are:

1. A = 0
2. B = 4 (A -> B)
3. C = 5 (A -> C)
4. D = 4 + 9 = 13 (A -> B -> D)
5. E = 5 + 3 = 8 (A -> C -> E)
6. F = 5 + 3 + 6 = 14 (A -> C -> E -> F)

NOTE: **IMP for IA-1

You might also like