0% found this document useful (0 votes)
49 views

Module 04 University Question Answers

Sem 5 qp

Uploaded by

sonkawadeyash.47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Module 04 University Question Answers

Sem 5 qp

Uploaded by

sonkawadeyash.47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Module 04

University questions and answers

Q.What is subnetting? Compare subnetting and supernetting

Subnetting is the process of dividing a larger IP network (or block) into smaller, more
manageable sub-networks, known as subnets. This allows for better utilization of IP addresses
and improved network performance by limiting broadcast domains, enhancing security, and
allowing more granular control over network traffic.
 Purpose: Efficient IP address management by breaking down large networks into
smaller sub-networks.
 How it works: It involves borrowing bits from the host portion of the IP address to
create additional network addresses (subnets). The more bits borrowed, the more
subnets created, but this reduces the number of available host addresses in each
subnet.
 Benefits:
o Reduces broadcast traffic, improving performance.
o Enhances security by isolating different segments of the network.
o Allows better IP address allocation.
Example: If you have a network with a Class C address of 192.168.1.0/24 (with 256
addresses), you can use subnetting to divide it into smaller subnets, such as 192.168.1.0/25
and 192.168.1.128/25, each with 128 addresses.
Supernetting:
Supernetting, or CIDR (Classless Inter-Domain Routing), is the opposite of subnetting.
Instead of dividing a network into smaller subnets, supernetting combines multiple smaller
networks (or subnets) into a single, larger network. Supernetting is used primarily for route
aggregation to reduce the number of routing table entries, improving the efficiency of routing
in large networks, such as the Internet.
 Purpose: Reduce the number of routing entries by combining multiple contiguous
networks.
 How it works: It involves using a shorter subnet mask to combine several adjacent
networks into one. This helps ISPs and large enterprises to manage their networks
efficiently and reduces the size of routing tables.
 Benefits:
o Reduces the size of routing tables, improving performance and scalability.
o Simplifies route management in large networks.
o Efficient use of IP addresses across larger blocks.
Example: If an ISP owns several adjacent Class C networks, such as 192.168.1.0/24,
192.168.2.0/24, and 192.168.3.0/24, they can advertise them as a single 192.168.0.0/22
network to reduce the number of entries in their routing tables.
Comparison: Subnetting vs Supernetting
Aspect Subnetting Supernetting (CIDR)
Dividing a larger network into Combining multiple networks into a
Definition
smaller sub-networks. larger one.
Improve network management, Simplify routing, reduce routing table
Purpose
reduce broadcast traffic. entries.
Borrow bits from the host part to Shorten subnet mask to combine
Technique
create subnets. networks.
Result Smaller, more manageable subnets. Larger, aggregated networks.
Within internal networks, for dividing Used by ISPs and in large-scale
Common Use
company LANs. Internet routing.
Impact on Increases the number of routes (more Decreases the number of routes
Routing subnets). (aggregated networks).
Better for internal traffic control and Better for large-scale routing and IP
Efficiency
security. management.
Q. Explain the count to infinity problem in detail.

The count-to-infinity problem is a well-known issue in distance-vector routing protocols,


such as the Routing Information Protocol (RIP). This problem occurs when routers in a
network continue to propagate incorrect routing information in a loop, causing them to
"count" toward an infinite distance (or metric) when trying to update the route to a failed or
unreachable destination.
Context:
In distance-vector routing protocols, each router periodically shares its routing table with its
neighbors. Routers calculate the best path to each destination based on the distance (or "cost")
reported by their neighbors. If a router detects that a destination is unreachable (because its
neighbor reports a failure), it updates its routing table and advertises the new information to
its neighbors.
However, the count-to-infinity problem arises when routers fail to quickly realize that a
destination is permanently unreachable due to the limitations of how these protocols
exchange information.
How the Count-to-Infinity Problem Occurs:
1. Initial State:
o Router A has a route to a destination (say, network X) through Router B, with
a metric (distance) of 1.
o Router B also has a route to network X, either directly or via other routers,
with a metric of 1.
2. Link Failure:
o The link to network X fails, making it unreachable.
o Router B realizes that network X is unreachable, and it updates its routing
table, setting the distance to X as "infinity" (unreachable) and advertises this
to Router A.
3. Incorrect Update:
o Before Router A receives this update, it still believes network X is reachable
via Router B (with a distance of 1).
o Router A advertises to Router B that it can still reach network X with a
distance of 2 (A -> B -> X).
o Router B receives this update and assumes Router A has a valid route to
network X with a distance of 2. Router B updates its table to reflect that it can
reach X via A with a distance of 3.
4. Propagation of Incorrect Information:
o This process continues, with the routers incrementally increasing the metric
(or distance) to X as they continue to incorrectly inform each other that
network X is still reachable. Each time, the distance increases by 1 (e.g., 4, 5,
6, etc.).
o This counting continues indefinitely until the routing protocol's maximum
metric (often set to 16 in RIP) is reached, at which point the destination is
declared unreachable.
Solutions to the Count-to-Infinity Problem:
Several mechanisms have been developed to mitigate the count-to-infinity problem:
1. Maximum Hop Count (Infinity Value):
o In RIP, the maximum hop count is set to 16, meaning a distance of 16 is
considered infinity, and the destination is declared unreachable. This prevents
routers from counting endlessly, but it still causes a delay in reaching this
conclusion.
2. Split Horizon:
o Split horizon prevents a router from advertising a route back to the neighbor
from which it learned that route. For example, if Router A learned about
network X from Router B, Router A will not advertise that it can reach X back
to Router B. This helps prevent routing loops.
3. Route Poisoning:
o When a router detects that a destination is unreachable, it advertises this route
with a distance of "infinity" to all its neighbors. This ensures that other routers
know the destination is unreachable as quickly as possible.
4. Hold-Down Timers:
o A router waits for a specific period (hold-down time) before accepting any
update about a failed route. This allows time for the network to stabilize after
a topology change.
5. Triggered Updates:
o Instead of waiting for the regular update interval, routers send an immediate
(triggered) update when they detect a significant change in their routing table,
such as a failed route. This speeds up convergence and helps prevent routing
loops

