Network Layer and Routing Complete Study Guide – Data Communication Chapter 4

Overview of the Network Layer

Hello, my dear students! Welcome to Chapter 4. Today we are going to learn about the Network Layer, which is one of the most important layers in networking. Let me start by asking you a simple question. When you send a message from your computer in Ethiopia to a friend in another country, how does the data find its way through all those different networks? The answer lies in the network layer.

The network layer is responsible for getting packets from the source to the destination, possibly across multiple networks. This is called host-to-host delivery. The network layer does not care about which process (application) on the host will receive the data — that is the job of the transport layer. The network layer only cares about moving the packet from one computer to another computer, even if they are on completely different networks.

Three Key Responsibilities of the Network Layer

Let me explain each responsibility in a way that is easy to understand and remember for your exam.

1. Logical Addressing: Imagine you are sending a letter to someone. You need their address, right? In the same way, the network layer implements a global addressing system to distinguish source and destination systems across network boundaries. These addresses are called IP addresses. They are “logical” addresses because they are defined by software, not by the physical hardware.

2. Routing: When you travel from one city to another, there are many possible routes. Some routes are shorter, some are faster, and some are more reliable. The network layer does the same thing for packets. It chooses the best path for each packet and transports it through the network. This process of path selection is called routing.

3. Packetization: The data that comes from the upper layers (transport layer) is usually too large to send as one piece. The network layer encapsulates this data into packets by adding a header. This header contains important control information like source address, destination address, and sequencing details.

Key Exam Note
The network layer has three main responsibilities: Logical Addressing (IP addresses), Routing (path selection), and Packetization (encapsulating data into packets).
The network layer handles host-to-host delivery, NOT process-to-process delivery.
Exam Questions – Overview

Q1. Which layer is responsible for host-to-host delivery of packets?

  1. a) Data Link Layer
  2. b) Transport Layer
  3. c) Network Layer
  4. d) Physical Layer

Q2. Which of the following is NOT a responsibility of the network layer?

  1. a) Logical addressing
  2. b) Routing
  3. c) Flow control
  4. d) Packetization

Q3. The process of dividing data into smaller units called packets before transmission is known as ________.

Answers with Explanations

Q1 Answer: (c) Network Layer. The network layer handles host-to-host delivery. The data link layer handles node-to-node delivery, and the transport layer handles process-to-process delivery.

Q2 Answer: (c) Flow control. Flow control is a responsibility of the data link layer and transport layer, NOT the network layer. Logical addressing, routing, and packetization are all network layer responsibilities.

Q3 Answer: Packetization. Packetization is the process of dividing data into packets and adding headers with control information before transmission.


Packetization – Explained in Detail

Now, let me explain packetization more deeply. Why do we need it in the first place? Think about a large book. If you try to send the entire book in one package, it might be too heavy, too expensive, and if it gets lost, you lose the whole book. But if you divide the book into smaller chapters and send each one separately, it becomes easier to manage.

The network layer does the same thing with data. It divides the data into smaller units called packets. Each packet contains:

  • A portion of the actual data from the upper layer
  • A header containing control information such as:
    • Source IP address
    • Destination IP address
    • Error detection codes
    • Sequencing details (to reassemble packets in order)

This process allows efficient and reliable data transfer across networks. Multiple packets can be sent independently, and they can even take different routes through the network. At the destination, they are reassembled correctly using the sequencing information in the headers.


Routing Basics

Now, class, let us talk about routing. This is a very important topic for your exam. Routing is the process of determining the optimal paths and transporting packets through a network. The device that does this job is called a router.

A router is a device that is connected to at least two networks. It receives incoming packets, evaluates available paths based on its routing table, and decides the next “hop” to forward the packet toward its destination. Think of a router like a traffic police officer at an intersection — it looks at each vehicle (packet), checks the destination, and points it in the right direction.

How a Router Works:Incoming Routing Outgoing Packet –> Table Look –> Next Hop | v +——————+ | Routing Table | |——————| | Dest | Next Hop | | Net A | Port 1 | | Net B | Port 2 | | Net C | Port 3 | +——————+

Path Determination and Metrics

Routers use information about the network topology to evaluate and establish the “best” path. But how do they decide which path is best? They use something called metrics. A metric is a value that measures how “good” or “bad” a particular path is. Common metrics include:

  • Delay time: How long does it take for a packet to travel along this path? Lower delay is better.
  • Reliability: How often does this path fail? Higher reliability is better.
  • MTU (Maximum Transmission Unit): What is the largest packet size this path can handle? Larger MTU means fewer packets needed.

Static vs. Dynamic Routing

Now, this is a very common exam topic. There are two main types of routing. Let me explain both clearly.

Static Routing: In static routing, the network administrator manually configures the routing table. The router does not learn routes on its own. It simply follows what the administrator has set up.

  • Advantages: No overhead on CPU (the router does not calculate paths), no bandwidth usage between routers for exchanging route information, and increased security (because routes are not advertised).
  • Disadvantages: Not feasible for large networks. If anything changes in the network (a link goes down, a new network is added), the administrator must manually update every affected router.

Dynamic Routing: In dynamic routing, routers use specialized protocols to automatically learn about network changes and adjust their routing tables accordingly.

  • Advantages: Highly scalable and adaptable. If a link goes down, routers automatically find alternative paths.
  • Disadvantages: More complex to set up, adds CPU overhead (routers must calculate paths), and consumes bandwidth for exchanging routing updates between routers.
Static vs Dynamic Routing:+——————+ +——————+ | Static Routing | | Dynamic Routing | |——————| |——————| | Manual config | | Auto by protocols| | No CPU overhead | | CPU overhead | | No bandwidth use | | Uses bandwidth | | More secure | | Less secure | | Small networks | | Large networks | | Manual updates | | Auto updates | +——————+ +——————+
Key Exam Note
Static Routing = Manual, no overhead, small networks, not adaptable.
Dynamic Routing = Automatic, has overhead, large networks, adaptable to changes.
Exam Questions – Routing Basics

