Module 04 University Question Answers
Module 04 University Question Answers
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.
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
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.
We will now assign IP ranges to each organization, starting from 198.16.0.0 and working
sequentially.
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.
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.
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.
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 = ∞
A = 0, B = 2, C = ∞, D = 1, E = 7, F = ∞
A = 0, B = 2, C = 7, D = 1, E = 5, F = 7