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 :
Complément : IPv4 packet header
Complément : IPv4 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.
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ément : Subnet 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éthode : Finding a Subnetwork
Network Address = IP[1] Address AND Subnet Mask
PC1: IP[1] address= 192.168.1.10, Subnet Mask = 255.255.255.0
Convert to binary:
IP[1] address: 11000000.10101000.00000001.00001010
Mask: 11111111.11111111.11111111.00000000
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éthode : Check 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
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
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.
