The TCP/IP reference model is a very basic, but also very important, basic framework for getting started. This is a basic concept that must be mastered, and this document uses a simple example to analyze the basic process of a digital pass with a reference model.
The network environment is very simple, as shown, we now analyze the PC to access webserver Web services, how the entire data communication process occurs, in order to simplify the description, we temporarily ignore the DNS, ARP, frame check and other mechanisms of work details, only consider the more macroscopic level.
1) PC access to webserver Web services,
is actually the HTTP service that accesses webserver。 This process for people, is to enter the webserver IP address or domain name in the PC browser, this behavior in the application level of the PC will
triggers the local HTTP process to produce some data, we refer to this data as a valid payload of http:
2) The final task of the digital pass is to help the PC pass the payload of this HTTP to the HTTP process on the webserver. This is a seemingly simple task, but in fact the data is going over the hill. The application layer of the PC gives this HTTP payload to the "Transport layer" (we ignore the TCP three handshake, etc.), and the transport layer encapsulates the last packet header for the application layer, and HTTP is TCP-based, so the
the head of TCP, in this head, there
Destination port number, this port number will tell the peer after the data arrives webserver
I want to visit your service。 Of course, in order for this data to be reliably transmitted, there are other important elements in the TCP header, which are not mentioned here.
3) Well, HTTP load is encapsulated on the TCP header, in order for this data to be able to transfer in the IP network, we also need an "envelope", so the data to the PC "Internet Layer", on this layer, the data is encapsulated a
IP Packet Header, in the IP header, writes the
source and destination IP addresses, the source IP address is the ip:192.168.1.1 of the PC, and the destination IP address is webserver ip:192.168.2.1. Another important field in the IP header is
protocol NumberThis
value is 6, which corresponds to the protocol that is encapsulated after the IP header, which is the TCP。 Well, with the IP header this envelope, our data can be transferred from the source to the destination in the IP network:
4) However, the envelope is not enough, at least, we have to send this letter a link to a section of the transport of the past, and can not be directly from the source to travel to the destination, it is not the celestial cross play is not? Well, we need a
header of the data link layer, because this is the Ethernet environment, the Ethernet link, so the data in the upper layer is encapsulated with an Ethernet frame header, this is to enable the PC to transfer this data to the same link on the
Gateway R1 (f0/0 Port)。 Because
the gateway address for PC settings is 192.168.1.254, which is the f0/0 port IP address of R1, so when accessing webserver 192.168.2.1 the IP of this non-local network, the PC has to turn to its gateway, so at the data link level, the PC wants data to pass to the gateway, which will encapsulate the
Ethernet HeaderWrite to the source Mac is its own mac:00dd.f800.0001, while writing to the destination Mac is the router R1 f0/0 Port mac:000.aaaa.0001, of course, if the PC does not have a gateway IP corresponding Mac, then it will
send ARP message to request。 There is also an important field in the Ethernet frame header that is
Type field, the Type field is used to describe what message is encapsulated behind the frame head of this Ethernet, and the value written here is
0x0800, which means that the following is an IP message:Black tea Three Cups (Http://weibo.com/vinsoney) original technology blog, copyright belongs to the author, reproduced please indicate the source.
5) A great effort, layers of feeding, finally, the data is finally ready for transmission, from the PC to the same on the link on the R1, a little closer to the destination, of course, in the transmission of data in the process, it is not possible like our pictures so literary, it should be some electrification of information, For example 1010101 God horse, do not bird him, anyway is this tuo thing is spread to the R1:
6) R1 f0/0 mouth received this thing, first to restore it into a data frame, view the frame head, find the destination MAC address is the MAC address of their own f0/0 port, happy bad, think is who wrote their love letter, so combined to view
Type field, found to be 0800, so that the upper layer is encapsulated is an IP packet, it will
The Ethernet frame header is stripped and the IP packets are handed over to the IP stack for processing:
7) Next is the R1 of the Internet layer of work, he received the lower level to pass enough IP packets, view IP packet IP address, the destination is 192.168.2.1, I 艹, not to me is to others, no way, R1 take this address to their own map--
routing table to find, found a destination 192.168.2.0/24 network, the exit is its own fa1/0 port, the next hop address is 192.168.12.2 is R2:
8) Discovery Packet Destination IP address is not your own R1, find
The path where the data is sent to the destination, which is 192.168.12.2 Closer to the destination, and in order to give the data to 192.168.12.2 On the same link, the data
Reseal the frame header on the Ethernet, this time in the frame header
The source Mac fills in the MAC address of the R1 fa1/0 port, and the destination Mac writes the MAC address of the R2 f0/0 port:
9) The data was passed on to the R2 by R1:
R2 received this data, the same is the first to restore the data frame, and then look at the frame head, the results found that the purpose of MAC is their own Mac, but also very happy, the data frame is dropped to the upper layer of the IP protocol to deal with:Black tea Three Cups (Http://weibo.com/vinsoney) original technology blog, copyright belongs to the author, reproduced please note
11) The same result, ah a look at the IP header of the destination IP address, wiping class is not to their own, why, why to say the word? Anyway, it's not for your own right:
12) So Anza by the table, found that the destination IP address 192.168.2.1 is in their own fa1/0 directly connected to the network 192.168.2.0/24 an IP address, good to do, the edge is the door of the people ah. It then encapsulates the data in the Ethernet frame header,
The source Mac is the MAC address of its own fa1/0 port, the destination Mac is webserver macIf there is no webserver 192.168.2.1 corresponding to the Mac, the same, or send an ARP message to request:
13) data is on the road, passed to the webserver
14) Good macro analysis, said that there has become microscopic. Webserver after receiving this data frame, look at the frame header, the destination MAC is its own Nic Mac, and
Type field 0800:
15) The frame head is then taken apart, the IP message is given to the IP protocol to handle. Then IP protocol analysis This IP packet, look at the destination IP address in Baotou, found it is the same network card IP, and found
the protocol number in the IP header is 6, which indicates that the IP header is wrapped in a TCP message:
16) know that after the IP header is wrapped in a TCP message, it will be stripped of the IP header, the TCP packet inside out, to find the purpose of the TCP head
the port number is, this is a well-known well-known port number:
17) The 80 port number corresponding to the service is HTTP. PC found that its own port 80 is just open, the HTTP service is working, so the TCP head off, exposing the effective load inside, hey, finally ... The little girl finally came out and was finally given the HTTP service. In this way, a piece of data is eventually delivered to the destination application. Of course, we still omit a lot of detail in this process. It is worth noting that the process of data communication is bidirectional, so the PC sends the webserver, in order for the service to interact properly, the data will return, so there is actually a data return process here we no longer analyze, the principle is similar.
-
Top
-
0
-
Step
Linux System Application Programming--Network programming (using TCP/IP model to analyze data transfer process)