Learn computer networking knowledge you should know

foreword

Network is a necessary knowledge for embedded learning. Many embedded learners have not really systematically understood the knowledge of network. Just recently, Abin is also learning about the knowledge of network. He has compiled some network notes. learning can help

Then, let's take a look at the relevant knowledge of computer network with Abin! This article is long, it is recommended to like, collect and watch repeatedly!

In this article, Abin will systematically introduce the computer network from the following aspects:

1. What is a computer network?

2. Classification of networks

3. Seven-layer network model

4. IP address

5. Subnet mask

6. TCP/IP protocol

7. Three handshakes and four waves


What is a computer network?

Computer network refers to the connection of multiple computers with independent functions in different geographical locations and their external devices through communication lines, under the management and coordination of network operating systems, network management software and network communication protocols, to achieve resource sharing and information. delivered computer system. – (The definition comes from Baidu Encyclopedia)

After reading this official definition, you may not know what a computer network is, so let's use a few keywords to define a computer network! A computer network is an autonomous computer cluster connected to each other for the purpose of resource sharing.

First of all, it is necessary to understand that the computer network is of a cluster nature. A computer is not called a network. Only the interconnection of multiple computers that can autonomously (work independently) can form a network! In the network, one of the most important and the core of the network is multi-machine sharing, and it is people based on sharing that the network appears.

Classification of networks

Understand the definition of computer network, and then understand the classification of computer network. Generally speaking, it can be classified according to the following five points: network coverage, network transmission mode, topology, network protocol, transmission medium.

1. According to the coverage

The coverage of the network can be divided into: local area network, metropolitan area network and wide area network.

Local area network English is LAN (Local Area Network), Local, local, local. Anyone who has installed a network cable or router should know that there is a LAN port on the router. The network connection in everyone's home is generally PC —> wireless router —> (LAN) optical cat (WAN) —> ISP —> Internet GW —> Internet, under normal circumstances, the computers connected to the same router form a simple local area network.

However, if the router is connected to an advanced switch that can be managed by the network, this type of switch can be divided into VLANs (Virtual Local Area Networks), so that some computers may belong to different VLANs, that is, different LANs, even if they are under the same router.

Local area networks are relatively small in scale, with short communication lines and coverage areas usually ranging from a few hundred meters to several kilometers in diameter. A metropolitan area network refers to a computer network that covers a city. A wide area network refers to a larger network that covers a country or even the entire planet.

Although the terms local area network, metropolitan area network, and wide area network are proposed for the coverage of the network, they are more distinct from network construction techniques.

2. The transmission method of the network is divided into

The network can be divided into broadcast network and point-to-point network according to the transmission mode.

A broadcast network has only a single communication channel in the network, shared by all hosts in the network. That is, multiple computers are connected to different branch points on a communication line, and the packet sent by any node is accepted by all other nodes. There is an address field in the sent packet, indicating the target recipient and source address of the packet.
https://f11.baidu.com/it/u=1171636252,2312538932&fm=173&app=49&f=JPEG?w=414&h=565&s=5AAC3C624BB2C9EB16F595CE0000C0B1&access=215967316

