NETWORK LAYER - IP Addressing
NETWORK LAYER - IP Addressing
The network layer's primary role is to route and forward data packets between devices over a
network. The main design issues can be summarized as:
Classful Addressing
1. Overview
Classful addressing is the original method of dividing the IPv4 address space into five classes
(A, B, C, D, and E). Each class has a predefined size and purpose, with a fixed boundary
between the network and host portions of the address.
● IP addresses are divided into 5 classes based on the first few bits of the address:
4. Reserved Addresses
1. Network Address: The first address in a block, used to identify the network (e.g.,
192.168.1.0 in Class C).
2. Broadcast Address: The last address in a block, used to send data to all hosts in the
network (e.g., 192.168.1.255 in Class C).
3. Private IP Ranges: Not routable on the internet, used within local networks:
○ Class A: 10.0.0.0 - 10.255.255.255
○ Class B: 172.16.0.0 - 172.31.255.255
○ Class C: 192.168.0.0 - 192.168.255.255.
5. Example Breakdown
1. Fixed Subnet Masks: Every Class A network must have ~16 million hosts, which leads
to inefficiency.
2. Wastage of Addresses: Small organizations could not use Class A or B efficiently due
to the large number of unused IPs.
3. Scalability Issues: The rigid division made it difficult to create subnets for finer control.
4. Not Flexible for Modern Needs: Classless addressing (CIDR) replaced this system to
provide more efficient IP utilization.
Sample Questions
MCQs:
○ a) Class A
○ b) Class B
○ c) Class C
○ d) Class D
(Answer: a)
2. What is the default subnet mask for Class C addresses?
○ a) 255.0.0.0
○ b) 255.255.255.0
○ c) 255.255.0.0
○ d) 255.255.255.128
(Answer: b)
Subjective:
1. Overview
● Goal: Solve the inefficiency and address exhaustion problems of Classful Addressing.
● Key Idea: Use a suffix (/n) to indicate the number of bits allocated for the network
portion of the IP address.
Examples:
● 192.168.1.0/24:
1. Efficient Address Allocation: Assigns only the required number of IPs. For example, a
network needing 30 IPs doesn’t have to use a full Class C range.
2. Aggregation of Routes (Supernetting): Reduces the size of routing tables by
summarizing multiple routes into one.
3. Scalability: Allows for fine-grained control over network sizes using variable-length
subnet masks.
● Convert /n to a subnet mask by making the first n bits 1 and the rest 0.
● Example: /22
○ First 22 bits = 11111111.11111111.11111100.00000000
○ Subnet mask = 255.255.252.0.
For a given prefix /n, the number of IPs in the block is:
2^(32 − 𝑛)
Example: /22
Subtract 2 from the total number of IPs (for network and broadcast addresses).
Example: /22
Example of Supernetting:
6. Example Problems
Example 1:
MCQs:
○ a) 16
○ b) 14
○ c) 32
○ d) 30
(Answer: a)
2. What is the subnet mask for a /19 prefix?
○ a) 255.255.255.0
○ b) 255.255.224.0
○ c) 255.255.192.0
○ d) 255.255.240.0
(Answer: b)
Subjective:
1. Subnetting: Overview
Subnetting divides a larger network into smaller, more manageable subnetworks (subnets). It is
primarily used to:
The primary goal of subnetting is to "borrow" bits from the Host ID portion to extend the
Network ID, creating smaller subnetworks.
3. Subnetting Process
1. Determine Requirements:
2^𝑏≥𝑅𝑒𝑞𝑢𝑖𝑟𝑒𝑑 𝑆𝑢𝑏𝑛𝑒𝑡𝑠.
4. Example of Subnetting
○ 192.168.1.0 - 192.168.1.31
○ 192.168.1.32 - 192.168.1.63
○ 192.168.1.64 - 192.168.1.95
○ ... and so on.
● Step 4: Usable IPs per Subnet
Total IPs: 25=322^5 = 32.
Usable IPs = 32−2=3032 - 2 = 30.
Example for first subnet:
5. Supernetting: Overview
Supernetting combines multiple smaller networks into a larger network. It is used primarily for:
7. Example of Supernetting
Problem: Combine 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, and
192.168.3.0/24 into a supernet.
○ 192.168.0.0 → 11000000.10101000.00000000.00000000
○ 192.168.3.0 → 11000000.10101000.00000011.00000000
● Step 2: Identify Common Bits
First 22 bits are identical.
Purpose Divides a large network into smaller Combines smaller networks into
ones. one.
Use Case Efficiently utilize IPs in local networks. Optimize routing in global
networks.
Sample Questions
MCQs:
○ a) 6
○ b) 8
○ c) 16
○ d) 32
(Answer: b)
2. What is the new subnet mask when dividing 10.0.0.0/16 into 16 subnets?
○ a) 255.255.224.0
○ b) 255.255.255.0
○ c) 255.255.240.0
○ d) 255.255.248.0
(Answer: b)
Subjective:
The Network Layer provides critical services that ensure efficient, reliable, and secure
communication between devices across a network. These services are fundamental to the
operation of both small and large-scale networks.
● Routing: Determining the best path for data packets to travel from source to destination.
● Forwarding: Transmitting packets to the next device or network along the chosen route.
● Logical Addressing: Assigning IP addresses to devices to uniquely identify them within
a network.
● Fragmentation and Reassembly: Splitting large packets into smaller fragments for
transmission and reassembling them at the destination.
● Error Handling and Diagnostics: Detecting and reporting errors using protocols like
ICMP (Internet Control Message Protocol).
A. Packet Switching
● Transmits data in small units called packets.
● Uses store-and-forward technology: Packets are temporarily stored at intermediate
routers before being forwarded.
● Ensures efficient use of bandwidth.
B. Connectionless Service
C. Connection-Oriented Service
● Transparency: End-users should not need to know about the underlying network
operations.
● Scalability: Support for large networks with millions of devices.
● Reliability: Resilient to hardware or network failures.
● Efficiency: Optimal use of available resources, minimizing delays and congestion.
● Interoperability: Seamless communication across different types of networks (e.g.,
Ethernet, Wi-Fi).
A. Addressing
C. Forwarding
● The process of moving packets from an input interface to the correct output interface on
a router.
● Large packets are broken down into fragments when the data size exceeds the
Maximum Transmission Unit (MTU) of the network.
● Fragments are reassembled at the destination.
Sample Questions
MCQs:
○
a) Routing
○
b) Forwarding
○
c) Error-free transmission
○
d) Logical addressing
(Answer: c)
2. What is the main protocol used by the network layer for error reporting?
○ a) TCP
○ b) UDP
○ c) ICMP
○ d) ARP
(Answer: c)
Subjective:
The performance of the Network Layer significantly impacts the efficiency and reliability of data
transmission across networks. Several key factors influence the network layer's performance,
including throughput, delay, jitter, and packet loss.
A. Throughput
● Definition: The rate at which data packets are successfully delivered over a network.
● Measured in bits per second (bps) or packets per second (pps).
● Affected by:
○ Network Congestion: Excess traffic can reduce throughput.
○ Bandwidth: Higher bandwidth increases potential throughput.
B. Latency (Delay)
● Definition: The time taken for a packet to travel from source to destination.
● Components of latency:
1. Propagation Delay: Time for a signal to travel through the medium.
2. Transmission Delay: Time to push all packet bits onto the link.
3. Processing Delay: Time taken by routers to process packets.
4. Queuing Delay: Time packets spend in router queues.
● Formula for total delay: Total Delay=Propagation Delay+Transmission Delay+Processing
Delay+Queuing Delay\text{Total Delay} = \text{Propagation Delay} + \text{Transmission
Delay} + \text{Processing Delay} + \text{Queuing Delay}
C. Jitter
D. Packet Loss
● Definition: The percentage of packets that fail to reach their destination.
● Causes:
○ Congested routers dropping packets.
○ Faulty hardware or transmission errors.
● Impact: Retransmissions are required, increasing overall delay.
A. Congestion Control
C. Routing Protocols
3. Performance Metrics
Sample Questions
MCQs:
1. Which of the following affects latency the most in a heavily congested network?
○ a) Propagation delay
○ b) Queuing delay
○ c) Transmission delay
○ d) Processing delay
(Answer: b)
2. What is jitter primarily associated with?
○ a) Packet corruption
○ b) Variation in packet delay
○ c) Bandwidth limitations
○ d) Routing errors
(Answer: b)
Subjective:
Forwarding of IP Packets
Packet forwarding is a key operation in the Network Layer, where routers determine how to
direct incoming packets toward their destination. This involves examining packet headers and
using routing tables to decide the next hop.
● Routing:
○ Involves determining the best path for data packets between devices.
○ Requires dynamic updates to the routing table using routing protocols like RIP,
OSPF, or BGP.
● Forwarding:
○ Executes the decision made by routing to move packets from one hop to the
next.
○ Is a per-packet operation.
B. Default Forwarding
● When no specific route is found, packets are forwarded to the default gateway.
● Example:
○ Routing table entry: 0.0.0.0/0 indicates the default route.
C. Next-Hop Forwarding
● Instead of storing the complete route, the router stores only the next hop for each route.
● Reduces storage and computational requirements.
5. Challenges in Forwarding
A. Scalability
B. Performance
● Forwarding must be fast to ensure low latency.
● Hardware solutions like Content Addressable Memory (CAM) are often used.
C. Loop Avoidance
A. Cache-Based Forwarding
● Uses a cache to store frequently used routes, reducing the need for table lookups.
B. Hardware-Based Forwarding
● IPv6 forwarding is similar to IPv4 but simpler due to the absence of fragmentation at
intermediate routers.
● IPv6 uses hierarchical addressing to reduce routing table size.
Sample Questions
MCQs:
1. What is the primary technique used in Classless Inter-Domain Routing (CIDR) for
forwarding packets?
○ a) Default routing
○ b) Longest prefix matching
○ c) Flooding
○ d) Shortest prefix matching
(Answer: b)
2. Which component of the routing table specifies the next device to which a packet is
forwarded?
○ a) Metric
○ b) Netmask
○ c) Next hop
○ d) Interface
(Answer: c)
Subjective:
1. Explain the difference between routing and forwarding, with examples of how each is
implemented.
2. Describe the structure of a routing table and explain how it is used for packet forwarding.
3. Discuss the role of the longest prefix matching in forwarding IP packets in CIDR.
IP Header
The IP header is a critical component of the Internet Protocol (IP), containing essential control
information required for the successful delivery of packets across networks. The structure and
contents of the header vary between IPv4 and IPv6, with IPv4 having more fields and IPv6
designed for simplicity and efficiency.
1. IPv4 Header
The IPv4 header is typically 20 bytes long (without optional fields) and contains the following
fields:
Type of Service (ToS) 8 Indicates priority and QoS (now replaced by DSCP).
Total Length 16 Total size of the packet (header + data) in bytes (max:
65,535).
Time to Live (TTL) 8 Specifies the maximum number of hops a packet can
take before being discarded.
2. IPv6 Header
IPv6 simplifies the header for improved performance. It is fixed at 40 bytes and eliminates
optional fields like checksum and fragmentation, making routers more efficient.
QoS Support Limited (ToS field) Enhanced (Traffic Class, Flow Label)
Fragmentation occurs when a packet exceeds the MTU (Maximum Transmission Unit) of a
network.
Sample Questions
MCQs:
○ a) 20 bytes
○ b) 40 bytes
○ c) 60 bytes
○ d) Variable
(Answer: b)
3. Which field is present in IPv4 but not in IPv6?
○ a) Version
○ b) Traffic Class
○ c) Checksum
○ d) Flow Label
(Answer: c)
Subjective:
IPv6 Addressing
IPv6 (Internet Protocol version 6) was introduced to address the limitations of IPv4, primarily the
exhaustion of IPv4 addresses. It offers a significantly larger address space and enhanced
features for modern networks. Let’s break down the key concepts and details about IPv6
addressing.
1. Address Length:
5. Auto-Configuration:
○ Devices can automatically generate their own IPv6 addresses using a process
like SLAAC (Stateless Address Auto-Configuration).
1. Unicast:
1. Network Prefix: Specifies the network portion of the address, similar to IPv4’s network
ID.
2. Interface Identifier: The host portion, often derived from the device’s MAC address
using EUI-64 format.
1. CIDR Notation:
1. Fixed Header Size: 40 bytes (no optional fields in the base header).
2. No Checksum: Reduces processing overhead as the link-layer and transport-layer
protocols already provide error detection.
3. Extension Headers: Instead of optional fields, IPv6 uses extension headers for
additional functionality like routing, fragmentation, or security.
Advantages of IPv6 Addressing
2. Efficient Routing:
Simplified headers and hierarchical addressing improve routing performance.
3. Improved Security:
IPv6 natively supports IPsec (encryption and authentication).
4. Auto-Configuration:
Devices can configure their addresses automatically, reducing the need for DHCP.
5. Eliminates NAT:
With abundant addresses, IPv6 eliminates the need for Network Address Translation,
simplifying peer-to-peer communication.
Common Questions
○ a) 32 bits
○ b) 64 bits
○ c) 128 bits
○ d) 256 bits
(Answer: c)
2. What is the prefix for Link-Local addresses in IPv6?
○ a) 2000::/3
○ b) FC00::/7
○ c) FE80::/10
○ d) FF00::/8
(Answer: c)
3. Which IPv6 address type is used for communication within a local link?
○ a) Global Unicast
○ b) Link-Local
○ c) Anycast
○ d) Multicast
(Answer: b)
Subjective Questions
Subnetting and supernetting are critical concepts in IP addressing and network design. These
techniques allow for efficient use of IP address space and facilitate scalable network
management.
Subnetting
Subnetting is the process of dividing a larger network into smaller, more manageable
sub-networks (subnets). Each subnet operates as an independent network, though they remain
part of the original larger network.
Why Subnet?
1. Subnet Mask:
○ A 32-bit value that separates the network and host portions of an IP address.
○ Example:
■ Class C default mask: 255.255.255.0
■ In CIDR: /24 (24 bits for the network, 8 for hosts).
2. CIDR Notation:
○ Borrow bits from the host portion of the address to create additional subnets.
○ For 8 subnets, borrow 3 bits from the host portion.
3. Calculate the Subnet Mask:
○ Use the new subnet mask to divide the address space into blocks.
Example of Subnetting
○
2n≥Number of Subnets2^n ≥ \text{Number of Subnets} → 22=42^2 = 4. Borrow 2
bits.
2. New Subnet Mask:
○ Subnets:
■ 192.168.1.0 - 192.168.1.63
■ 192.168.1.64 - 192.168.1.127
■ 192.168.1.128 - 192.168.1.191
■ 192.168.1.192 - 192.168.1.255
Supernetting
Supernetting is the opposite of subnetting. It involves combining multiple smaller networks into
a larger one. Supernetting is typically used in routing to reduce the size of routing tables (route
aggregation).
Why Supernet?
1. Reduces Routing Table Size: Aggregates multiple routes into a single route.
2. Simplifies Network Management: Easier to manage fewer aggregated networks.
3. Improves Performance: Speeds up routing by reducing lookup time.
Example of Supernetting
Given Networks:
● 192.168.0.0/24
● 192.168.1.0/24
● Original masks: /24. Combine to use fewer bits for the network.
● New mask: /23 (extends the network portion).
Common Questions
Objective (MCQs):
○
a) Dividing a network into smaller parts.
○
b) Assigning multiple IPs to a single device.
○
c) Combining multiple networks into a larger one.
○
d) Reserving IPs for multicast.
(Answer: c)
3. How many subnets can be created from a /24 network by borrowing 3 bits?
○ a) 2
○ b) 4
○ c) 6
○ d) 8
(Answer: d)
Subjective:
MCQS
1. What is the main purpose of the network layer in the OSI model?
● a) /16
● b) /24
● c) /32
● d) /8
Answer: b) /24
● a) 172.16.0.1
● b) 192.168.255.255
● c) 10.0.0.1
● d) All of the above
● a) 14
● b) 16
● c) 30
● d) 32
Answer: a) 14
● a) 2
● b) 4
● c) 8
● d) 16
Answer: c) 8
6. Which of the following is the correct CIDR notation for the IP address
192.168.100.0 with the subnet mask 255.255.255.192?
● a) /25
● b) /26
● c) /27
● d) /28
Answer: b) /26
● a) Unicast
● b) Broadcast
● c) Multicast
● d) Anycast
Answer: c) Multicast
● a) 8
● b) 16
● c) 32
● d) 64
Answer: b) 16
10. What is the range of IP addresses for the subnet 192.168.1.0/26?
● a) 192.168.1.0 - 192.168.1.63
● b) 192.168.1.0 - 192.168.1.127
● c) 192.168.1.64 - 192.168.1.127
● d) 192.168.1.0 - 192.168.1.255
11. What is the maximum number of subnets that can be created from the
address 192.168.0.0/24 by borrowing 3 bits?
● a) 2
● b) 4
● c) 8
● d) 16
Answer: c) 8
● a) Class A
● b) Class B
● c) Class C
● d) Class D
Answer: a) Class A
● a) 255.255.255.0
● b) 255.255.255.192
● c) 255.255.255.252
● d) 255.255.255.255
Answer: c) 255.255.255.252
14. What is the CIDR notation for a subnet mask of 255.255.255.128?
● a) /25
● b) /26
● c) /27
● d) /28
Answer: a) /25
● a) 10.0.0.1
● b) 127.0.0.1
● c) 192.168.1.1
● d) 172.16.0.1
Answer: c) 192.168.1.1
● a) 255.255.0.0
● b) 255.255.255.0
● c) 255.0.0.0
● d) 255.255.255.255
Answer: b) 255.255.255.0
18. Which of the following is the correct IP address for a
192.168.10.64/28 subnet?
● a) 192.168.10.64 - 192.168.10.79
● b) 192.168.10.64 - 192.168.10.95
● c) 192.168.10.64 - 192.168.10.127
● d) 192.168.10.64 - 192.168.10.255
● a) /16
● b) /32
● c) /64
● d) /128
Answer: c) /64
● a) 192.168.1.0/24
● b) 192.168.0.0/24
● c) 192.168.1.0/28
● d) 192.168.1.0/25
Answer: a) 192.168.1.0/24
● a) 10.0.0.1 - 10.255.255.254
● b) 10.0.0.0 - 10.255.255.255
● c) 10.0.0.0 - 10.0.0.255
● d) 10.0.1.0 - 10.255.255.255
22. Which of the following is the correct formula to calculate the number of
subnets?
● a) 2^n - 2
● b) 2^n
● c) 2^2n-1
● d) 2^n + 1
Answer: b) 2^n
● a) 2
● b) 6
● c) 8
● d) 10
Answer: b) 6
● a) Unicast
● b) Anycast
● c) Multicast
● d) Broadcast
Answer: a) Unicast
Answer: b) `2001:0db8:85a3:0000:000
0:8a2e:0370:7334`
● a) Broadcast address
● b) Gateway address
● c) Network address
● d) Usable address
● a) 192.168.0.0/23
● b) 192.168.0.0/25
● c) 192.168.0.0/26
● d) 192.168.0.0/27
Answer: a) 192.168.0.0/23
● a) 11111111.11111111.11111111.11110000
● b) 11111111.11111111.11110000.00000000
● c) 11111111.11110000.00000000.00000000
● d) 11111111.00000000.00000000.00000000
Answer: a) 11111111.11111111.11111111.11110000
29. In a /30 subnet, how many usable IP addresses are there?
● a) 2
● b) 4
● c) 6
● d) 8
Answer: a) 2
● a) 192.168.5.0 - 192.168.5.31
● b) 192.168.5.0 - 192.168.5.63
● c) 192.168.5.0 - 192.168.5.255
● d) 192.168.5.0 - 192.168.5.127
These MCQs cover basic concepts related to IP addressing, subnetting, supernetting, and
related subnet mask operations.