I have recently learned the principles of the network, and I will learn a summary. To know why IP protocols must first understand two concepts: 1, what is a network. 2, what is the internet. What is the network? My understanding is that the host in the network is sent, and the frame does not cause a set of hosts that can be reached by routing into a network. Simple point is that all hosts are two or two. What is the internet? Simply, it is the interconnection of the network. Several networks are connected to the Internet. For the image representation, the difference is illustrated by the following figure: Figure 1 shows the network, and Fig. 2 shows the network interconnect. Where is their difference? If the host 1 issues a frame, the host 3 needs to respond, then 2, 3, 4 hosts will receive this frame. After these hosts receive the frame, the target physical address in the frame is compared to the local physical address, if it is a response. Don't do any reply. This will only respond with host 3. In Figure II, it is completely different. The host 1 is to reach the host 3, and the frame cannot be sent, but to send an IP packet. Because only host 2 and the router receive frames sent by the host 1, the router does not provide frame forwarding. Therefore, both the router and the host 2 throw the frame so that the host 3 cannot receive a call from the host 1. So how can IP packets? It is also necessary to introduce a concept, ARP mapping, is actually the binding of IP addresses and network card physical addresses. (Here, 10.0 representing the network 1 network number, 10.1 representing the network number of the network 2) The step of the host 1 sent to the host 3: (1), determine whether the host 3 is in the same network. The result is not. (2) Locate the IP of the router (the general router is set to the gateway) to make an ARP mapping, find the physical address of the router. (3) Fill in the physical address of the found router to the first part of the frame, and put the IP data in the data portion of the frame, and then issue it. (4) The router receives the message and responds. (5) The router proposes the IP address of the IP packet. (6) There is an IP address of the host 3 in the router, so it is possible to make an ARP mapping, find the physical address of the host 3,. (7) Fill in the first part of the frame with the physical address of the host 3, put the data portion of the received IP packet into the frame. Send frame. Note that both hosts 1, 2, 3, 4 can receive frames sent by the router, but only host 3 will respond. Such a message of the host 1 can reach the host 3. Is it a bit amazed. I just think so. Now, the frame is based on the physical line, so two two can be connected to each other. So why did the Internet do not make a network, but in the form of the Internet? Is it because all the computers in the world cannot be connected two or two, so what must be an internet? The answer is actually not the case! Here is another concept: the type of network. (Note is the type of network, not the type of the Internet. The network and network interconnection is decisive. I have an error-friendly understanding often appearing here) network can be divided into: Ethernet, token network, etc. (I I only remember these two). They are all required for the sending time of the frame. In the Ethernet, the host detects whether the network is idle. If you send a frame, if you don't wait for a period of time to detect. The token is the transfer of the token, and the token can be sent. This avoids conflict. Everyone's wind is turning, this is an average idea.
Now, I will answer the questions just now, there are many different types of networks in the Internet, and these different types of networks must never be in a network. There is another main reason: if the Internet is in a network, and assumes that it is an Ethernet. Then there are billions of hosts on the Internet to grab this bus. So, what is the 10M fiber, even if it is 10mmm fiber. This will have the concept of network interconnection. Network interconnection allows yourself to deliver your own information yourself. Not interfere with other networks.. Only when the host in a network is to access the host in another network, you need to cross the network. After finishing the concept of the Internet, I will start to tell the IP protocol. The frame is the unit propagating in the network, and the IP package is the unit that is propagated in the Internet. The frame is used as a house number with the physical address, and the IP package is used as the IP address as the house number. The IP address is represented by four eight-bit group (4 bytes) points, Example: 10.1.0.11. So is it possible to set it with an IP address of each host? It is not in the Internet, here is two reasons: one is an unsatisfactory, the other is unable to pass. When IP can set it at will be set, look at the following: Host 1 If you want to send the data packet to the host 3. Then, the packet is sent to the router 1, forward to the router 2 via the router 1, and the router 2 is sent to the host 3. This is ideal, but there is a problem. Is how to use the router 1 knows that the packet is sent to the router 2, and does not send it to the router 3? There are two ways here: 1. The IP packet of the host 1 contains all the router IP addresses that arrive through the host 3. 2. The router 1 checks the router address to be delivered to the host 3 in the selection routing table. These two methods are still feasible in a small local area network. But in the Internet, it will represent the end of the Internet. In order to meet the needs of the Internet, the IP address has a new explanation. The IP address can be divided into network segments and host segments. The IP network can be divided into three categories of A, B, and C. The first bit of IP in the class A is 0, and the network number is represented by the first 8 digits. The first bit of the B class is 1, the second is 0, and the network number is represented by the top 16. The first bit of the C class is 1, the second is 1, and the network number is represented by the first 24. Such a router will first raise the first two bit when the IP address is analyzed, and it is determined that the number of points should be proposed to represent the network number, and then transmit the packet according to the IP address of the other router corresponding to the network number in the routing table. Take later and similar maps, this time IP address is divided according to network segments and host segments. Now if the host 1 is to send a packet to the host 2. First, the router 2 is received by the packet, and analyzes the purpose IP address 2.0.0.2, 2.0.0.2 is a Class A address, the representative network number in front of the first point, get the network number 2. The routing table of the router 1 contains the IP address of the router 2 to be sent by the network number 2. The router 1 sends the packet to the router 2. Router 2 receives IP packets, finds the target IP and analyzes the IP number, and discovers the network number and its own network number, then analyze the full segment of the IP address. It is found that the data is distributed to the host 2 with the IP address of the host 2. In this way, the delivery of a packet is successful. Everything is so natural. But with the increase of the network (note is the increase in the network, it is not an increase in the host), and there will be problems. Look at the picture below: In such a network, then see the host 1 transmit an IP packet to the host 2. The first few steps are the same, but it is different after the packet reaches the router 2. Router 2 found already in this website, but there is no one with the host IP number and destination number. This cannot be forwarded again, and the packet will be lost.
Then what should be done? The general approach is to put the network composed of host 2 and host 6 as a subnet in the network where the router 2 is located. Assign a network number for the router 4. However, there is only one network number on the IP address on the Internet, and this network number has allocated router 2, where is another network number? There is a new concept in here, the subnet mask. Subnet mask and IP address, consisting of 32 bits, indicated by point distribution. The bit represents the network number in the subnet mask. In the figure, the router 2 sets the subnet mask to 255.255.0.0. Thus, in the network of the router 2, the network number has a new interpretation, which represents the network number with the two bytes in front of the second point. Then the router 2 can allocate a network address for the router 4. In this first, the subnet mask of the router 4 must also be set to 255.255.0.0? The answer to this question is negative. Look at the process of data delivery. When the router 2 receives the IP of the sending network, then use the subnet mask to find the network number to 2.1. Then find the IP address of the router 4 corresponding to the network number 2.1 in the routing table. This will send the data to the router 4. After the router 4 receives a packet, it will encounter a problem. The address of the router 4 is 2 or 2.1? The answer is 2. The setting of the local URL of each router is set in the network segment specified in the IP address. Therefore, when the router 4 receives the packet, first, according to the network classification method of the IP address, the IP address is 2.1.0.2, discovery and the local network number, then propose the full segment of the IP address, in the routing table The host 2 corresponding to the 2.1.0.2 address of the 2.1.0.2 address. This is sent to the host 2. From the previous example, you can get a conclusion: the subnet mask does not increase the number of IP addresses, and can only increase the number of networks. The increase in the number of networks is obvious, which can reduce the load of the network and make the network more flexible. But it has a big disadvantage: reducing the mobility of the IP address. The more networks, the worse the mobility of the IP address. You can't move the host belonging to a network to another and does not change its IP address. If this is done, then you will never receive packets to send yourself. There is also a question that has to be mentioned is to share IP Internet. In the Internet, only IP's network numbers can represent a network, and an IP address can also represent a network (but not very legal). In real life, this is often encountered. A ADSL, connecting several users, sharing the Internet. This uses a NAT (Network Address Translation) technology. This technique divides the transfer of data into two parts, one is the data of the data, the other is the outward of the data. When the host 1 sends a packet to the server, the server first checks the destination IP network segment is an internal network. If it is not sent to the outside, it is sent directly to the IP address in the internal network. If the part is an external network, send a packet to the telecommunications, but then do 2 operations: 1, fill in a record in the NAT conversion table. There are two columns in the NAT conversion table: one column is the host IP address on the Internet, and the other is the host IP address of the intranet. Fill in the IP of the request for the host 1 into the previous column, fill the IP of the host 1 into a list. 2. Change the address of the source IP in the IP packet, and fill the external IP address (219.139.206.157) into the source IP address portion in the packet. Then send it. When the data of the data external network is passed, the server first checks where the IP packet is sent. Then find the address of the destination IP in the NAT conversion table. Then fill the address of the destination IP in the IP packet, send it to the destination host. The NAT principle is this. However, its implementation is not so simple, including many controls to maintain an emergency accident of the network.