A pure peer-to-peer network has no concept of client or server, only equal peer nodes, acting as clients and servers for other nodes on the network at the same time. This network design model differs from the client-server model, in which communication is usually to and from a central server.
(https://f11.baidu.com/it/u=943720333,2391930586&fm=173&app=49&f=JPEG?w=406&h=550&s=4AAA3C624BBFC9EB1ED5B0CA000080B1&access=215967316)

You may have heard of the network structure such as P2P when learning C language. An important goal of P2P network is to allow all clients to provide resources, including bandwidth, storage space and computing power. The distributed nature of P2P networks also increases failure-proof robustness by replicating data across multiple nodes, and in pure P2P networks, nodes do not need to rely on a central indexing server to discover data. In the latter case, there is also no single point of crash of the system.

3. According to the topological structure

Network topology refers to the physical layout that uses transmission media to connect various devices such as computers to each other. Network topology can be classified by shape, including: star, ring, bus, tree, bus/star and network. shape topology.
![](https://iknow-pic.cdn.bcebos.com/6609c93d70cf3bc799055588dc00baa1cd112a48

1. Star topology The
star structure is a center with multiple sub-nodes. It has simple structure, convenient connection, relatively easy management and maintenance, and strong expansibility. The network delay time is small and the transmission error is low. There is no fault in the center, and there is no problem with the general network. If the center fails, the network will have problems. At the same time, the sharing ability is poor, and the utilization rate of communication lines is not high.

2. Bus topology In the
bus topology, all devices are connected to a connection medium. The number of cables required by the bus structure is small, the cable length is short, and the wiring and maintenance are easy. Multiple nodes share a transmission channel, and the channel utilization rate is high, but no fault diagnosis is found.

3. Ring topology network
Ring topology network is a closed loop formed by nodes. Fewer workstations, saving equipment. Of course, this will lead to a problem with one node, the network will have problems, and it is not easy to diagnose the fault.

4. Tree topology
The tree topology evolved from the bus topology. It is shaped like an upside-down tree. The top is the root of the tree. There are branches below the root. Each branch can also have sub-branches. The data is then broadcast and sent to the entire network. Good extension, easy to diagnose errors, but demanding on the root.

5. Mesh topology
is the most widely used. Its advantage is that it is not affected by bottleneck problems and failure problems. If there is a problem with one line, other lines can be used, but it is too complicated and the cost is high.

6. Hybrid topology
is to use two or more of the above. For example, there are many star bus type, star ring type and so on.
Advantages: Can complement the basic topology of the network.
Disadvantages: It is difficult to configure the network configuration package.

4. According to the network protocol

First of all, everyone must understand what a network protocol is. A communication protocol is a rule or agreement that both parties abide by. Different networks use different communication protocols. For example, the Ethernet in the local area network uses the CSMA protocol, the packet switching network in the wide area network uses the X.25 protocol, and the Internet network uses the TCP/IP protocol.

5. According to the transmission medium

The transmission medium is the communication line. At present, wired or wireless transmission media such as coaxial cable, twisted pair, optical fiber, satellite, and microwave are commonly used. The corresponding networks are called coaxial cable network, twisted pair network, optical fiber network, satellite network, wireless network, etc.

Seven-layer network model

OSI seven-layer model, OSI is the abbreviation of (Open System interconnect), from top to bottom, it is application layer, presentation layer, session layer, transport layer, network layer, data link layer, physical layer, these knowledge are in C language. Or you should have already learned something in the basics of computer. Let's take a look at the seven-layer network model separately!

1) Physical Layer
First of all, the physical layer defines the specifications of all electronic and physical devices, and provides a physical medium for the transmission of the upper layer. The unit of data is bit (bit). Although the physical layer is at the bottom, it is the foundation of the entire open system. Further, the role of the physical layer is to shield the differences between hardware devices and transmission media in the computer network as much as possible. After all, there are so many hardware device manufacturers in the world, and we use many means to access the Internet. Of course, there are many kinds of hardware. . What the physical layer needs to do is to shield this difference as much as possible, so that the data link layer only needs to consider how to complete the protocols and services at this level, without having to consider the specific transmission medium of the network.

2) Data Link Layer
The data link layer is the second layer in the OSI reference model and is between the physical layer and the network layer. The data link layer provides services to the network layer on the basis of the services provided by the physical layer. Its most basic service is to reliably transmit the data from the network layer to the network layer of the target machine of the adjacent node.

3) Network Layer
The purpose of the network layer is to realize the transparent transmission of data between two end systems, and the specific functions include addressing and routing, connection establishment, maintenance and termination. It provides services so that the transport layer does not need to know the data transmission and switching technology in the network.

4) Transport Layer (Transport Layer)
The transport layer is responsible for segmenting the upper layer data and providing end-to-end, reliable or unreliable transmission. At this layer, the protocol data units in which information is conveyed are called segments or packets. , the network layer only transmits the data packets sent by the source node to the destination node according to the network address, while the transport layer is responsible for reliably transmitting the data to the corresponding port.

5) Session layer
The session layer manages session processes between hosts, that is, is responsible for establishing, managing, and terminating sessions between processes. The session layer also implements data synchronization by inserting checkpoints in the data.

6) Presentation layer
The presentation layer transforms the upper layer data or information to ensure that the application layer information of one host can be understood by the application program of another host. The data conversion of the presentation layer includes data encryption, compression, format conversion, etc.

7) The application layer
provides an interface for the operating system or network application to access network services.

IP address and hardware address

The so-called IP address is a 32-bit address assigned to each host connected to the Internet. According to the TCP/IP protocol, IP addresses are represented in binary, each IP address is 32 bits long, and the bits are converted into bytes, which is 4 bytes. An IP address is a logical address used by IP datagrams at the network layer and above, and a hardware address is an address used by the physical layer and the data link layer.
[External link image transfer failed, the source site may have an anti-leech mechanism, it is recommended to save the image and upload it directly (img-ZpE74A1W-1650714589441) (images/b49269c8537520cdadc2b04d5b9fa2b7.jpg)]
From the above figure, we can see: abstraction at the IP layer Only IP datagrams are seen on the Internet. IP1→IP2 in the figure indicates that the IP addresses of the two routers from the source address IP1 to the destination address IP2 do not appear in the header of the IP datagram, and the routers only perform routing based on the network number of the IP address of the destination station. Each host (Host) on the Internet has a unique IP address. The IP protocol is to use this address to transmit information between hosts, which is the basis for the operation of the Internet.

