UNIT 3 Network Layer
UNIT 3 Network Layer
A computer network can be as simple as two PCs connected together via a single copper
cable or it can be grown up to the complexity where every computer in this world is
connected to every other, called the Internet. A network then includes more and more
components to reach its ultimate goal of data exchange. Below is a brief description of the
components involved in computer network −
Hosts − Hosts are said to be situated at ultimate end of the network, i.e. a host is a source of
information and another host will be the destination. Information flows end to end between
hosts. A host can be a user’s PC, an internet Server, a database server etc.
Media − If wired, then it can be copper cable, fiber optic cable, and coaxial cable. If wireless,
it can be free-to-air radio frequency or some special wireless band. Wireless frequencies can
be used to interconnect remote sites too.
Hub − A hub is a multiport repeater and it is used to connect hosts in a LAN segment.
Because of low throughputs hubs are now rarely used. Hub works on Layer-1 (Physical
Layer) of OSI Model.
Switch − A Switch is a multiport bridge and is used to connect hosts in a LAN segment.
Switches are much faster than Hubs and operate on wire speed. Switch works on Layer-2
(Data Link Layer), but Layer-3 (Network Layer) switches are also available.
Router − A router is Layer-3 (Network Layer) device which makes routing decisions for the
data/information sent for some remote destination. Routers make the core of any
interconnected network and the Internet.
Gateways − A software or combination of software and hardware put together, works for
exchanging data among networks which are using different protocols for sharing data.
Firewall − Software or combination of software and hardware, used to protect users data
from unintended recipients on the network/internet.
Host Addressing
Communication between hosts can happen only if they can identify each other on the
network. In a single collision domain (where every packet sent on the segment by one host is
heard by every other host) hosts can communicate directly via MAC address.
MAC address is a factory coded 48-bits hardware address which can also uniquely identify a
host. But if a host wants to communicate with a remote host, i.e. not in the same segment or
logically not connected, then some means of addressing is required to identify the remote
host uniquely. A logical address is given to all hosts connected to Internet and this logical
address is called Internet Protocol Address.
● We can restrict access to any network by allowing only those devices which have the
authorized MAC addresses to connect. Thus, it can also be used for network security.
Disadvantages
● MAC addresses can be easily spoofed. Thus, the devices can easily gain unauthorized access
to a network.
● As physical addresses cannot traverse through the routers therefore they can only be used in
local networks and not between different networks.
Physical and Logical Address
● They can handle a number devices and networks. Even if the number of devices and network
increases, the logical address is able to handle all them very easily. Thus, they are highly
scalable.
Disadvantages
● Internet Protocol is vulnerable to attacks such as hacking, phishing etc. and there can be data
loss.
● It lacks privacy. The data which is moving through the packets can be intercepted, traced and
monitored by unauthorized entities.
Differences between Physical Address and Logical Address
Physical Address Logical Address
What is IPv4?
IP stands for Internet Protocol version v4 stands for Version Four (IPv4), is the most widely used
system for identifying devices on a network. It uses a set of four numbers, separated by periods (like
192.168.0.1), to give each device a unique address. This address helps data find its way from one
device to another over the internet.
IPv4 was the primary version brought into action for production within the ARPANET in 1983. IP
version four addresses are 32-bit integers which will be expressed in decimal notation. Example-
192.0.2.126 could be an IPv4 address.
What is an IP Address?
An IP address (Internet Protocol address) is a unique identifier assigned to each device connected
to a network that uses the Internet Protocol for communication. It serves two main purposes:
● Identification: It uniquely identifies a device on a network.
● Location Addressing: It indicates where a device is located within a network, making data
routing possible.
Understanding IPv4 Addressing
An IPv4 address consists of series of four eight-bit binary numbers which are separated by decimal
point. Although any numbering system can be used to represent a unique 32- bit number, most
commonly you see IP address expressed in dot decimal notation. Some of the examples are :
Site Dot-decimal Binary
● 107: 01101011
● 80: 01010000
● 231: 11100111
Parts of IPv4
IPv4 addresses consist of three parts:
● Network Part: The network part indicates the distinctive variety that’s appointed to the
network. The network part conjointly identifies the category of the network that’s assigned.
● Host Part: The host part uniquely identifies the machine on your network. This part of the
IPv4 address is assigned to every host.
For each host on the network, the network part is the same, however, the host half must vary.
● Subnet Number: This is the non obligatory part of IPv4. Local networks that have massive
numbers of hosts are divided into subnets and subnet numbers are appointed to that.
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.
Subnet Mask
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 −
\
Characteristics of IPv4
● IPv4 could be a 32-bit IP Address.
● IPv4 could be a numeric address, and its bits are separated by a dot.
● The number of header fields is twelve and the length of the header field is twenty.
● IPv4 uses the Post Address Resolution Protocol to map to the MAC address.
Advantages of IPv4
● IPv4 security permits encryption to keep up privacy and security.
● IPV4 network allocation is significant and presently has quite 85000 practical routers.
● It becomes easy to attach multiple devices across an outsized network while not NAT.
● IPv4 has high System Management prices and it’s labor-intensive, complex, slow & prone to
errors.
● Routing is scalable and economical as a result of addressing its collective more effectively.
● Data communication across the network becomes a lot of specific in multicast organizations.
Limitations of IPv4
● IP relies on network layer addresses to identify end-points on the network, and each network
has a unique IP address.
● The world’s supply of unique IP addresses is dwindling, and they might eventually run out
theoretically.
● If there are multiple hosts, we need the IP addresses of the next class.
IPV6
The wonder of IPv6 lies in its header. An IPv6 address is 4 times larger than IPv4, but surprisingly,
the header of an IPv6 address is only 2 times larger than that of IPv4. IPv6 headers have one Fixed
Header and zero or more Optional (Extension) Headers. All the necessary information that is essential
for a router is kept in the Fixed Header. The Extension Header contains optional information that
helps routers to understand how to handle a packet/flow.
Fixed Header
IPv6 fixed header is 40 bytes long and contains the following information.
Traffic Class (8-bits): These 8 bits are divided into two parts. The most significant 6 bits are
2 used for Type of Service to let the Router Known what services should be provided to this
packet. The least significant 2 bits are used for Explicit Congestion Notification (ECN).
Flow Label (20-bits): This label is used to maintain the sequential flow of the packets
belonging to a communication. The source labels the sequence to help the router identify that a
3
particular packet belongs to a specific flow of information. This field helps avoid re-ordering of
data packets. It is designed for streaming/real-time media.
Payload Length (16-bits): This field is used to tell the routers how much information a
particular packet contains in its payload. Payload is composed of Extension Headers and Upper
4 Layer data. With 16 bits, up to 65535 bytes can be indicated; but if the Extension Headers
contain Hop-by-Hop Extension Header, then the payload may exceed 65535 bytes and this field
is set to 0.
Next Header (8-bits): This field is used to indicate either the type of Extension Header, or if
5 the Extension Header is not present then it indicates the Upper Layer PDU. The values for the
type of Upper Layer PDU are same as IPv4s.
Hop Limit (8-bits): This field is used to stop packet to loop in the network infinitely. This is
6 same as TTL in IPv4. The value of Hop Limit field is decremented by 1 as it passes a link
(router/hop). When the field reaches 0 the packet is discarded.
7 Source Address (128-bits): This field indicates the address of originator of the packet.
Destination Address (128-bits): This field provides the address of intended recipient of the
8
packet.
Extension Headers
In IPv6, the Fixed Header contains only that much information which is necessary, avoiding those
information which is either not required or is rarely used. All such information is put between the
Fixed Header and the Upper layer header in the form of Extension Headers. Each Extension Header is
identified by a distinct value.
When Extension Headers are used, IPv6 Fixed Headers Next Header field points to the first Extension
Header. If there is one more Extension Header, then the first Extension Headers Next-Header field
points to the second one, and so on. The last Extension Headers Next-Header field points to the Upper
Layer Header. Thus, all the headers points to the next one in a linked list manner.
If the Next Header field contains the value 59, it indicates that there are no headers after this header,
not even Upper Layer Header.
The following Extension Headers must be supported as per RFC 2460:
These headers:
● 1. should be processed by First and subsequent destinations.
Encryption and authentication is not provided in IPv4 Encryption and authentication is provided in
(Internet Protocol Version 4). IPv6 (Internet Protocol Version 6)
Packet flow identification is not available in IPv4 (Internet Packet flow identification is available in IPv6.
Protocol Version 4). Flow label field is available in the header.
IPv4 addresses are usually represented in dot-decimal An IPv6 address is represented as eight groups
notation, consisting of four decimal numbers, each ranging of four hexadecimal digits, each group
from 0 to 255, separated by dots. representing 16 bits.
Sender and forwarding routers performs fragmentation in Fragmentation is performed only by the sender
IPv4 in IPv6.
In IPv4, security features relies on application In IPv6, there is an inbuilt security feature
named IPSEC.
End to end connection integrity cannot be achieved in IPv4. End to end connection integrity can be done in
IPv6.
IPv4 supports DHCP and Manual address configuration IPv6 supports renumbering and auto address
configuration.
IPv4 addresses are 32-bit long IPv6 addresses are 128 bits long.
The address space in IPv4 is 4.29 ×109 The address space in IPv6 is 3.4 ×1038
IPv4 has a broadcast message transmission scheme. Multicast and Anycast message transmission
scheme is available in IPv6.
● Class B
● Class C
● Class D
● Class E
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 determines the classes of the IP
address.
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
an IP address to each device that is connected to its network.
Classful Addressing
Note:
● IP addresses are globally managed by Internet Assigned Numbers Authority (IANA) and
Regional Internet Registries (RIR).
● 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.
Occupation of The Address Space In Classful Addressing
Class A
IP addresses belonging to class A are assigned to the networks that contain a large number of hosts.
● The network ID is 8 bits long.
The higher-order bit of the first octet in class A is always set to 0. The remaining 7 bits in the 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:
● 224 – 2 = 16,777,214 host ID
Class A
Class B
IP address belonging to class B is assigned to networks that range from medium-sized to large-sized
networks.
● The network ID is 16 bits long.
Class B
Class C
IP addresses belonging to class C are assigned to small-sized networks.
● The network ID is 24 bits long.
The higher-order bits of the first octet of IP addresses of class C is always set to 110. The remaining
21 bits are used to determine the network ID. The 8 bits of host ID are used to determine the host in
any network. The default subnet mask for class C is 255.255.255.x. Class C has a total of:
● 221 = 2097152 network address
Class C
Class D
IP address belonging to class D is reserved for multi-casting. The higher-order bits of the first octet of
IP addresses belonging to class D is always set to 1110. The remaining bits are for the address that
interested hosts recognize.
Class D does not possess any subnet mask. IP addresses belonging to class D range from 224.0.0.0 –
239.255.255.255.
Class D
Class E
IP addresses belonging to class E are reserved for experimental and research purposes. IP addresses of
class E range from 240.0.0.0 – 255.255.255.255. This class doesn’t have any subnet mask. The
higher-order bits of the first octet of class E are always set to 1111.
Class E
Range of Special IP Addresses
169.254.0.0 – 169.254.0.16 : Link-local addresses
127.0.0.0 – 127.255.255.255 : Loop-back addresses
0.0.0.0 – 0.0.0.8: used to communicate within the current network.
Rules for Assigning Host ID
Host IDs are used to identify a host within a network. The host ID is assigned based on the following
rules:
● Within any network, the host ID must be unique to that network.
● A 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.
Rules for Assigning Network ID
Hosts that are located on the same physical network are identified by the network ID, as all host on
the same physical network is assigned the same network ID. The network ID is assigned based on the
following rules:
● The network ID cannot start with 127 because 127 belongs to the class A address and is
reserved for internal loopback functions.
● All bits of network ID set to 1 are reserved for use as an IP broadcast address and therefore,
cannot be used.
● All bits of network ID set to 0 are used to denote a specific host on the local network and are
not routed and therefore, aren’t used.
Structure of Classful Addressing
In the above table No. of networks for class A should be 127. (Network ID with all 0 s is not
considered)
Problems With Classful Addressing
The problem with this classful addressing method is that millions of class A addresses are wasted,
many of the class B addresses are wasted, whereas, the number of addresses available in class C is so
small that it cannot cater to the needs of organizations. Class D addresses are used for multicast
routing and are therefore available as a single block only. Class E addresses are reserved.
Since there are these problems, Classful networking was replaced by Classless Inter-Domain Routing
(CIDR) in 1993.
● The network ID is 24 bits long.
● 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.
● The network ID cannot start with 127 because 127 belongs to the class A address and is
reserved for internal loopback functions.
● All bits of network ID set to 1 are reserved for use as an IP broadcast address and therefore,
cannot be used.
● All bits of network ID set to 0 are used to denote a specific host on the local network and are
not routed and therefore, aren’t used.
Classful and Classless Addressing
Here is the main difference between Classful and Classless Addressing:
Network ID and The changes in the Network ID and There is no such restriction of
Host ID Host ID depend on the class. class in classless addressing.
● Network
● Host
Division of Address ● Host
● Subnet
● Subnet
Conclusion
Classful IP addressing, with its categorization into classes like A, B, and C, was a fundamental
method in early networking. It organized IP addresses based on network size but faced limitations in
flexibility and efficient use of address space. The development of CIDR addressed these issues by
allowing more precise control over subnetting and optimizing address allocation.
In case of addressing with subnetting, the process of reaching an address is done by 4 steps –
1. Identification of the network
2. Identification of the subnet
3. Identification of the host
4. Identification of the process
Suppose we have a Class C network and we want to divide it into 4 subnets. To divide we need to
choose 2 bits from the host part.
As the first and last IP addresses are reserved for network ID and directed broadcast address in
every subnet, we have to reserve 8 IP addresses in this case.
In some cases the network id may match with two entries in the routing table, so here the interface
having the longest subnet mask (more 1’s) is selected.
How Does Subnetting Work
Subnetting divides a large network into smaller sub-networks by modifying the subnet mask. This
improves the management of IP addresses, reduces broadcast traffic, and increases network security
by isolating different parts of the network. Subnetting also helps optimize the use of IP address space
and improves troubleshooting and overall network performance.
For example, subnetting can organize devices into logical groups, such as separating a company’s
departments into different subnets. This way, traffic within one department does not unnecessarily
interfere with others, improving performance and security
Network Classes
The Internet Assigned Numbers Authority (IANA), through InterNIC, oversees the allocation of IP
addresses. IP addresses are divided into classes to simplify their use, with Classes A, B, and C being
the most commonly used. Classes D and E exist but are not used by end users. Each class has
a default subnet mask, and the first octet of the IP address determines its class. The ranges of Class
A, B, and C Internet addresses are given below, along with a sample address for each:
Range of Classes
Advantages of Subnetting
● Reduces network congestion: Limits broadcast traffic, improving network speed.
Disadvantages of Subnetting
● Limited IP Address Space: Dividing networks reduces available IPs per subnet.
● Additional Hardware: Subnetting reduces the overall number of IP addresses in the network,
yet it could necessitate purchasing extra hardware, like a router. Thus it could be very
expensive.
● Complex Setup: Requires expertise to plan and configure subnets.
● Compatibility Issues: Older devices or systems may struggle with subnetting configurations.