Life has a comfortable area, excuses to become lazy amulet, learning also has a comfort zone, Escape is the biggest obstacle to prevent progress. After more than half a year of embedded work and learning, I improved a lot, but at the same time I also faced with the problems of their own clear:
1. In practice, the theoretical foundation is not strong
2. The algorithm, the data structure cognition is too shallow
3. Interface programs and GUI-related learning are more exclusive
I have also been subjective to avoid the learning of these knowledge, which is why I write the content is based on practice. Starting with this series, I try to get away from the comfort zone of my brain and solidify my theory-related knowledge.
As the foundation of the whole modern Internet Society, TCP/IP plays an important role, so it is necessary to learn the knowledge of the protocol stack. But purely theoretical things are difficult to understand, so I recommend or combine projects (such as LWIP transplant to achieve remote communication), the use of practice to learn theory, and finally systematic summary, to be able to deepen the cognition, in this series combined with their own practice to understand the LWIP,HTTP,SNMP-related knowledge, in accordance with the " TCP/IP Detailed Volume One: Protocol chapter sequence, in-depth system learning to explain the TCP/IP protocol stack.
1. Layering
TCP/IP can be divided into four tiers depending on the communication function:
1). Link layer for handling the physical interface section
Device drivers (PHY, Mac Configuration), managed card management, ARP and RARP, and other communication media details.
2). The network layer is used to process activities grouped in the network, providing point-to-point services.
IP protocol: Internet Protocol to send data from the source node as fast as possible to the destination node (unreliable, no connection)
ICMP protocol: A PING packet is implemented based on this protocol and is often used to test network conditions.
IGMP Protocol: Group Management Protocol
3). The Transport layer provides end-to-end output
TCP Protocol: Transport Layer protocol, provides reliable end-to-end communication, high reliability
UDP protocol: User Data Protocol, simple packet data transmission, any necessary reliability provided by the application layer
4). The application layer processes the upper layer data and provides it to the transport layer for sending data
http: Hypertext Transfer Protocol, the foundation of the Web
ftp: File Transfer Protocol
Telnet: remote Login
SMTP: Simple Mail Transfer Protocol
SNMP: Network Management protocol based on UDP protocol, data set through MIB, read, modify.
For example Analysis:
For example, the dotted line is the TCP/IP hierarchical correspondence relationship, the real wire is the actual data transmission path, wherein the router is called the intermediary system, this is to allow the different types of physical interface can be connected, which for the modern Internet equipment compatibility has great significance.
The most difficult way to get started with TCP/IP learning is how to understand the concept of layering?
The following is my understanding, TCP/IP is actually a logical layering, the sending end of the data through a layer of packaging, call drivers, and finally sent through a network card, if the complex to go through a number of routers, to reach the receiving end after a layer of unpacking, and finally by the receiving end of the application layer processing. Packaged data and package data is fully transparent to the protocol, so in the same location the receiving end and the sender side of the data is consistent, as the actual physical connection, and each layer is responsible for different communication functions, so there is a hierarchical definition.
The code is broadly framed as follows:
Send End Data-->tcp_process ()-->ip_process ()-->eth_translate ()-->tdata ...
Receive End data<--tcp_process () <--ip_process () <--eth_receive () <--rdata ...
Send-side processing is to add user data to the corresponding header and passed to the next layer, and finally sent out through a network card, the process is called Encapsulation , and the receiving end processing is to receive data, and remove the corresponding header and passed to the previous layer, and finally obtain user data, this process is called the separation . Knowing this is a good idea:
Of course I'm just a general explanation, the actual code implementation is far more complicated than this, but the overall framework is very similar to this. The TCP/IP protocol stack is typically implemented by the kernel, unless you are using LWIP or UIP, which requires a thin stack of your own porting configuration, like the Windows,linuix kernel already has a full TCP/IP implementation, as long as the dedicated interface functions are called: Sockets and Tli ( Transport Layer Interface), it is sufficient to understand these.
2. Internet address
Internet definition Each interface must have a unique IP address, take IPV4 as an example, the IP address is 32bits long.
To make it easier to remember, we divide the IP address into four decimal digits. As follows:
Here is a relatively simple method of recording, because all IP addresses only start at the first location, can be 0 (+128) 128 (+64) 192 (+32) 224 (+16) 240 can clearly delineate the scope of the address type, so as to determine the type of an IP address. such as 192.168.1.1 is the C-type address.
3. Domain Name System and port
The domain Name System can be understood as a distributed database, which provides a mapping between IP addresses and host names, allowing users to access directly through IP addresses.
Ports are used by the transport layer to identify applications, like the well-known application-layer protocols mentioned above, which implement transport-layer data submissions through different port numbers. such as the FTP service port number is the 21,telnet service port number is the 23,http service port number is 80 and so on. These port numbers are between 1~1023 and are managed centrally by Inan.
4. Summary
This chapter is a quick tour of the TCP/IP protocol family, describes the reasons for layering and the principle of implementation, a simple description of the IP address classification, domain Name System and port, of course, the content of the first article is far less than this, but considering the length and other reasons I can only focus on the detailed explanation, if the tcp/ IP protocol Family Learning needs, it is recommended to buy "TCP/IP detailed Volume One: agreement" and "embedded network those things", one is biased to the theory, the other is biased to practice, combined learning is very convenient.
TCP/IP Detailed learning notes (i) overview