Q1. A device connected to at least two networks that forwards packets based on a routing table is called a:

  1. a) Switch
  2. b) Hub
  3. c) Router
  4. d) Bridge

Q2. Which of the following is an advantage of static routing?

  1. a) Automatically adapts to network changes
  2. b) No CPU overhead on the router
  3. c) Suitable for large networks
  4. d) Uses routing protocols

Q3. True or False: Dynamic routing consumes bandwidth for exchanging routing updates between routers.

Q4. The process of determining optimal paths and transporting packets through a network is called ________.

Answers with Explanations

Q1 Answer: (c) Router. A router is connected to at least two networks and uses its routing table to decide where to forward each packet. A switch works at the data link layer, a hub is a physical layer device, and a bridge connects two segments of the same network.

Q2 Answer: (b) No CPU overhead. Because static routing is manually configured, the router does not need to run routing protocols or calculate paths, so there is no CPU overhead. Options (a), (c), and (d) are advantages of dynamic routing, not static routing.

Q3 Answer: True. Dynamic routing protocols require routers to exchange routing information with each other, which consumes network bandwidth. This is one of the disadvantages of dynamic routing.

Q4 Answer: Routing. Routing is the process of path determination and packet forwarding through a network.


Routing Protocol Classifications

There are different ways to classify routing protocols. Let me explain the two main classification methods that are important for your exam.

Classification 1: IGP vs. EGP

Interior Gateway Protocols (IGP): These protocols are used within a single Autonomous System (AS). An Autonomous System is a group of networks under the control of a single organization. Examples of IGPs include RIP, OSPF, and EIGRP. Think of IGP like the internal roads within a city — they are managed by the city authority.

Exterior Gateway Protocols (EGP): These protocols are used between different Autonomous Systems, typically between different Internet Service Providers (ISPs). The most common example is BGP (Border Gateway Protocol). Think of EGP like the highways connecting different cities — they are managed at a higher level.

Classification 2: Classful vs. Classless Protocols

Classful Protocols: These protocols do NOT include subnet mask information in their route advertisements. They rely on the class of the IP address (A, B, or C) to determine the mask. The main example is RIPv1. The problem with classful protocols is that they waste IP addresses because they cannot use Variable-Length Subnet Masking (VLSM).

Classless Protocols: These protocols DO include subnet mask information in their route advertisements. They support Variable-Length Subnet Masking (VLSM), which allows more efficient use of IP addresses. Examples include OSPF and RIPv2.

ClassificationDescriptionExamples
IGPWithin a single Autonomous SystemRIP, OSPF, EIGRP
EGPBetween different Autonomous SystemsBGP
ClassfulNo subnet mask in advertisementsRIPv1
ClasslessIncludes subnet mask, supports VLSMOSPF, RIPv2
Key Exam Note
IGP = Inside one AS (RIP, OSPF, EIGRP).
EGP = Between different ASs (BGP).
Classful = No subnet mask in ads (RIPv1).
Classless = Subnet mask included, supports VLSM (OSPF, RIPv2).
Exam Questions – Protocol Classifications

Q1. Which routing protocol is an example of an Exterior Gateway Protocol?

  1. a) RIP
  2. b) OSPF
  3. c) EIGRP
  4. d) BGP

Q2. Which of the following is a classful routing protocol?

  1. a) RIPv1
  2. b) RIPv2
  3. c) OSPF
  4. d) BGP

Q3. Classless routing protocols support ________, which allows more efficient use of IP addresses.

Q4. What is the difference between IGP and EGP? Give one example of each.

Answers with Explanations

Q1 Answer: (d) BGP. BGP (Border Gateway Protocol) is an Exterior Gateway Protocol used between different Autonomous Systems, typically between ISPs. RIP, OSPF, and EIGRP are all Interior Gateway Protocols used within a single AS.

Q2 Answer: (a) RIPv1. RIPv1 is a classful protocol that does NOT include subnet mask information in route advertisements. RIPv2, OSPF, and BGP are all classless protocols that include subnet masks.

Q3 Answer: VLSM (Variable-Length Subnet Masking). VLSM allows networks of different sizes to be created from a single address block, making much more efficient use of available IP addresses.

Q4 Answer: IGP (Interior Gateway Protocol) operates within a single Autonomous System. Example: RIP or OSPF. EGP (Exterior Gateway Protocol) operates between different Autonomous Systems. Example: BGP.

See also  Computer Network and Its Applications: Complete Lesson for Ethiopian Students

Internet Protocol (IP) and IP Addressing

Now we come to one of the most important topics in this chapter. Internet Protocol (IP) is a core protocol in TCP/IP that enables data transfer between devices across the internet. IP uses unique IP addresses to route packets through multiple networks, ensuring data reaches the correct destination globally. IP operates at the network layer and is essential for host-to-host communication worldwide.

There are two versions of IP: IPv4 and IPv6. Let me compare them for you.

FeatureIPv4IPv6
Address Length32 bits128 bits
Address FormatDecimal (e.g., 192.168.0.1)Hexadecimal (e.g., 2001:0db8::1)
Address Space\(2^{32}\) = ~4.3 billion\(2^{128}\) addresses
Header ComplexitySimple, fixed headerLarger, more complex header

For your exam, we will focus mainly on IPv4 addressing since that is what the textbook covers in detail. But remember the comparison above — it is a common exam question!


IPv4 Addressing – Complete Details

Let me now teach you IPv4 addressing from the ground up. This topic requires your full attention because many exam questions come from here.

What is an IPv4 Address?

An IPv4 address is a 32-bit (4-byte) identifier that is unique to each device connection on the Internet. Each address corresponds to only one device, ensuring no two devices share the same address at the same time.

Address Space

The address space is the total number of unique addresses possible. For IPv4, since we have 32 bits:

Important Formula
\[\text{Address Space} = 2^N\]

