Technology Sharing | Common Interface Protocol Analysis

The transfer of data packets between services often uses different communication protocols for different application scenarios. For example, website visits are often delivered using the HTTP protocol, file transfers use FTP, and mail transfers use SMTP. The above three types of protocols are all at the application layer in the network model. In addition to the commonly used protocols at the application layer, you must have a certain understanding and awareness of basic network knowledge such as TCP and UDP protocols at the transport layer, Restful architecture style, and RPC protocol.

Introduction to Network Protocols

Before understanding the specific protocol, you need to understand three different network models: OSI seven-layer model, TCP/IP four-layer model, and five-layer architecture.

Network protocol model comparison chart:

  • The OSI Reference Model is a conceptual framework used when developing standards for coordinated interprocess communication, it is not a standard.
  • The TCP/IP four-layer model is the basic communication architecture of the Internet. Often viewed as a simplified seven-layer OSI model.
  • The five-layer protocol is a synthesis of OSI and TCP/IP, and the actual application is still the four-layer structure of TCP/IP.
  • The TCP/IP protocol stack is a specific network protocol used by the four-layer model corresponding to TCP/IP.

TCP protocol

The TCP protocol is a connection-oriented, reliable, byte stream-based transport layer communication protocol in the transport layer. The working method of the TCP protocol is that a "three-way handshake" is required when establishing a connection, and a "four-way wave" is required when the connection is terminated. "Three-way handshake" and "four-way wave" are important knowledge points of the TCP protocol, which will be introduced in detail through the combination of actual combat and theory in later chapters.

Applicable scene

The connection-oriented, error retransmission, and congestion control features of the TCP protocol are suitable for scenarios with high reliability, such as data transmission involving user information.

UDP protocol

Once the UDP protocol sends the data sent by the application to the network layer, it does not keep data backup. It only adds multiplexing and data check fields to the header of the IP data packet. So UDP is often considered an unreliable packet protocol.

Applicable scene

The UDP protocol does not need to establish a connection in advance and implements simple features, which is very suitable for high real-time scenarios, such as streaming media and online games.

HTTP protocol

The HTTP protocol is the most common protocol in interface testing and is an application layer protocol for distributed, collaborative and hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web. The client sends an HTTP request to the server, and the server returns the requested data in response. During the testing process, it is often necessary to verify the request and response results, so understanding the HTTP protocol is the most important thing for interface testing.

In the following chapters, we will introduce the differences between HTTP and HTTPS protocols, as well as the basic knowledge information of HTTP protocol.

RESTful protocol

origin

A style of software architecture for the World Wide Web proposed by Dr. Roy Thomas Fielding in his doctoral dissertation in 2000. Its purpose is to facilitate different software to transfer information in the network. RESTful is a resource request and operation style based on the HTTP protocol. In one sentence, it uses URLs to locate resources and HTTP verbs to describe operations.

Typical application of HTTP request method in RESTful api:

Note:  There are some differences when different companies use the RESTful architectural style.

RPC protocol

The English name of RPC is Remote Procedure Call, which explains the concept of RPC protocol very well, that is, to realize remote execution by means of local code calling, RPC is mainly used for service calls within the company. The advantages of the RPC interface are higher transmission efficiency, lower performance loss, built-in load balancing strategy, and better service governance capabilities.

Common RPC protocols

Currently, the RPC protocols commonly used in the industry are mainly as follows:

  • Dubbo: A high-performance RPC protocol based on Java.
  • gRPC: High-performance general-purpose RPC framework, based on Protocol Buffers. PB is a language-neutral, platform-neutral data serialization framework.
  • Thrift: A polyglot RPC framework similar to gRPC.

Finally:  In order to give back to the die-hard fans, I have compiled a complete software testing video learning tutorial for you. If you need it, you can get it for free 【保证100%免费】

insert image description here

How to obtain the full set of materials: Click the small card below to get it yourself

 

Guess you like

Origin blog.csdn.net/weixin_57794111/article/details/131554329