Q. An organization has granted a block of addresses starting with


105.8.71.0/24,
organization wanted to distribute this block to 11 subnets as follows
1. First Group has 3 medium size businesses, each need 16 addresses
2. The second Group has 4 medium size businesses, each need 32
addresses.
3. The third Group has 4 households, each need 4 addresses. Design the
sub blocks and give slash notation for each subblock. Find how many
addresses have been left after this allocation.

To solve this problem, we will divide the IP block 105.8.71.0/24 into subnets for the
organization's needs. The block has 256 addresses (2^8 = 256) since it is a /24 network. We
need to design sub-blocks to satisfy the given requirements, starting with the largest groups to
the smallest, ensuring efficient allocation with minimal wasted IP addresses.
1. First Group (3 Medium Businesses - Each Needs 16 Addresses):
Each business requires 16 IP addresses. To accommodate 16 addresses, we need a subnet
with a block size of 16. For 16 addresses, the subnet mask will be /28 (since 2^(32-28) = 16
addresses).
 1st Business: 105.8.71.0/28 (Addresses: 105.8.71.0 - 105.8.71.15)
 2nd Business: 105.8.71.16/28 (Addresses: 105.8.71.16 - 105.8.71.31)
 3rd Business: 105.8.71.32/28 (Addresses: 105.8.71.32 - 105.8.71.47)
Total addresses used by this group: 48 (3 subnets of 16 addresses each).
2. Second Group (4 Medium Businesses - Each Needs 32 Addresses):
Each business needs 32 IP addresses. To accommodate 32 addresses, we need a subnet with
a block size of 32. For 32 addresses, the subnet mask will be /27 (since 2^(32-27) = 32
addresses).
 1st Business: 105.8.71.48/27 (Addresses: 105.8.71.48 - 105.8.71.79)
 2nd Business: 105.8.71.80/27 (Addresses: 105.8.71.80 - 105.8.71.111)
 3rd Business: 105.8.71.112/27 (Addresses: 105.8.71.112 - 105.8.71.143)
 4th Business: 105.8.71.144/27 (Addresses: 105.8.71.144 - 105.8.71.175)
Total addresses used by this group: 128 (4 subnets of 32 addresses each).
3. Third Group (4 Households - Each Needs 4 Addresses):
Each household needs 4 IP addresses. To accommodate 4 addresses, we need a subnet with a
block size of 4. For 4 addresses, the subnet mask will be /30 (since 2^(32-30) = 4 addresses).
 1st Household: 105.8.71.176/30 (Addresses: 105.8.71.176 - 105.8.71.179)
 2nd Household: 105.8.71.180/30 (Addresses: 105.8.71.180 - 105.8.71.183)
 3rd Household: 105.8.71.184/30 (Addresses: 105.8.71.184 - 105.8.71.187)
 4th Household: 105.8.71.188/30 (Addresses: 105.8.71.188 - 105.8.71.191)
Total addresses used by this group: 16 (4 subnets of 4 addresses each).
Total Addresses Used:
 First Group: 48 addresses (3 subnets of 16 addresses each)
 Second Group: 128 addresses (4 subnets of 32 addresses each)
 Third Group: 16 addresses (4 subnets of 4 addresses each)
Total Addresses Allocated:
Total used = 48 + 128 + 16 = 192 addresses
Remaining Addresses:
The original block (105.8.71.0/24) contains 256 addresses. After allocating 192 addresses,
the number of addresses left is:
 Remaining addresses = 256 - 192 = 64 addresses
Q. A large number of consecutive IP address are available starting at
198.16.0.0. Suppose that four organizations, A, B, C, and D, request 4000,
2000, 4000, and 8000 addresses, respectively, and in that order. For each of
these, give the first IP address assigned, the last IP address assigned, and
the mask in the w.x.y.z/s notation

We are given a block of consecutive IP addresses starting at 198.16.0.0, and four


organizations (A, B, C, and D) request different numbers of addresses. The task is to allocate
the appropriate number of addresses to each organization, making sure to use the correct
subnet mask for each block.

The number of addresses requested by each organization are as follows:

 Organization A: 4000 addresses

 Organization B: 2000 addresses

 Organization C: 4000 addresses

 Organization D: 8000 addresses

Step 1: Determine the Subnet Size and Mask

The number of addresses requested must be rounded up to the nearest power of 2 because
subnetting works with powers of 2. For each organization, we'll find the smallest power of 2
that can accommodate the requested addresses, then calculate the corresponding subnet mask.

 Organization A: Needs 4000 addresses.

o The smallest power of 2 greater than or equal to 4000 is 4096 (2^12).

o Subnet mask: /20 (since 2^(32 - 20) = 4096).

 Organization B: Needs 2000 addresses.

o The smallest power of 2 greater than or equal to 2000 is 2048 (2^11).

o Subnet mask: /21 (since 2^(32 - 21) = 2048).

 Organization C: Needs 4000 addresses.

o Same as Organization A: 4096 addresses.


o Subnet mask: /20.

 Organization D: Needs 8000 addresses.

o The smallest power of 2 greater than or equal to 8000 is 8192 (2^13).

o Subnet mask: /19 (since 2^(32 - 19) = 8192).

Step 2: Assign IP Ranges

We will now assign IP ranges to each organization, starting from 198.16.0.0 and working
sequentially.

1. Organization A (4000 addresses):

o First address: 198.16.0.0

o Number of addresses: 4096

o Last address: 198.16.15.255

o Subnet mask: /20

2. Organization B (2000 addresses):

