Protocol is the abbreviation of network protocol. Network protocol is a set of agreements that must be complied with by both parties of the communication computer. Such as how to establish a connection, how to identify each other, etc. Only by observing this agreement can computers communicate with each other. Its three elements are: grammar, semantics, and timing.
(1) Grammar: the structure or format of data and control information;
(2) Semantics: what kind of control information needs to be sent, what actions to complete, and what kind of responses to make;
(3) Timing: a detailed description of the sequence of events.
TCP/IP
The TCP/IP protocol is the protocol adopted by the Internet today. It not only contains two parts, TCP and IP, but also a protocol cluster composed of FTP, SMTP, TCP, UDP, IP and other protocols. The fourth layer of the TCP/IP protocol-the network layer, is responsible for creating network connections between hosts and completing IP-based addressing and forwarding functions.
DNS
DNS (Domain Name System) is a domain name resolution service. It resolves domain names into IP addresses so that everyone can use easy-to-remember English letters to access the Internet. The following example completes a resolution. By pinging the domain name, we can get its IP address.
macbook:~ aaron$ ping baidu.com
PING baidu.com (39.156.69.79): 56 data bytes
64 bytes from 39.156.69.79: icmp_seq=0 ttl=49 time=33.982 ms
64 bytes from 39.156.69.79: icmp_seq=1 ttl=49 time=34.098 ms
64 bytes from 39.156.69.79: icmp_seq=2 ttl=49 time=34.129 ms
--- baidu.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 33.982/34.070/34.129/0.063 ms
Local domain name resolution
In addition to DNS, when we access the internal server through the domain name, we can use the local HOSTS file to complete the domain name resolution. Note that this process takes precedence over DNS.
The file is C:\WINDOWS\system32\drivers\etc\hosts under Windows, and /etc/hosts under Linux. An example is given below.
macbook:~ aaron$ more /etc/hosts
# 內置环回地址
127.0.0.1 localhost
# 本地测试服务器
127.0.0.1 zentaopms.tester.im
# 国内GitHub加速地址
140.82.113.4 github.com
DHCP
DHCP (Dynamic Host Configuration Protocol, dynamic host configuration protocol) is used to dynamically allocate available IP addresses to hosts in the local area network. Under Windows, you can use the ipconfig command to view the IP address assigned by the machine. Under Linux, please use ifconfig instead.
macbook:~ aaron$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=400<CHANNEL_IO>
ether a4:83:e7:8c:45:a1
inet6 fe80::1867:7b0e:305b:87f2%en0 prefixlen 64 secured scopeid 0x8
inet 192.168.0.100 netmask 0xffffff00 broadcast 192.168.0.255
nd6 options=201<PERFORMNUD,DAD>
media: autoselect
status: active
Two IP addresses are shown here:
lo0 127.0.0.1 是用于本机内部通讯的环回地址。它是一个每台机器都相同、永远有效的虚拟机本地IP地址;
en0 192.168.0.100 是DHCP服务器为第一块以太网卡分配的动态IP地址。机器关机后,DHCP会为该机器(网卡)保留此地址一段时间。
NAT
NAT (Network Address Translation) maps the private IP address of the internal network to different ports of a single IP address of the public network to provide external access to the internal network, thereby saving public IP resource costs.
For example, the telecom broadband in our home is bound to a single static IP address 58.208.178.58. If you want to access multiple computers in the home from an external office, you can configure NAT on the home router to achieve this. As a result, 58.208.178.58 is supported. :50001 and 58.208.178.58:50002 to connect to the remote desktop of different Windows computers.
VPN
VPN (Virtual Private Network, virtual private network) can establish a private connection between two locations through a public network (such as the Internet), and conduct encrypted communication. There are multiple ways of implementing VPN, such as hardware and software, so that employees can enjoy the same intranet environment as the company when they work at a remote home.
HTTP/HTTPS
HTTP (HyperText Transfer Protocol) is the most widely used protocol on the Internet. The article you are using a browser to read is transmitted using this protocol. HTTPS implements encryption on its basis.
HTTP/HTTPS is a connectionless, stateless application layer protocol. In other words, after the browser sends a request to the server to obtain a response through it, the connection is closed. A mechanism called Session is used between the browser and the server, so that when the next request comes, the server still knows who the visitor is. The method used by the server to identify the Session usually works with a unique identifier (such as jsessionid, bearer token, cookie) carried in the request URL or header. When we introduce interface testing later, we will elaborate further.
WebSocket
WebSocket establishes a persistent connection between the client and the server, allowing the server to actively push data to the client to achieve real-time two-way data transmission. It solves the problem of excessive consumption of Long Polling resources when the HTTP protocol was used in the past, only to pull data in a single item, or when using HTTP to simulate a long connection.
WebSocket is an application layer protocol, which is a subset of the TCP/IP protocol. It completes the handshake through the HTTP protocol when connecting.
RPC
RPC (Remote Procedure Call Protocol, remote procedure call protocol) is mostly used in the current popular microservice architecture, which is convenient for one computer to directly call the program on the other without needing to understand the underlying network technology/protocol. RPC can be based on the HTTP (application layer) protocol, or it can be implemented directly on the TCP (transport layer) protocol.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。