3 RD
3 RD
o It handles the service requests from the transport layer and further forwards the service
request to the data link layer.
o The network layer translates the logical addresses into physical addresses
o It determines the route from the source to the destination and also manages the traffic
problems such as switching, routing and controls the congestion of data packets.
o The main role of the network layer is to move the packets from sending host to the receiving
host.
Network Addressing
o A host is also known as end system that has one link to the network. The boundary between
the host and link is known as an interface. Therefore, the host can have only one interface.
o A router is different from the host in that it has two or more links that connect to it. When a
router forwards the datagram, then it forwards the packet to one of the links. The boundary
between the router and link is known as an interface, and the router can have multiple
interfaces, one for each of its links. Each interface is capable of sending and receiving the IP
packets, so IP requires each interface to have an address.
o Each IP address is 32 bits long, and they are represented in the form of "dot-decimal notation"
where each byte is written in the decimal form, and they are separated by the period. An IP
address would look like 193.32.216.9 where 193 represents the decimal notation of first 8 bits
of an address, 32 represents the decimal notation of second 8 bits of an address.
Classful Addressing
An IP address is 32-bit long. IP address is divided into five sub-classes. These are given below:
• Class A
• 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 IPv4 address is divided into two parts:
Network ID : It represents the number of networks.
Host ID : It represents the number of hosts.
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.
Note:
1. IP addresses are globally managed by Internet Assigned Numbers Authority(IANA) and
regional Internet registries(RIR).
2. 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 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 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 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.
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.
• 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 the network ID. The 16 bits of host ID are used to determine the host
in any network. The default subnet 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.0.0 – 191.255.255.255.
Class C
IP addresses 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 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:
• 2^21 = 2097152 network address
• 2^8 – 2 = 254 host address
IP addresses belonging to class C range from 192.0.0.0 – 223.255.255.255.
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 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.254. This class doesn’t have any subnet mask. The
higher-order bits of the first octet of class E are always set to 1111.
Rules for Assigning Host ID
• 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
• 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.
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.
Subnetting
Dividing a large block of addresses into several contiguous sub-blocks and assigning these sub-blocks
to different smaller networks is called subnetting. It is a practice that is widely used when classless
addressing is done.
A subnet or subnetwork is a network inside a network. Subnets make networks more efficient.
Through subnetting, network traffic can travel a shorter distance without passing through
unnecessary routers to reach its destination.
Classless Addressing
To reduce the wastage of IP addresses in a block, we use sub-netting.
Some Values Calculated in Subnetting:
1. Number of subnets : 2(Given bits for mask – No. of bits in default mask)
2. Subnet address : AND result of subnet mask and the given IP address
3. Broadcast address : By putting the host bits as 1 and retaining the network bits as in the IP address
4. Number of hosts per subnet : 2(32 – Given bits for mask) – 2
5. First Host ID : Subnet address + 1 (adding one to the binary representation of the subnet address)
6. Last Host ID : Subnet address + Number of Hosts
Question: Given IP Address – 172.16.0.0/25, find the number of subnets and the number of hosts
per subnet. Also, for the first subnet block, find the subnet address, first host ID, last host ID, and
broadcast address.
Solution:
This is a class B address. So, no. of subnets = 2(25-16) = 29 = 512.
No. of hosts per subnet = 2(32-25) – 2 = 27 – 2 = 128 – 2 = 126
For the first subnet block(means Subnet Number=1), we have subnet address = 172.16.0.0, first host
id = 172.16.0.1, last host id = 172.16.0.126 and broadcast address = 172.16.0.127
Sr.
Parameter Classful Addressing Classless Addressing
No.
• Network
Division of • Host
9. • Host
Address • Subnet
• Subnet
Supernetting is the process of aggregating routes to multiple smaller networks. Thus saving storage
space in the routing table, simplifying routing decisions, and reducing route advertisements to
neighboring gateways. Supernetting has helped address the increasing size of routing tables as the
Internet has expanded. Supernetting is mainly used in Route Summarization, where routes to
multiple networks with similar network prefixes are combined into a single routing entry, with the
routing entry pointing to a Super network, encompassing all the networks. This in turn significantly
reduces the size of routing tables and also the size of routing updates exchanged by routing
protocols.
Example : 192.168.1.152192.168.1.152
Parts of IPv4:
Network part :
The network part is also known as net id which is used to classify the network to which the host is
connected.
Host part :
The host part is also known as the host id which is the part of the IP address which is used to
uniquely identify the host on a network.
Characteristics of IPv4
Limitations of IPv4
• IP relies on network layer addresses to identify end-points on 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 host, we need IP addresses of next class.
• Complex host and routing configuration, non-hierarchical addressing, difficult to re-
numbering addresses, large routing tables, non-trivial implementations in providing
security, QoS (Quality of Service), mobility and multi-homing, multicasting etc. are the
big limitation of IPv4 so that’s why IPv6 came into the picture.
There are three different types of addressing modes supported by IPv4.
3. New options
IPv6 has new options to allow for additional functionalities.
• Unicast
• Multicast
• Anycast
Addressing methods
1. 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.
2. 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.
3. 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).
Note: Broadcast is not defined in IPv6.
Advantages of IPv6 :
1. Realtime Data Transmission : Realtime data transmission refers to the process of transmitting
data in a very fast manner or immediately
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.
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.
Routing
Routing is a process that is performed by layer 3 (or network layer) devices in order to deliver the
packet by choosing an optimal path from one network to another.
Types of Routing
1. Static Routing
Static routing is a process in which we have to manually add routes to the routing table.
2. Default Routing
This is the method where the router is configured to send all packets toward a single router (next
hop). It doesn’t matter to which network the packet belongs, it is forwarded out to the router
which is configured for default routing. It is generally used with stub routers. A stub router is a
router that has only one route to reach all other networks.
3. Dynamic Routing
Dynamic routing makes automatic adjustments of the routes according to the current state of the
route in the routing table. Dynamic routing uses protocols to discover network destinations and
the routes to reach them. RIP and OSPF are the best examples of dynamic routing protocols.
Automatic adjustments will be made to reach the network destination if one route goes down.
A dynamic protocol has the following features:
• The routers should have the same dynamic protocol running in order to exchange
routes.
• When a router finds a change in the topology then the router advertises it to all other
routers.
Unicast Routing
Unicast 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 Categories
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.
Distance Vector Routing (DVR) Protocol
A distance-vector routing (DVR) protocol requires that a router inform its neighbors of topology
changes periodically. Historically known as the old ARPANET routing algorithm (or known as
Bellman-Ford algorithm).
Distance Vector Algorithm –
1. A router transmits its distance vector to each of its neighbors in a routing packet.
2. Each router receives and saves the most recently received distance vector from each
of its neighbors.
3. A router recalculates its distance vector when:
• It receives a distance vector from a neighbor containing different
information than before.
• It discovers that a link to a neighbor has gone down.
Advantages of Distance Vector routing –
• It is simpler to configure and maintain than link state routing.
Disadvantages of Distance Vector routing –
• It is slower to converge than link state.
• It is at risk from the count-to-infinity problem.
• It creates more traffic than link state since a hop count change must be
propagated to all routers and processed on each router.
Note – Distance Vector routing uses UDP(User datagram protocol) for transportation.
Examples of distance vector routing protocols include Routing Information Protocol (RIP) and
Enhanced Interior Gateway Routing Protocol (EIGRP).
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.
Protocols of Link State Routing
1. Open Shortest Path First (OSPF)
2. Intermediate System to Intermediate System (IS-IS)
1.Open Shortest Path First (OSPF): Open Shortest Path First (OSPF) is a unicast routing protocol
developed by a working group of the Internet Engineering Task Force (IETF). It is an intradomain
routing protocol. It is an open-source protocol. It is similar to Routing Information Protocol (RIP).
OSPF is a classless routing protocol, which means that in its updates, it includes the subnet of each
route it knows about, thus, enabling variable-length subnet masks. With variable-length subnet
masks, an IP network can be broken into many subnets of various sizes. This provides network
administrators with extra network configuration flexibility. These updates are multicasts at specific
addresses (224.0.0.5 and 224.0.0.6). OSPF is implemented as a program in the network layer using
the services provided by the Internet Protocol. IP datagram that carries the messages from OSPF
sets the value of the protocol field to 89. OSPF is based on the SPF algorithm, which sometimes is
referred to as the Dijkstra algorithm.
2.Intermediate System to Intermediate System (IS-IS): Intermediate System to Intermediate
System is a standardized link-state protocol that was developed as the definitive routing protocol
for the OSI Model. IS-IS uses System ID to identify a router on the network. IS-IS doesn’t require IP
connectivity between the routers as updates are sent via CLNS instead of IP.
Path-Vector Routing: Path-Vector routing is a type of routing protocol where routers exchange
information about the path to reach a destination rather than just the distance or topology
information. Border Gateway Protocol (BGP) is the most commonly used path-vector routing
protocol, extensively used in the internet for inter-domain routing.
Routing Information Protocol (RIP): RIP is one of the oldest routing protocols still in use. It uses
distance-vector algorithm and hop count as its metric to determine the best path to a destination.
RIP is simple to configure and deploy, but it may not scale well in large networks.
Border Gateway Protocol (BGP): BGP is a path vector routing protocol used between different
autonomous systems (ASes) on the internet. It makes routing decisions based on network policies,
path attributes, and AS path information. BGP is highly scalable and provides extensive control over
routing decisions, making it suitable for large-scale internet routing.
Enhanced Interior Gateway Routing Protocol (EIGRP): EIGRP is a Cisco proprietary routing protocol
that combines features of both distance-vector and link-state protocols. It uses a hybrid algorithm to
calculate the best path based on bandwidth, delay, load, and reliability. EIGRP provides fast
convergence and efficient bandwidth utilization.
Delivery:
• Delivery refers to the process of ensuring that data packets are successfully transmitted from
the source to the destination.
• In the context of the OSI model, delivery primarily occurs at the Network Layer (Layer 3),
where routing decisions are made to determine the path that packets take through the
network.
• Successful delivery involves several steps, including addressing, routing, and transmission
across various network devices.
Forwarding:
• Forwarding is the process of moving data packets from a router's input interface to the
appropriate output interface based on the destination address.
• When a router receives a packet, it examines the packet's destination IP address and consults
its routing table to determine the best interface or next-hop router to forward the packet.
• Forwarding occurs at the Data Link Layer (Layer 2) and Network Layer (Layer 3) of the OSI
model, depending on whether the forwarding decision is based on MAC addresses or IP
addresses.
Address Mapping:
• ARP is used to map an IP address to a hardware (MAC) address within the same local
network.
• When a device wants to communicate with another device on the same network, it first
checks its ARP cache (a table that stores IP-to-MAC address mappings). If the MAC address is
not found in the cache, the device sends out an ARP request broadcast asking for the MAC
address associated with the target IP address. The device with the corresponding IP address
responds with its MAC address.
• ARP operates at the link layer (Layer 2) of the OSI model.
If the host wants to know the physical address of another host on its network, then it sends an ARP
query packet that includes the IP address and broadcast it over the network. Every host on the
network receives and processes the ARP packet, but only the intended recipient recognizes the IP
address and sends back the physical address. The host holding the datagram adds the physical address
to the cache memory and to the datagram header, then sends back to the sender.
o Dynamic entry: It is an entry which is created automatically when the sender broadcast its
message to the entire network. Dynamic entries are not permanent, and they are removed
periodically.
o Static entry: It is an entry where someone manually enters the IP to MAC address association
by using the ARP command utility.
RARP
o If the host wants to know its IP address, then it broadcast the RARP query packet that contains
its physical address to the entire network. A RARP server on the network recognizes the RARP
packet and responds back with the host IP address.
o The protocol which is used to obtain the IP address from a server is known as Reverse Address
Resolution Protocol.
o The message format of the RARP protocol is similar to the ARP protocol.
o Like ARP frame, RARP frame is sent from one machine to another encapsulated in the data
portion of a frame.
• BOOTP is a precursor to DHCP and was used to assign IP addresses dynamically to diskless
workstations during boot-up.
• Unlike ARP and RARP, BOOTP also provides additional configuration parameters such as
subnet mask, default gateway, and IP address of a TFTP (Trivial File Transfer Protocol) server
to the client.
• BOOTP operates at the application layer (Layer 7) of the OSI model.
• DHCP is a widely used protocol for dynamically assigning IP addresses and other network
configuration parameters to devices on a network.
• DHCP operates based on a client-server model, where DHCP clients request IP addresses and
configuration parameters from DHCP servers.
• DHCP servers maintain a pool of available IP addresses and lease them to clients for a
specific period. DHCP also provides additional configuration information such as subnet
mask, default gateway, DNS server addresses, etc.
• DHCP operates at the application layer (Layer 7) of the OSI model.