Application layer part 2
The application layer is the top layer of both the TCP/IP and OSI models. It’s the layer that provides network services to applications. In simpler terms, it’s the layer that users interact with directly when they use applications that need to communicate over a network.
1. Supernetting (Application layer)
Purpose
Supernetting is used to combine multiple smaller networks (subnets) into a single larger network. This helps:
- Reduce the size of routing tables.
- Make routing more efficient.
- Save IP address space.
Example
Suppose you have four subnets: (Application layer)
- 192.168.0.0/26
- 192.168.0.64/26
- 192.168.0.128/26
- 192.168.0.192/26
All these can be merged into a single supernet:
192.168.0.0/24
This allows a router to use just one route instead of four.
2. Classless Addressing (CIDR – Classless Inter-Domain Routing)
What is CIDR?
CIDR replaces class-based addressing with variable-length subnet masks. It allows flexible allocation of IP addresses based on need rather than fixed blocks (Class A, B, C). (Application layer)
Format
CIDR uses a format like:
IP_address/prefix_length
Example: 192.168.1.0/24
Here, the first 24 bits are the network portion, and the remaining are for hosts.
Advantages
- Saves IP addresses by allocating only as many as needed.
- Supports supernetting and subnetting.
- Reduces routing table size.
- Efficient IP management.
3. Network Address Translation (NAT)
What is NAT?
NAT is a process where a router modifies IP addresses in packets as they pass through, allowing multiple devices in a private network to access the internet using a single public IP. (Application layer)

Purpose
- Conserves IPv4 addresses.
- Hides internal IP addresses (security).
- Allows private networks to access public networks.
Types of NAT
PAT (Port Address Translation): Many-to-one mapping using different ports. Common in homes and offices.
Static NAT: One-to-one mapping of a private IP to a public IP.
Dynamic NAT: Private IPs are assigned any available public IP from a pool.
(Application layer)
Routing Algorithm: Distance-Vector Routing Algorithm
Routing Algorithm
Routing algorithms are used to determine the optimal path for data to travel from source to destination in a network. These algorithms help routers make decisions about where to forward packets.
Distance-Vector Routing Algorithm
Distance-Vector Routing is a dynamic routing protocol where routers share information with their immediate neighbors and update their routing tables based on the shortest path (least cost).
Definition
In this algorithm, each router maintains a table (called a vector) showing the best-known distance to each destination and which direction (neighbor) to send the packet.
Key Features
- Based on the Bellman-Ford algorithm.
- Routers exchange routing tables with neighbors periodically.
- Updates are simple and distributed.
- Slower convergence.
- Vulnerable to count-to-infinity problems.
How It Works
- Each router initializes its table with direct neighbors’ distances.
- Routers send their table to directly connected neighbors.
- On receiving updates, a router recalculates the shortest paths.
- The process continues until no changes occur in any table.
Numerical Based on Distance-Vector Routing Algorithm
Example Network Topology
Consider 4 routers: A, B, C, D
Connections:
- A–B: 1
- A–C: 4
- B–C: 2
- B–D: 5
- C–D: 1
Step 1: Initial Distance Tables
Each router only knows its direct neighbors.
Router | To A | To B | To C | To D |
---|---|---|---|---|
A | 0 | 1 | 4 | ∞ |
B | 1 | 0 | 2 | 5 |
C | 4 | 2 | 0 | 1 |
D | ∞ | 5 | 1 | 0 |
Step 2: Exchange and Update
Routers share tables with neighbors.
Example: A learns from B that C can be reached with cost 1+2=3, which is better than 4.
A also learns D can be reached via B: 1+5=6.
Updated A’s table:
To A | To B | To C | To D |
---|---|---|---|
0 | 1 | 3 | 6 |
This process continues until all routers reach a stable state.
Link-State Routing Algorithm
Definition
Link-State Routing is a dynamic routing algorithm where each router has a complete map (topology) of the entire network and independently calculates the shortest path to every other router using Dijkstra’s algorithm.
Key Features
- Each router discovers its neighbors and learns their link costs.
- Routers generate (LSAs) to share link info.
- All routers build the same topology map.
- Shortest paths are computed
- Faster convergence and more scalable than Distance-Vector.
Steps Involved
- Discover neighbors and learn their link costs.
- Build LSA and send it to all routers in the network.
- Receive LSAs from other routers.
- Construct the complete network topology.
- Use Dijkstra’s algorithm to compute shortest paths.
Numerical Based on Link-State Routing Algorithm
Example Network Topology
Consider routers A, B, C, D, and E with the following link costs:
A
/ \
B C
| \ |
E D--/
Link costs:
- A–B: 2
- A–C: 5
- B–D: 1
- C–D: 3
- B–E: 3
- D–E: 2
Step 1: Build Topology Map
Each router receives LSAs from others and constructs the full network graph with all link costs.
Step 2: Apply Dijkstra’s Algorithm (from Router A)
Initialize:
- Distance to A = 0
- All others = ∞
Progressively update shortest distances and previous nodes:
Node | Distance from A | Previous Node |
---|---|---|
A | 0 | – |
B | 2 | A |
C | 5 | A |
D | 3 (A→B→D) | B |
E | 5 (A→B→E) | B |