Linux-----Network Foundation (1)

computer network background

network development

(1) Independent mode: The computers are independent of each other.

(2) Network interconnection: multiple computers are connected together to complete data sharing, and the shared data is centrally managed by the server.

(3) Local area network LAN: There are more computers, which are connected together through switches; under the same local area network, two computers can communicate with each other. (Switch: can reduce the collision domain in the local area network. Router: connect to the external network).

(4) WAN: Connecting computers thousands of miles away.

The so-called "local area network" and "wide area network" are only relative concepts.

Understanding "agreement"

An agreement is an agreement. (Protocols are subject to the same point) The transmission medium between computers is optical and electrical signals. Information such as 0 and 1 is represented by "frequency" and "strength". In order to transmit a variety of different information, it is necessary to agree on the data format of both parties.

Network protocol

protocol layering

OSI seven-layer model:

(1) 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;

(2) The network is logically divided into 7 layers, and each layer has related and corresponding physical devices, such as routers and switches;

(3) The OSI seven-layer model is a frame-based design method, and its main function is to help different types of hosts realize data transmission;

(4) Its biggest advantage is that it clearly distinguishes the three concepts of service, interface and protocol. The concept is clear and the theory is relatively complete. Through seven hierarchical structural models, different systems and different networks can be Enable reliable communication. However, it is complex and impractical; so we will focus on the TCP/IP four-layer model next.

TCP/IP five-layer (or four-layer) model

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.

(1) Physical layer: responsible for the transmission of optical/electrical signals. For example, the common network cable (twisted pair) of Ethernet, the network axis cable used in Ethernet earlier (now mainly used for wired cable), optical fiber, and the use of electromagnetic waves in the current WiFi wireless network belong to the concept of physical layer. The capability of the physical layer determines the maximum transmission rate, transmission distance, and anti-interference. The hub (Hub) works at the physical layer.

(2) Data link layer: responsible for the transmission and identification of data frames between devices. For example, the driver of the network card device, frame synchronization (that is, what signal detected from the network line is counted as the start of a new frame), conflict detection (automatic retransmission if a conflict is detected), data error checking, etc. There are standards such as Ethernet, Token Ring, and Wireless LAN. The switch (Switch) works at the data link layer.

(3) Network layer: responsible for address management and routing. For example, in the IP protocol, a host is identified by an IP address, and a data transmission line (route) between the two hosts is planned by means of a routing table. Routers work at the network layer.

(4) Transport layer: responsible for data transmission between two hosts. Such as Transmission Control Protocol (TCP), which can ensure that data is reliably sent from the source host to the destination host.

(5) Application layer: responsible for communication between applications, such as simple email transfer (SMTP), file transfer protocol (FTP), network remote access protocol (Telnet), etc. Our network programming is primarily aimed at the application layer.


Basic process of network transmission

Two hosts in the same network segment perform file transfer. (The OS is responsible for the communication details)


The process of two computers communicating through the TCP/IP protocol is as follows:

TCP/IP communication process


For file transfer between hosts on a network segment, data must pass through one or more routers during the process of transferring data from one computer to another. In a network, peer-to-peer protocols think they are communicating with each other's peer-to-peer protocols.


Whether routing: determine whether your own IP and destination IP are in the same local area network

Packet encapsulation and demultiplexing

(1) Different protocol layers have different names for data packets, which are called segments at the transport layer, datagrams at the network layer, and frames at the link layer.

(2) When the application layer data is sent to the network through the protocol stack, each layer protocol must add a data header, which is called encapsulation.

(3) The header information contains some information such as how long the header is, how long the payload is, and what the upper-layer protocol is.

(4) The data is encapsulated into a frame and sent to the transmission medium. After reaching the destination host, each layer of the protocol strips the corresponding header, and according to the "upper layer protocol field" in the header, the data is handed over to the corresponding upper layer protocol for processing.

The data encapsulation process is shown in the following figure:







Guess you like

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