o First address: 198.16.16.0 (Next available after A’s allocation)

o Number of addresses: 2048

o Last address: 198.16.23.255

o Subnet mask: /21

3. Organization C (4000 addresses):

o First address: 198.16.24.0 (Next available after B’s allocation)

o Number of addresses: 4096

o Last address: 198.16.39.255

o Subnet mask: /20

4. Organization D (8000 addresses):

o First address: 198.16.40.0 (Next available after C’s allocation)

o Number of addresses: 8192

o Last address: 198.16.71.255


o Subnet mask: /19

Final Allocation Summary:

Organization First Address Last Address Number of Addresses Subnet Mask

A 198.16.0.0 198.16.15.255 4096 /20

B 198.16.16.0 198.16.23.255 2048 /21

C 198.16.24.0 198.16.39.255 4096 /20

D 198.16.40.0 198.16.71.255 8192 /19


Q. Explain classful IP addressing scheme in detail? List the advantages and
disadvantages of classless IP addressing scheme.

Classful IP Addressing Scheme


Classful IP addressing was the original system used for allocating IP addresses in IPv4,
developed in the early days of the internet. The primary goal of classful addressing was to
simplify the process of routing by dividing the IP address space into fixed-size blocks based
on the first few bits of the IP address. In this system, IP addresses were categorized into
different classes, each with a predetermined size and structure.
Structure of an IP Address:
An IP address consists of 32 bits and is written in dotted-decimal notation, split into four 8-
bit octets (e.g., 192.168.1.1). The 32 bits are divided into two parts:
1. Network ID: Identifies the network to which the host belongs.
2. Host ID: Identifies the specific device (host) on that network.
In classful addressing, the network and host portions of the address were determined based on
the class of the address. There are five primary address classes, denoted as Class A, Class B,
Class C, Class D, and Class E.
IP Address Classes:
1. Class A:
o Range: 1.0.0.0 to 126.255.255.255
o Network Size: Very large networks.
o Structure:
 First 8 bits for the Network ID.
 Remaining 24 bits for the Host ID.
o Number of Networks: 2^7 = 128 networks.
o Hosts per Network: 2^24 - 2 = 16,777,214 hosts (the two addresses reserved
are for the network address and broadcast address).
2. Class B:
o Range: 128.0.0.0 to 191.255.255.255
o Network Size: Medium to large networks.
o Structure:
 First 16 bits for the Network ID.
 Remaining 16 bits for the Host ID.
o Number of Networks: 2^14 = 16,384 networks.
o Hosts per Network: 2^16 - 2 = 65,534 hosts.
3. Class C:
o Range: 192.0.0.0 to 223.255.255.255
o Network Size: Small networks.
o Structure:
 First 24 bits for the Network ID.
 Remaining 8 bits for the Host ID.
o Number of Networks: 2^21 = 2,097,152 networks.
o Hosts per Network: 2^8 - 2 = 254 hosts.
4. Class D:
o Range: 224.0.0.0 to 239.255.255.255
o Purpose: Reserved for multicasting (not used for traditional unicast
addressing).
o Structure: Class D addresses do not have separate Network ID and Host ID
portions.
5. Class E:
o Range: 240.0.0.0 to 255.255.255.255
o Purpose: Reserved for experimental purposes.
Limitations of Classful Addressing:
 Rigid Structure: The fixed size of the network and host portions in Class A, B, and C
addresses often led to inefficient use of IP address space. For instance, an organization
needing 1,000 IP addresses would have to use a Class B address (with 65,534 possible
hosts), resulting in significant wastage.
 Depletion of IP Addresses: Classful addressing accelerated the depletion of available
IP addresses, particularly Class B, which offered a balance between network size and
number of hosts.
 No Flexibility: The lack of flexibility in defining the subnet mask made it difficult to
allocate just the right number of addresses based on the organization's needs.
These limitations led to the development of Classless Inter-Domain Routing (CIDR),
which is more flexible and scalable.

Classless IP Addressing Scheme (CIDR)


Classless Inter-Domain Routing (CIDR) is an alternative to the classful addressing scheme
that eliminates the rigid class structure and introduces flexible subnetting. It allows for more
efficient allocation of IP addresses by enabling the use of variable-length subnet masks
(VLSM), where the network portion of the address can be defined to any number of bits, not
just those fixed by Class A, B, or C.
How CIDR Works:
 CIDR Notation: In CIDR, an IP address is followed by a forward slash (/) and a
number that indicates the length of the network prefix (e.g., 192.168.0.0/24). This
notation indicates that the first 24 bits of the address represent the network, while the
remaining 8 bits are used for hosts.
 Variable Length Subnet Mask (VLSM): CIDR allows for networks of varying sizes
by allowing subnet masks of arbitrary lengths (e.g., /18, /26, etc.). This allows for
precise allocation of IP addresses based on the needs of the network, avoiding
wastage.
Advantages of Classless IP Addressing (CIDR):
1. Efficient Use of IP Addresses:
o CIDR allows for the allocation of IP addresses based on actual need, not based
on rigid classes. This greatly reduces the wastage of IP addresses, especially
for small and medium-sized networks.
2. Route Aggregation:
o CIDR enables route summarization, which reduces the size of routing tables.
Multiple IP addresses can be represented with a single CIDR notation,
simplifying the management of routing information. For example, instead of
advertising four individual Class C networks (192.168.0.0/24, 192.168.1.0/24,
192.168.2.0/24, 192.168.3.0/24), you can aggregate them into one single
route: 192.168.0.0/22.
3. Supports Subnetting and Supernetting:
o CIDR supports both subnetting (breaking larger networks into smaller
subnets) and supernetting (combining smaller networks into larger
aggregates), giving administrators the flexibility to design network sizes based
on actual needs.
4. Prevents IPv4 Exhaustion:
o By allocating IP addresses more efficiently, CIDR helps slow down the
depletion of the IPv4 address space. It allows for more effective use of the
available address pool by reducing wastage.
5. Flexibility in Network Design:
o CIDR provides flexibility by allowing network administrators to create
subnets of any size, tailored to the specific requirements of different
departments, branches, or clients within an organization.