The hardware address is what we often call the MAC address. This address is unique in the world just like your ID card. It is written into the device's chip when the device leaves the factory. It is in a unified format according to international standards and regulations. , this address will never change, and the hardware addresses of two devices of the same model are also different. There are many ways to find the hardware address in the local area network. One of the biggest features of routing is to broadcast all the PCs or computers below it. The MAC address of a switch or router is automatically added to its allocation table, so that they can be assigned IP addresses. After obtaining their actual MAC addresses, IP addresses are assigned according to the MAC addresses. The route has the function of automatic learning.

subnet mask

Subnet mask (subnet mask) is also called network mask, address mask, subnet mask. It is a bitmask used to indicate which bits of an IP address identify the subnet the host is on, and which bits identify the host.

The subnet mask cannot exist alone, it must be used in conjunction with the IP address. The subnet mask has only one function, which is to divide an IP address into two parts: the network address and the host address. A subnet mask is a 32-bit address used to mask a portion of an IP address to distinguish a network identity from a host identity, and to indicate whether the IP address is on a local area network or a wide area network.

TCP/IP

TCP/IP is a communication protocol for Internet-connected computers to communicate. When an application wants to communicate with another application over TCP, it sends a communication request. This request must be sent to an exact address. After the two sides "handshake", TCP will establish a full-duplex (full-duplex) communication between the two applications.

TCP/IP means that TCP and IP work together. TCP is responsible for communication between application software (such as your browser) and network software, and IP is responsible for communication between computers. TCP is responsible for splitting the data into IP packets and then reassembling them as they arrive, and IP is responsible for sending the packets to the recipient.

The standardization process of TCP/IP is roughly divided into the following stages:

①. Internet draft stage: From the beginning of the proposal, we will continue to discuss and experiment, and when we have a certain maturity, we think it is practical and feasible, and we think it can be standardized, and we can enter the next stage.

②. Proposed standard stage: It is included in the RFC, and it begins to enter the production process of many equipment manufacturers and put it into experimental use. It is generally 6 months. When all the people participating in the protocol feel that it is "practical and there are not too many problems", then enter the next stage

③. Draft standard stage: generally lasts for 4 months. After continuous use, discussion and improvement, it is accepted by the public, then the draft standard will enter the next stage

④.Standard stage: At this stage, it means that the standard has been widely used and has strong practicability

Three handshakes four waves

(1) Step 1: The TCP of source host A sends a connection request segment to host B, and the SYN (synchronization) flag in its header should be set to 1, indicating that it wants to communicate with target host B and send a synchronization Sequence number X (eg: SEQ=100) is used for synchronization, indicating that the sequence number of the first data byte when data is transmitted later is X+1 (ie 101). The SYN synchronization message will indicate the port used by the client and the initial sequence number of the TCP connection.

(2) Step 2: After the TCP of the target host B receives the connection request segment, if it agrees, it will send back confirmation. In the acknowledgment, the ACK bit and the SYN bit should be set to 1, indicating that the client's request is accepted. The confirmation number should be X+1 (101 in the figure), and also choose a serial number Y for yourself.

(3) Step 3: After receiving the confirmation from the target host B, the TCP of the source host A will give the confirmation to the target host B, the ACK is set to 1, the confirmation number is Y+1, and its own serial number is X+1. The TCP standard stipulates that a segment with SYN set to 1 consumes a sequence number.

The TCP of the source host A running the client process notifies the upper-layer application process that the connection has been established. When the source host A sends the first data segment to the destination host B, its sequence number is still X+1, because the previous acknowledgment segment does not consume the sequence number.

When the TCP of the target host B running the service process receives the confirmation from the source host A, it also notifies its upper-layer application process that the connection has been established. A full-duplex connection is now established.

The reason for
the three-way handshake If the three-way handshake is used, even if the invalid message is sent, the server receives the invalid message and replies with the confirmation message, but the client will not send confirmation again. Since the server does not receive an acknowledgment, it knows that the client did not request a connection.

Students who learn embedded can pay attention to the WeChat public account [Embedded Yuexiang Garden] and reply to "resources" to get all embedded resources, including STM32 resources, 51 microcontroller resources, Linux learning resources, etc. If you want to learn embedded Go follow it!
Please add image description

Guess you like

Origin blog.csdn.net/qq_45172832/article/details/124369083