Where N = number of bits in the address.

For IPv4: \(\text{Address Space} = 2^{32} \approx 4.29 \text{ billion addresses}\)

However, the actual number of usable addresses is less than 4.29 billion because some addresses are reserved for special purposes. If a protocol uses N bits for addresses, the address space is always \(2^N\) because each bit can be either 0 or 1.

IPv4 Address Notations

There are two ways to write an IPv4 address:

1. Binary Notation: The address is displayed as 32 bits, divided into four 8-bit groups called octets (or bytes).

Example: 01110101 10010101 00011101 00000010

2. Dotted-Decimal Notation: Each octet is converted to a decimal number (0 to 255), and the four numbers are separated by dots. This is the format humans use because it is much easier to read.

Example: 117.149.29.2

Key Exam Note
Each octet in dotted-decimal notation ranges from 0 to 255 (because 8 bits = 256 values, from 00000000 to 11111111).
An IPv4 address always has exactly 4 octets.
Leading zeros are NOT allowed in dotted-decimal notation (e.g., 045 is invalid, write 45).

Solved Examples – Converting Between Notations

Worked Example 1: Binary to Dotted-Decimal

Convert: 10000001 00001011 00001011 11101111 to dotted-decimal.

Detailed Solution

First octet: 10000001 = \(128 + 0 + 0 + 0 + 0 + 0 + 0 + 1 = 129\)

Second octet: 00001011 = \(0 + 0 + 0 + 0 + 8 + 0 + 2 + 1 = 11\)

Third octet: 00001011 = \(0 + 0 + 0 + 0 + 8 + 0 + 2 + 1 = 11\)

Fourth octet: 11101111 = \(128 + 64 + 0 + 16 + 8 + 4 + 2 + 1 = 239\)

Answer: 129.11.11.239

Worked Example 2: Binary to Dotted-Decimal

Convert: 11001001 10010011 00101011 11101111 to dotted-decimal.

Detailed Solution

First octet: 11001001 = \(128 + 64 + 0 + 0 + 8 + 0 + 0 + 1 = 201\)

Second octet: 10010011 = \(128 + 0 + 0 + 16 + 0 + 0 + 2 + 1 = 147\)

Third octet: 00101011 = \(0 + 0 + 32 + 0 + 8 + 0 + 2 + 1 = 43\)

Fourth octet: 11101111 = \(128 + 64 + 0 + 16 + 8 + 4 + 2 + 1 = 239\)

Answer: 201.147.43.239

Worked Example 3: Dotted-Decimal to Binary

Convert: 111.56.45.78 to binary notation.

Detailed Solution

For each decimal number, we find the largest power of 2 that fits, subtract, and continue:

111: 111 – 128? No(0). 111 – 64 = 47(1). 47 – 32 = 15(1). 15 – 16? No(0). 15 – 8 = 7(1). 7 – 4 = 3(1). 3 – 2 = 1(1). 1 – 1 = 0(1) = 01101111

56: 56 – 128? No(0). 56 – 64? No(0). 56 – 32 = 24(1). 24 – 16 = 8(1). 8 – 8 = 0(1). 0 – 4? No(0). 0 – 2? No(0). 0 – 1? No(0) = 00111000

45: 45 – 128? No(0). 45 – 64? No(0). 45 – 32 = 13(1). 13 – 16? No(0). 13 – 8 = 5(1). 5 – 4 = 1(1). 1 – 2? No(0). 1 – 1 = 0(1) = 00101101

78: 78 – 128? No(0). 78 – 64 = 14(1). 14 – 32? No(0). 14 – 16? No(0). 14 – 8 = 6(1). 6 – 4 = 2(1). 2 – 2 = 0(1). 0 – 1? No(0) = 01001110

Answer: 01101111 00111000 00101101 01001110

Finding Errors in IPv4 Addresses

This is a very common type of exam question. Let me teach you the three types of errors to look for:

Worked Example: Finding Errors

Find the error in each address:

a. 111.56.045.78

b. 221.34.7.8.20

c. 75.45.301.14

Detailed Solution

(a) 111.56.045.78 — Error: Leading zero. The third octet is “045”. Leading zeros are not allowed in dotted-decimal notation. It should be written as “45”, not “045”.

(b) 221.34.7.8.20 — Error: Too many octets. An IPv4 address must have exactly 4 octets. This address has 5 numbers separated by dots, which is invalid.

(c) 75.45.301.14 — Error: Octet exceeds 255. The third octet is “301”, which is greater than 255 (the maximum value for an 8-bit number). Valid octets range from 0 to 255 only.

Three Common IPv4 Address Errors to Check
1. Leading zeros (e.g., 045 is wrong, write 45)
2. Wrong number of octets (must be exactly 4)
3. Octet value > 255 (each octet must be 0–255)
Exam Questions – IPv4 Notations

Q1. Convert 11000001 10000011 00011011 11111111 to dotted-decimal notation.

  1. a) 193.131.27.255
  2. b) 193.195.27.255
  3. c) 129.131.27.255
  4. d) 193.131.27.127

Q2. What is wrong with the IPv4 address 192.168.001.100?

  1. a) An octet exceeds 255
  2. b) There are too many octets
  3. c) Leading zero in the third octet
  4. d) Nothing is wrong

Q3. The IPv4 address space is ________ unique addresses.

Q4. True or False: An IPv4 address in dotted-decimal notation can have an octet value of 256.

Answers with Explanations

Q1 Answer: (a) 193.131.27.255. First octet: 128+64+0+0+0+0+0+1 = 193. Second: 128+0+0+0+0+0+2+1 = 131. Third: 0+0+0+16+8+2+1+0 = 27. Fourth: 128+64+32+16+8+4+2+1 = 255.

Q2 Answer: (c) Leading zero in the third octet. “001” has a leading zero. It should be written as “1” without the leading zeros.

