Preface : now engaged in the design of embedded products, many are based on TCP/IP, the requirements of the development of equipment to access the WAN for remote setup and access, which involves the principle of routing and the use of routers. Including ADSL used in the home, wireless routers and enterprises and routers used in industrial sites, switches, have been contacted and used, but has been stuck on the surface of the operation of understanding. Now because of the needs of product development, I hope to further deepen the understanding of the internal operating mechanism of the router, clarify some vague understanding, so close this article.
before reading this article, we will first define the concept of the host:A host is a device connected to one or more networks that can send and receive data to any network, but it never transmits data from one network to another. Frankly speaking, 1 hosts are the 1 devices that are used to connect in the network.
1. Why use a router?
now we are engaged in embedded product design, to be exposed to a lot of network concepts, such as Ethernet, WiFi network, 485 network, MBus Network, can network, ZigBee network and so on. In the course of the development of our project, we will notice a very important and outstanding problem, that is, "the number of hosts in a single network is limited and cannot be increased indefinitely". in a single network, too many hostscan cause the following problems:A, the bandwidth resources exhausted;
b, each device will waste a lot of time to deal with irrelevant broadcast data;
c, the network becomes unable to manage, any mistake may cause the entire network to be paralyzed;
d, each host can listen to the communication of other devices. The above problems can only be solved through network segmentation, but at the same time we must provide a good mechanism to enable the communication between different network segments of the device. This is why the network is segmented? , "OSI Layer 7 Network protocol" and "TCP/IP 4 Layer network protocol". Lists the OSI Layer 7 network protocol,TCP/IP Layer 4 network protocol ", as well as the corresponding relationship between the corresponding hardware devices in the three layer. It is also important to note that the OSI only provides a network model, and we use the TCP/IP protocol (layer 4) when it comes to Ethernet specific applications .). OSI Layer 7 network protocol:A, physical: physical layer,the physical layer provides for the activation, maintenance, closing of the communication end point (endpoint) between the mechanical characteristics, electrical characteristics,functional characteristics and process characteristics. This layer provides a physical medium for the upper level protocol to transmit data. Corresponding connection device: hub.
B, Data Link:Data Link Layer,The Data link layer provides reliable transmission on unreliable physical media. corresponding connecting devices: bridges, switches.
C,Network:Network Layer,the network layer is responsible for routing data packets between subnets. In addition, the network layer can alsoIt realizes congestion control, Internet interconnection and other functions. the corresponding connection device: router.
D,Transport:Transport Layer,The Transport layer is the first end-to-end, that is, the host-to-host hierarchy. The transport layer is responsible forlayer data is fragmented and provides end-to-end, reliable, or unreliable transmissions.
E,Session:Session Layer,The session layer manages the session process between hosts, which is responsible for establishing, managing, and terminating processes betweensession. The session layer also uses the insertion of checkpoints in the data to synchronize data.
F,Presentation:Presentation layer ,the presentation layer transforms the upper data or information to ensure that a host application layer information can bethe application of another host is understood. Data transformations for presentation tiers include encryption, compression, and format conversion of dataand so on.
G,Application:Application Layer,The application layer provides an interface for operating system or network applications to access network services.
from the above analysis, we can know that the actual function of the router is to complete the different segments betweennetwork interconnection, which corresponds to the OSI and TCP/IP network layer.
2. The segmentation principle of TCP/IP V4 protocol Network
The TCP/IP protocol assigns an IP address to each host in the network, which contains two pieces of information: The network address and the host address. There are two ways to store this information: one is to use two separate domains, so we have to consider the maximum length of two domains, the other is to wrap the network address and host address in 1 domains, sometimes the host address part is very short, sometimes the host address part is very long, this can effectively use the address space, reduce the address length. the IP address in the TCP/IP protocol is the latter method, which willthe network address and host address are wrapped in a 32-bit domain ( TCP/IPV4), this is the IP address that we often use, for example: 192.168.1.1. initially, IP address design, according to the IP address of the 1th byte, the IP address is divided into 3 categories:
A, 1-126,a class: Network address 1 bytes, host address 3 bytes.
B, 128-192,b class:the network address is 2 bytes, and the host address is 2 bytes.
C, 192-223,c class:the network address is 3 bytes, and the host address is 1 bytes.
D, 0,127,224-255:keep not.
based on the application of this way, people find that there are many problems, the first is that we are familiar with the exhaustion of IP address, followed by this classification method, for the same network address can not do any route in the network, when the number of host more, the problems mentioned in this article 1 highlighted, especially for large Class A network, The method of using only bridges and switches is difficult to manage, so there are 1 new domain "Subnet masks" that can be resolved only by logically dividing it into smaller networks. The subnet mask indicates which parts of the address are network addresses and which are host addresses. In the subnet mask, the binary 1 represents the network address bit, and the binary 0 represents the host address bit. The subnet masks for the traditional types of addresses are:
A, Class A : 255.0.0.0.
B, Class B: 255.255.0.0.
C, Class C:255.255.255.0.
If you want to use the address of a Class B network as a class C-size address, you can 255.255.255.0 with a mask. the three seed mesh masks described above are: 255.0.0.0, 255.255.0.0, and 255.255.255.0, which are byte-aligned subnet masks. But it can also be divided in the middle of the byte. asvery Small Network for point-to-point connections (Mask 255.255.255.252,30-bit network address, 2-bit host address: two host subnets, or a medium network (such as a mask 255.255.240.0,20 bit network address, 12-bit host address: 4,094 host subnets).
This article describes the "Why to use a router"and"the segmentation principle of TCP/IP V4 protocol network"2 questions,"Routing and routers in-depth analysis of the principle of 2: the principle of routing will explain how the routing works.
Note 1: This article in the process of writing access to a large number of online information, the citation of the source could not be one by one marked, special apology.
original articles, reproduced please indicate the sourcehttp://user.qzone.qq.com/2756567163.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Routing and routers in-depth analysis of working principles 1: Overview