The previous article mainly introduced the public Internet topology, or the physical structure, then this article to introduce ip--is the network of each node or end system identification problem. In reality, the end of the road is a village or city, they are names, but the network world, with the name of each host is not very wise, so people invented the IP this way to identify the host.
IP is a binary number, a total of 32 bits, theoretically can have 2 32 (about 4 billion) different 0, 1 combinations, so can be labeled so many hosts, each combination is a host name. As an example of an IP:
11000001 00100000 11011000 00001001
Obviously, this inconvenient memory and writing, so people invented the dot decimal method to do the replacement, specifically, each eight bits with a decimal number, and then the decimal number is separated by a dot, so the above IP can be expressed as:
193.32.216.9
It is not difficult to imagine that, since the router to do a transit station, it is necessary to connect with multiple host/end systems, the router extends multiple links to each host, each host is assigned an IP address. So what is the IP of the router? In fact, the router has multiple IPs or it does not have an IP in itself, because IP is an interface-related concept, not a machine. The so-called interface is the junction of a machine and a link. On the surface, one link connects two machines, but deep into the inside of the machine, the link is the network card in the machine (also known as the line card in the router). So the essence of the interface is this NIC, IP is bound together with this NIC. Each network card has a global unique IP, so each end system can be uniquely located or identified, but the router has a lot of network cards, so it can be said that there are many IP, it can be said that these IPs do not represent the router itself. In fact, the location of the router itself is meaningless, we will know below.
The first thing to look at is how the router itself works and how each console system gets its own IP. The router maintains a forwarding post, which is the mapping between IP and its own interface. IP refers to the destination IP of the packet received by the router, and each of the internal network cards (that is, the interface) is numbered. As an example:
192.0.0.1 ———— 1 —————— A
192.0.0.2 ———— 2 —————— B
192.0.0.3 ———— 3 —————— C
192.0.0.4 ———— 4 —————— D
The router forwards the packet according to its forwarding publication, in which the 192.0.0.1 decides that the destination IP is the packet to be sent to the number 1th interface, and then an interface is connected to host a through a link, then A's IP becomes 192.0.0.1, the same way B, C, The IP of D is 192.0.2/3/4 in turn.
See here maybe you can understand that the so-called IP is a router to the publication of a number, or that your IP is not your, you do not use it, only your router needs it. The router needs an IP to decide which interface (i.e. the link) to throw a packet to. There may be a link that secures one of your hosts and routers, but that doesn't mean your IP is fixed, because the router can change the forwarding address at any time, modifying the mapping between your router's interface and the IP. For example, in college, every person in our dormitory has a network cable socket under each table, which must be fixed by a link and an interface of the school router, but I find that the IP of my computer is not fixed.
Summary: IP decisions are not in the hands of the end system, but in the hands of the router connected to it.
The router in the example above is still very low-level, because each interface directly connected to a console system, or the router in the publication of the interface number corresponding to a specific IP. In fact, the real router is too much for this kind of work, because it is too overqualified. In the real world, this kind of work is often undertaken by Ethernet switches or hubs, and Ethernet is a realization of LAN. Why do you say you are overqualified? Because the interface number in router forwarding is not actually a specific IP, but a range of IP, as follows:
192.0.0.0~192.0.0.63 ———— 1 —————— A
192.0.0.64 ~ 192.0.0.127 ———— 2 —————— B
192.0.0.128 ~ 192.0.0.191 ———— 3 —————— C
192.0.0.192 ~ 192.0.0.255 ———— 4 —————— D
In this way, the router receives a packet, checks its destination IP for which range, and then throws it to the corresponding interface. Note that in this diagram, A~d is no longer a specific end system, but rather a switch or hub in a local area network, and they receive the packet before continuing to decide which specific end system to send the packet to.
The advantage of this is that it reduces the burden on the router, and it does not need to maintain so many mappings for forwarding.
Now we focus on the IP range in the example above, and we convert the 192.0.0.0~192.0.0.63 into binary:
11000000 00000000 00000000 00000000 ~ 11000000 00000000 00000000 00111111
It can be found that the number in this range (binary), the first 26 bits are the same, are 11000000 00000000 00000000 00, only the latter six bits are different. People have invented a way to represent this rule-based range, namely: 192.0.0.0/26,26 indicates that the first 26 bits of the address of this range are the same, called the IP address prefix; 192.0.0.0 is the starting IP for this range.
Similarly,192.0.0.64 ~ 192.0.0.127 is represented as 192.0.0.64/26;192.0.0.128 ~ 192.0.0.191 is expressed as 192.0.0.128/26;
192.0.0.192 ~ 192.0.0.255 is expressed as 192.0.0.192/26.
Now, each interface of the router is attached to a switch (the switch itself does not have an IP), the switch is connected to the various end systems, and each interface connected to the switch has the same prefix: Each end system does not have to say much, why is the interface on the router to maintain the same prefix? Although the previous said it also has its own IP, but did not say how specific. In fact, the interface of this router and the end system of the switch to form a subnet, all interfaces within the same subnet must have the same prefix, so that we can give the address of this subnet, that is, the starting IP mentioned above (note that the beginning of the IP at the end of several are 0, international regulations, An IP after removing the prefix after the end of a few if all is 0, then this IP represents the IP of the subnet, and the IP can not be used as a subnet in any of the system's IP).
To talk about this router interface IP, in fact, I think it can be seen as a sub-network sent to the inside of the router's diplomat, is for the other side of the subnet inside the system to find a router and set up. As we can see from the above analysis, the IP of this interface is not used inside the router because the router gives it an internal number directly.
OK, the above router is an entry level, it has 4 subnets below (and the network segment is very average), which is certainly an idealized state, the reality may be more complex. It can be thought that the 4 subnets under this router actually constitute another larger subnet, and this router is a higher-level switch, the larger subnet address is not difficult to see is 192.0.0.0/24, the first 24 bits are the same.
Subnets are a relative concept, and we can say that the Chinese network is a subnet as well, because it also has a high-level router. Obviously, the larger the range of subnets, the shorter the prefix, and the smaller the subnet, the longer the prefix. ISPs actually get the distribution of a subnet and then sell the IP address. The more advanced the ISP manages the larger the range of subnets. So who's the ultimate Big Boss? Haha, Icann,dns also belongs to his tube, Google a bit.
Another problem: in the lowest-level routers (also known as Gateway routers), why do you need a switch to connect to each end system? Can't you extend many lines from one interface and connect to each host? Well, I haven't figured out the question yet.
Information roaming in the network (ii)