Q3 Answer: \(2^{32}\) or approximately 4.29 billion. Since IPv4 uses 32 bits, the address space is \(2^{32}\).

Q4 Answer: False. Each octet is 8 bits, so the maximum value is \(2^8 – 1 = 255\). A value of 256 requires 9 bits and is invalid.


Classful Addressing

Now, class, this is a very important section. In the early days of the Internet, IP addresses were divided into five classes: A, B, C, D, and E. This system is called classful addressing. Each class has a different structure, determining how many bits are used for the network ID and how many for the host ID.

ClassFirst BitsAddress RangeNetwork IDHost IDDefault MaskUse
A00.0.0.0 – 127.255.255.2558 bits (1 octet)24 bits (3 octets)255.0.0.0Large organizations
B10128.0.0.0 – 191.255.255.25516 bits (2 octets)16 bits (2 octets)255.255.0.0Midsize organizations
C110192.0.0.0 – 223.255.255.25524 bits (3 octets)8 bits (1 octet)255.255.255.0Small organizations
D1110224.0.0.0 – 239.255.255.255N/A (multicast)N/AMulticast groups
E1111240.0.0.0 – 255.255.255.255N/A (reserved)N/AReserved/future

How to Find the Class of an IP Address

There are two methods to find the class. Let me teach you both.

Method 1: Using Binary Notation. Look at the first few bits of the address:

  • If the first bit is 0 → Class A
  • If the first two bits are 10 → Class B
  • If the first three bits are 110 → Class C
  • If the first four bits are 1110 → Class D
  • If the first four bits are 1111 → Class E

Method 2: Using Dotted-Decimal Notation. Look at the value of the first octet:

  • 0 to 127 → Class A
  • 128 to 191 → Class B
  • 192 to 223 → Class C
  • 224 to 239 → Class D
  • 240 to 255 → Class E
Easy Way to Remember Class Ranges
Class A: 0–127 (starts with 0, so small numbers)
Class B: 128–191 (starts with 10 in binary = 128-191)
Class C: 192–223 (starts with 110 = 192-223)
Class D: 224–239 (starts with 1110 = multicast)
Class E: 240–255 (starts with 1111 = reserved)
Worked Examples – Finding the Class

a. 00000001 00001011 00001011 11101111

b. 11000001 10000011 00011011 11111111

c. 14.23.120.8

d. 252.5.15.111

Detailed Solutions

(a) The first bit is 0. → Class A

(b) The first two bits are 11, the third bit is 0 (pattern is 110). → Class C

(c) The first octet is 14, which falls in the range 0–127. → Class A

(d) The first octet is 252, which falls in the range 240–255. → Class E

Exam Questions – Classful Addressing

Q1. What class does the address 172.16.0.1 belong to?

  1. a) Class A
  2. b) Class B
  3. c) Class C
  4. d) Class D

Q2. A Class C address uses how many bits for the network ID?

  1. a) 8 bits
  2. b) 16 bits
  3. c) 24 bits
  4. d) 32 bits

Q3. What is the default subnet mask for a Class B address?

  1. a) 255.0.0.0
  2. b) 255.255.0.0
  3. c) 255.255.255.0
  4. d) 255.255.255.255

Q4. The address range 224.0.0.0 to 239.255.255.255 belongs to Class ________ and is used for ________.

Q5. True or False: Class A addresses have 16 bits for the host ID.

Answers with Explanations

Q1 Answer: (b) Class B. The first octet is 172, which falls in the range 128–191. Therefore, it is a Class B address.

Q2 Answer: (c) 24 bits. Class C uses the first 3 octets (24 bits) for the network ID and the last octet (8 bits) for the host ID.

Q3 Answer: (b) 255.255.0.0. Class B uses 16 bits for network ID, so the first 16 bits of the mask are 1s and the remaining 16 bits are 0s, giving 255.255.0.0.

Q4 Answer: Class D, multicast. Class D addresses (224–239) are reserved for multicast group communication, not for assigning to individual hosts.

Q5 Answer: False. Class A addresses have 24 bits for the host ID (the last 3 octets), not 16 bits. 16 bits for host ID is the characteristic of Class B.


Default Masks – Detailed Explanation

The default mask (also called the subnet mask) helps us identify which part of an IP address is the network ID and which part is the host ID. The mask works by performing a bitwise AND operation with the IP address.

How the Mask Works

The mask has 32 bits, just like an IP address. The bits are either 1 or 0:

  • 1 bits indicate the network portion of the address
  • 0 bits indicate the host portion of the address

When you perform a bitwise AND between the IP address and the mask, the result is the network ID. The remaining bits (where the mask has 0s) form the host ID.

Important Formulas
\[\text{Network ID} = \text{IP Address} \text{ (bitwise AND)} \text{ Mask}\] \[\text{Host ID} = \text{IP Address} – \text{Network ID}\]

Default Masks for Each Class

Class A: 255.0.0.0 = 11111111.00000000.00000000.00000000 (8 ones, 24 zeros)

Class B: 255.255.0.0 = 11111111.11111111.00000000.00000000 (16 ones, 16 zeros)

Class C: 255.255.255.0 = 11111111.11111111.11111111.00000000 (24 ones, 8 zeros)

Bitwise AND Rules

Before we solve an example, let me quickly remind you of the AND rules:

1 AND 1 = 1

1 AND 0 = 0

0 AND 1 = 0

0 AND 0 = 0

Worked Example: Finding Network ID and Host ID

Given: IP Address = 10.0.0.100, Class A Default Mask = 255.0.0.0

Find: Network ID and Host ID.

Detailed Solution – Step by Step

Step 1: Write both in binary:

IP Address: 00001010 . 00000000 . 00000000 . 01100100

Mask:       11111111 . 00000000 . 00000000 . 00000000

Step 2: Apply bitwise AND to get Network ID:

Result:       00001010 . 00000000 . 00000000 . 00000000

Network ID = 10.0.0.0

