Software-Engineering

IP Addresses

What are IP Addresses?

IP (Internet Protocol) addresses are numerical labels assigned to devices connected to a computer network that uses the Internet Protocol for communication. They serve as unique identifiers for hosts on a network, enabling routing of data packets across the internet.

How Do IP Addresses Work?

IP addresses work at the Network Layer (Layer 3) of the OSI model. They provide logical addressing that allows routers to forward packets between different networks. The IP protocol encapsulates data from the Transport Layer and adds routing information.

IP Packet Structure

An IP packet consists of:

graph TD
    A[IP Header<br/>20-60 bytes] --> B[Payload<br/>TCP/UDP data]
    A --> C[Source IP]
    A --> D[Destination IP]
    A --> E[Protocol<br/>TCP=6, UDP=17]
    A --> F[TTL<br/>Time to Live]

IPv4 vs IPv6

IPv4

IPv6

graph TD
    A[IPv4 Address] --> B[32 bits<br/>192.168.1.1]
    A --> C[Network + Host<br/>192.168.0.0/16]
    D[IPv6 Address] --> E[128 bits<br/>2001:db8::1]
    D --> F[Network + Interface<br/>2001:db8::/32]

Why Are IP Addresses Needed?

IP addresses are fundamental to internet communication:

Ports

What are Ports?

Ports are 16-bit numbers (0-65535) that identify specific processes or services on a host. They work with IP addresses to create socket endpoints for network communication.

How Do Ports Work?

Ports allow multiple applications on the same host to use network services simultaneously:

Port Ranges

Why Are Ports Needed?

Ports enable multiplexing of network services: