Network Layer – IPv4 Addressing, Subnetting, CIDR, and Datagram Forwarding (Lecture Notes)
Network Layer – Lecture Notes (Week 4)
OSI Model context
- The Network Layer sits above Data Link and Physical layers and below Transport in the OSI model.
- Key functions at the Network Layer: routing (determining the path for packets) and forwarding (moving packets from a router’s input to the appropriate output port).
- Practical analogy:
- Routing: planning a trip from source to destination.
- Forwarding: getting through a single interchange on that trip.
- Core responsibilities per slide: end-to-end connections and data delivery, routing data packets, and selecting the best path to deliver data.
Two core Network Layer functions (overview)
- Routing: determines the route taken by packets from source to destination – implemented via routing algorithms.
- Forwarding: moves packets from the router’s input to the appropriate router’s output.
- Analogy recap: routing = trip planning; forwarding = traversing a single leg.
Network Layer within the broader protocol stack (context)
- End-to-end delivery is achieved through hops across multiple networks.
- Routers make forwarding decisions using routing tables and IP addressing.
- The Network Layer is responsible for selecting routes and ensuring data reaches the destination across multiple networks; the Data Link and Physical layers handle actual transmission on a given link.
IP addressing fundamentals (IPv4) – 32-bit addressing and dotted decimal notation
- An IP address is a 32-bit binary number.
- Readability format: divide into four 8-bit octets and convert each to decimal, e.g. the 32-bit binary example can be grouped into 4 octets and shown as dotted decimal:
- Example workflow from slide:
- Binary example: 10101100 00010000 10000000 00010001
- Decimal per octet: 172, 16, 128, 17
- Dotted decimal notation:
- Addresses can be written in binary, decimal, or dotted decimal formats; networks rely on consistent representation for routing and subnetting.
IP Address Classes (overview) and role
- Class A, B, C are the most commonly referenced in traditional (classful) addressing:
- Class A: large number of hosts per network; default network prefix /8.
- Class B: medium size; default prefix /16.
- Class C: smaller networks; default prefix /24.
- Class D: multicast addresses (not commonly used for unicast host addressing).
- Class E: experimental addresses (not normally assigned publicly).
- Addresses also include special-purpose ranges (e.g., 127.0.0.1 is loopback).
- Loopback note: 127.0.0.0/8 reserved for loopback testing and cannot be assigned to devices on a network.
Subnetting: subnet concept and purpose
- A subnet is a network within a network; subnetting divides a larger network into two or more smaller networks.
- Benefits of subnetting:
- Easier network management.
- Reduced overall traffic within each subnet.
- Easier application of network security policies.
- Subnet mask concept: separates the IP address into a network part and a host part.
- In the subnet mask, network bits are 1s and host bits are 0s.
- Bitwise AND of IP address and subnet mask yields the network prefix.
- Subnet mask defines how many bits are significant for the network portion.
Subnetting examples and key ideas
- Subnetting example (conceptual): a given IP address and a subnet mask produce a network prefix and a host ID.
- A concrete example shown: subnet 192.168.5.0/24
- IP address: 192.168.5.130 with subnet mask 255.255.255.0 (i.e., /24).
- Network prefix: 192.168.5.0
- Host part: 130 (binary 00000000.00000000.00000000.10000010 in host bits)
- In the /24 example, the first 24 bits are the network, last 8 bits identify hosts within that network.
- The subnet mask can be represented in binary form to illustrate the boundary: 11111111.11111111.11111111.00000000 for /24.
CIDR (Classless Inter-Domain Routing) fundamentals
- CIDR purpose: improve IP address allocation efficiency and delay IPv4 address exhaustion.
- CIDR notation: a/b where a is an IP address and b is the number of network bits in the prefix (the network mask length).
- IPv4 address space: 2^32 ≈ 4.29 billion addresses.
- Classful addressing (A, B, C) allocates in 8-bit increments and can be wasteful (minimum allocation of 256 addresses for many organizations).
- CIDR allows allocation in smaller (or larger) blocks by prefix length, e.g. /8, /16, /24, etc., enabling precise control over address space.
- CIDR can represent classful addresses by using the corresponding prefix length (e.g., Class A = /8, Class B = /16, Class C = /24).
- CIDR notational example: 216.3.128.0/25 represents a block with a 25-bit network prefix.
- CIDR RFC reference: RFC 1519 (for detailed CIDR specs).
CIDR example calculations and practical blocks
- Example: 216.3.128.0/25
- Network prefix length: 25 bits.
- Host bits: 32 - 25 = 7 bits.
- Possible hosts per subnet:
- Subnet mask in dotted decimal:
- Example: ISP block 122.211.0.0/16
- Network prefix length: 16 bits; host bits: 16.
- A customer needing up to 6 hosts can be allocated a /29 block if appropriate: 122.211.176.208/29.
- Subnet mask for /29: (3 bits for host part).
Subnetting in detail: number of subnets and hosts (Classful context)
- Class C networks:
- Default: /24 (network bits = 24; host bits = 8).
- If you borrow s bits for subnets from the host portion, then:
- Number of subnets:
- Number of hosts per subnet:
- Class B networks:
- Default: /16 (host bits = 16).
- If you borrow s bits from hosts for subnets:
- Subnets:
- Hosts per subnet:
- Class A networks:
- Default: /8 (host bits = 24).
- If you borrow s bits:
- Subnets:
- Hosts per subnet:
- Practical note: traditional tables show subnets per class and available hosts per subnet; modern practice often uses CIDR rather than strict classful borrowing.
CIDR-based address allocation implications
- CIDR enables flexible aggregation (route summarization) and avoids excessive subnetting waste.
- The prefix length (b) indicates the number of network bits; host bits are 32 - b.
- Example recap:
- /25: 7 host bits → up to 126 usable hosts per subnet.
- /29: 3 host bits → up to 6 usable hosts per subnet.
IPv4 vs IPv6 (high-level differences)
- IP address size:
- IPv4: 32-bit addresses.
- IPv6: 128-bit addresses.
- Address space:
- IPv4: ~4.3 billion addresses (2^32).
- IPv6: ~3.4 × 10^14 (340 trillion) addresses (2^128).
- Notation and formatting:
- IPv4: four groups of two hexadecimal digits separated by dots (example: 172.16.50.3).
- IPv6: eight groups of four hexadecimal digits separated by colons (example: 2001:0db8:0012:0001:3c5e:7354:0000:5db1).
- (Note: Both protocols will coexist until IPv6 fully replaces IPv4; IPv6 adoption has been increasing over time; as of late 2022, IPv6 share of Internet traffic was significant according to Google statistics.)
Datagram forwarding and routing (how a datagram gets from source to destination)
- IP datagram carries source IP, destination IP, and payload, and is routed hop-by-hop across networks.
- Forwarding table concept (illustrative): destination network, next router, and number of hops to next hop.
- Key steps in delivering a datagram:
- At the source, determine the destination network address.
- If the destination is on the same network, the data can be delivered directly via the data link layer to the destination.
- If the destination is on a different network, forward the datagram to the next-hop router according to the routing table.
- The datagram then travels from router to router until it reaches the destination network, where the final delivery occurs on the destination link.
- Illustration examples (high level):
- Case A: destination on the same network as the source → direct link-layer delivery within the local network.
- Case E: destination on a different network → router-by-router forwarding using the next-hop information in routing tables.
- Routing decisions are based on the destination IP, routing tables, and network topology; forwarding is the act of moving a datagram between interfaces on a router.
Practical network design and learning checkpoints (course context)
- Week 4 focus includes network layer devices and configurations, subnetting, and CIDR.
- Practical lab activities include designing a network in Cisco Packet Tracer and configuring routers and PCs to reinforce subnetting concepts and routing/forwarding fundamentals.
- Reading and reference materials include classic textbooks and online resources on OSI layers, subnetting, and IP addressing.
Key formulas and reference calculations (summary)
- Subnetting host capacity (classful baseline):
- Class A: hosts per subnet when s bits borrowed:
- Class B:
- Class C:
- Number of subnets when borrowing s bits:
- CIDR host capacity for a given prefix length b (network bits):
- Hosts per subnet:
- CIDR examples:
- For a /25 network:
- For a /29 network:
- IPv4 vs IPv6 scope notes:
- IPv4 address space:
- IPv6 address space:
References and suggested readings (from slides)
- Tanenbaum, A., Wetherall, D., Computer Networks, 5/E, Prentice Hall
- Comer, D., Computer Networks and Internets, 5/E, Prentice Hall
- Paterson, D.A., Hennessy, J.L., Computer Organization and Design, 4th Ediion
- Kurose, J. Ross, K., Computer Networking: A Top-Down Approach
- Computer Networking Notes and online study guides: e.g., CCNA study guide resources
Quick recap of the week’s lab and tasks
- In this week’s lab, you will design a network in Cisco Packet Tracer, configure routers and PCs, and reinforce subnetting learning.
Notes on practical application and real-world relevance
- CIDR is essential for efficient IP address management and scalable routing on the Internet.
- Subnetting allows organizations to control broadcast domains, implement security policies, and tailor network size to departmental needs.
- Understanding how datagrams are forwarded hop-by-hop helps in diagnosing routing issues and optimizing network performance.
Concepts to remember for exams
- Distinguish routing vs forwarding and give examples.
- Be able to convert between binary and dotted decimal and to segment an IP address into network and host portions given a subnet mask.
- Compute the number of subnets and hosts given a classful network with borrowed bits, and perform similar calculations for CIDR-prefix networks.
- Explain the differences between IPv4 and IPv6 in terms of address size, formatting, and the rationale for CIDR.
- Describe how a datagram is routed from source to destination across multiple routers using routing tables and next-hop information.