Step 3: Find Host ID (IP Address minus Network ID):

IP Address: 00001010 . 00000000 . 00000000 . 01100100

Network:       00001010 . 00000000 . 00000000 . 00000000

Host ID:        00000000 . 00000000 . 00000000 . 01100100

Host ID = 0.0.0.100

Understanding: The network ID tells us this device is on network 10.0.0.0. The host ID (100) tells us this is host number 100 on that network.

Exam Questions – Default Masks

Q1. What is the network ID of IP address 150.50.25.10 using its default mask?

  1. a) 150.0.0.0
  2. b) 150.50.0.0
  3. c) 150.50.25.0
  4. d) 150.50.25.10

Q2. The default mask for Class C is ________, which means the first ________ bits are network bits.

Q3. Explain how the default mask is used to separate the network ID from the host ID in an IP address.

Answers with Explanations

Q1 Answer: (b) 150.50.0.0. 150 falls in the range 128–191, so this is a Class B address with default mask 255.255.0.0. Performing AND: first octet AND 255 = 150, second octet AND 255 = 50, third AND 0 = 0, fourth AND 0 = 0. Network ID = 150.50.0.0.

Q2 Answer: 255.255.255.0, 24. Class C mask has 24 contiguous 1s followed by 8 zeros.

Q3 Answer: The default mask is a 32-bit number where 1s represent the network portion and 0s represent the host portion. By performing a bitwise AND between the IP address and the mask, the host portion becomes all zeros, leaving only the network ID. The remaining bits (where mask is 0) form the host ID.


Subnetting and Classless Addressing (CIDR)

Now, class, let me explain one of the most important and frequently tested topics. Subnetting is the process of “borrowing” bits from the host portion of an IP address to create smaller internal networks called subnets. This gives network administrators more control over their network.

Important note: Every subnet loses two addresses. The first address in a subnet is the Network Address (used to identify the subnet itself), and the last address is the Broadcast Address (used to send messages to all hosts in the subnet). These two addresses cannot be assigned to any host.

Classless Inter-Domain Routing (CIDR)

CIDR was designed to overcome the problem of IP address depletion. In classful addressing, many addresses were wasted because organizations were given fixed-size blocks. CIDR solves this by granting blocks of varying sizes rather than fixed classes.

Key points about CIDR:

  • There are no fixed classes — addresses are granted in variable-sized blocks
  • The mask can range from /0 to /32 (any number of network bits)
  • A mask is a 32-bit number with the leftmost n bits as 1s and the rightmost (32-n) bits as 0s

CIDR Notation

CIDR uses a convenient notation: /n, where n is the number of leftmost bits that are 1s in the mask. For example:

/8 means the first 8 bits are network bits (equivalent to Class A mask 255.0.0.0)

/16 means the first 16 bits are network bits (equivalent to Class B mask 255.255.0.0)

/24 means the first 24 bits are network bits (equivalent to Class C mask 255.255.255.0)

/28 means the first 28 bits are network bits (4 bits borrowed for subnetting from a Class C)

Critical Formulas for CIDR
\[\text{Number of addresses in a block} = 2^{32-n}\] \[\text{Host bits} = 32 – n\]

First address: Set the last (32-n) bits to 0

Last address: Set the last (32-n) bits to 1

Key Exam Note
First address = set all host bits to 0 (this is the network address)
Last address = set all host bits to 1 (this is the broadcast address)
Number of addresses = \(2^{32-n}\)
Usable hosts = \(2^{32-n} – 2\) (subtract network address and broadcast address)
Worked Example: Complete CIDR Problem

Problem: A block of addresses is granted to a small organization. One of the addresses is 205.16.37.39/28.

Find: (a) The first address, (b) The last address, (c) The number of addresses.

Detailed Solution – Step by Step

Step 1: Understand the CIDR notation. /28 means the first 28 bits are network bits. The last 4 bits (32 – 28 = 4) are host bits.

Step 2: Convert the given address to binary.

205.16.37.39 = 11001101 . 00010000 . 00100101 . 00100111

Step 3: Find the first address. Set the last 4 bits (host bits) to 0:

Original: 11001101 . 00010000 . 00100101 . 00100111

First:     11001101 . 00010000 . 00100101 . 00100000

Convert last octet: 00100000 = 32

First address = 205.16.37.32

Step 4: Find the last address. Set the last 4 bits (host bits) to 1:

Original: 11001101 . 00010000 . 00100101 . 00100111

Last:      11001101 . 00010000 . 00100101 . 00101111

Convert last octet: 00101111 = 47

Last address = 205.16.37.47

Step 5: Find the number of addresses.

\[\text{Number of addresses} = 2^{32-28} = 2^4 = \boxed{16}\]

Summary: The block ranges from 205.16.37.32 to 205.16.37.47, containing 16 addresses. The first (205.16.37.32) is the network address, the last (205.16.37.47) is the broadcast address, and 14 addresses are usable for hosts.

Exam Questions – Subnetting and CIDR

Q1. If a CIDR block is /26, how many addresses does it contain?

  1. a) 32
  2. b) 64
  3. c) 128
  4. d) 256

Q2. For the address 192.168.1.100/26, what is the network address (first address)?

  1. a) 192.168.1.0
  2. b) 192.168.1.64
  3. c) 192.168.1.96
  4. d) 192.168.1.100

Q3. In CIDR notation, /24 means ________ bits are used for the network portion and ________ bits for the host portion.

Q4. True or False: In a subnet, the first and last addresses are reserved for network and broadcast, so they cannot be assigned to hosts.

Q5. An organization has the address 192.168.10.130/28. Find the first address, last address, and number of addresses in the block.

Answers with Explanations

Q1 Answer: (b) 64. Number of addresses = \(2^{32-26} = 2^6 = 64\).

Q2 Answer: (b) 192.168.1.64. /26 means 26 network bits and 6 host bits. 100 in binary = 01100100. Setting the last 6 bits to 0: 01000000 = 64. So first address = 192.168.1.64.