Disadvantages of Classless IP Addressing (CIDR):


1. Complexity in Network Design:
o CIDR requires more planning and careful design. The flexibility offered by
CIDR can be difficult for network administrators to manage, as they need to
calculate the appropriate subnet mask for each block of addresses.
2. Increased Processing in Routing:
o The introduction of variable-length subnet masks means that routers must
process and store more detailed routing information, increasing the complexity
of routing algorithms and potentially slowing down packet forwarding
decisions in some networks.
3. Potential for Fragmentation:
o While CIDR helps address wastage, it can lead to fragmentation of the IP
address space. If not managed properly, IP blocks might be allocated in a way
that makes it difficult to aggregate routes efficiently.
4. Non-Compatibility with Older Systems:
o Some older systems and routing protocols that were designed for classful
addressing may not fully support CIDR, requiring upgrades or replacements to
work with modern IP addressing schemes.
Q. Explain the link state routing algorithm with example?

The Link State Routing Algorithm is a dynamic routing algorithm used by routers to build
the shortest path to every destination in a network. The main idea of link-state routing is that
every router has a complete view of the network topology, and based on that view, each
router independently calculates the best path to each destination using Dijkstra's shortest path
algorithm.
How Link State Routing Works:
1. Neighbor Discovery:
o Each router identifies and communicates with its immediate neighbors (routers
directly connected to it) and determines the cost (metric) to each neighbor
(e.g., delay, bandwidth, or hop count).
2. Flooding of Link State Information:
o Each router creates a Link State Packet (LSP) containing the state of its links
(cost and connection to neighbors) and floods this information to all other
routers in the network. The flooding ensures that every router has a copy of
the entire network's link-state information.
3. Building a Complete Network Topology:
o After receiving all the LSPs from other routers, each router builds a Link
State Database (LSDB). The LSDB is essentially a map of the network
showing all routers and the links between them, along with the associated
costs.
4. Running Dijkstra's Algorithm:
o Once the router has the complete topology, it runs Dijkstra's algorithm to
compute the shortest path from itself to every other router in the network. The
result of this computation is a routing table that tells the router the next hop
to use for every destination.
5. Routing Table Update:
o Each router uses the result of Dijkstra's algorithm to update its routing table.
The routing table will have entries like "Destination X: Next hop Y,"
indicating the next router to which the packet should be forwarded to reach the
destination via the shortest path.
Example of Link State Routing:
Let’s consider a simple network with 5 routers (A, B, C, D, and E) and the following link
costs between them:
 A is connected to B with a cost of 2, and to C with a cost of 1.
 B is connected to C with a cost of 2, and to D with a cost of 3.
 C is connected to D with a cost of 1, and to E with a cost of 4.
 D is connected to E with a cost of 1.

(2)
A ------- B
| /|
(1)| (2) |(3)
| / |
C ------- D
| /|
(4)| (1) |(1)
| / |
E ---------

Step-by-Step Process:
1. Neighbor Discovery: Each router first identifies its directly connected neighbors and
the associated link costs. For example:
o Router A knows it’s connected to B with a cost of 2 and to C with a cost of 1.
o Router B knows it’s connected to A (cost 2), C (cost 2), and D (cost 3).
o Router C knows it’s connected to A (cost 1), B (cost 2), D (cost 1), and E (cost
4), and so on for all other routers.
2. Flooding of Link State Information:
o Each router creates a Link State Packet (LSP) and sends it to all other routers
in the network. For example:
 A sends its LSP to B and C, stating that it has links to B (cost 2) and C
(cost 1).
 B sends its LSP to A, C, and D, stating its links to A (cost 2), C (cost
2), and D (cost 3).
 This process continues until every router has received LSPs from every
other router, resulting in each router having the same view of the
network topology.
3. Building the Link State Database (LSDB):
o Once the LSPs are flooded, each router constructs a map (LSDB) of the entire
network. For example, Router A knows:
 Link A-B: Cost 2
 Link A-C: Cost 1
 Link B-C: Cost 2
 Link B-D: Cost 3
 Link C-D: Cost 1
 Link C-E: Cost 4
 Link D-E: Cost 1
4. Running Dijkstra’s Algorithm:
o Each router runs Dijkstra’s shortest path algorithm on its LSDB to calculate
the shortest paths. Let’s run the algorithm on Router A:
o Initially, Router A knows its own distance (cost 0) and assumes all other
routers are infinitely far away.
o Router A’s direct neighbors are B (cost 2) and C (cost 1).
o Among the neighbors, C has the shortest distance from A (cost 1), so A marks
C as the next hop to C and explores C’s neighbors (B, D, and E).
 The cost from A to D through C is 1 (A → C) + 1 (C → D) = 2.
 The cost from A to E through C is 1 (A → C) + 4 (C → E) = 5.
o Next, Router A considers B. The cost from A to B is 2 directly. The cost from
A to B through C is 1 (A → C) + 2 (C → B) = 3, so Router A uses the direct
link to B.
o After computing these values, the final routing table for Router A would look
like:
 Destination B: Next hop B (cost 2)
 Destination C: Next hop C (cost 1)
 Destination D: Next hop C (cost 2)
 Destination E: Next hop C (cost 5)
The same process is repeated by all other routers, resulting in each router having its own
routing table that defines the next hop and cost for every destination.

5. Routing Table Update:


