Network Layer
Network Layer
The network layer is the third layer (from bottom) in the OSI Model. The network layer is
concerned with the delivery of a packet across multiple networks. The network layer is
considered the backbone of the OSI Model. It selects and manages the best logical path for
data transfer between nodes. This layer contains hardware devices such as routers, bridges,
firewalls, and switches, but it actually creates a logical image of the most efficient
communication route and implements it with a physical medium. Network layer protocols
exist in every host or router. The router examines the header fields of all the IP packets that
pass through it. Internet Protocol and Netware IPX/SPX are the most common protocols
associated with the network layer.
In the OSI model, the network layer responds to requests from the layer above it (transport
layer) and issues requests to the layer below it (data link layer).
Selects Transport
Logical Path Layer
Manages
Network Data Link
Data
Layer Layer
Transfer
Hardware
Devices
Variable
Efficiency
High Efficiency
Flexible Data
Path
Fixed Data Path
Shared
Connection
Dedicated
Connection
Packet Switched
Network
Circuit Switched
Network
Packet Switching
Allows packets to take different
paths, potentially improving
efficiency.
Circuit Switching
Ensures data packets are received
in order through a single path.
IPv4:
IPv4 is a connectionless protocol used for packet-switched networks. It operates on a best
effort delivery model, in which neither delivery is guaranteed, nor proper sequencing or
avoidance of duplicate delivery is assured. Internet Protocol Version 4 (IPv4) is the fourth
revision of the Internet Protocol and a widely used protocol in data communication over
different kinds of networks. IPv4 is a connectionless protocol used in packet-switched layer
networks, such as Ethernet. It provides a logical connection between network devices by
providing identification for each device. There are many ways to configure IPv4 with all kinds
of devices – including manual and automatic configurations – depending on the network
type.
IPv4 is defined and specified in IETF publication RFC 791.
IPv4 uses 32 -bit addresses for Ethernet communication in five classes: A, B, C, D and E.
Classes A, B and C have a different bit length for addressing the network host. Class D
addresses are reserved for military purposes, while class E addresses are reserved for future
use.
IPv4 uses 32 -bit (4 byte) addressing, which gives 232 addresses. IPv4 addresses are written in
the dot -decimal notation, which comprises of four octets of the address expressed
individually in decimal and separated by periods, for instance, [Link].
Classful Addressing
The 32 bit IP address is divided into five sub -classes. These are:
• · Class A
• · Class B
• · Class C
• · Class D
• · Class E
Class C
Best for small networks with
fewer hosts.
Class B
Ideal for medium-sized
networks with a balance of Class D
networks and hosts.
Used for multicast addressing.
Class A
Class E
Suitable for large networks
with many hosts. Reserved for future use.
Each of these classes has a valid range of IP addresses. Classes D and E are reserved for
multicast and experimental purposes respectively. The order of bits in the first octet
determine the classes of IP address. IPv4 address is divided into two parts:
· Network ID
• · Host ID
The class of IP address is used to determine the bits used for network ID and host ID and the
number of total networks and hosts possible in that particular class. Each ISP or network
administrator assigns IP address to each device that is connected to its network.
Note: IP addresses are globally managed by Internet Assigned Numbers Authority(IANA) and
regional Internet registries(RIR).
Note: While finding the total number of host IP addresses, 2 IP addresses are not counted and
are therefore, decreased from the total count because the first IP
address of any network is the network number and whereas the last IP address is reserved
for broadcast IP.
Class A:
IP address belonging to class A are assigned to the networks that contain a large number of
hosts.
• · The network ID is 8 bits long.
• · The host ID is 24 bits long.
The higher order bit of the first octet in class A is always set to 0. The remaining 7 bits in first
octet are used to determine network ID. The 24 bits of host ID are used to determine the host
in any network. The default subnet mask for class A is 255.x.x.x. Therefore, class A has a total
of:
• · 2^7 -2= 126 network ID(Here 2 address is subtracted because [Link] and 127.x.y.z are
special address. )
• · 2^24 – – 2 = 16,777,214 host ID
IP addresses belonging to class A ranges from 1.x.x.x – 126.x.x.x
Class B:
IP address belonging to class B are assigned to the networks that ranges from medium -sized
to large-sized networks.
• · The network ID is 16 bits long.
• · The host ID is 16 bits long.
The higher order bits of the first octet of IP addresses of class B are always set to 10. The
remaining 14 bits are used to determine network ID. The 16 bits of host ID is used to
determine the host in any network. The default sub-net mask for class B is 255.255.x.x. Class B
has a total of:
• · 2^14 = 16384 network address
• · 2^16 – – 2 = 65534 host address
IP addresses belonging to class B ranges from 128.0.x.x – 191.255.x.x.
Class C:
IP address belonging to class C are assigned to small-sized networks.
• · The network ID is 24 bits long.
• · The host ID is 8 bits long.
The higher order bits of the first octet of IP addresses of class C are always set to 110. The
remaining 21 bits are used to determine network ID. The 8 bits of host ID is used to determine
the host in any network. The default sub-net mask for class C is 255.255.255.x. Class C has a
total of:
• · 2^21 = 2097152 network address
• · 2^8 – – 2 = 254 host address
IP addresses belonging to class C ranges from 192.0.0.x – 223.255.255.x.
Class D:
IP address belonging to class D are reserved for multi-casting. The higher order bits of the
first octet of IP addresses belonging to class D are always set to 1110. The remaining bits are
for the address that interested hosts recognize.
Class D does not posses any sub-net mask. IP addresses belonging to class D ranges from
[Link] – – [Link].
Class E:
IP addresses belonging to class E are reserved for experimental and research purposes. IP
addresses of class E ranges from [Link] – [Link]. This class doesn't have any
sub-net mask. The higher order bits of first octet of class E are always set to 1111.
Range of special IP addresses:
[Link] – – [Link] : Link local addresses
[Link] – –
[Link] : Loop-back addresses
[Link] – – [Link] : used to communicate within the current network.
Rules for assigning Host ID:
Host ID's are used to identify a host within a network. The host ID are assigned based on the
following rules:
• · Within any network, the host ID must be unique to that network.
• · Host ID in which all bits are set to 0 cannot be assigned because this host ID is used
to represent the network ID of the IP address.
• · Host ID in which all bits are set to 1 cannot be assigned because this host ID is
reserved as a broadcast address to send packets to all the hosts present on that
particular network.
Subnetting:
When a bigger network is divided into smaller networks, in order to maintain security, then
that is known as Subnetting. so, maintenance is easier for smaller networks.
Now, let’s talk about dividing a network into two parts:
so to divide a network into two parts, you need to choose one bit for each Subnet from the
host ID part.
In the above diagram, there are two Subnets.
Note: It is a class C IP so, there are 24 bits in the network id part and 8 bits in the host id part.
• · For Subnet -1:
The first bit which is chosen from the host id part is zero and the range will be from
(193.1.2.00000000 till you get all 1's in the host ID part i.e, 193.1.2.01111111) except for the first bit
which is chosen zero for subnet id part.
Thus, the range of subnet-1:
[Link] to [Link]
• · For Subnet -2:
The first bit chosen from the host id part is one and the range will be from (193.1.2.100000000
till you get all 1's in the host ID part i.e, 193.1.2.11111111).
Thus, the range of subnet-2:
[Link] to [Link]
Note:
• To divide a network into four (22) parts you need to choose two bits from host id part
for each subnet i.e, (00, 01, 10, 11).
• To divide a network into eight (23) parts you need to choose three bits from host id
part for each subnet i.e, (000, 001, 010, 011, 100, 101, 110, 111) and so on
Network Supernetting
Network Addresses
Network Range
Network Size
Supernet
• Contiguous: You can easily see that all networks are contiguous all having size 256
hosts.
• Range of first Network from [Link] to [Link]. If you add 1 in last IP address of
first network that is [Link] + [Link], you will get the next network id which is
[Link]. Similarly, check that all network are contiguous.
• Equal size of all network: As all networks are of class C, so all of them have a size of
256 which is in turn equal to 28 .
• First IP address exactly divisible by total size: When a binary number is divided by 2n
then last n bits are the remainder. Hence in order to prove that first IP address is
exactly divisible by while size of Supernet Network. You can check that if last n v=bits
are 0 or not.
In the given example first IP is [Link] and whole size of supernet is 4*28 = 210. If last 10 bits
of first IP address are zero then IP will be divisible.
• Last 10 bits of first IP address are zero (highlighted by green color). So 3rd condition is
also satisfied.
• Control and reduce network traffic
• Helpful to solve the problem of lacking IP addresses
• Minimizes the routing table
• · It cannot cover a different area of the network when combined
• · All the networks should be in the same class and all IP should be contiguous
Classless Addressing
To reduce the wastage of IP addresses in a block, we use sub-netting. What we do is that we
use host id bits as net id bits of a classful IP address. We give the IP address and define the
number of bits for mask along with it (usually followed by a '/' symbol), like, [Link]/28.
Here, subnet mask is found by putting the given number of bits out of 32 as 1, like, in the
given address, we need to put 28 out of 32 bits as 1 and the rest as 0, and so, the subnet
mask would be [Link].
IPv6:
IP address is your digital identity. It's a network address for your computer so the Internet
knows w where to send you emails, data, etc.
IP address determines who and where you are in the network of billions of digital devices
that are connected to the Internet.
IPv6 or Internet Protocol Version 6 is a network layer protocol that allows communication to
take place over the network. IPv6 was designed by Internet Engineering Task Force (IETF) in
December 1998 with the purpose of superseding the IPv4 due to the global exponentially
growing internet users.
IPv4 vs IPv6
The common type of IP address (is known as IPv4, for "version 4"). Here's an example of what
an IP address might look like:
[Link]
An IPv4 address consists of four numbers, each of which contains one to three digits, with a
single dot (.) separating each number or set of digits. Each of t the four numbers can range
from 0 to 255. This group of separated numbers creates the addresses that let you and
everyone around the globe to send and retrieve data over our Internet connections. The IPv4
uses a 32 -bit address scheme allowing to store 2^32 addresses which is more than 4 billion
addresses. To date, it is considered the primary Internet Protocol and carries 94% of Internet
traffic.
Initially, it was assumed it would never run out of addresses but the present situation paves a
new way to IPv6, let's see why?
An IPv6 address consists of eight groups of four hexadecimal digits. Here's an example IPv6
address:
3001:0da8:75a3:0000:0000:8a2e:0370:7334
This new IP address version is being deployed to fulfill the need for more Internet addresses.
It w was aimed to resolve issues which are associated with IPv4. With 128 -bit address space,
it allows 340 undecillion unique address space. IPv6 also called IPng (Internet Protocol next
generation).
IPv6 support a theoretical maximum of 340, 282, 366, 920, 938, 463, 463, 374, 607, 431, 768,
211, 456. To keep it straightforward, we will never run out of IP addresses again.
· Unicast addresses
It identifies a unique node on a network and usually refers to a single sender or a single
receiver.
· Multicast addresses
It represents a group of IP devices and can only be used as the destination of a datagram.
• · Anycast addresses
It is assigned to a set of interfaces that typically belong to different nodes.
Advantages of IPv6
• · Reliability
• · Faster Speeds: IPv6 supports multicast rather than broadcast in [Link] feature
allows bandwidth -intensive packet flows (like multimedia streams) to be sent to
multiple destinations all at once.
• · Stringer Security: IPSecurity, which provides confidentiality, and data integrity, is
embedded into IPv6.
• · Routing efficiency
• · Most importantly it's the final solution for growing nodes in Global-network.
Disadvantages of IPv6
• · Conversion: Due to widespread present usage of IPv4 it will take a long period to
completely shift to IPv6.
• · Communication: IPv4 and IPv6 machines cannot communicate directly with each
other. They need an intermediate technology to make that possible.
Parameter problem:
Whenever router receives data packets then calculated header checksum should always be
equal to received header checksum then only packet is accepted by the router otherwise
rejected.
• · If there is a mismatch packet will be dropped by the router. ICMP will take the source
IP from the discarded packet and informs to source by sending parameter problem
message.
Destination un -reachable :
• · Destination unreachable is generated by the host or its inbound gateway to inform
the client that the destination is unreachable for some reason.
• · There is no necessary condition that only router give the ICMP error message some
time destination host send ICMP error message when any type of failure (link failure,
hardware failure, port failure etc.) happen in the network.
Redirection message :
• · Redirect requests data packets be sent on an alternate route. The message informs to
a host to update its routing infoformation (to send packets on an alternate route).
• · If host tries to send data through a router R1 and R1 sends data on a router R2 and
there is a direct way from host to R2. Then R1 will send a redirect message to inform
the host that there is a best way to the destination directly through R2 available. The
host then sends data packets for the destination directly to R2.
The router R2 will send the original datagram to the intended destination.
But if datagram contains the routing information of the packet then this message will not be
sent even if another better route is available. As redirected messages should only be sent by
the gateways and not by the Internet hosts.
• · Whenever a packet is forwarded into a wrong direction later it is redirected in a
current direction and then ICMP will send re -directed message.
Advantages of NAT ––
• · NAT conserves legally registered IP addresses.
• · It provides privacy as the device 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 tunnelling 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.