Network protocol | Typical protocol, B/S mode, C/S mode

insert image description here

Welcome to follow the blogger Mindtechnist or join [ Linux C/C++/Python Community ] to learn and share Linux, C, C++, Python, Matlab, robot motion control, multi-robot collaboration, intelligent optimization algorithm, filter estimation, multi-sensor information fusion, Knowledge and technology in machine learning, artificial intelligence and other related fields.


Network protocol | Typical protocol, B/S mode, C/S mode


Column: "Network Programming"


Network protocol

What is a protocol
From an application point of view, a protocol can be understood as a "rule", which is a rule for data transmission and data interpretation.
Assume that both parties A and B want to transfer files. Regulation:

- 第一次,传输文件名,接收方接收到文件名,应答OK给传输方;
- 第二次,发送文件的尺寸,接收方接收到该数据再次应答一个OK;
- 第三次,传输文件内容。同样,接收方接收数据完成后应答OK表示文件内容接收成功。

Therefore, no matter what kind of file is transferred between A and B, it is completed through three data transfers. The simplest data transmission rule is formed between A and B. Both parties send and receive data according to this rule. The mutual compliance rules reached between A and B are agreements.
This kind of agreement that is only observed between A and B is called the original agreement. When this protocol is adopted by more people, it will continue to increase, improve, maintain, and improve. Finally, a stable and complete file transfer protocol is formed, which is widely used in various file transfer processes. This agreement becomes a standard agreement. The earliest ftp protocol was derived from this. The TCP protocol focuses on data transmission. The http protocol focuses on the interpretation of data.
typical protocol

  • transport layer 常见协议有TCP/UDP协议.
  • application layer 常见的协议有HTTP协议,FTP协议.
  • network layer 常见协议有IP协议、ICMP协议、IGMP协议.
  • network interface layer 常见协议有ARP协议、RARP协议.
  • TCP Transmission Control Protocol (Transmission Control Protocol) is a connection-oriented, reliable, byte stream-based transport layer communication protocol.
  • UDP User Datagram Protocol (User Datagram Protocol) is a connectionless transport layer protocol in the OSI reference model, which provides transaction-oriented simple and unreliable information transmission services.
  • HTTP Hypertext Transfer Protocol (Hyper Text Transfer Protocol) is the most widely used network protocol on the Internet.
  • FTP File Transfer Protocol
  • The IP protocol is the Internet Protocol (Internet Protocol)
  • The ICMP protocol is the Internet Control Message Protocol (Internet Control Message Protocol). It is a sub-protocol of the TCP/IP protocol family and is used to transmit control messages between IP hosts and routers.
  • The IGMP protocol is the Internet Group Management Protocol (Internet Group Management Protocol), which is a multicast protocol in the Internet protocol family. This protocol runs between hosts and multicast routers.
  • The ARP protocol is a forward address resolution protocol (Address Resolution Protocol), through the known IP, to find the MAC address of the corresponding host.
  • RARP is a reverse address translation protocol, which determines the IP address through the MAC address.

TCP/IP four-layer model
TCP/IP network protocol stack is divided into application layer (Application), transport layer (Transport), network layer (Network) and link layer (Link) four layers. As shown below:

TCP/IP model

OSI seven layer model

OSI model

①物理层:主要定义物理设备标准,如网线的接口类型、光纤的接口类型、各种传输介质的传输速率等。它的主要作用是传输比特流(就是由`10`转化为电流强弱来进行传输,到达目的地后再转化为`10`,也就是我们常说的数模转换与模数转换)。这一层的数据叫做比特。
②数据链路层:定义了如何让格式化数据以帧为单位进行传输,以及如何让控制对物理介质的访问。这一层通常还提供错误检测和纠正,以确保数据的可靠传输。如:串口通信中使用到的`1152008、N、1`
③网络层:在位于不同地理位置的网络中的两个主机系统之间提供连接和路径选择。Internet的发展使得从世界各站点访问信息的用户数大大增加,而网络层正是管理这种连接的层。
④传输层:定义了一些传输数据的协议和端口号(WWW端口80等),如:TCP(传输控制协议,传输效率低,可靠性强,用于传输可靠性要求高,数据量大的数据),UDP(用户数据报协议,与TCP特性恰恰相反,用于传输可靠性要求不高,数据量小的数据,如QQ聊天数据就是通过这种方式传输的)。 主要是将从下层接收的数据进行分段和传输,到达目的地址后再进行重组。常常把这一层数据叫做段。
⑤会话层:通过传输层(端口号:传输端口与接收端口)建立数据传输的通路。主要在你的系统之间发起会话或者接受会话请求(设备之间需要互相认识可以是IP也可以是MAC或者是主机名)。
⑥表示层:可确保一个系统的应用层所发送的信息可以被另一个系统的应用层读取。例如,PC程序与另一台计算机进行通信,其中一台计算机使用扩展二一十进制交换码(EBCDIC),而另一台则使用美国信息交换标准码(ASCII)来表示相同的字符。如有必要,表示层会通过使用一种通格式来实现多种数据格式之间的转换。
⑦应用层:是最靠近用户的OSI层。这一层为用户的应用程序(例如电子邮件、文件传输和终端仿真)提供网络服务。

Web Application Design Patterns

C/S mode
Traditional network application design mode, client (client) / server (server) mode. Clients and servers need to be deployed at both ends of the communication to complete data communication.
B/S mode
Browser ()/server (server) mode. You only need to deploy a server at one end, and the other end uses the default browser configured on each PC to complete the data transmission.
Compared
with the C/S mode, its advantages are obvious. The client is located on the target host to ensure performance, and the data is cached locally on the client, thereby improving data transmission efficiency. Moreover, generally speaking, the client and server programs are created by a development team, so the protocol adopted between them is relatively flexible. On the basis of standard protocols, it can be tailored and customized according to requirements. For example, the communication protocol adopted by Tencent is a modified and tailored version of the ftp protocol.
Therefore, the C/S mode is preferred for development of traditional network applications and larger network applications. For example, the well-known online game World of Warcraft. The 3D picture has a huge amount of data. Using the C/S mode can cache a large amount of data locally in advance to improve the look and feel.
The shortcomings of the C/S model are also more prominent. Since both the client and the server need a development team to complete the development. The workload will be doubled and the development cycle will be longer. In addition, from the user's point of view, the client needs to be installed on the user host, which poses a threat to the security of the user host. This is also an important reason why many users are reluctant to use C/S mode applications.
Compared with the C/S mode, the B/S mode does not have an independent client and uses a standard browser as the client, so the amount of work and development is relatively small. Just develop the server side. In addition, because it uses a browser to display data, it has very good portability and is not limited by the platform. Such as the early food stealing game, it can run perfectly on all platforms.
The shortcomings of the B/S mode are also more obvious. Web app support is limited due to use of third-party browsers. In addition, no client is placed on the other host, and the cached data is not satisfactory, so the amount of transmitted data is limited. The look and feel of the application is greatly reduced. Third, it must use the standard http protocol to communicate with the browser, and the protocol selection is not flexible.
Therefore, in the development process, the choice of mode is determined by the above-mentioned respective characteristics. Choose an application design pattern based on actual needs.

...

insert image description here
insert image description here


Guess you like

Origin blog.csdn.net/qq_43471489/article/details/130342283