IP Definition
On an IP network, if a user wants to connect a computer to the Internet, the user needs to apply for an IP address for the computer. An IP address identifies a node on a network and is used to find the destination for data. We use IP addresses to implement global network communication.
An IP address is an attribute of a network device interface, not an attribute of the network device itself. To assign an IP address to a device is to assign an IP address to an interface on the device. If a device has multiple interfaces, each interface needs at least one IP address.
IP has two versions: IPv4 and IPv6. IPv4 packets prevail on the Internet, and the Internet is undergoing the transition to IPv6.
(Unless otherwise specified, IP addresses mentioned in this post refer to IPv4 addresses.)

IP Address Notation
An IP address can be written as a 32-bit binary integer. To facilitate reading and analysis an IP address is usually represented in dot-decimal notation, consisting of four decimal numbers, each ranging from 0 to 255, Separated by dots, such as, 192.168.10.1.

IP Address Structure
l An IPv4 address is divided into two parts:
n Network part (network ID): indicates a network where a host is located, which is similar to the function of 'Community A in district B of City X in province Y'.
n Host part: identifies a host and is used to differentiate hosts on a network. The function of host ID is like a host Location "No. A Street B”.
l A network mask is also called a subnet mask:
n A network mask is 32 bits long, which is also represented in dotted-decimal notation, like bits in an IP address.
n The network mask is not an IP address. The network mask consists of consecutive 1s followed by consecutive 0s in binary notation.
n Generally, the number of 1s indicates the length of a network mask. For example, the length of mask 0.0.0.0 is 0, and the length of mask 252.0.0.0 is 6.
n The network mask is generally used together with the IP address. Bits of 1 correspond to network bits in the IP address. Bits of 0 corresponds to host bits in the IP address. In other words, in an IP address, the number of 1s in a network mask is the number of bits of the network ID, and the number of 0s is the number of bits in the host ID.

Network addressing
A network range defined by a network ID is called a network segment.
Layer 2 network addressing:
Host interfaces in the same network segment can be found based on IP addresses.
Layer 3 network addressing:
During packet forwarding, a device determines a forwarding path and an interface connected to a destination network segment. If the destination host and source host are on different network segments, packets are forwarded to the gateway and then the gateway forwards the packets to the destination network segment.
A gateway receives and processes packets sent by hosts on a local network segment and forwards the packets to the destination network segment. To implement this function, the gateway must know the route of the destination network segment. The IP address of the interface on the gateway connected to the local network Segment is the gateway address of the network segment.
IP Address Classification
To facilitate IP address management and networking, IP addresses are classified into the following classes:
l The easiest way to determine the class of an IP address is to check the most significant bits in a network ID. Classes A, B, C, D, and E are identified by binary digits 0 10, 110, 1110, and 1111, respectively.
l Class A, B, and C addresses are unicast IP addresses (except Some Special addresses). Only these addresses can be assigned to host interfaces.
l Class D addresses are multicast IP addresses. Class E addresses are used for special experiment purposes.
Comparison of class A, B, and C addresses:
l A network using class A addresses is called a class A network. A network using class B addresses is called a class B network. A_network that uses class C addresses is called a class C network.
l The network ID of a class A network is 8 bits, indicating that the number of network IDs is small and a large number of host interfaces are supported. The leftmost bit is fixed at 0, and the address space is 0.0.0.0-127.255.255.255.
l The network ID of a class B network is 16 bits, which is between class A and class C networks. The leftmost two bits are fixed at 10, and the address space is 128.0.0.0-191.255.255.255.
l The network ID of a class C network is 24 bits, indicating that a large number of network IDs are Supported, and the number of host interfaces is small The leftmost three bits are fixed at 110, and the address space is 192.0.0.0-223.255.255.255.

Note:
A host refers to a router or a computer. In addition, the IP address of an interface on a host is called a host IP address.
Multicast address: is used to implement one-to-multiple message transmission.
IP Address Type
l Network_address
The network ID is X, and each bit in the host ID is 0. lt cannot be assigned to a host interface.
For example: 192.168.10.0 /24
l Broadcast address
The network ID is X, and each bit in the host ID is 1. lt cannot be assigned to a host interface.
For example: 192.168.10.255 /24
l Available address
It is also called a host address. It can be assigned to a host interface.
For example: 192.168.10.1 /24 ~ 192.168.10.254 /24
l The number of available IP addresses on a network segment is calculated using the following method:
Given that the host part of a network segment is n bits, the number of IP and the number of available IP addresses is 2n addresses is 2n- 2 (one network address and one broadcast address).
Private IP Addresses
Public IP address: An IP address is assigned by the Internet Assigned Numbers Authority (IANA), and this address allocation mode ensures that each IP address is unique on the Internet. Such an IP address is a public IP address.
Private IP address: In practice, some networks do not need to connect to the Internet. For example, on a network of a lab in a college, IP addresses of devices need to avoid conflicting with each other only within the same network. In the IP address space, some IP addresses of class A, B, and C addresses are reserved for the preceding situations. These IP addresses are called private IP addresses.
l Class A: 10.0.0.0 - 10.255.255.255
l Class B: 172.16.0.0 - 172.31.255.255
l Class C: 192.168.0.0 -192.168.255.255
Connecting a private network to the Internet: A private network is not allowed to connect to the Internet because it uses a private IP address. Driven by requirements, many private networks also need to connect to the Internet to implement communication between private networks and the Internet and between private networks through the Internet. The interconnection between the private network and the Internet must be implemented using the NAT technology.
Special IP address
Some IP addresses in the IP address space are of special meanings and functions.
l 255.255.255.255
This address is called a limited broadcast address and can be used as the destination IP address of an IP packet.
After receiving an IP packet whose destination IP address is a limited broadcast address, the router stops forwarding the IP packet.
l 0.0.0.0
If this address is used as a network address, it means the network address of any network. If this address is used as the IP address of a host interface, it is the IP address of a source host interface on this network.
For example, if a host interface does not obtain its IP address during startup, the host interface can send a DHCP Request message with the destination IP address set to a limited broadcast address and the source IP address set to 0.0.0.0 to the network. The DHCP server is expected to allocate an available IP address to the host interface after receiving the DHCP Request message.
l 127.0.0.0/8
This address is called a Loopback address and can be used as the destination IP address of an IP packet. It is used to test the software System of a test device.
The IP packets that are generated by a device and whose destination IP address is set to a Loopback address cannot leave the device itself.
l 169.254.0.0/16
If a network device is configured to automatically obtain an IP address but no DHCP server is available on the network, the device uses an IP address in the 169.254.0.0/16 network segment for temporary communication.
Note: The Dynamic Host Configuration Protocol (DHCP) is used to dynamically allocate network configuration parameters, such as IP addresses.