o After running Dijkstra’s algorithm, each router updates its routing table. For
example, Router A knows that to reach D, the shortest path is via C, and to
reach E, the shortest path is also via C.
Advantages of Link State Routing:
1. Accurate and Efficient Routing:
o Each router has a complete view of the network, allowing it to make accurate
routing decisions based on the shortest path.
2. Faster Convergence:
o Link state protocols converge faster than distance vector protocols because
each router can compute its routing table independently without waiting for
periodic updates from neighbors.
3. Less Vulnerable to Routing Loops:
o Since all routers have a consistent view of the network topology, the risk of
routing loops is reduced.
4. Scalable for Large Networks:
o Link-state routing can handle larger networks better than distance-vector
algorithms because it reduces the amount of routing traffic once the network
topology is stable.
Disadvantages of Link State Routing:
1. High Memory and CPU Usage:
o Routers must store the entire network topology and compute the shortest path
using Dijkstra’s algorithm, which requires more memory and processing
power compared to distance vector routing protocols.
2. Complexity:
o The link-state algorithm is more complex to implement and configure
compared to simpler routing protocols like RIP (Routing Information
Protocol).
3. Initial Overhead:
o When a router joins the network or when there is a topology change, the initial
LSP flooding can cause significant overhead as all routers must process the
new information and recompute their routing tables.

Q. Explain IPv4 header format with diagram.

The IPv4 header is a crucial component of the Internet Protocol (IP) that carries important
information about how a packet should be routed across networks. It contains various fields
that provide details about the packet, such as the source and destination addresses, packet
length, fragmentation information, and more.
Below is a breakdown of the IPv4 header along with a diagram that illustrates its structure:

1. Version (4 bits):
o Indicates the IP version being used. In the case of IPv4, the value is 4.
2. Internet Header Length (IHL) (4 bits):
o Specifies the length of the header in 32-bit words (multiples of 4 bytes). The
minimum value is 5 (indicating a 20-byte header without options), and the
maximum value is 15 (60 bytes if options are included).
3. Type of Service (TOS) (8 bits):
o Specifies the priority or quality of service desired for the packet (e.g., delay,
throughput, reliability). This field was later redefined to support the
Differentiated Services (DiffServ) field and Explicit Congestion Notification
(ECN).
4. Total Length (16 bits):
o Specifies the total length of the entire IP packet, including both the header and
the data. The minimum size is 20 bytes (for the header alone), and the
maximum size is 65,535 bytes.
5. Identification (16 bits):
o Used for uniquely identifying fragments of a single IP datagram. When a
packet is fragmented, each fragment carries the same identification number to
be reassembled correctly.
6. Flags (3 bits):
o Controls fragmentation. The bits are:
 Reserved (1 bit): Reserved for future use; always set to 0.
 DF (Don't Fragment): If set, it instructs the router not to fragment the
packet.
 MF (More Fragments): If set, it indicates that more fragments follow
this one.
7. Fragment Offset (13 bits):
o Indicates the position of the fragment in the original packet. This field allows
fragments to be reassembled in the correct order at the destination.
8. Time to Live (TTL) (8 bits):
o Limits the lifespan of a packet. This field is decremented by 1 each time the
packet passes through a router, and when it reaches 0, the packet is discarded.
This prevents packets from circulating indefinitely in the network.
9. Protocol (8 bits):
o Indicates the protocol used in the data portion of the packet. Examples
include:
 1 for ICMP (Internet Control Message Protocol)
 6 for TCP (Transmission Control Protocol)
 17 for UDP (User Datagram Protocol)
10. Header Checksum (16 bits):
 Used for error-checking the header. If the checksum doesn't match the computed
checksum at the receiving end, the packet is discarded. Note that this checksum only
applies to the header, not the data.
11. Source Address (32 bits):
 The IP address of the sender (source) of the packet.
12. Destination Address (32 bits):
 The IP address of the intended recipient (destination) of the packet.
13. Options (variable length):
 This field is optional and is used for testing, debugging, and other purposes. It
includes options such as source routing, record route, and timestamp. If the options
field is used, the header length increases beyond the minimum of 20 bytes.
14. Padding (variable length):
 Padding bits are added to ensure that the header ends on a 32-bit boundary (a multiple
of 4 bytes). This field ensures alignment when options are present.
Q. Explain Classful and Classless IPv4 addressing.

IP addressing is the process of assigning a unique numerical identifier to each device on a


network. IPv4 addresses are 32-bit binary numbers typically represented in decimal format as
four groups of octets (e.g., 192.168.1.1). There are two main types of addressing systems for
IPv4: Classful and Classless addressing. Each system has its own rules for how IP addresses
are assigned and used.

1. Classful IP Addressing
Classful IP addressing was the original IP addressing system defined by the IETF (Internet
Engineering Task Force) in the early days of the Internet. In this system, IP addresses were
divided into 5 classes: A, B, C, D, and E. Each class had a predefined range of addresses and
a fixed subnet mask.
IP Address Classes:
1. Class A (1.0.0.0 to 127.255.255.255):
o Network size: Designed for very large networks.
o Address range: From 1.0.0.0 to 127.255.255.255.
o Default subnet mask: 255.0.0.0 (/8)
o First octet range: 1 to 127
o Available hosts: Over 16 million hosts per network (2²⁴ - 2).
2. Class B (128.0.0.0 to 191.255.255.255):
o Network size: For medium to large-sized networks.
o Address range: From 128.0.0.0 to 191.255.255.255.
o Default subnet mask: 255.255.0.0 (/16)
o First octet range: 128 to 191
o Available hosts: 65,534 hosts per network (2¹⁶ - 2).
3. Class C (192.0.0.0 to 223.255.255.255):
o Network size: For small networks.
o Address range: From 192.0.0.0 to 223.255.255.255.
o Default subnet mask: 255.255.255.0 (/24)
o First octet range: 192 to 223
o Available hosts: 254 hosts per network (2⁸ - 2).
4. Class D (224.0.0.0 to 239.255.255.255):
o Purpose: Reserved for multicasting (used for sending a packet to multiple
destinations).
o Address range: From 224.0.0.0 to 239.255.255.255.
o No subnet mask: Multicast addresses are not used for standard host
addressing.
5. Class E (240.0.0.0 to 255.255.255.255):
o Purpose: Reserved for experimental use.
o Address range: From 240.0.0.0 to 255.255.255.255.
o No subnet mask: Not used for general Internet traffic.
Example:
A typical Class B address might be 130.50.0.0 with a default subnet mask of 255.255.0.0
(/16). This means that the first two octets (130.50) represent the network part, while the last
two octets represent the host part.
Drawbacks of Classful Addressing:
1. Inefficient Address Allocation:
o Classful addressing leads to wastage of IP addresses. For example, a Class A
network can support over 16 million hosts, but even small networks were
assigned Class A addresses, leading to under-utilization.
2. Rigid Subnet Masking:
o Classful addressing doesn't allow flexible subnetting. Networks are limited by
the default subnet masks (e.g., Class A is always /8, Class B is /16, etc.).
3. Limited Number of Networks:
o With predefined network sizes, many addresses were reserved for large
networks, reducing the number of smaller networks that could be supported.

2. Classless IP Addressing (CIDR)


To overcome the inefficiencies of Classful addressing, a more flexible system called
Classless Inter-Domain Routing (CIDR) was introduced in 1993. CIDR allows IP addresses
to be assigned more efficiently by removing the fixed class boundaries and allowing for
variable-length subnet masks (VLSM).
Key Features of Classless Addressing:
1. Flexible Subnet Masks:
o Instead of using predefined classes (A, B, C), CIDR uses variable-length
subnet masks (VLSM), which allows for more granular allocation of IP
address blocks.
o For example, an IP address might be written as 192.168.10.0/28. The /28
indicates that the first 28 bits are the network part, and the remaining 4 bits
are for hosts.
2. Efficient Address Allocation:
o CIDR allows for more efficient use of IP addresses. ISPs (Internet Service
Providers) can allocate just the right number of addresses needed for a
network.
o For example, instead of giving a company a whole Class C network (/24), an
ISP could allocate a smaller block of addresses such as /26 (which provides 64
IP addresses).
3. Address Aggregation:
o CIDR allows the aggregation of multiple IP address ranges into a single, larger
block called supernetting. This reduces the number of routing table entries in
routers, improving the efficiency of Internet backbone routing.
o For example, multiple Class C addresses (e.g., 192.168.0.0/24,
192.168.1.0/24) can be combined into one supernet, such as 192.168.0.0/23.
CIDR Notation:
CIDR uses the format IP address/Prefix length, where the prefix length specifies the number
of bits used for the network portion. The rest of the bits represent the host portion.
 Example: 192.168.10.0/26
o Here, the /26 means that the first 26 bits are used for the network, and the
remaining 6 bits are for host addresses.
o This network has 2^6 - 2 = 62 usable host addresses (the -2 accounts for the
network and broadcast addresses).
Example:
Let’s say you are given the IP address 192.168.10.0/28 (a classless address). This means that
28 bits are reserved for the network part, and only 4 bits are left for the host part. In this case,
you can have a total of 2^4 = 16 addresses, but only 14 are usable for hosts (because the first
address is the network address, and the last is the broadcast address).
Benefits of Classless Addressing:
1. Efficient Use of IP Addresses:
o Classless addressing helps avoid wastage by allowing networks to be assigned
blocks of addresses that closely match their size needs.
2. Scalability:
o CIDR allows for a more scalable Internet by reducing the size of routing tables
and allowing flexible allocation of IP address blocks.
3. Better Support for VLSM:
o Classless addressing allows network administrators to subdivide an IP address
space into subnets of varying sizes (VLSM), which is useful in large, complex
networks.

Comparison of Classful and Classless Addressing


Feature Classful Addressing Classless Addressing (CIDR)
Divided into fixed classes (A, B, No fixed classes; addresses
Address Range
C, D, E) assigned in blocks
Fixed for each class (e.g., /8 for Variable-Length Subnet Mask
Subnet Mask
Class A) (VLSM)
Address Allocation Efficient; addresses assigned based
Inefficient; leads to wastage
Efficiency on need
Larger; more entries due to class Smaller; CIDR allows route
Routing Table Size
boundaries aggregation
Rigid; limited by predefined Flexible; allows customized
Flexibility
classes subnetting
Example Address 192.168.1.0/24 (Class C) 192.168.1.0/26
Use of VLSM Not supported Supported

Advantages of Classless Addressing (CIDR):


1. More Efficient Addressing: Classless addressing reduces IP address waste by
allowing precise address allocation.
2. Scalable: Helps manage larger and more complex networks due to the use of variable-
length subnet masks.
3. Routing Optimization: CIDR supports route aggregation, reducing the size of
routing tables, which is essential for the scalability of the Internet.
Disadvantages of Classless Addressing (CIDR):
1. Complexity: Managing classless IP addresses and calculating subnets can be more
complex than classful addressing.
2. Fragmentation: Because address blocks are not constrained by classes, fragmentation
may occur, making routing less straightforward.

Q. Explain shortest path ( Dijkastra’s Algorithm) routing algorithm.

Dijkstra's Algorithm is a well-known algorithm for finding the shortest path between nodes in
a graph, which can represent networks such as computer or road networks. In the context of
networking, it is used in link-state routing protocols like OSPF (Open Shortest Path First) to
determine the best path for data to travel through a network.
How Dijkstra's Algorithm Works:
Dijkstra's algorithm finds the shortest path from a source node to all other nodes in a
weighted graph. The weights represent the cost of traversing between nodes (e.g., the
distance, delay, or bandwidth between network routers).
Steps of Dijkstra's Algorithm:
1. Initialization:
o Start with a source node, and mark the distance to it as 0 (because the distance
to itself is zero).
o Mark the distance to all other nodes as infinity (since the shortest distance to
those nodes is initially unknown).
o Create a set of unvisited nodes consisting of all the nodes in the graph.
2. Exploration:
o At each step, choose the node with the smallest tentative distance from the
unvisited set. Let's call this node the current node.
o For each neighbor of the current node that has not been visited, calculate the
tentative distance through the current node. If this distance is smaller than the
previously recorded tentative distance for that neighbor, update the distance.
3. Mark Node as Visited:
o Once a node's shortest distance has been determined (meaning its tentative
distance is finalized and it will no longer change), mark it as visited. A node is
visited when the shortest path to it is known.
4. Repeat:
o Repeat the process for all unvisited nodes. Select the next node with the
smallest tentative distance, explore its neighbors, and update distances until all
nodes have been visited or the destination node is reached.
5. Termination:
o The algorithm ends when all nodes have been visited, or the shortest path to
the destination node has been found (if searching for a single path).
Example of Dijkstra’s Algorithm:
Let's say we have a simple network (graph) where nodes represent routers and the edges
represent the cost of sending data between them:

