IP

TCP/UDP define the port to deliver the data, but where is the destination machine?

• To reach the correct host or computer, we need its address (IP address).

Définition

IP[1] handles the addressing[2] and routing[3] of packets across networks.

Versions: IPv4[4] (32-bit) and IPv6[5] (128-bit).

It works with TCP[7] or UDP[6] at the transport layer for end-to-end communication.

ComplémentIPv4 packet header

The IPv4[4] packet is the basic unit of data at the network layer. It contains an IP[1] header and a payload (data from transport layer).

The header includes key information such as:

  • Source IP[1] address– the sender machine

  • Destination IP[1] address– the receiver machine

  • Protocol– indicates if payload is TCP[7], UDP[6], or another protocol

ComplémentIPv4 addresses

Every host and router on the Internet network has an IP address. This combination is unique, two machines cannot have the same IP[1] address in the same netwrok. IPv4[4] addresses are 32-bit encoded

Although an IPv4[4] address is a 32-bit binary number, it is usually written in dotted-decimal format (e.g.,192.168.1.10) for easier reading and configuration. IP[1] addresses are grouped into classes to adapt addressing to network size and number of hosts.

IPv4[4] classes:

  • Class A: 0.0.0.0 – 126.255.255.255 (very large networks)

  • Class B: 128.0.0.0 – 191.255.255.255 (medium networks)

  • Class C: 192.0.0.0 – 223.255.255.255 (small networks)

  • Class D: 224.0.0.0 – 239.255.255.255 (multicast)

  • Class E: 240.0.0.0 – 255.255.255.255 (reserved)

Exceptions:

  • 127.0.0.0/8: loopback (localhost, e.g., 127.0.0.1)

  • 0.0.0.0 : special, often used for default route

ComplémentSubnet Mask

The subnet mask defines which part of an IP[1] address identifies the network and which part identifies the host.

IP Address

Subnet Mask

Network / Host

192.168.1.10

255.255.255.0

Network: 192.168.1 / Host: 10

172.16.5.20

255.255.0.0

Network: 172.16 / Host: 5.20

10.2.3.4

255.0.0.0

Network: 10 / Host: 2.3.4

The host part identifies the specific machine in that network.

Machines can communicate directly only if their network part is the same.

MéthodeFinding a Subnetwork

Network Address = IP[1] Address AND Subnet Mask

PC1: IP[1] address= 192.168.1.10, Subnet Mask = 255.255.255.0

  1. Convert to binary:

    IP[1] address: 11000000.10101000.00000001.00001010

    Mask: 11111111.11111111.11111111.00000000

  2. Apply logical AND:

    IP[1] address AND MASK = Network Address: 11000000.10101000.00000001.00000000 = 192.168.1.0

The network address of PC1 is 192.168.1.0.

MéthodeCheck if two machines can communicate directly

PC1: IP[1] address= 192.168.1.10, Subnet Mask = 255.255.255.0

PC2: IP[1] address= 192.168.1.20, Subnet Mask = 255.255.255.0

  1. Find the network address of each machine

    Convert to binary and perform AND with subnet mask:

    PC1: 11000000.10101000.00000001.00001010 AND 11111111.11111111.11111111.00000000 = 192.168.1.0

    PC2: 11000000.10101000.00000001.00010100 AND 11111111.11111111.11111111.00000000 = 192.168.1.0

  2. Compare network addresses

    • If network addresses are the same = direct communication possible

    • If network addresses differ = communication requires a router

      PC1 Network = 192.168.1.0

      PC2 Network = 192.168.1.0

PC1 and PC2 -> same network -> direct communication.