I have learned about computer networks, MAC addresses, IP addresses, route forwarding, and routing.Algorithm. At the same time, we also understand that IP addresses are 4 bytes divided into A, B, and C networks, and D broadcast e is retained, indicating that the number of networks and machines are limited. With the increasing number of computers, more and more IP addresses are needed. The insufficient IP addresses indicate that there are so many networks and machines. There are also various methods to solve the problem of expanding subnets, such as classless and subnet address extension (CIDR) --- from Douglas E. the subnet addressing mentioned in internetworking with tcp I --- in the commer classic book, these are all extended LAN addresses, but essentially they do not increase the number of machines. In reality, I apply for an IP address, connect to a modem, connect to a route, and then I can connect four computers and access the Internet at the same time. In other words, these four computers actually use an IP address to access the Internet at the same time. How can this problem be solved?
It seems that this is a real extended IP address. The LAN of several machines connected by the router has only one IP address. All requests are forwarded by routers when all machines access the internet. I thought the request was like this. A machine in the lan sends a request which is encapsulated into several IP packets. For each IP packet, the router adds the IP addresses of its own common network to the IP packet, and then forward it to the destination address on the external network.
However, it seems wrong. If the request is accepted by the other server, how does the server differentiate between the common IP address (the IP address of the router, which is allocated from China Telecom) and its private IP address (the IP address of the LAN )? How does the opposite server respond to the request? If it is based on socketProgramIf you get so many IP addresses from the other side? If it is obtained, does the client program have to be changed again? What's more, if the packet is forwarded multiple times in this way, the IP package has multiple IP addresses, which is not complicated.
I felt wrong. In this way, the LAN that shares IP addresses does not constitute an IP link to forward messages. What should it be?
Review the entire process: different machines send IP packets to the vro. The vro only converts the IP address of the IP packet and converts the private IP address to a common IP address, that is, the IP address of the vro. (You can use tracert to view the first outbound IP address, that is, the IP address assigned by the ISP), and then the router sends it out in a unified manner. The requests sent from different machines in the LAN are routed through routers, and the converted IP addresses are the same. Then, how do I forward a router to a machine in the specified LAN for external access?
As you can see, the vro is a forwarding station that forwards outgoing requests to the outside and forwards the outgoing requests back. We need such a table to forward requests from the LAN and forward the requests from the outside according to the table. It feels like a port. The router uses port forwarding.
For a request packet from and within the vro, write it down from that machine and use the specified port to send it. Modify the IP packet according to the port number and table, and forward it to the specified machine. So General.
Check the information as if it was the natp principle.
However, natp also has problems. For example, the FTP protocol has two connections, one is control connection and the other is data connection. First, an FTP client establishes a TCP connection to connect to the server. Then, when there is data transmission, the client needs to apply for a new connection. Create a new socket. How does the server know the port number of the client? This requires a control connection established by the client to convert the newly generated socket port to an ascii code, and then transmit the control connection to the other party. Then, the other party establishes a data connection based on the port, to transfer files. If natp is used, the user's port is a local port. If the router does not parse the IP packet and maps it to a local port, otherwise, the client port is invalid for the server.
Bold assumptions, careful proof.