1. IP address
1. Basic concept of IP address
IP address combines different physical networks at the network layer The address is unified into a globally unique IP address (shielding physical network differences), which is the logical address that uniquely identifies computers on the Internet (equivalent to a mobile phone number, and the mobile phone can be found through the unique mobile phone number), so the IP address is also called an Internet address (This shows its importance).
2. IP address format
Our currently commonly used IPv4 stipulates that the IP address length is 32-bit binary. When represented, the 32-bit address is generally split into four 8-bit binary , and then converted into four decimal numbers, with each number separated by a dot, such as 127.0.0.1 (localhost). This description method is called "dot-number notation".
IP address level: divided into two levels: network number and host number. The network number indicates the network to which the host belongs, and the host number indicates the host itself. The number of digits in the network number and host number is related to the IP address classification.
3. IP address allocation
The basic principle of IP address allocation is: assign the same network number and different host numbers to different hosts in the same network (subnet, network segment).
2. Subnet mask
Subnet mask is also called network mask and address mask.
We mentioned above that IP addresses are divided into network numbers and host numbers, but how does routing distinguish between network numbers and host numbers? You need to pass the subnet mask. The subnet mask must be used in conjunction with the IP address. The subnet masks of classes A, B, and C are 255.0.0.0, 255.255.0.0, and 255.255.255.0 respectively (the network number byte is 255, and the host number byte is 0) .
In other words, if you are given an IP address, how do you know the number of digits in its network number and host number?
If you don’t specify it, you won’t know which bits are the network number and which bits are the host number. This requires a subnet mask to achieve
The important role of the subnet mask: it is to An IP address is divided into two parts: the network address and the host address.
The number of digits in the subnet mask is the number of digits in the network. The network number of Class A network is 8 bits, the subnet mask is 255.0.0.0, the network number of Class B network is 16 bits, the subnet mask is 255.255.0.0, and the Class C network is 24 bits, 255.255.255.0.
3. Gateway
Gateway, also known as the Internet connector, is the "gateway" that connects one network to another.
A gateway is essentially the IP address from one network to other networks. For example, there are network A and network B. The IP address range of network A is "192.168.1.1~192. 168.1.254" and the subnet mask is 255.255.255.0; the IP address range of network B is "192.168.2.1~192.168. 2.254", the subnet mask is 255.255.255.0. In the absence of a router, TCP/IP communication is not possible between the two networks. Even if the two networks are connected to the same switch (or hub), the TCP/IP protocol will use the subnet mask (255.255 .255.0) determines that the hosts in the two networks are in different networks.
To achieve communication between the two networks, it must pass through the gateway. If the host in network A finds that the destination host of the data packet is not in the local network, it forwards the data packet to its own gateway, which then forwards it to the gateway of network B, and the gateway of network B forwards it to someone in network B. host.
The above is the detailed content of Introduction to Network Basics. For more information, please follow other related articles on the PHP Chinese website!