Step-by-Step Execution:
1. Initialization:
o Start from node A. Set the distance to A as 0, and the distance to all other
nodes as infinity.
A = 0, B = ∞, C = ∞, D = ∞, E = ∞, F = ∞

2. Visit Node A:
 The neighbors of A are B and D.
 Distance to B through A = 0 + 2 = 2 (update B's distance).
 Distance to D through A = 0 + 1 = 1 (update D's distance).

A = 0, B = 2, C = ∞, D = 1, E = ∞, F = ∞

3. Visit Node D (smallest distance):


 The only neighbor of D is E.
 Distance to E through D = 1 + 6 = 7 (update E's distance).

A = 0, B = 2, C = ∞, D = 1, E = 7, F = ∞

4 . Visit Node B (next smallest distance):


 The neighbors of B are A, C, and E.
 Distance to C through B = 2 + 5 = 7 (update C's distance).
 Distance to E through B = 2 + 3 = 5 (update E's distance to 5).
A = 0, B = 2, C = 7, D = 1, E = 5, F = ∞

5 . Visit Node E (smallest distance):


 The neighbors of E are B, D, and F.
 Distance to F through E = 5 + 2 = 7 (update F's distance).

A = 0, B = 2, C = 7, D = 1, E = 5, F = 7

6. Visit Node C (smallest distance):


 The neighbors of C are B and F.

 Distance to F through C = 7 + 2 = 9 (which is greater than the current distance to F, so


no update is made).
A = 0, B = 2, C = 7, D = 1, E = 5, F = 7

7. Visit Node F (smallest distance):


o No further updates are made as there are no unvisited neighbors.
At the end of the algorithm, the shortest distances from node A are:
 A=0
 B=2
 C=7
 D=1
 E=5
 F=7
Final Shortest Paths:
 A to B: Cost = 2
 A to C: Cost = 7
 A to D: Cost = 1
 A to E: Cost = 5
 A to F: Cost = 7

Q. Explain ARP protocol in detail.

Address Resolution Protocol (ARP)


ARP (Address Resolution Protocol) is a network layer protocol used to map or translate IP
addresses (a Layer 3 address) to MAC addresses (a Layer 2 address). It plays a critical role in
enabling communication between devices in a local network. Since devices communicate
using MAC addresses at the data link layer (Layer 2), ARP is needed to discover the MAC
address corresponding to an IP address.
ARP is primarily used in IPv4 networks (in IPv6, a similar protocol called Neighbor
Discovery Protocol (NDP) is used). ARP operates only within a local network and cannot
resolve addresses across routers or networks.
How ARP Works
When a device needs to send a packet to another device on the same local network, it must
encapsulate the IP packet inside a data link layer frame (such as Ethernet). To do this, it needs
to know the MAC address of the destination device, which corresponds to the device’s IP
address.
Here’s how the ARP process works:
1. ARP Request:
o The source device (let's say Host A) knows the IP address of the destination
device (Host B) but does not know its MAC address.
o Host A broadcasts an ARP Request frame to the entire local network (Layer 2
broadcast). The ARP request contains the following information:
 "Who has IP address X.X.X.X? Tell me your MAC address."
o Since it’s a broadcast message, all devices on the local network receive this
request.
2. ARP Reply:
o The device with the corresponding IP address (Host B in this case) recognizes
that the request is for its own IP address and responds with an ARP Reply.
o The ARP reply contains:
 "I am IP address X.X.X.X. My MAC address is Y:Y:Y
."
o Host B sends the ARP reply directly to Host A (unicast).
3. Caching:
o Upon receiving the ARP reply, Host A caches (stores) the IP-to-MAC address
mapping in its ARP cache. This cache is temporary, and the entries usually
expire after a certain period (e.g., 2 to 10 minutes).
o Host A can now send its data packet to Host B using the correct MAC address.
4. Data Transmission:
o Host A encapsulates the IP packet inside an Ethernet frame and sends it to the
MAC address of Host B.
This process allows devices to communicate on a local network using both IP and MAC
addresses.
ARP Message Format
An ARP message consists of several fields that help in resolving the address. Here’s the
structure of an ARP message:
1. Hardware Type: This field specifies the network type. For Ethernet, it is set to 1.
2. Protocol Type: This field indicates the protocol being mapped, usually IPv4 (value:
0x0800).
3. Hardware Address Length: The length of the MAC address, which is 6 for Ethernet (6
bytes).
4. Protocol Address Length: The length of the IP address, which is 4 for IPv4 (4 bytes).
5. Operation: Indicates whether the message is a request (1) or a reply (2).
6. Sender Hardware Address: The MAC address of the sender.
7. Sender Protocol Address: The IP address of the sender.
8. Target Hardware Address: The MAC address of the intended recipient. In ARP
requests, this is typically left blank (0s) because the MAC address is what needs to be
discovered.
9. Target Protocol Address: The IP address of the intended recipient.
Example ARP Process
Let’s walk through an example:
 Host A wants to send data to Host B.
 Host A has the IP address of Host B (let's say 192.168.1.20), but it does not know the
MAC address of Host B.
 Host A sends an ARP Request: "Who has IP address 192.168.1.20?"
 Host B, with IP address 192.168.1.20, responds with its MAC address, let's say
00:1A:2B:3C:4D:5E.
 Host A stores this IP-to-MAC mapping in its ARP cache and proceeds to send the data
to Host B using its MAC address.
ARP Cache
The ARP cache is a table stored in a device that contains mappings of IP addresses to MAC
addresses. When a device learns the MAC address corresponding to an IP address through
ARP, it stores this information in the ARP cache to avoid sending ARP requests repeatedly for
the same IP address.
 ARP Cache Timeout: The entries in the ARP cache are not permanent. They expire
after a certain period (usually a few minutes). If a cached entry expires, the device
will need to send another ARP request the next time it needs to send data to that IP
address.
ARP in Different Scenarios
1. ARP for Hosts on the Same Network:
o When two devices (hosts or routers) are on the same local network, ARP is
used to resolve the IP address of the destination to its corresponding MAC
address.
2. ARP for Hosts on Different Networks:
o When a host wants to send data to a device on another network, ARP is still
used, but it resolves the IP address of the default gateway (router). The host
sends the packet to the router, which then forwards the packet to the next hop
in the network. At each hop, ARP is used to resolve MAC addresses of the
next device in the path.
Types of ARP
There are several types of ARP messages used for different purposes:
1. ARP Request: Sent by a host to request the MAC address of a device with a known IP
address.
2. ARP Reply: Sent by the device with the requested IP address, providing its MAC
address.
3. Reverse ARP (RARP): Used by a device to request its own IP address from a network.
This is useful for diskless devices that know their MAC address but need to obtain an
IP address (now largely replaced by DHCP).
4. Proxy ARP: When one device (often a router) answers ARP requests on behalf of
another device. This allows devices on different networks to communicate as if they
are on the same network.
5. Gratuitous ARP: A device sends an ARP request for its own IP address to inform
others of its MAC address. This is often used when a device's IP or MAC address
changes or when a device wants to check for IP conflicts.
ARP Issues
1. ARP Spoofing/Poisoning:
o ARP is inherently insecure because it does not authenticate the sender of an
ARP reply. An attacker can send fake ARP replies to associate their own MAC
address with the IP address of another device (e.g., a router or another host).
This is called ARP spoofing or ARP poisoning.
o By doing this, the attacker can intercept traffic meant for another device,
perform a Man-in-the-Middle (MITM) attack, or disrupt network
communication.
2. Broadcast Overhead:
o Since ARP requests are broadcast, they generate extra traffic on the network,
especially in large networks where many ARP requests may be broadcasted
simultaneously.
3. ARP Cache Overflow:
o In large networks, the ARP cache of devices can overflow due to the large
number of devices trying to communicate, causing ARP requests to be sent
repeatedly and degrading network performance.
ARP Security Solutions
1. Dynamic ARP Inspection (DAI):
o DAI is a security feature implemented in network switches that helps prevent
ARP spoofing attacks by validating ARP packets against a known trusted list
(e.g., binding MAC addresses to IP addresses).
2. Static ARP Entries:
o One way to prevent ARP spoofing is to manually configure static ARP entries
in a device’s ARP table. This prevents attackers from sending false ARP
replies. However, this is not practical for large networks due to the amount of
manual work involved.
3. Use of VPNs or Encryption:
o Using encrypted protocols like IPsec or VPNs can help mitigate the risks of
ARP spoofing by encrypting traffic, preventing attackers from intercepting
useful information.

Q. Write a short note on following ARP & RARP

Reverse Address Resolution Protocol (RARP)


Reverse Address Resolution Protocol (RARP) is a network protocol that enables a device to
obtain its IP address when it only knows its MAC address. It was primarily used by diskless
workstations that lacked the capability to store IP address information locally.
Purpose:
RARP allows devices, particularly diskless computers, to dynamically discover their IP
address on the network. When a device is turned on, it might not have the information
necessary to communicate over an IP network. RARP helps in this scenario by allowing the
device to request its IP address from a RARP server.
How RARP Works:
1. RARP Request: A device, such as a diskless workstation, broadcasts a RARP request
on the local network. This request asks: "What is my IP address?" The request is
broadcast using the device’s MAC address.
2. RARP Server Response: A RARP server, which maintains a table of MAC addresses
and their corresponding IP addresses, receives the request. The server looks up the
requesting device's MAC address and responds with the assigned IP address.
3. IP Address Assignment: The device receives its IP address from the server and can
now participate in the IP-based network.
Example:
Consider a diskless workstation with MAC address 00:1A:2B:3C:4D:5E. It sends a RARP
request asking for its IP address. The RARP server recognizes the MAC address and replies
with the IP address 192.168.1.10, allowing the workstation to communicate on the network.
Limitations of RARP:
 Static Mapping: The RARP server requires manual configuration of the MAC-to-IP
address mapping, which limits its scalability.
 Limited Information: RARP only provides the IP address, unlike modern protocols
(e.g., DHCP) that offer additional configuration settings such as subnet mask, default
gateway, DNS server, etc.
 Server Dependency: The network needs to have a RARP server that maintains the
mappings, and this setup can be cumbersome for larger networks.
Replacement by DHCP:
RARP was replaced by more advanced protocols like DHCP (Dynamic Host Configuration
Protocol), which provides a more flexible, automated, and feature-rich mechanism for
address assignment. DHCP can also assign other parameters, such as DNS information,
gateway addresses, and lease times.

You might also like