Basic understanding of computer networks

1. Background knowledge

As a programmer, it is impossible not to deal with the web. Let's take a look at the basics of networking.
1. What is computer network
Computer network refers to computers and peripheral devices with independent functions in different geographical locations, through the communication lines connected in the network operating system, to manage and coordinate network management software and network communication protocols, and realize the resource sharing and information transmission of computer systems. computer system.

The basic function of computer network is data communication and resource sharing. capital
Source sharing includes the sharing of hardware, software and data resources.

2. Classification of networks
According to the geographical coverage covered:
Wide Area Network: A wide area network is a public data network that can connect computers thousands of miles apart.
Local area network: A local area network is generally owned by a unit and is used to connect various computers, terminals and external devices within a limited range.
Metropolitan Area Network: Based on IP, it forms a network communication platform covering urban areas through the integration of computer networks, radio and television networks, and telecommunication networks.
For example: the campus network belongs to the local area network

2. OSI--- Basic Reference Model for Open Systems Interconnection
The OSI (Open System Interconnection, Open System Interconnection) seven-layer network model is called the Open System Interconnection Reference Model, which is a logical definition and specification
, as the name suggests, logically divides the network into 7 layers. Each layer has related and corresponding physical devices, such as routers and switches;

The OSI seven-layer model is a framework design method, and its main function is to help different types of hosts realize data transmission. 
When learning the principles of computer network, the architecture of five-layer protocol is often used: physical layer, data link layer, network layer, transport layer and application layer.
But let's take a look at what's on the seventh floor today.

1. Physical layer

We all know that there are only 0s and 1s in the computer world, and it is also a combination of a large series of 0s and 1s stored in the computer. But these numbers cannot be transmitted in the real physical medium, but need to be converted into optical or electrical signals, so this layer is responsible for converting these bit streams to optical signals.

If there is no physical layer, then there is no Internet, and there is no sharing of data, because data cannot flow in the network.
Therefore, the physical layer is at the lowest level of the OSI reference model. It uses the transmission medium to establish, manage and release physical connections between communicating hosts, realize the transparent transmission of the bit stream (the transmission unit is bits), and ensure that the bit stream passes through the transmission medium. transmit correctly.
2. Data link layer

At this layer, data is no longer transmitted in the form of a bit stream, but is divided into frames for transmission. That is to say, the data link layer provides data transmission services for the network layer , and this service depends on the functions of this layer to achieve.
The link layer should have the following functions:
(1) Establishment, teardown and separation of link connections
(2) Frame delimitation and frame synchronization . The data transmission unit of the link layer is a frame. The length and interface of the frame are different depending on the protocol, but the frame must be delimited anyway;
(3) Sequence control, which refers to the control of the sequence of sending and receiving frames;
(4) Error detection and recovery. There are also link identification, flow control , and more. Error detection mostly uses the square matrix code check and the cyclic code check to detect the error code of the data on the channel, and the frame loss is detected by the serial number. The recovery of various errors is often completed by feedback retransmission technology.
3. Network layer
The network layer is to translate the network address into the corresponding physical address, select the appropriate transmission path for the packet through the communication subnet through the routing algorithm, and realize the functions of flow control, congestion control and network interconnection; the network layer is used for the local LAN network segment. It can do so because it has its own routing address structure, which is separate and independent from the second layer machine address. Such protocols are called routing or routable protocols.

In order to establish network connections and provide services for the upper layers, the network layer should have the following main functions:
(1). Routing and relaying;
(2). Activate and terminate the network connection;
(3). Multiple network connections are multiplexed on one data link, and time- division multiplexing technology is mostly adopted;
(4). Detection and recovery;
(5). Sorting, flow control ;
(6). Service selection;

4. Transport layer
The transport layer is the first end-to-end layer when two computers communicate with each other through the network, and has a buffering effect. When the service quality of the network layer cannot meet the requirements, it will improve the service to meet the requirements of the upper layer; when the service quality of the network layer is better, it only needs little work. The transport layer can also be multiplexed, that is, create multiple logical connections on one network connection. The transport layer is also known as the transport layer . The transport layer only exists in the terminal open system, and is a layer between the lower 3-layer communication subnet system and the upper 3-layer, but a very important layer. Because it is the last layer that controls data transfer from low to high from source to destination.
The main function is to confirm the receipt of data between the end open systems. At the same time, it is also used to make up for the quality difference of various communication networks, to recover the transmission errors that still exist after passing through the lower three layers, and to further improve the reliability. In addition, through technical measures such as multiplexing, segmentation and combination, connection and separation, shunting and confluence, etc., throughput and quality of service are improved.

The main focus of this layer is on two protocols: UDP and TCP. Both protocols will be introduced in future articles.

5. Session layer

The session layer is responsible for establishing, maintaining and terminating communications between two nodes in the network.

