4. Network Layer

Ip Addressing

IPv4 and IPv6 addressing formats, subnetting, CIDR, address allocation, and address resolution principles.

IP Addressing

Welcome to your lesson on IP addressing, students! 🌐 This lesson will help you understand how devices on computer networks are identified and communicate with each other through unique addresses. By the end of this lesson, you'll master the fundamentals of IPv4 and IPv6 addressing formats, learn how subnetting works, understand CIDR notation, and discover how devices resolve addresses to communicate effectively. Get ready to unlock the secrets of how billions of devices across the internet find and talk to each other!

Understanding IP Addresses: The Foundation of Network Communication

Think of an IP address like your home address - it's a unique identifier that tells other devices exactly where to find you on a network! šŸ“® An IP (Internet Protocol) address is a numerical label assigned to every device connected to a computer network that uses the Internet Protocol for communication.

Currently, there are two main versions of IP addresses in use: IPv4 and IPv6. IPv4 has been the backbone of internet communication since the 1980s, but with the explosive growth of internet-connected devices, we've needed to transition to IPv6 to accommodate more addresses.

IPv4 Addressing Format

IPv4 addresses are 32-bit numbers, typically written in dotted decimal notation. This means the 32 bits are divided into four 8-bit sections (called octets), each represented as a decimal number from 0 to 255. For example: 192.168.1.100.

