Table 5. IP packages from A to B
In this case, IP addresses are redundant because they do not play any role at all. IP addresses can only increase the processing time and occupy excessive transmission bandwidth. After B receives the package, the IP layer checks whether the destination address in the package is the same as its own IP address. If the destination address is the same, the data is returned to the upper-layer protocol. This is called direct routing.
5.2 indirect Routing
The following figure shows the real situation of the Internet. Three small Ethernet networks, each with three computers, each with a unique ethernet address and IP address. These three networks are connected through a router. This router has an IP address and three Ethernet addresses, because it is connected to three networks, of course three are required. Remember that there is only one IP address.
Computer D is a router, and its TCP/IP protocol stack may have no TCP or UDP at all, there may be multiple ARP modules and multiple Ethernet drivers (because there are multiple Ethernet adapters, multiple drivers are required ). The Network Administrator specifies a network number for each subnet (which has three subnets). It is the name of the network, which is not indicated.
If computer A wants to communicate with computer B, use direct routing. This process has been mentioned above. Direct routing is used in the same subnet. If computer D wants to communicate with computer A, this is also A direct route. Direct communication is enough. communication between computer D and all other computers is direct communication. However, if computer A does not want to communicate with computers in the non-subscriber network, it cannot use direct routing. The IP packet sent by computer A must be sent to computer D and sent by computer D to other networks, this type of communication is not direct.
Routes are transparent to the upper-layer protocols of the IP protocol. They do not know what routes exist.
Note that in the figure below, the source address is computer A, the destination IP address is computer E, and the destination ethernet address is computer D, because computer A and computer E are not in the same subnet, it cannot communicate directly and must be forwarded by computer D. Therefore, this package can only be sent to the computer.
Table 6. Ethernet frames from computer A to computer E
For computer D, its Ethernet frame address is as follows:
Table 7. From Computer d to computer e Ethernet frame
Because computer D and computer e can communicate directly. We can see that during direct communication, both the destination IP address and the ethernet address are the receiver, while in non-direct communication, the destination IP address is the receiver, while the destination ethernet address is the router. The above example is relatively simple. The real routing is much more complicated than this one. Because the real network is very large and many routers need to work at the same time, the situation is more complicated.
5.3 IP routing rules
For an IP packet to be sent, the IP address must determine whether to send the packet directly or not. This is done with the help of the route table. For an incoming IP packet, the IP module must be able to identify whether it is a required package. If it is needed by itself, it will transmit the data to the previous protocol. If it is not required, it will forward the data. After the IP address reaches the destination address, it no longer forwards the IP address.
5.4 IP Address
An IP address is the IP address specified by the Network Manager for a computer. One part of the IP address serves as the network number, and the other part serves as the host number in the network. For more information, see. The IP address is managed by the NIC. If you need an IP address for all computers directly connected to the Internet, you must contact the NIC. If you need to establish your own network, the corresponding network number also needs to be obtained from the NIC.
5.5 name
People like to use computer names rather than numbers to mark a computer. For small networks, the corresponding table of computer names and IP addresses can be stored on each computer, for a large network, a dedicated computer is required to convert IP addresses to computer names. The following table lists the corresponding IP addresses and computer names.
223.1.2.1 alpha
223.1.2.2 Beta
223.1.2.3 Gamma
223.1.2.4 Delta
223.1.3.2 Epsilon
223.1.4.2 iota
The previous column is the IP address, and the last column is the computer name. You can specify multiple IP addresses for a computer name. After receiving the package, the computer with multiple IP addresses can determine whether to send the package to itself based on the destination address. This destination address can be any of its own addresses. The name is also used for the network number. The following is an example:
223.1.2 development
223.1.3 accounting
223.1.4 factory
The first column is the IP address, and the last column is the network name. We can compare the table above to see what network each computer belongs.
5.6 IP route table
We have mentioned the term route table above. Let's take a closer look at this table. It usually consists of the following columns: IP address number, direct/non-direct mark, router IP address and interface number. This table is generally maintained by the Administrator because it specifies an IP address for your computer.
5.7 direct routing
Next, let's take a closer look at the example of direct routing we have seen above.
The route table in computer alpha is as follows:
Table 8. Route table example
We may see such a result through the "netstat-r" command in UNIX.
5.8 instance
Alpha sends an IP package to beta. The target IP address of the alpha IP package is the beta address (223.1.2.2 ). The IP address obtains the network number and queries the first part of the route table to see where the package should be wrapped. It finds that the network is consistent with the first project in the table. Other information in this project indicates that the target computer can communicate directly, so ARP translation (parsing) is directly performed and data is sent through interface 1.
5.9 non-direct routing
Next, let's take a closer look at the example of non-direct routing we have seen above.
The route table in computer alpha is as follows:
Table 10. Route table in Alpha
5.10 instance
Alpha sends an IP packet to epsilon. The destination address in the IP packet is epsilon (223.1.3.2 ). The IP address analyzes the network number of the destination address, queries the first column in the route table, and finds that the second project meets the conditions. The information in this project indicates that the computer can be reached by the vrodevdevnetrouter. The Alpha IP Module performs ARP resolution and transmits data to the IP address of the devnetrouter through interface 1. This package still includes the destination IP address 223.1.3.2. This package arrives at the development Network Interface and is sent to the IP module of delta Computer. delta Computer finds that this package is not for it, so it decides to forward it. The Delta IP Module parses the network number from the destination address and queries the route table. The Delta route table is as follows:
Table 11. Delta route table
The second line meets the conditions, so IP Module Interface 3 sends data to the computer epsilon. When the IP package reaches epsilon, the IP module of epsilon finds that the destination address is the same as its own, therefore, the received data is transmitted to the upstream protocol.
5.11 route Summary
In a large network, an IP packet usually needs to go through multiple routers before arriving at the target computer. The route forward is not set in advance, but queried step by step on each router, each computer only needs to transmit data to the next stop.
5.12 manage routes
It is not easy to support a route table on each machine in a large network. If a router has a problem, it will not be able to transmit the network. We can also use the ICMP protocol to monitor the network. The IP address of a computer must be changed when a machine is moved from one location to another. To update the host address file, this is simply impossible, and DNS helps solve this problem.
6. User Datagram Protocol (UDP)
UDP is one of the two important protocols on the IP address. It provides services for your network applications. We often use NFS, and SNMP uses UDP. The UDP protocol is not connection-oriented. This is different from the TCP protocol. UDP adds the port number and Verification Code parameters to the IP package.
Port 6.1
How does a client program on a computer reach the server? The communication lines of applications and UDP are the same through UDP ports. These ports are numbers, starting with 0. A port is generally used as a service peer. The server and the customer are waiting for the request (or response) from the other party on this port ). UDP retains the message boundary defined by the application. It never connects two messages, or divides a message into two parts.
6.2 Verification Code
If the received IP packet is marked with "UDP", the IP Module sends the data to UDP. The UDP checks the verification code. If the calculation result is 0, the data is correct. UDP verification codes can or cannot be generated. If the UDP packet sent exceeds the processing capability of the Upper-layer application, it will be temporarily saved. If the stored data exceeds certain limits, UDP will be discarded.
7. Transmission Control Protocol (TCP)
The services provided by TCP are different from those provided by UDP. The biggest difference between them is that TCP is connection-oriented. TCP ensures that data is transmitted to the receiver, But UDP does not. TCP is used to ensure data transmission. We usually know that FTP and telnet are based on the TCP protocol, while some other TCP network applications include the X-window system, RCP (remote replication) and R-series commands also use TCP. TCP provides such a good service at a cost. It requires more C