Q3 Answer: 24, 8. /24 means 24 bits for network, and 32 - 24 = 8 bits for host.

Q4 Answer: True. The first address (all host bits = 0) is the network address, and the last address (all host bits = 1) is the broadcast address. Neither can be assigned to a host.

Q5 Answer:

/28 means 28 network bits, 4 host bits. 130 in binary = 10000010. Setting last 4 bits to 0: 10000000 = 128. Setting last 4 bits to 1: 10001111 = 143.

First address = 192.168.10.128

Last address = 192.168.10.143

Number of addresses = \(2^{32-28} = 2^4 = \boxed{16}\)


Address Mapping Protocols

Now, class, let me ask you a question. We have IP addresses (logical addresses) that work at the network layer. We also have MAC addresses (physical addresses) that work at the data link layer. When a packet needs to be delivered on a local network, the network layer knows the destination IP address, but the data link layer needs the destination MAC address. How do we map from IP to MAC? The answer is Address Mapping Protocols.

ARP (Address Resolution Protocol)

ARP maps a logical (IP) address to a physical (MAC) address for local delivery. When a host wants to send a packet to another host on the same network, it knows the destination IP address but not the MAC address. ARP sends a broadcast message to all hosts on the local network asking: "Who has this IP address? Please tell me your MAC address." The host with that IP address responds with its MAC address.

ARP Process:Host A (Sender) Local Network +------------------+ | Knows: IP of B | "Who has IP_B? Tell me your MAC!" | Needs: MAC of B | ------------------------> All Hosts | | <------------------------ Host B replies: | Gets MAC of B | "I have IP_B, my MAC is..." +------------------+ | v Now A can send the frame directly to B using B's MAC address

RARP (Reverse Address Resolution Protocol)

RARP does the opposite of ARP. It maps a known physical (MAC) address back to its logical (IP) address. This is useful for a device that knows its own MAC address (burned into the hardware) but does not know its IP address. It sends a broadcast asking: "My MAC address is X. What is my IP address?" A RARP server responds with the IP address.

ARP vs RARP:+------------------+ +------------------+ | ARP | | RARP | |------------------| |------------------| | IP --> MAC | | MAC --> IP | | Logical to | | Physical to | | Physical | | Logical | | "Who has this | | "My MAC is X, | | IP?" | | what is my IP?" | +------------------+ +------------------+

Other Network Layer Protocols

ICMP (Internet Control Message Protocol): Used for management and error reporting at the network layer. Have you ever used the "ping" command to check if a host is reachable? Ping uses ICMP! When a router cannot deliver a packet, it sends an ICMP error message back to the sender.

IGMP (Internet Group Management Protocol): Used to manage multicast group memberships. When a host wants to join or leave a multicast group, it uses IGMP to inform the local router.

ProtocolFull NameFunctionDirection of Mapping
ARPAddress Resolution ProtocolMaps IP to MAC for local deliveryIP → MAC
RARPReverse ARPMaps MAC to IP (find own IP)MAC → IP
ICMPInternet Control Message ProtocolError reporting and managementN/A
IGMPInternet Group Management ProtocolMulticast group managementN/A
Key Exam Note
ARP = IP address to MAC address (most commonly tested!)
RARP = MAC address to IP address
ICMP = Error reporting (ping command uses ICMP)
IGMP = Multicast group management
Exam Questions – Address Mapping Protocols

Q1. Which protocol maps a logical (IP) address to a physical (MAC) address?

  1. a) RARP
  2. b) ICMP
  3. c) ARP
  4. d) IGMP

Q2. A device knows its MAC address but not its IP address. Which protocol can help it find its IP address?

  1. a) ARP
  2. b) RARP
  3. c) ICMP
  4. d) IGMP

Q3. Which protocol is used for error reporting at the network layer?

  1. a) ARP
  2. b) RARP
  3. c) ICMP
  4. d) IGMP

Q4. The "ping" command uses the ________ protocol to check if a host is reachable.

Q5. ________ is used to manage multicast group memberships at the network layer.

Q6. True or False: ARP maps a MAC address to an IP address.

Answers with Explanations

Q1 Answer: (c) ARP. ARP (Address Resolution Protocol) maps IP addresses to MAC addresses for delivery on a local network.

Q2 Answer: (b) RARP. RARP (Reverse ARP) maps a known MAC address to its corresponding IP address. This is useful when a device knows its hardware address but needs to find its logical address.

Q3 Answer: (c) ICMP. ICMP (Internet Control Message Protocol) is used for error reporting and network management at the network layer.

Q4 Answer: ICMP. The ping command sends ICMP Echo Request messages and waits for ICMP Echo Reply messages to determine if a host is reachable.

Q5 Answer: IGMP. IGMP (Internet Group Management Protocol) manages multicast group memberships.

Q6 Answer: False. ARP maps IP to MAC. RARP maps MAC to IP. This is a common trick question in exams — do not confuse the direction!

Challenge Exam Questions – Network Layer and Routing

Dear students, these questions will truly test your understanding. Try each one carefully before revealing the answer!

MCQ

Q1. A network administrator manually configures all routes in a small office with 5 routers. Which type of routing is being used, and what is its main advantage in this scenario?

  1. a) Dynamic routing; automatically adapts to changes
  2. b) Static routing; no CPU overhead and no bandwidth consumed for updates
  3. c) Dynamic routing; supports VLSM
  4. d) Static routing; suitable for large networks

Answer: (b). Static routing is being used because the administrator manually configures routes. Its main advantage is no CPU overhead on routers and no bandwidth consumption for routing updates, which is ideal for a small network of 5 routers. Option (d) is wrong because static routing is NOT suitable for large networks.

MCQ

Q2. An IP address in binary starts with the bits 110. Which class does it belong to, and how many bits are used for the host ID?

  1. a) Class B, 16 bits
  2. b) Class C, 8 bits
  3. c) Class C, 16 bits
  4. d) Class A, 24 bits