Let's break this down:

  • Each octet can represent values from 0 to 255 (that's 256 possible values per octet)
  • Total possible IPv4 addresses: $2^{32} = 4,294,967,296$ (about 4.3 billion addresses)
  • The format looks like: XXX.XXX.XXX.XXX where each XXX is between 0-255

IPv6 Addressing Format

IPv6 addresses are 128-bit numbers, written in hexadecimal notation with colons separating groups of four hexadecimal digits. A typical IPv6 address looks like: 2001:0db8:85a3:0000:0000:8a2e:0370:7334.

Key facts about IPv6:

  • Uses 128 bits instead of 32 bits
  • Total possible addresses: $2^{128}$ (that's about 340 undecillion addresses!)
  • Written in hexadecimal (0-9 and A-F)
  • Can be shortened by removing leading zeros and consecutive zero groups

The massive increase in available addresses means we'll never run out of IPv6 addresses - there are enough to assign millions of addresses to every person on Earth! šŸš€

Address Classes and Private vs Public Addresses

IPv4 Address Classes

Traditionally, IPv4 addresses were divided into classes based on their first octet:

  • Class A: 1.0.0.0 to 126.255.255.255 (for very large networks)
  • Class B: 128.0.0.0 to 191.255.255.255 (for medium-sized networks)
  • Class C: 192.0.0.0 to 223.255.255.255 (for small networks)
  • Class D: 224.0.0.0 to 239.255.255.255 (for multicast)
  • Class E: 240.0.0.0 to 255.255.255.255 (reserved for experimental use)

Private vs Public IP Addresses

Not all IP addresses are created equal! Some are meant for use within private networks, while others are routable on the public internet.

Private IP Address Ranges (RFC 1918):

  • Class A: 10.0.0.0 to 10.255.255.255
  • Class B: 172.16.0.0 to 172.31.255.255
  • Class C: 192.168.0.0 to 192.168.255.255

These private addresses are like having an internal phone system in a large office building - they work great for communication within the building, but you can't call them directly from outside! Your home router likely assigns devices addresses like 192.168.1.100 or 10.0.0.5.

Public IP addresses are globally unique and routable on the internet. When you visit a website, you're connecting to its public IP address. Internet Service Providers (ISPs) assign public IP addresses to customers.

Subnetting: Dividing Networks Efficiently

Subnetting is like dividing a large apartment building into smaller floors and units - it helps organize and manage network traffic more efficiently! šŸ¢

Subnet Masks

A subnet mask determines which portion of an IP address represents the network and which part represents the host (individual device). The most common subnet mask is 255.255.255.0, which means:

  • First three octets (24 bits) identify the network
  • Last octet (8 bits) identifies individual hosts
  • This allows for 254 usable host addresses per subnet (256 - 2 for network and broadcast addresses)

Subnetting Example

Let's say you have the network 192.168.1.0/24 and want to create smaller subnets:

Original network: 192.168.1.0/24 (254 hosts)

  • Subnet 1: 192.168.1.0/25 (126 hosts)
  • Subnet 2: 192.168.1.128/25 (126 hosts)

By borrowing one bit from the host portion, you've created two smaller subnets, each capable of supporting 126 devices.

Benefits of Subnetting:

  • Improved network performance by reducing broadcast traffic
  • Enhanced security through network segmentation
  • Better organization of network resources
  • More efficient use of IP address space

CIDR: Classless Inter-Domain Routing

CIDR (pronounced "cider") revolutionized how we think about IP addressing by moving away from rigid address classes! šŸŽ

CIDR Notation

CIDR uses a slash followed by a number to indicate how many bits are used for the network portion. For example:

  • 192.168.1.0/24 means 24 bits for network, 8 bits for hosts
  • 10.0.0.0/8 means 8 bits for network, 24 bits for hosts
  • 172.16.0.0/12 means 12 bits for network, 20 bits for hosts

Calculating Available Hosts

To find how many hosts a CIDR block can support:

Host bits = 32 - network bits

Available hosts = $2^{\text{host bits}} - 2$

Example: 192.168.1.0/26

  • Network bits: 26
  • Host bits: 32 - 26 = 6
  • Available hosts: $2^6 - 2 = 64 - 2 = 62$ hosts

The "-2" accounts for the network address and broadcast address, which cannot be assigned to individual devices.

Address Allocation and Management

Internet Assigned Numbers Authority (IANA)

IANA is the global coordinator of IP address allocation, like a central bank for IP addresses! They delegate large blocks of addresses to Regional Internet Registries (RIRs):

  • ARIN (American Registry for Internet Numbers) - North America
  • RIPE NCC - Europe, Middle East, Central Asia
  • APNIC - Asia Pacific region
  • LACNIC - Latin America and Caribbean
  • AFRINIC - Africa

Dynamic vs Static IP Assignment

Dynamic IP Assignment (DHCP):

  • Addresses assigned automatically when devices connect
  • Addresses can change over time
  • More efficient use of available addresses
  • Common in home networks and for client devices

Static IP Assignment:

  • Manually configured addresses that don't change
  • Used for servers, printers, and network infrastructure
  • Provides consistent accessibility
  • Requires careful planning to avoid conflicts

Address Resolution: How Devices Find Each Other

Address Resolution Protocol (ARP)

ARP is like a phone book that translates IP addresses to MAC (Media Access Control) addresses on local networks! šŸ“ž When your computer wants to send data to another device on the same network, it needs to know that device's physical MAC address.

ARP Process:

  1. Device A wants to communicate with IP address 192.168.1.50
  2. Device A broadcasts an ARP request: "Who has 192.168.1.50?"
  3. The device with that IP responds with its MAC address
  4. Device A stores this information in its ARP table for future use
  5. Communication can now proceed using the MAC address

Domain Name System (DNS)

DNS translates human-readable domain names (like google.com) into IP addresses that computers can understand. It's like having a massive contact list that converts names into phone numbers!

When you type www.example.com in your browser:

  1. Your computer checks its local DNS cache
  2. If not found, it queries your ISP's DNS server
  3. The DNS server returns the corresponding IP address
  4. Your browser connects to that IP address

IPv6 Transition and Coexistence

As IPv4 addresses become increasingly scarce, the transition to IPv6 becomes more critical. Several technologies help IPv4 and IPv6 networks coexist:

Dual Stack: Devices run both IPv4 and IPv6 simultaneously, choosing the best protocol for each connection.

Tunneling: IPv6 packets are encapsulated within IPv4 packets to traverse IPv4-only networks.

Translation: Gateways convert between IPv4 and IPv6 protocols, allowing communication between different protocol versions.

Conclusion

IP addressing forms the foundation of all network communication, providing unique identifiers for billions of devices worldwide. You've learned how IPv4's 32-bit addresses provide over 4 billion unique combinations, while IPv6's 128-bit addresses solve address scarcity with an virtually unlimited address space. Subnetting and CIDR allow efficient network organization and address allocation, while protocols like ARP and DNS ensure devices can find and communicate with each other seamlessly. As networks continue to grow and evolve, understanding these addressing principles will help you navigate and troubleshoot network connectivity issues effectively.

Study Notes

• IPv4 Format: 32-bit addresses in dotted decimal notation (e.g., 192.168.1.1), providing $2^{32}$ ā‰ˆ 4.3 billion addresses

• IPv6 Format: 128-bit addresses in hexadecimal notation with colons, providing $2^{128}$ addresses

• Private IPv4 Ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 - not routable on public internet

• Subnet Mask: Determines network vs host portions of IP address (e.g., 255.255.255.0 = /24)

• CIDR Notation: Network/prefix length format (e.g., 192.168.1.0/24 means 24 network bits, 8 host bits)

• Host Calculation: Available hosts = $2^{\text{host bits}} - 2$ (subtract network and broadcast addresses)

• Address Classes: Class A (1-126), Class B (128-191), Class C (192-223) - largely obsolete due to CIDR

• DHCP: Dynamic Host Configuration Protocol automatically assigns IP addresses to devices

• ARP: Address Resolution Protocol maps IP addresses to MAC addresses on local networks

• DNS: Domain Name System translates domain names to IP addresses

• IPv6 Transition: Dual stack, tunneling, and translation enable IPv4/IPv6 coexistence

• Regional Registries: ARIN, RIPE NCC, APNIC, LACNIC, AFRINIC manage regional IP address allocation

Practice Quiz

5 questions to test your understanding

Ip Addressing — Computer Networks | A-Warded