3.9.1.linux Network Programming framework

Source: Internet
Author: User
Tags file transfer protocol

Ref: 52078962
This section describes the framework of network programming, the introduction of layered thinking and TCP/IP protocol, the introduction of BS Architecture and CS Architecture, etc.

3.9.1.1, the network is layered

(1) OSI 7-Layer model

Transport Layer-Application layer: Defines the functionality of the application, leaving three layers of end-to-end traffic primarily through the network. The OSI seven-layer model is a theoretical model, and more of it is used as a basis for analyzing and judging various network technologies.

The physical layer provides a physical link to the data Link layer, which transmits the bitstream in its serial (unit bit of data transfer).
The data link layer is responsible for error-free transmission of data (frame units) through inspection, flow control, and re-sending on the Delta line between network nodes. In order to do this, in each frame must also have synchronization, address, error control and flow control and other information.
The task of network layer is to select the appropriate routing and switching nodes, so that the packet information transmitted by the data source in the transport layer can find the destination according to the address without error, and deliver to the corresponding transport layer, that is, to complete the network addressing function.
The transport layer is the interface layer between the high and low layers. The data transmission unit is the message, when the message is longer, it is divided into several groups, and then handed over to the network layer for transmission. The transport layer is the most critical layer of the computer network protocol, and the layers above are not the management information transmission problem.
The session layer provides management services for the transmitted messages, establishing, organizing, and coordinating interactions between the two different systems that communicate with each other. Column such as: OK is duplex or half duplex work
The task of this layer in the presentation layer is to change the abstract syntax of the transmitted data into the transfer syntax, that is, to convert different representations within different computers into standard forms of contempt in communication. Also encrypt or decrypt the transmitted data, compress or decompress the text.
Application layer This layer is directly oriented to the user and is the highest level in the OSI. To provide users with the interface of the application, not only to provide file transfer between different computers, access and management, e-mail processing, different computers through the network interactive access to the needs of your terminal function.

Seven-layer structure memory method: should, table, meeting, transmission, net, number, object
The application layer protocol needs to be mastered: HTTP (Hyper Text Transfer Protocol), FTP (File Transfer Protocol), SMTP (Simple Mail transfer rotocol), POP3 (Post Office Protocol 3), IMAP4 (Internet Mail Access Protocol)

(2) Why the network should be layered: the network is too complex
(3) The specific performance of network stratification

3.9.1.2, TCP/IP protocol Introduction

(1) TCP/IP protocol is the most used network protocol implementation

* TCP/IP是一个计算机通信的一组协议,称它为TCP/IP协议族。在其中还包含了其他的协议(http、telnet、icmp、arp、rarp),正因为TCP/IP协议很重要,就以它们两个命名。

(2) TCP/IP is divided into 4 tiers, corresponding to the 7 layers of OSI

* 应用层:对应OSI中的应用层、表示层、会话层* 物理链路层:对应OSI中的数据链路层、物理层(也有叫网络接口层)

The relationship between OSI layer seven and TCP/IP layer four

* OSI引入了服务、接口、协议、分层的概念,TCP/IP借鉴了OSI的这些概念建立TCP/IP模型。* OSI先有模型,后有协议,先有标准,后进行实践;而TCP/IP则相反,先有协议和应用再提出了模型,且是参照的OSI模型。* OSI是一种理论下的模型,而TCP/IP已被广泛使用,成为网络互联事实上的标准。

Tcp:transmission Control Protocol Transmission Protocol Udp:user Data Protocol User Datagram Protocol
(3) We program the most attention to the application layer, understanding the transport layer, the Internet layer and the network access layer without the tube

1. TCP/IP provides services for applications (so-called everything over Ip)
2. TCP/IP allows the Internet to operate on a wide variety of networks (so-called IP over Everything)

UDP and TCP contrast
UDP is an unreliable, non-linked protocol that is primarily suitable for traffic control situations where messages need not be sorted.
TCP is a link-oriented, reliable protocol. It sends the byte stream sent by one host without error to other hosts on the Internet.
At the sending end, TCP is responsible for dividing the stream of bytes from the upper layer into the message segment and passing it to the lower layer.
At the receiving end, TCP is responsible for reorganizing the received messages and submitting them to the upper layer.
The TCP protocol also handles end-to-flow control to avoid slow-receiving receivers that do not have enough buffers to receive large amounts of data from the sender.

IP protocol is the most important protocol in the family of TCP/IP protocols, it provides unreliable, non-linked services, and also relies on the protocol process error control of other layers. In a local area network, IP protocols are often encapsulated in Ethernet frames for transmission. All TCP, UDP, ICMP, and IGMP data are encapsulated in an IP datagram for transmission.

TCP is a point-to-Point protocol, which means that each customer needs to separate the client/server link so that data broadcasts to multiple clients are not implemented at the network level. If a data stream must be delivered to multiple clients at the same time, the server must transmit a copy of the data stream to each client.
TCP can dynamically adjust the transmission speed and resend the lost packets according to the network bandwidth and congestion, so that the reliability of the data transmission is ensured, but the server resource is expensive, so it is difficult to guarantee the real-time data transmission in the case of large data flow.

UDP is an unreliable transfer protocol, in the sending segment, the speed of UDP data transmission is only the speed of data generated by the application, the ability of the computer and the limit of transmission bandwidth; At the receiving end, UDP places each message segment in the queue and the application reads a message segment from the queue each time.
The UDP protocol does not need to maintain the connection state, and does not think that each packet must reach the receiving end, so the network load is smaller than TCP, the transmission speed is faster than TCP, but the more congested the network, the more packets are lost.

The RTMP protocol is a protocol designed specifically for the efficient transmission of video, audio and data. It enables real-time video and sound transmission by establishing a binary TCP connection or connecting to an HTTP tunnel.
Shared object is a more important data type in rtmp data, and when any client changes the data, the shared object can update the data of the server segment in time, so that each client can know the change of the data in time.
RTMP supports more media protocols than traditional media servers. It supports the dynamic transmission of multiple lines that may contain sound, image and script data from the server to the customer and from the customer to the server. RTMP handles sound, image, and script data separately.
Sound and video data are buffered separately from the server. If the sound data reaches a certain limit in the sound buffer, all data in the buffer is discarded and the recently arrived data is allowed to start collecting in the buffer and being sent to each customer. The video data is processed in a similar manner, unlike when a new keyframe arrives and the data in the buffer is cleared. When the old frame data is discarded, if the client's data is found to be incorrect, the old and new two different frames are fitted.
RTMP gives different priority levels to the data. In real-time conversations, the sound is the most important, the image is given a low priority, and the script data is given priority over the middle of the sound and the image.
The RTMP protocol can create multiple data streams, but each data flow can have only one direction.
With rtmp, you can build a system that allows clients to interact with the RTMP server and the application server at the same time, allowing the server's load to be dispersed, although the performance requirements for rtmp servers are high in this improved system architecture.

3.9.1.3, BS and CS

(1) Introduction to the CS architecture (client server, clients servers architecture)
(2) BS Architecture Introduction (broswer server, browser server architecture)

3.9.1.linux Network Programming framework

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.