The functions of the session layer include: establishing a communication link, keeping the communication link unblocked during the session, synchronizing the dialogue between two nodes, deciding whether the communication is interrupted and deciding where to re-send when the communication is interrupted.
The session layer sets the communication period by determining the priority of node communication and the length of communication time.

6. Presentation layer
One of its main roles is to provide a common language for heterogeneous machine communication so that it can interoperate. This type of service is required because different computer architectures use different representations of data. Unlike Layer 5, which provides transparent data transport, the presentation layer handles all issues related to data presentation and transport, including transformation , encryption, and compression. In addition to this, the presentation layer protocol also decodes and encodes picture and file format information.
For example, IBM mainframes use EBCDIC encoding, while most PCs use ASCII. In this case, the presentation layer is required to complete this conversion.
7. Application layer
The highest level of the OSI reference model.
Its function is to realize the exchange of information between application processes (such as user programs, terminal operators, etc.). At the same time, it also has a series of service functions required for business processing.
The application layer generally includes common application service elements (CASE) and specific application service elements (SASE). Among them, CASE provides the most basic services in the application process, and provides the application process with the capability of communication that is necessary for information transmission but is independent of the application process. SASE is essentially the mapping of various application processes in the application layer. Each SASE is aimed at a specific type of application, such as file transfer, access and management (FTAM), virtual terminal (VT), message processing system (MHS), Electronic Data Interchange (EDI) and directory inquiries, etc.

Advantages of the OSI seven-layer model
The OSI seven-layer model clearly distinguishes the three concepts of service, interface and protocol, so that each layer has strong independence, so:
(The service describes what functions a certain layer provides for the upper layer, the interface describes how the upper layer uses the services of the lower layer, and the protocol involves how to implement the services of this layer)
1. Reduce the complexity of the network. Once the network fails, the level of the fault can be quickly located, which is easy to find and correct;
2. Standardization, each layer follows the same standard, which is convenient for different network devices to achieve interoperability
3. Modules
4. Collaboration 5. Accelerate development, effectively stimulate network technology
innovation, because each update can be carried out in a small area without major surgery on the entire network.
6. Simple teaching
Three, TCP/IP five (four) layer model

1. What is TCP/IP?
TCP/IP is synonymous with a set of protocols, and it also includes many protocols that make up the TCP/IP protocol suite.
The TCP/IP communication protocol adopts a 5-layer hierarchical structure, and each layer calls the network provided by the next layer to complete its own needs.
as follows:

2. Layered introduction
(1) Physical layer: responsible for the transmission of optical/electrical signals.
For example, the common network cable (twisted pair) of Ethernet, the coaxial cable used in early Ethernet (now mainly used for cable TV), optical fiber, and the use of electromagnetic waves in the current wifi wireless network belong to the concept of physical layer.
The ability of the physical layer determines the maximum transmission rate, transmission distance, anti-interference, etc. The hub (Hub) works at the physical layer. 
(2) Application layer

The TCP/IP model incorporates the functions of the session layer and presentation layer in the OSI reference model into the application layer implementation.  

The application layer introduces different application layer protocols to different network applications. Among them, some are based on the TCP protocol, such as the File Transfer Protocol (File Transfer Protocol, FTP), the virtual terminal protocol (TELNET), the Hyper Text Transfer Protocol (Hyper Text Transfer Protocol, HTTP), and some are based on the UDP protocol.

(3) Transport layer: Responsible for data transmission between two hosts. For example, Transmission Control Protocol (TCP), which can ensure that data is reliably sent from the source host to the target host.
在TCP/IP模型中,传输层的功能是使源端主机和目标端主机上的对等实体可以进行会话。在传输层定义了两种服务质量不同的协议。即:传输控制协议TCP(transmissioncontrol protocol)和用户数据报协议UDP(user datagram protocol)。  
 TCP协议是一个面向连接的、可靠的协议。它将一台主机发出的字节流无差错地发往互联网上的其他主机。在发送端,它负责把上层传送下来的字节流分成报文段并传递给下层。在接收端,它负责把收到的报文进行重组后递交给上层。TCP协议还要处理端到端的流量控制,以避免缓慢接收的接收方没有足够的缓冲区接收发送方发送的大量数据。  
 UDP协议是一个不可靠的、无连接协议,主要适用于不需要对报文进行排序和流量控制的场合。  
(4)网络层: 负责地址管理和路由选择.
例如在IP协议中, 通过IP地址来标识一台主机, 并通过路由表的方式规划出两台主机之间的数据传输的线路(路由). 路由器(Router)工作在网络层.

(5)网络接口层
对实际的网络媒体的管理,定义如何使用实际网络(如Ethernet、Serial Line等)来传送数据。
如简单电子邮件传输(SMTP)、文件传输协议(FTP)、网络远程访问协议(Telnet)等. 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325183746&siteId=291194637