The popular sentence is: IP address is used to mark the identity of your computer, just like each of us has an ID card; the subnet mask indicates which network segment the network used belongs to, and two IP addresses You can communicate directly if you belong to the same network segment; when you belong to different network segments, you need a gateway to function; and gateway refers to the exit of the sent information (data packets), generally refers to the address of the router.
2. IP protocol and IP address
What is the IP protocol?
(1) That is, “a protocol that can communicate with each other between networks”, that is, computers and computers must follow the IP protocol to communicate with each other through the network.
(2) For example, if you drive to allow you to take the highway, then your vehicle must be licensed if someone else’s vehicle is also licensed. Then everyone can get on the highway. Vehicles without a license plate cannot go on the road. The IP protocol here is equivalent to the license plate that the vehicle needs to install.
(3) The location of the IP protocol? It
is located at the “network layer” in OSI (network seven-layer model).
(4) The composition of the IP protocol?
It packs the data frames from the data link layer into an “IP data packet” format to pass to the next layer.
What is an IP address?
(1) Composition of
IP address IP address = network number + host number
IP address consists of 4 bytes (one byte is 8 bits), that is, 32 bits.
(2) The five types of
IP address coding scheme divides the IP address space into A, B, C, D, and E types, where A, B, and C are basic types, and D and E are used as multicast and reserved .
IP address classification Highest position Network number (digit) Host number (digit)
Address range Default subnet mask
Class A IP address 0 8 twenty four 0.0.0.0 to 127.255.255.255 255.0.0.0
Class B IP address 10 16 16 18.104.22.168 to 22.214.171.124 255.255.0.0
Class C IP address 110 twenty four 8 192.0.0.0 to 126.96.36.199 255.255.255.0
Class D: Multicast addresses. The highest bit of the network address must be 1110, so the network number of the address ranges from 224 to 239. Generally used for multicast users.
Class E: reserved addresses. The highest bit of the network address must be 1111, so the network number of the address ranges from 240 to 255.
(3) Purpose of
An IP address is used to identify the identity of each computer. It assigns a logical address to each computer on the Internet to identify the uniqueness of this computer. That is the computer’s network ID.
3. Subnet mask
What is a subnet mask?
The subnet mask is used to determine whether the IP addresses of two computers belong to the same network segment. If the two computers are in the same network segment, the two computers can communicate directly.
The composition of the subnet mask consists of a 32-bit binary, for example:
The subnet mask binary:
11111111. 11111111. 11111111. 00000000 means: 255 .255. 255. 0
The role of the subnet mask is to divide an IP address into two parts: a network address and a host address, and it can be judged whether the two computers are in the same network segment.
Convert the computer’s IP address and subnet mask into binary, and perform the AND operation. If the result is the same, it means that the two computers are in the same network segment and can communicate directly.
4. The default gateway
What is a gateway?
To draw an analogy: In ancient times, we had to pass through a city gate from one place to another. For example, to enter the mainland from the northeast, we had to pass through Shanhaiguan. The gate of this city is called the “gate”. So in the same way, from one network channel to another network channel, we must also go through such a “gate”, here we call it a gateway. That is, the “entry” from one network connection to another network.
Gateway: Usually refers to the default gateway. For example, the two computers are in different network fields through the subnet mask. The two computers cannot communicate directly, so can’t we be distressed. In order to be able to communicate, a gateway appears at this time, which can link two computers in different network frequency bands together to communicate.
The role of the gateway
The internet IP Subnet mask
Network 1 192.168.1.1 ~ 192.168.1.255 255.0.0.0
Network 2 192.168.2.1 ~ 192.168.2.255 255.255.0.0
For example, there are two networks, network 1 and network 2, and if there is no router between the two networks, TCP / IP communication is not possible between network 1 and network 2. Because we judged that network 1 and network 2 are in different networks based on the above subnet mask, in reality, to make the two networks connect to each other, you must pass through the gateway.
The gateway is the knowledge at the network layer. When two computers in different network fields want to contact each other, they must pass through the gateway.
To draw an analogy: You communicate with an American, and you do not understand English, and Americans do not understand Chinese. What should you do? If you talk to each other, you cannot communicate. At this time, we can use a translator to translate what the other party said into a language I can understand. This is enough, the role of the gateway is also the same, two computers in different network frequency bands, through the gateway (the gateway needs to rely on the router to achieve the role of the protocol) can communicate without barriers.
5. How do computers in different network segments communicate?
When computers on different network segments need to communicate, a gateway is needed.
Gateway: A device connected to two different networks can be called a gateway.
Router: look for and implement routing forward, that is, to achieve gateway connectivity to two different networks of a device.
- The IP address is used to mark the identity of your computer, just like each of us has an ID card;
- The subnet mask indicates to which network segment the network used by the computer belongs. Two IP addresses belonging to the same network segment can communicate directly;
- When they belong to different network segments, a gateway is required to function. The gateway refers to computers in different network segments connected together to allow them to communicate with each other. The gateway needs to rely on a router to complete its functions.