Answer: (b) Class C, 8 bits. The pattern 110 at the beginning identifies a Class C address. Class C uses 24 bits for the network ID and 8 bits for the host ID (the last octet).

MCQ

Q3. Which combination of routing protocol classifications is correct?

  1. a) OSPF is an EGP and classful protocol
  2. b) BGP is an IGP and classless protocol
  3. c) RIPv1 is an IGP and classful protocol
  4. d) RIPv2 is an EGP and classless protocol

Answer: (c). RIPv1 is an Interior Gateway Protocol (IGP) because it operates within a single AS, and it is classful because it does not include subnet masks in advertisements. Option (a) is wrong because OSPF is an IGP, not EGP. Option (b) is wrong because BGP is an EGP, not IGP. Option (d) is wrong because RIPv2 is an IGP, not EGP.

MCQ

Q4. The IPv4 address space is approximately 4.3 billion. Why is the actual number of usable addresses less than this?

  1. a) Because IPv4 uses 31 bits, not 32
  2. b) Because some addresses are reserved for special purposes
  3. c) Because of the difference between binary and decimal notation
  4. d) Because the dotted-decimal format loses precision

Answer: (b). The theoretical address space is \(2^{32} \approx 4.29\) billion, but many addresses are reserved (like private addresses, loopback addresses, broadcast addresses, etc.), so the actual usable public addresses are fewer.

MCQ

Q5. Which of the following is TRUE about CIDR compared to classful addressing?

  1. a) CIDR uses fixed-size address blocks based on classes
  2. b) CIDR does not use subnet masks
  3. c) CIDR grants variable-sized blocks to reduce address waste
  4. d) CIDR only works with Class A addresses

Answer: (c). CIDR was designed to overcome address depletion by granting variable-sized blocks rather than fixed classes. It does use subnet masks (ranging from /0 to /32), and it works with any address, not just Class A.

Fill in the Blank

Q6. The process of "borrowing" bits from the host portion to create smaller internal networks is called ________.

Answer: Subnetting. Subnetting borrows bits from the host portion of an IP address to divide a network into smaller sub-networks (subnets).

Fill in the Blank

Q7. In CIDR notation, the address 10.0.0.0/16 has ________ network bits and ________ host bits, giving a total of ________ addresses in the block.

Answer: 16, 16, 65,536. /16 means 16 network bits. Host bits = 32 - 16 = 16. Number of addresses = \(2^{16} = 65,536\).

Fill in the Blank

Q8. A ________ is a device connected to at least two networks that forwards packets based on its ________ table using metrics like delay, reliability, and MTU.

Answer: Router, routing. A router uses its routing table and metrics (delay, reliability, MTU) to determine the best path for forwarding packets.

Fill in the Blank

Q9. The protocol that maps a known physical (MAC) address to a logical (IP) address is ________, while the protocol that maps a logical (IP) address to a physical (MAC) address is ________.

Answer: RARP (first blank), ARP (second blank). Be careful with the order! RARP = MAC to IP. ARP = IP to MAC.

Fill in the Blank

Q10. Every subnet loses two addresses: the ________ address and the ________ address, which cannot be assigned to any host.

Answer: Network, broadcast. The first address (all host bits = 0) is the network address, and the last address (all host bits = 1) is the broadcast address.

True / False

Q11. True or False: The network layer handles process-to-process delivery of packets.

Answer: False. The network layer handles host-to-host delivery. Process-to-process delivery is handled by the transport layer.

True / False

Q12. True or False: In classful addressing, RIPv1 includes the subnet mask in its route advertisements.

Answer: False. RIPv1 is a classful protocol, meaning it does NOT include subnet masks in advertisements. It relies on the address class to determine the mask. RIPv2 is the classless version that includes subnet masks.

True / False

Q13. True or False: IPv6 uses 128-bit addresses and hexadecimal notation.

Answer: True. IPv6 uses 128-bit addresses written in hexadecimal format (e.g., 2001:0db8::1), compared to IPv4 which uses 32-bit addresses in dotted-decimal format.

True / False

Q14. True or False: The default mask for a Class A address is 255.255.0.0.

Answer: False. The default mask for Class A is 255.0.0.0 (/8). 255.255.0.0 is the default mask for Class B (/16).

True / False

Q15. True or False: Packetization adds only the source and destination IP addresses to the data.

Answer: False. Packetization adds a header that includes source IP address, destination IP address, error detection codes, and sequencing details — not just the addresses.

Short Answer

Q16. Explain the difference between static routing and dynamic routing. Give one advantage and one disadvantage of each.

Answer:

Static routing: Routes are manually configured by the network administrator. Advantage: No CPU overhead and no bandwidth consumed for routing updates. Disadvantage: Not feasible for large networks; requires manual updates when the network changes.

Dynamic routing: Routes are automatically learned and adjusted using routing protocols. Advantage: Highly scalable and adapts automatically to network changes. Disadvantage: More complex, adds CPU overhead, and consumes bandwidth for exchanging routing updates.

Short Answer

Q17. What is the difference between IGP and EGP? Why is this classification important?

Answer: IGP (Interior Gateway Protocol) operates within a single Autonomous System (AS) — a network under one administrative control. Examples: RIP, OSPF, EIGRP. EGP (Exterior Gateway Protocol) operates between different Autonomous Systems, typically between ISPs. Example: BGP.

This classification is important because routing within an organization has different requirements than routing between organizations. Internal routing needs to know detailed topology, while external routing needs to know which AS can reach which destinations, without revealing internal topology for security.

Short Answer

Q18. Explain how ARP works when Host A wants to send a packet to Host B on the same local network.

Answer: When Host A wants to send a packet to Host B, it knows Host B's IP address but not its MAC address. Host A broadcasts an ARP request message to all hosts on the local network saying: "Who has this IP address? Please tell me your MAC address." All hosts receive the broadcast, but only Host B (which has that IP address) responds with an ARP reply containing its MAC address. Host A then stores this mapping in its ARP cache and can now send the frame directly to Host B using the MAC address.

