Computer Networks · Unit 4 · 10 hrs
Network Layer
Exam-focused notes for Network Layer (Computer Networks, CSC263): what the TU syllabus asks and how it has actually been tested, with 20 solved past questions from this unit.
Network Layer in short
This chapter is the addressing and routing core of the course: how the network layer moves packets between different networks, how IPv4 and IPv6 addresses are structured and subnetted, how a router picks the best path, and the protocols, transition mechanisms and security controls that keep that path working.
What this unit covers
- Introduction and Functions
- IPv4 Addressing & Sub-netting
- Class-full and Classless Addressing
- IPv6 Addressing and its Features
- IPv4 and IPv6 Datagram Formats
- Comparison of IPv4 and IPv6 Addressing
- Example Addresses: Unicast, Multicast and Broadcast
- Routing
- Introduction and Definition
- Types of Routing (Static vs Dynamic, Unicast vs Multicast, Link State vs Distance Vector, Interior vs Exterior)
- Path Computation Algorithms: Bellman Ford, Dijkstra's
- Routing Protocols: RIP, OSPF & BGP
- Overview of IPv4 to IPv6 Transition Mechanisms
- Overview of ICMP/ICMPv6&NATing
- Overview of Network Traffic Analysis
- Security Concepts: Firewall & Router Access Control
IPv4 and IPv6 Datagram Formats
2081 · 10 marks
Provide reasons for transitions from IPv4 to IPv6. Describe the IPv6 datagram format.[10]
Overview of ICMP/ICMPv6&NATing
2076 · 5 marks
What is NAT? How does it work? What are its benefits? [5]
IPv4 Addressing & Sub-netting
2081 · 5 marks
Assume a class C network and divide it into three subnets. What is the value of the new subnet? [5]
Show solved answerHide answer
Subnetting a Class C Network into Three Subnets
Given
- Network Class: Class C
- Default Subnet Mask: 255.255.255.0 (/24)
- Network bits: 24, Host bits: 8
- Required subnets: 3
- Example network (for illustration, standard assumption): 192.168.1.0
No specific IP address is given in the question, so a representative network 192.168.1.0 is used only for demonstration.
Solution
Step 1: Bits to Borrow
Number of subnets = $2^n$, where $n$ = borrowed bits.
We need at least 3 subnets:
| Borrowed bits $n$ | Subnets $2^n$ | Enough for 3? |
|---|---|---|
| 1 | 2 | No |
| 2 | 4 | Yes |
So borrow $n = 2$ bits.
Step 2: New Subnet Mask
Remaining host bits = $8 - 2 = 6$.
$$ \text{New mask} = 11111111.11111111.11111111.\underline{11}000000 $$
$$ \boxed{255.255.255.192 ;(/26)} $$
Step 3: New Subnet Value (Block Size / Increment)
$$ \text{Block size} = 2^{\text{remaining host bits}} = 2^{6} = 64 $$
Alternatively, block size = $256 - 192 = 64$.
$$ \boxed{\text{Subnet value} = 64} $$
Step 4: Resulting Subnets (using 192.168.1.0)
| Subnet | Network | Host Range | Broadcast |
|---|---|---|---|
| 0 | 192.168.1.0 | .1 - .62 | 192.168.1.63 |
| 1 | 192.168.1.64 | .65 - .126 | 192.168.1.127 |
| 2 | 192.168.1.128 | .129 - .190 | 192.168.1.191 |
| 3 | 192.168.1.192 | .193 - .254 | 192.168.1.255 |
Three of these four subnets satisfy the requirement.
Step 5: Usable Hosts per Subnet
$$ 2^{6} - 2 = 64 - 2 = 62 \text{ hosts} $$
Summary
| Parameter | Value |
|---|---|
| Bits borrowed | 2 |
| Subnets created | 4 (3 required) |
| New Subnet Mask | 255.255.255.192 |
| New Subnet Value (block size) | 64 |
| Usable hosts/subnet | 62 |
2080 · 5 marks
Suppose you are given an IP address 172.16.0.0, perform subnetting and divide the given network into 2 subnets. Calculate total number of hosts that can be configured, range of the IP addresses. [5]
2079 · 5 marks
Write the subnet ID and broadcast address of each subnet if you divide a class C network (192.168.3.0 – 192.168.3.255) into 4 different subnets. What is the new subnet mask? [5]
Show solved answerHide answer
Subnetting Class C Network (192.168.3.0 - 192.168.3.255) into 4 Subnets
Given
- Network: 192.168.3.0 - 192.168.3.255 (Class C, default mask /24 = 255.255.255.0)
- Required subnets: 4
Step 2: Bits to Borrow
To create 4 subnets:
$$2^n \geq 4 \implies 2^2 = 4 \implies n = 2 \text{ bits}$$
Borrow 2 bits from the host portion.
Step 3: New Subnet Mask
Original:
11111111.11111111.11111111.00000000 = 255.255.255.0 (/24)
Borrow 2 host bits:
11111111.11111111.11111111.11000000 = 255.255.255.192 (/26)
New Subnet Mask = 255.255.255.192 (/26)
Step 4: Block Size
$$\text{Block Size} = 256 - 192 = 64$$
Remaining host bits $= 8 - 2 = 6 \Rightarrow 2^6 = 64$ addresses per subnet (62 usable).
Step 5: Subnet Table
| Subnet | Subnet ID (Network Address) | Broadcast Address | Usable Host Range |
|---|---|---|---|
| 1 | 192.168.3.0 | 192.168.3.63 | 192.168.3.1 - 192.168.3.62 |
| 2 | 192.168.3.64 | 192.168.3.127 | 192.168.3.65 - 192.168.3.126 |
| 3 | 192.168.3.128 | 192.168.3.191 | 192.168.3.129 - 192.168.3.190 |
| 4 | 192.168.3.192 | 192.168.3.255 | 192.168.3.193 - 192.168.3.254 |
Step 6: Rule
- Subnet ID = first address of each block (host bits all 0).
- Broadcast = last address of each block (host bits all 1).
Summary
| Parameter | Value |
|---|---|
| Original Network | 192.168.3.0/24 |
| Subnets | 4 |
| Bits Borrowed | 2 |
| New Subnet Mask | 255.255.255.192 (/26) |
| Addresses / Subnet | 64 (62 usable) |
2078 · 5 marks
What subnet ID and broadcast address of each subnet if you divide a class B network (150.10.0.0 – 150.10.255.255) in 4 different subnets. What is the new subnet mask? [5]
Show solved answerHide answer
Subnetting Class B Network 150.10.0.0 into 4 Subnets
Given
- Network: 150.10.0.0 to 150.10.255.255
- Network Address: 150.10.0.0
- Class B default mask: 255.255.0.0 (/16)
- Host bits: 16 (last two octets)
- Required subnets: 4
Step 2: Bits to Borrow
$$2^n \geq 4 \implies n = 2 \text{ bits}$$
Borrow 2 bits from the host portion (third octet).
Step 3: New Subnet Mask
New prefix = $16 + 2 = /18$
Third octet: $11000000_2 = 192$
$$\boxed{\text{New Subnet Mask} = 255.255.192.0 ;(/18)}$$
Step 4: Block Size
$$\text{Block Size} = 256 - 192 = 64$$
Subnets increment by 64 in the third octet.
Hosts per subnet: $2^{14} - 2 = 16382$ usable hosts.
Step 5: Subnet Details
| Subnet | Subnet ID | First Host | Last Host | Broadcast | Mask |
|---|---|---|---|---|---|
| 1 | 150.10.0.0 | 150.10.0.1 | 150.10.63.254 | 150.10.63.255 | 255.255.192.0 |
| 2 | 150.10.64.0 | 150.10.64.1 | 150.10.127.254 | 150.10.127.255 | 255.255.192.0 |
| 3 | 150.10.128.0 | 150.10.128.1 | 150.10.191.254 | 150.10.191.255 | 255.255.192.0 |
| 4 | 150.10.192.0 | 150.10.192.1 | 150.10.255.254 | 150.10.255.255 | 255.255.192.0 |
Summary
- New Subnet Mask: 255.255.192.0 (/18)
- Subnet IDs: 150.10.0.0, 150.10.64.0, 150.10.128.0, 150.10.192.0
- Broadcast Addresses: 150.10.63.255, 150.10.127.255, 150.10.191.255, 150.10.255.255
2076 · 5 marks
In a block of address, we know the IP Address of one host is 192.34.12.56/28. What are the first address(network address) and the last address (limited broadcast address) in this block? [5]
2080.1 · 5 marks
Suppose you are given an IP address 192.168.0.0, perform subnetting and divide the given network in 2 subnets. Calculate total number of host that can be configured, range of IP address. [5]
Class-full and Classless Addressing
2080 · 10 marks
What is classless addressing? Explain distance vector routing with a suitable example.[10]
2080.1 · 10 marks
What is classful addressing? Explain link state routing with a suitable example.[10]
Types of Routing
2080 · 5 marks
Differentiate between link state and distance vector routing. [5]
2079 · 10 marks
Explain distance vector routing with example.[10]
Show solved answerHide answer
Distance Vector Routing
Definition
Distance Vector Routing is a dynamic routing algorithm where each router maintains a routing table (distance vector) that contains:
- The destination network/node
- The distance (cost/hop count) to reach that destination
- The direction (vector) i.e., the next hop (outgoing interface) to reach that destination
Each router shares its routing table only with its directly connected neighbors at regular intervals. Based on the received information, each router updates its own table. This process continues until all routers have consistent, stable routing tables -- a state called convergence.
Distance Vector Routing uses the Bellman-Ford Algorithm to compute shortest paths.
Key Characteristics
| Feature | Description |
|---|---|
| Algorithm used | Bellman-Ford |
| Information shared | Only with direct neighbors |
| Traffic overhead | Less (compared to Link State) |
| Convergence speed | Slower |
| Configuration | Easy |
| Hierarchical structure | No |
| Example protocol | RIP (max 15 hops) |
How It Works (Step-by-Step)
- Initialization: Each router knows only the cost to its directly connected neighbors. All other destinations are set to infinity (unknown).
- Advertisement: Each router sends its entire routing table to all directly connected neighbors periodically.
- Update: When a router receives a neighbor's table, it applies the Bellman-Ford equation:
$$D(x, y) = \min_{v} { c(x, v) + D(v, y) }$$
Where:
- $D(x, y)$ = estimated cost from node $x$ to destination $y$
- $c(x, v)$ = cost from $x$ to neighbor $v$
- $D(v, y)$ = neighbor $v$'s advertised cost to reach $y$
- Repeat until no more updates occur (convergence).
Example
Consider the following network with 4 routers: A, B, C, D and the link costs shown below:
A ---2--- B
| |
4 1
| |
D ---3--- C
Link costs:
- A -- B = 2
- A -- D = 4
- B -- C = 1
- D -- C = 3
Step 1: Initial Routing Tables (Each router knows only direct neighbors)
Router A:
| Destination | Cost | Next Hop |
|---|---|---|
| A | 0 | - |
| B | 2 | B |
| C | inf | - |
| D | 4 | D |
Router B:
| Destination | Cost | Next Hop |
|---|---|---|
| A | 2 | A |
| B | 0 | - |
| C | 1 | C |
| D | inf | - |
Router C:
| Destination | Cost | Next Hop |
|---|---|---|
| A | inf | - |
| B | 1 | B |
| C | 0 | - |
| D | 3 | D |
Router D:
| Destination | Cost | Next Hop |
|---|---|---|
| A | 4 | A |
| B | inf | - |
| C | 3 | C |
| D | 0 | - |
Step 2: First Exchange -- Routers share tables with neighbors
Router A updates using tables received from B and D:
- A to C via B: cost(A,B) + cost(B,C) = 2 + 1 = 3 (better than inf) --> update
- A to C via D: cost(A,D) + cost(D,C) = 4 + 3 = 7 (worse than 3) --> ignore
- A to D via B: cost(A,B) + cost(B,D) = 2 + inf = inf --> no update
- A to B via D: cost(A,D) + cost(D,B) = 4 + inf = inf --> no update
Updated Router A Table:
| Destination | Cost | Next Hop |
|---|---|---|
| A | 0 | - |
| B | 2 | B |
| C | 3 | B |
| D | 4 | D |
Router B updates using tables from A and C:
- B to D via A: cost(B,A) + cost(A,D) = 2 + 4 = 6 (better than inf) --> update
- B to D via C: cost(B,C) + cost(C,D) = 1 + 3 = 4 (better than 6) --> update
Updated Router B Table:
| Destination | Cost | Next Hop |
|---|---|---|
| A | 2 | A |
| B | 0 | - |
| C | 1 | C |
| D | 4 | C |
Router C updates using tables from B and D:
- C to A via B: cost(C,B) + cost(B,A) = 1 + 2 = 3 (better than inf) --> update
- C to A via D: cost(C,D) + cost(D,A) = 3 + 4 = 7 --> ignore
Updated Router C Table:
| Destination | Cost | Next Hop |
|---|---|---|
| A | 3 | B |
| B | 1 | B |
| C | 0 | - |
| D | 3 | D |
Router D updates using tables from A and C:
- D to B via A: cost(D,A) + cost(A,B) = 4 + 2 = 6 (better than inf) --> update
- D to B via C: cost(D,C) + cost(C,B) = 3 + 1 = 4 (better than 6) --> update
Updated Router D Table:
| Destination | Cost | Next Hop |
|---|---|---|
| A | 4 |
2078 · 5 marks
What is routing table? Differentiate static routing table with dynamic routing table. [5]
Show solved answerHide answer
Routing Table: Static vs Dynamic Routing
Routing Table
A routing table is a data structure stored in a router (or networked device) that lists the routes to particular network destinations. Routers use this table to make decisions on how to forward data packets based on their IP addresses. The routing table contains information such as destination network, next hop address, and interface to use. Routers normally connect LANs and WANs together and have a routing table based on which they make decisions on routing the data packets.
Static Routing Table
A static routing table is one in which routes are manually added and configured by a network administrator. The routes remain fixed unless manually updated or reconfigured.
Key characteristics:
- Routes are configured manually by the administrator
- Used when there are very few devices to configure
- Suitable when routes are known and are unlikely to change
- Does not handle network failures well, because any lost connectivity must be manually repaired or reconfigured
- No routing protocol is needed
Dynamic Routing Table
A dynamic routing table is one in which routes are automatically adjusted according to the current state of the network. It uses routing protocols to discover network destinations and the best routes to reach them.
Key characteristics:
- Routes are updated automatically based on current network conditions
- Uses routing protocols such as RIP, OSPF, and BGP to discover routes
- If one route goes down, automatic adjustment is made to find an alternate route
- Suitable for large and complex networks
- Requires more processing and bandwidth due to protocol overhead
Difference Between Static and Dynamic Routing Table
| Basis | Static Routing Table | Dynamic Routing Table |
|---|---|---|
| Configuration | Manually configured by administrator | Automatically configured using protocols |
| Adaptability | Cannot adapt to network changes automatically | Automatically adapts to network changes |
| Failure Handling | Poor; requires manual reconfiguration on failure | Handles failures automatically by finding alternate routes |
| Protocols Used | No routing protocol required | Uses protocols like RIP, OSPF, BGP |
| Scalability | Suitable for small networks with few devices | Suitable for large and complex networks |
| Administrative Overhead | High (manual updates needed) | Low (self-updating) |
| Resource Usage | Less CPU and bandwidth usage | More CPU and bandwidth usage due to protocol overhead |
Summary: Static routing is simple but inflexible, best for small stable networks. Dynamic routing is flexible and self-managing, best for large networks where topology may change frequently.
2076 · 5 marks
Define routing table. Differentiate static routing table with dynamic routing table. [5]
Show solved answerHide answer
Routing Table: Definition and Static vs Dynamic Routing Table
Definition of Routing Table
A routing table is a data structure stored in a router (or networked device) that lists the routes to particular network destinations. It contains information such as destination network addresses, next-hop addresses, and interface information that a router uses to determine the best path for forwarding data packets. Routers normally maintain a dynamically updating routing table based on which they make decisions on routing the data packets.
Differentiation: Static Routing Table vs Dynamic Routing Table
| Basis | Static Routing Table | Dynamic Routing Table |
|---|---|---|
| Definition | Routes are manually added and configured by the network administrator. | Routes are automatically adjusted according to the current state of the network. |
| Configuration | Manual configuration is required for each route. | Uses routing protocols (e.g., RIP, OSPF, BGP) to discover routes automatically. |
| Adaptability | Does not handle failures well; any lost connectivity must be fixed manually. | Automatically adjusts routes if one path goes down, maintaining connectivity. |
| Use Case | Used when there are very few devices to configure and routes are unlikely to change. | Used in large, complex networks where routes frequently change. |
| Administrative Overhead | High, since every change must be updated manually. | Low, since the protocol handles updates automatically. |
| Examples of Protocols | No protocol required. | RIP, OSPF, BGP, etc. |
| Network Size | Suitable for small networks. | Suitable for medium to large networks. |
| Reliability | Less reliable during network failures. | More reliable as it responds to network changes dynamically. |
Summary
- Static routing is simple but inflexible; it requires manual intervention for any route change or failure.
- Dynamic routing uses protocols to discover and maintain routes automatically, making it more scalable and fault-tolerant for larger networks.
2080.1 · 5 marks
Differentiate between unicast and multicast routing. [5]
IPv6 Addressing and its Features
Comparison of IPv4 and IPv6 Addressing
2078 · 5 marks
Explain the structure of IPv6 address. Compare IPv6 address with IPv4 address. [5]
Make Unit 4 stick
Practice CSC263 with flashcards & quizzes