current position:Home>On network protocol - Introduction

On network protocol - Introduction

2022-02-03 00:40:11 If white

This paper discusses the introduction knowledge of network protocol from the perspective of developers , If you can have a good understanding of network protocols , So it is also very helpful for daily development .

1. TCP agreement

TCP - Transmission Control Protocol It's a kind of Connection oriented 、 reliable 、 Transport layer communication protocol based on byte stream , The main function is to ensure the reliability and integrity of data , To prevent packet loss . The control mode ( Packet number 、 Packet encapsulation 、 Transmission confirmation mechanism 、 Packet loss retransmission mechanism ). Details refer to

2. IP agreement

IP-Internet Protocol agreement .IP The protocol is used to realize the data transmission between devices across LAN , You can get and define IP Address , Confirm whether the device crosses the network according to the subnet mask .

3. Socket

It provides a method of two-way communication between applications on different hosts in the network , Connect the application , Downlink network protocol , There is a set of TCP/IP Interface to protocol . stay unix perhaps linux In the system ,Socket It's just a file descriptor . Common programming methods :






 Copy code 

4. Http A long connection , Short connection

A long connection : Repeated use tcp Three handshakes , The connection between four waves transmits data (http 1.1, Connection:keep-alive). For example, visit Baidu .

keep-alive How does it work ? Actually Http The long connection is through TCP Long connection to achieve ,TCP The long connection is realized by sending probe packets periodically , That is to say “ heartbeat ”, Of course, if you can't receive the heartbeat packet after a certain time ,http The connection will automatically disconnect , Otherwise, the application will be disconnected after the data transmission is completed (Content-Length).

Short connection : The established connection cannot be reused , After transmitting data once each time, forcibly disconnect and re-establish the connection .


MQTT It's the Internet of things standard protocol , It is characterized by lightweight , Based on publish subscribe mode . Usually based on TCP/IP Based on . And TCP The advantages of long connections :

  1. MQTT The agreement is more standard , targeted , It is conducive to the development and implementation of third-party components .
  2. Add more functions and control mechanisms in the Internet of things scenario , Such as heartbeat mechanism 、 Publish and subscribe mechanism, etc .

6. Modbus agreement

Modbus The protocol belongs to the serial communication protocol of application layer message transmission , be based on Master/Slave framework ,request/response Pattern . Message types include ASCII、RTU、TCP Three . It is mostly used in data acquisition system and remote terminal control system RTU.

This is from the Internet , Just for communication and learning .

Reference link :

TCP agreement
Socket Principle explanation
What is a socket
Socket in Computer Network
Modbus Introduce

copyright notice
author[If white],Please bring the original link to reprint, thank you.

Random recommended