Calculation

Q19. Convert the following to dotted-decimal notation: 10101010 01010101 11110000 00001111

Solution:

First octet: 10101010 = 128 + 32 + 8 + 2 = 170

Second octet: 01010101 = 64 + 16 + 4 + 1 = 85

Third octet: 11110000 = 128 + 64 + 32 + 16 = 240

Fourth octet: 00001111 = 8 + 4 + 2 + 1 = 15

Answer: 170.85.240.15

Calculation

Q20. Convert 200.100.50.25 to binary notation.

Solution:

200: 128(1) + 64(1) + 32(1) + 16(0) + 8(0) + 4(1) + 2(0) + 1(0) = 11001000

100: 128(0) + 64(1) + 32(1) + 16(0) + 8(0) + 4(1) + 2(0) + 1(0) = 01100100

50: 128(0) + 64(0) + 32(1) + 16(1) + 8(0) + 4(0) + 2(1) + 1(0) = 00110010

25: 128(0) + 64(0) + 32(0) + 16(1) + 8(1) + 4(0) + 2(0) + 1(1) = 00011001

Answer: 11001000 01100100 00110010 00011001

Calculation

Q21. Given the IP address 172.20.5.100 with a Class B default mask, find the Network ID and Host ID.

Solution:

172 falls in range 128–191, so it is Class B with default mask 255.255.0.0 (/16).

Network ID = IP AND Mask = first two octets kept, last two set to 0:

Network ID = 172.20.0.0

Host ID = last two octets = 0.5.100 (or simply 5.100)

Calculation

Q22. An organization has the address 192.168.5.150/27. Find: (a) The first address, (b) The last address, (c) The number of addresses, (d) The number of usable host addresses.

Solution:

/27 means 27 network bits, 5 host bits (32 - 27 = 5).

150 in binary = 10010110. Keep first 3 bits (100), set last 5 bits to 0 for first address: 10000000 = 128. Set last 5 bits to 1 for last address: 10011111 = 159.

(a) First address = 192.168.5.128

(b) Last address = 192.168.5.159

(c) Number of addresses = \(2^{32-27} = 2^5 = 32\)

(d) Usable hosts = 32 - 2 = 30

Calculation

Q23. For the address 10.20.30.40/20, find the first address, last address, and total number of addresses.

Solution:

/20 means 20 network bits, 12 host bits (32 - 20 = 12).

The boundary between network and host falls within the third octet. 20 bits = 16 (first 2 octets) + 4 bits of the third octet.

Third octet 30 = 00011110. Keep first 4 bits (0001), set last 4 bits to 0: 00010000 = 16. Set last 4 bits to 1: 00011111 = 31.

First address = 10.20.16.0

Last address = 10.20.31.255

Number of addresses = \(2^{12} = 4,096\)

MCQ

Q24. A host sends a broadcast asking "Who has IP address 192.168.1.5?" No response is received. What is the most likely reason?

  1. a) The host's MAC address is wrong
  2. b) No host with that IP address exists on the local network
  3. c) The ARP cache is full
  4. d) The subnet mask is incorrect

Answer: (b). When a host sends an ARP request broadcast, all hosts on the local network receive it. If no host responds, it means no device on that local network has the IP address 192.168.1.5. The host either does not exist, is on a different network, or is turned off.

Short Answer

Q25. List the three common metrics used by routers for path determination and briefly explain each one.

Answer:

1. Delay time: The time it takes for a packet to travel from source to destination along a path. Lower delay is preferred.

2. Reliability: How often the path fails or produces errors. Higher reliability is preferred.

3. MTU (Maximum Transmission Unit): The largest packet size a path can handle without fragmentation. Larger MTU is preferred because it reduces the number of packets needed.

MCQ

Q26. Which of the following IPv4 addresses contains an error?

  1. a) 10.0.0.1
  2. b) 192.168.1.256
  3. c) 172.16.0.0
  4. d) 224.0.0.5

Answer: (b) 192.168.1.256. The fourth octet is 256, which exceeds the maximum value of 255 for an 8-bit number. All other addresses are valid: 10.0.0.1 is a Class A private address, 172.16.0.0 is a Class B private address, and 224.0.0.5 is a Class D multicast address.

Short Answer

Q27. Compare IPv4 and IPv6 in terms of address length, address format, and address space. Why was IPv6 developed?

Answer:

IPv4: 32-bit address length, dotted-decimal format (e.g., 192.168.0.1), address space of \(2^{32} \approx 4.3\) billion.

IPv6: 128-bit address length, hexadecimal format (e.g., 2001:0db8::1), address space of \(2^{128}\).

IPv6 was developed because IPv4's 4.3 billion addresses are not enough for the growing number of devices connected to the Internet. With IPv6's enormous address space, every device can have a unique address, solving the address depletion problem.

Calculation

Q28. Find the class, network ID, and host ID for the IP address 89.45.120.7.

Solution:

First octet = 89, which falls in range 0–127. Class = A

Default mask = 255.0.0.0 (8 network bits, 24 host bits)

Network ID = 89.0.0.0

Host ID = 0.45.120.7

Fill in the Blank

Q29. In CIDR notation, a /30 block contains ________ addresses, of which ________ are usable for hosts.

Answer: 4, 2. /30 means \(2^{32-30} = 2^2 = 4\) total addresses. Usable hosts = 4 - 2 = 2 (subtracting network address and broadcast address). /30 is commonly used for point-to-point links between two routers.

True / False

Q30. True or False: IGMP is used by routers to exchange routing information within an Autonomous System.

Answer: False. IGMP (Internet Group Management Protocol) is used to manage multicast group memberships, NOT for exchanging routing information. Protocols like RIP and OSPF are used for exchanging routing information within an AS.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top