OSI seven-layer model we all know, what happens when we enter http://bbs.51cto.com/from the browser to the page display?
Below we will analyze by grasping the package:
Network transmission
Tools: Any browser, Wireshark grab Bag tool
Application layer:
The browser receives the user input domain name http://bbs.51cto.com/, the browser proxy client sends the request get to the server, and the application layer's GET request is encapsulated in the HTTP protocol, the capture packet analysis get information is as follows:
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/07/91/wKiom1nLnfDBP11YAAFOvoTNPb0303.png "title=" Qq20170927204046.png "style=" WIDTH:1000PX;HEIGHT:104PX; "width=" "vspace=" 0 "hspace=" 0 "height=" 104 "border=" 0 " alt= "Wkiom1nlnfdbp11yaafovotnpb0303.png"/>
The way to request is get, in addition to the GET request there are other ways such as post, HEAD, PUT, DELETE, TRACE, OPTIONS;
The URI of the request is the Uniform Resource identifier, indicating the location of the resource to be accessed;
The version of the HTTP protocol used by the current browser;
The end server is to find the resources based on the get information and give the answer
In addition, the HTTP encapsulation content includes some other information:
The file format accepted by the client browser;
Language
Browser version Information
......
The network transport model is the lower layer to provide services for the upper layer, such as the physical layer for the link layer to provide services, and link layers to serve the network layer, and so on
The HTTP protocol of the application layer is the service provided by the lower layer of the presentation, session, and transport layers.
Transport Layer:
The IP of the network layer is to find the target machine in the boundless Internet path, the transport layer is to locate the specific service in this machine---through the port number, that is, the client to access the server-side resource premise is to establish a TCP connection with the server side, the server side uses the port is 80, the client uses the random port
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/A6/44/wKioL1nLo1XDJB1RAAQZr1FpDgM728.png "title=" Clipboard.png "style=" WIDTH:1000PX;HEIGHT:417PX; "width=" "vspace=" 0 "hspace=" 0 "height=" 417 "border=" 0 "alt=" Wkiol1nlo1xdjb1raaqzr1fpdgm728.png "/>
The client uses any port 61649, the so-called arbitrary port is greater than 1024 of the port, and less than 1024 of the port is a well-known port is reserved for specific services, such as 80 port is HTTP, 20, 21 is FTP, 22 port SSH, but there are some special, If MySQL is using the 3306 port;
TCP establishes the connection process is the process of three handshake, TCP disconnection is four times wave. Because TCP is connection-oriented.
I can see from the clutch that this is an ACK confirmation package.
With TCP port 80, the server will be able to find the corresponding HTTP service based on port 80 after receiving this packet.
Network layer:
The Transport Layer wraps the HTTP information of the application layer in the transport layer, which we call the data segment segment, and adds the transport layer header from the capture packet to 20 bytes
And then to the network layer processing, the same network layer of information sent to the transport layer to encapsulate the layer and add the network layer header information, called the packet Packet
In fact, the process of data transmission is the process of packaging and unpacking, our request data does not pass through a router will be unpacked and then encapsulated, until the destination
As for the constant solution encapsulation is to get the destination IP address, only then know the next hop path how to go
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/A6/44/wKioL1nLqbahUBMRAAJ6fxN01NA613.png "title=" Ip.png "style=" width:1000px;height:230px "width=" "vspace=" 0 "hspace=" 0 "height=" border= "0" alt= " Wkiol1nlqbahubmraaj6fxn01na613.png "/>
The current mainstream use of IPv4 version, IPv6 is also being popularized but the process is slow;
As with the transport layer, the network layer's head is also 20 bytes, the 20 bytes contain the most important destination IP address is 59.110.244.199, this address is our final access to the server address;
The total length of this packet is 821 bytes;
Link Layer:
This layer, in addition to specifying the upper layer protocol, is to give the MAC address, this layer is called the data frame package
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/07/92/wKiom1nLq3aQYZxBAAESGkHAtoQ601.png "title=" Qq20170927214340.png "style=" width:1000px;height:72px; "width=" "vspace=" 0 "hspace=" 0 "height=" "" border= "0" alt = "Wkiom1nlq3aqyzxbaaesgkhatoq601.png"/>
0X0800 indicates that the upper layer protocol is IP;
The destination hardware address is usually the MAC address of the gateway device, that is, who to give the data to
The last data frame is transmitted to the Internet in a current manner, and these are the physical layers to be done.
This process is a step-by-step encapsulation process, and when the data arrives at the destination, its operation is exactly the opposite of this one-step solution encapsulation
DNS resolution
The network transmission section describes how to address, port, package and unpack, but network addressing is also by dotted decimal format. The client is clearly entering the http://bbs.51cto.com
How does it become a digital IP address? This is where DNS works:
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/A6/44/wKioL1nLr_yDgFR1AAHelCqq_7I922.png "title=" Dns.png "style=" width:1000px;height:248px; "width=" "vspace=" 0 "hspace=" 0 "height=" 248 "border=" 0 "alt=" wKioL1nLr _ydgfr1aahelcqq_7i922.png "/>
The client wants to request the resource to the server to have the IP address of the other side, before the TCP connection can be established for subsequent operations, but where does the IP address come from?
Get the IP address, from the DNS server, where is the DNS? How does the client get the IP address of the server that we end up accessing from DNS?
Each region will have a dedicated DNS server for the region, and client request IP is generally a request to the local DNS. In other words, to obtain the final IP address our client also establishes a connection with the DNS server, which is generally a UDP connection;
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/07/93/wKiom1nLsaCxuXmCAAD9BPL894k597.png "title=" Udp.png "style=" WIDTH:1000PX;HEIGHT:89PX; "width=" "vspace=" 0 "hspace=" 0 "height=" 0 "border= Wkiom1nlsacxuxmcaad9bpl894k597.png "/>
UDP is a non-connected state, as with the HTTP protocol;
The port used by the DNS server is 53;
If the local DNS server does not have a record of bbs.51cto.com, then it will be to the root DNS server . Send a request, The root then replies with the subdomain. com address, the local DNS server then requests the IP address to. com, and then the. com domain server tells the 51cto.com address to the local DNS server, and eventually the local DNS server obtains the Bbs.51cto.com IP address through 51cto.com and then returns it to the client This address. The end client then passes through the "network transport" layer of encapsulation to encapsulate the data to the destination server;
Server response
Server processing request: To parse the request message, and obtain the requested resources and request methods and other relevant information, according to the method, resources, headers and optional main part of the request processing;
Server access resource: Gets the requested resource Web server in the request message, that is, the server that holds the Web resource, and is responsible for providing the requestor with the static resources requested by the requester, or dynamically running the generated resources;
Build Response message: Once the Web server recognizes the addition of resources, it executes the action (GET) described in the request method and returns the response message. The response message includes a response status code (200), a response header, and a response body if a response body is generated.
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/A6/45/wKioL1nLtObClJbHAAOlTEklP5k328.png "title=" Http.png "style=" width:1000px;height:353px; "width=" "vspace=" 0 "hspace=" 0 "height=" 353 "border=" 0 "alt=" Wkiol1nltobcljbhaaolteklp5k328.png "/>
The response message is then sent to the client and logs are logged
The response packet is then transferred from the network to the client, and a layer of solution is encapsulated to complete the process.
This article is from the "A_pan" blog, make sure to keep this source http://panpangao.blog.51cto.com/10624093/1969278
A complete HTTP request processing process