2.2 Network Theory
Now that I have mentioned the protocol layer, I will discuss how the network works and some examples of how the SOCK_DGRAM package is created. Of course, you can skip this section if you think you are familiar with it.
It's time to learn Data Encapsulation! It is very, very important. It is important that you have to master it in any way you study online courses. The main content is: a package is first packaged ("encapsulated") by the First Protocol (here TFTP) in its header (maybe at the end). Then, the entire data (including the TFTP header) is encapsulated by another protocol (UDP here), followed by the next (IP), which repeats until the hardware (physical) layer (Ethernet here ).
When another machine receives the packet, the hardware first removes the Ethernet header, the kernel removes the IP address and UDP header, the TFTP program then removes the TFTP header, and finally obtains the data.
Now we finally talk about the notorious Layered Network Model ). This network model has many advantages over other models in describing the network system. For example, you can write a socket program without worrying about the physical transmission of data (serial port, Ethernet, connection Unit Interface (AUI) or other media ), because the underlying program will process them for you. The actual network hardware and topology are transparent to programmers.
I will not talk about other things. Now I will list the entire hierarchical model. If you want to take the online exam, remember:
L presentation layer
L Session Layer
L Transport Layer
L Network Layer
L data link layer
L Physical Layer
The physical layer is hardware (serial port, Ethernet, etc ). The application layer is the farthest distance from the hardware layer-it is the place where users interact with the network.
This model is so common that you can use it as a maintenance guide if you want. Maps it to Unix. The result is:
L Application Layer (telnet, ftp, etc .)
L host-to-host transmission layer (TCP, UDP)
L Internet layer (IP routing)
L network access layer (Ethernet, Wi-Fi, and any)
Now, you may see how these layers are coordinated to encapsulate the original data.
How much does it work to create a simple data packet? Alas, you will have to use "cat" to create a data packet header! This is just a joke. For streaming sockets, you need to send data by sending. For a datagram socket, You encapsulate the data as you choose and then use sendto (). The kernel will create a transport layer and an Internet layer for you. The hardware completes the network access layer. This is modern technology.
Now we end our fast-paced Network Theory Course. Oh, I forgot to tell you about routing. But I'm not going to talk about it. If you really care about it, refer to IP RFC.
From the column xiaobin_HLJ80