The domain name
Domain name is the website that we usually say, for example: www.baidu.com
During the access, the domain name is resolved, that is, the domain name is translated into an IP address from the domain operator, for example, http://14.215.177.38/
It can be seen that IP is a string of numbers, which is not good to record, so the domain name can be translated into a better name to remember IP, generally in accordance with the fixed format, for example: www.xx.com
In addition, a domain name can only correspond to an IP, an IP can correspond to multiple domain names, usually can see multiple domain names will jump to the same page, that is the truth
In addition, the CORRESPONDING IP address of a domain name can be changed to another IP address. This is the domain name for sale, but a domain name can only correspond to one IP address
ip
IP is a necessary element in network requests to mark the identity of the user for proper information exchange
An IP address is a digital address used to identify a site on the network. Currently, the mainstream IP address follows ipv4 and ipv6 protocols
ipv4:
There are four groups of ipv4 digits. Each group contains eight digits and ranges from 0 to 255, that is, 2^8:2^8:2^8:2^8
For example, 192.168.0.1
You can see that the number of ipv4 web addresses is limited, only 2^32 in total, and some of them are occupied
Therefore, routers appear, common router address: 192.168.0.1, 192.168.1.1, etc
The router will take this IP address, create a subnet, and wrap it for multiple users to access the Internet
Introduction if the router extends IP:
When two users connect to two routers, they are marked with a subnet address, such as 192.168.0.101 and 192.168.1.102. When the two users want to establish a connection, they are marked with the router respectively. Then the two routers connect to each other with a secret code, and mark the corresponding subnet to locate the corresponding role. The proxy then passes the information, and if the router is nested in the same way, the subnet is split up again to mark access
ipv6
To address ipv4’s low number of IP addresses, ipv6 was introduced, which is an order of magnitude larger and can tag every living, even non-living, creature on the planet
An ipv6 number consists of eight groups of 16 digits, that is, the number ranges from 0 to 65535(usually a 4-digit hexadecimal number).
That is, 2^16:2^16:2^16:2^16:2^16:2^16:2^16:2^16:2^16
For example, ABCD: ABCD: ABCD: ABCD: ABCD: ABCD: ABCD: ABCD: ABCD: ABCD: ABCD
Request and response packets
HTTP request is also commonly used. The packet format of HTTP request is as follows
An HTTP request packet is shown as follows. You can also see that the URL usually transmitted is the URL. Header is the request header, and the entity is the body
An HTTP response message is shown below
TCP, UDP, Socket, HTTP, and HTTPS
udp
Udp Is a connection-oriented protocol. The sender can directly send the message to the network without establishing a connection. Therefore, packet header content is relatively small and the transmission efficiency is high
You can see the current game, if the UDP changes, part of the operation reliability requirements are not high can be used
tcp
TCP is a connection-oriented protocol, that is, the transmission end and the receiver establish a reliable connection before transmitting data, and then send messages. In addition, the transmission end also responds to the disconnection, using the three-way handshake protocol and the four-way handshake protocol respectively
Because reliable connections need to be established, related fields such as verification are increased, and the efficiency is lower than udp. However, udp is used in a wider range because of its reliability
Three-way handshake
Whether TCP, HTTP, or HTTPS, the connection is established through a three-way handshake. The connection is established using the client as an example:
1. The client sends a connection question seq=x
2. The server receives the connection establishment question seQ and replies seq+1, that is, ACK =x+1. At the same time, issue a confirmation question and answer seq=y, waiting for the client to reply to confirm that both ends of the message transmission is correct
3. Reply the server seQ and seq+1 (ACK = Y +1). The two ends send messages normally and confirm the connection
Four times to wave
Four times of waving is the procedure for normal disconnection (there is usually a timeout period for abnormal disconnection in practice, and the connection will be automatically disconnected if there is no response during this period). The disconnection process is as follows (take client initiation as an example) :
1. The client sends a request for disconnection fin=x
2. The server receives the connection request fin and replies fin+1, that is, ACK = X +1. After receiving the request, the client confirms that the request has been received and waits for the request to send an acknowledgement code
3. The server sends the confirmation code fin= Y to the client and waits for the reply code to disconnect the client
4. The client receives the fin operation code from the server and replies find+1, that is, ACK = Y +1, confirming the receipt of the disconnection request, and then disconnects. At the same time, the server also disconnects after receiving ack= Y +1
socket
Socket is the basic operation unit supporting TCP/IP network communication, that is, the interface API for the upper layer to facilitate network communication through TCP/IP protocol, so usually socket also represents the TCP connection
HTTP, HTTPS
http
HTTP: / / HTTP: / / HTTP: / / HTTP: / / HTTP: / / HTTP: / / HTTP: / / HTTP: / / http1.0
Note: In HTTP1.1, multiple requests can be processed in a single connection, and multiple requests can overlap without waiting for one request to complete before sending the next
https
HTTPS is a secure HTTP channel. In short, IT is a secure version of HTTP. In other words, add SSL layer under HTTP. SSL is the security foundation of HTTPS. Therefore,SSL is required for details of encryption.
In addition, HTTP is a hypertext transfer protocol, and information is transmitted in plain text. HTTPS is a secure SSL encryption transfer protocol. HTTP and HTTPS use completely different connection modes, and information is transmitted in ciphertext
ping
Finally, the ping command is a common command on the network. It uses ICMP, which is the same as TCP and UDP. It sends a test packet to the server, and the server receives a reply
Example: ping www.baidu.com
Note: The TTL after the ICMP in ping is the survival time of the secure packet (maximum 255, 64 recommended, 50 on the MAC), mainly to avoid loop waste during packet transmission. Therefore, the TTL value of the packet will be reduced before it passes through a route during transmission. If the TTL value is reduced to 0, it will be discarded as invalid packet
Network Layer 7 protocol
Through the seven-layer protocol, the network sends the content we want to send to the application of the other party’s device through the network cable
Layer 7 protocols include the application layer, presentation layer, session layer, transport layer, network layer, data link layer, and physical layer from top to bottom
We usually combine the application layer, presentation layer, and session layer into the application layer
Communication between protocols is eventually converted into 0 and 1 electrical signals, which can be transmitted through physical media before reaching the device of the other party. Therefore, the content to be transmitted is processed and transmitted to the device of the other party through the following layers of protocols, and the other party also needs to go through the same steps to reverse parse the correct transmission content