Fundamentals of computer network (1)

Time:2020-9-23

An overview of the article

Fundamentals of computer network (1)

Understanding computer network and its classification

What is computer network

The computer network is mainly made up of some common and programmable hardwareThrough these hardware, different types of data can be transmitted and a wide range of applications can be supported

  • Computer network is not only the concept of software, it also containsHardware equipment(network card, network cable, router)
  • Computer networks are not justInformation communicationIt can also support a wide range of applications

Classification of computer networks

1. According toThe scope of network functionThe computer network can be divided into

  • Wide area network (WAN)
  • Metropolitan area network (man)
  • Local area network (LAN)

Fundamentals of computer network (1)

2. According toUsers of the networkThe computer network can be divided into

  • Public network (any network that is willing to pay, or willing to join, can join)
  • Private network (a network established by some departments or people to meet special business needs. For example, the military, railway bureaus, banks and companies all have their own private networks)

Brief history of computer network development

The history of the Internet

There are three stages in the history of Internet development

Fundamentals of computer network (1)

Phase I: single network ARPANET

In this stage, some computers are connected through the switch. At this time, the computer can directly complete the information exchange by connecting the switch, and there are not many computers connected
Fundamentals of computer network (1)

The second stage: three level structure Internet

This stage is mainly connected to some major schools, research institutes, laboratories and other places with computers in the United States

Fundamentals of computer network (1)

The third stage: multi level ISP Internet

ISP(Internet service provider): network service provider (China Telecom, China Unicom and China Mobile are all famous network service providers in China)

The top one isBackbone ISPThe three network service providers mentioned above are included here. China’s backbone ISPs can be connected to the backbone ISPs in the United States, Australia and Europe. Below the backbone ISP isRegional ISPFor example, mobile network is called China Mobile in China, Beijing mobile in Beijing and Shanghai Mobile in Shanghai. This belongs to regional ISP, which is mainly responsible for the provision of regional network services

Fundamentals of computer network (1)

You can see the internet route through this website: https://live.infrapedia.com

Fundamentals of computer network (1)

A brief history of Internet development in China

The development of China’s Internet can also be divided into three stages:

Fundamentals of computer network (1)

With the development of China’s Internet, China has also established a number of public computer networks, which can carry out international information exchange. Among them, five public computer networks are the largest

  • China Telecom Internet (Chinanet)
  • China Unicom Internet
  • China Mobile Internet (cmnet)
  • China Education and research computer network (CERNET)
  • China Science and technology network (CSTNet)

Our overseas traffic is mainly through these five networks to access foreign information. In addition to the participation of national scientific research and technology, private enterprises have also made great contributions to the Internet, including well-known entrepreneurs

  • In 1996, Zhang Chaoyang founded Sohu
  • In 1997, Ding Lei founded Netease
  • In 1998, Wang Zhidong founded Sina
  • In 1998, Ma Huateng and Zhang Zhidong founded Tencent
  • In 1999, Ma Yun founded Alibaba
  • In 2000, Robin Li founded Baidu.

These deeds have also promoted the development of China’s Internet

Hierarchical structure of computer network

Basic principles of hierarchical structure design

Before we understand the basic principles of computer hierarchy design, let’s take a look,Why do computer networks need to use hierarchical design

Suppose there are two computers a and B, and they are connected through the computer network. You can imagine what kind of problems the computer network solves here

  • Ensure smooth data access
  • Identify destination computer
  • Destination computer status
  • Is the data wrong

Computer network needs to solve the problem is numerous and complex, so the computer network usedlayeredTo achieve different functions

Let’s look at an example of a hierarchy that we use in modern times

Fundamentals of computer network (1)

Basic principles of hierarchical structure design
  • The layers are independent of each otherA layer does not need to know how its upper and lower layers are implemented, it only needs to know how the layer provides services through the interface. The coupling between layers is very low
  • Each layer has enough flexibility: because the computer network is constantly developing, it is necessary to design each layer with enough flexibility so that each layer can cope with some changes in the future
  • All layers are decoupled completely: that is to say, the changes of the upper and lower layers of a certain layer will not affect the stability of the current layer (although this is the principle of computer level design, in fact, if we can draw lessons from these principles when designing a relatively large system, this is the charm of the computer bottom layer.)

OSI seven layer model

The computer network has a seven layer model, which is defined by international standards

Fundamentals of computer network (1)

OSI seven layer modelAt the time of formulation, we want to be the standard followed by computers all over the world, and then promote computers all over the world to use this standard to facilitate interconnection and data exchange. In fact, there are many difficulties in the process of OSI’s marketization, because when OSI standards were formulated,TCP / IP modelIt has been successfully operated on a global scale. Therefore, the OSI seven layer model has only achieved theoretical research results, but it has not been successfully promoted in the aspect of marketization. Therefore, OSI has not become a widely used standard model in the end

Several reasons why OSI is not accepted by the market
  • OSI experts lack practical experience (they are based on theory and lack experience in actual production environment. Theory must be combined with practice)
  • The development cycle of OSI standard is too long, and the equipment manufactured according to OSI Standard cannot enter the market in time
  • The design of OSI model is unreasonable, and some functions appear repeatedly in multiple layers

TCP / IP four layer model

The following is the mapping between OSI seven layer model and TCP / IP four layer model

Fundamentals of computer network (1)
Note: on the right are some protocols used in each layer of TCP / IP four layer model

Practical application of TCP / IP four layer model

Suppose that computer a and B are connected through a router, computer a will communicate with the router through the four layers of TCP / IP, and the data of computer a will come to the router through the network interface layer and network layer (in the router, only the network layer and network interface layer are reached). The router will forward the data through the route and forward it to computer B. computer B receives the data through the four layers from the bottom to the top. This is an example of TCP / IP four layer model in sending and receiving data

Fundamentals of computer network (1)

In addition, we can also understand different levels through a hierarchical approach

Fundamentals of computer network (1)

Network topology of modern Internet

understandNetwork topologyThe computer network that can help us form an image in our mind is helpful for us to learn further. The network topology of modern Internet is mainly divided into two parts

  1. Marginal part
  2. Core part

Marginal part

It mainly refers to the parts that users can contact directly. For example, the network used at home, in the company or in the shopping mall belongs to the computer networkMarginal part(mobile phones, computers and smart appliances at home are connected to routers via wired or wireless means. Routers are connected to a local gateway, and then the gateway is connected to the regional ISP)

Fundamentals of computer network (1)

The top is a network topology of a home networking, and the bottom is a network topology of an enterprise

Fundamentals of computer network (1)

Core part

The core part is mainly composed of regional ISP, backbone is and some international routers

Fundamentals of computer network (1)

These backbone ISPs are connected with each other and connected with backbone ISPs in other countries and regions through international routers, which belong to the InternetCore part。 Among them, there are many submarine cables, cross regional cables and other communication equipment. They are mainly laid by China Unicom and China Telecom. Some of the equipment they use is from Huawei of China, so Huawei has a certain position in the field of communication

The upper part is a simple illustration of the core part and the edge part of the network topology. If the core part and the edge part are connected, the whole network topology is very complex

Fundamentals of computer network (1)

Although in learning computer networks, we need to have a certain understanding of network topology, but we do not perceive the existence of these network topologies when we usually use the network. We don’t know where the backbone ISP is, the regional ISP, or even the gateway. What we can know at most is the routers that have more contact with. This is mainly because we usually use the computer network from the perspective of a user. If we look at the Internet from the perspective of users, there are more modes, such asClient server (C / s) mode

For the client server (C / s) mode, in the Internet, there are many devices connected through the Internet, but we do not need to perceive the details of the Internet. If we want to use a certain service and send a request directly from our PC, the request will be routed to the place where the service is provided. After the server receives the request, it will respond, and the local PC will receive the response. This is the client server (C / s) mode. When customers seek services, and when the server provides services, they do not need to perceive the specific details of the network

Fundamentals of computer network (1)

Performance index of computer network

Knowing the performance index of network is helpful to evaluate or judge the quality or speed of network. Before understanding, a simple understanding of the commonly used measurement units (rate)

Fundamentals of computer network (1)

Why is the test peak speed of 100m optical fiber pulled by telecom only 12m / S?

First of all, because the common unit of network is Mbps
100M/s = 100Mbps = 100Mbit/s
The conversion from bit to byte has one base, and eight bits are equal to one byte
100Mbit/s = (100/8)MB/s  = 12.5MB/s

time delay

The delay can be subdivided into

  • transmission delay
  • Queuing delay
  • Propagation delay
  • Processing delay
transmission delay

It mainly refers to the time that the local computer stays in the local computer when sending the network

Transmission delay = data length (bit) / transmission rate (bit / s)

Data length: it is determined by the user. For example, to download a 100m video, the 100m is the data length
Send rate: determined by the network card (the better the performance of the network card, the faster the transmission rate)
Propagation delay
Propagation delay = transmission path length / propagation rate (bit / s)
Transmission path length: for example, Beijing sends data to Shanghai, which is relatively short. If Beijing sends data to the United States, the data must go through submarine cables to reach the United States, and the transmission path is very long
Propagation rate: This is limited by the transmission medium (e.g. copper wire, optical fiber)
Queuing delay

data packetWaiting time in a network device to be processed

If a data is sent from the local computer to a router, the router does not process it immediately because it may be processing many other packets. Therefore, the packets we send may stay in the router for a period of time, and the waiting time is the queuing delay

Processing delay

Packets arrive at the device orThe time required for the destination machine to be processed

If we get to the server, its performance is not good, maybe the packet arrived at it, it will take a while to process our packet

Therefore, to evaluate the time index of computer network, the total delay is

Total delay = transmission delay + propagation delay + queuing delay + processing delay

In addition to the time delay, there is another index to evaluate the time of computer networkRound trip time RRT

  • RTTRoute trip time is an important index to evaluate network quality
  • RTT represents the data message in the end-to-end communicationA round trip time
  • Commonly usedpingCommand to view RTT

Ping an IP in Guangzhou (the one on the far right is the round trip time)

Fundamentals of computer network (1)

Ping An American IP

Fundamentals of computer network (1)
(it is obvious that the round-trip time is relatively long)

Physical layer overview

The role of the physical layer

In the case of OSI seven layer model, the physical layer is at the bottom. For the TCP / IP four layer model, it belongs to the bottom layerNetwork interface layer。 The role of the physical layer is

  • Connect different physical devices (e.g. router to computer through network cable)
  • Transmit bit stream (bit stream is the high and low level of 0, 1, or digital signal)

Transmission medium

The media connecting different physical devices includes wired media and wireless media, wherein the wired media includes

Twisted pair

Fundamentals of computer network (1)

Coaxial cable

Fundamentals of computer network (1)

Optical fiber

Fundamentals of computer network (1)
Wireless media: infrared (remote control), wireless, laser

Bitstream

High level represents 1, low level represents 0,The change of high level and low level can form bit stream
Fundamentals of computer network (1)

Basic concept of channel

  • A channel is a medium that transmits information in one direction
  • A communication circuit usually contains a receiving channel and a transmitting channel
  • Because the direction of sending and receiving information is different, there are two channels here

A communication line, both sending and receiving, what if there is a conflict?

Fundamentals of computer network (1)

In fact, the physical layer has solved this problem. According to the different channels, the communication circuit can be divided into

  • Simplex communication channel
  • Half duplex communication channel
  • Full duplex communication channel
Simplex communication channel
  • can onlyOne direction communicationChannel with no feedback in the opposite direction
  • Limited television, radio and so on, all belong to the simplex communication channel (one side sends, the other side can only receive)
Half duplex communication channel
  • Both parties can send and receive messages
  • It can’t be sent by both sides at the same timeNot at the same timereceive
Full duplex communication channel
  • Both sides canmeanwhileSending and receiving messages
  • These are full duplex communication channels

Division reuse technology

As mentioned earlier, if two computers communicate, there will be a communication line between them. In this communication circuit, the sending channel and the receiving channel may be used. Consider a situation, if there are many computers, they all need to connect, at this time there are a lot of sending channels and receiving channels, and in many cases, they are not in the active state. This will lead to low channel utilization. Therefore, it is proposed thatDivision reuse technologyTo improve the channel utilization

How to improve the channel utilization by using the division multiplexing technology?

Multiple computer connectionsMultiplexer, computer connection on the other sideDistributor。 Through multiplexer and demultiplexer, the two devices can share a transmission channel and a receiving channel, which can greatly improve the channel utilization

Fundamentals of computer network (1)
Note: if there are many computers, send and receive information through the channel frequently, it will lead to channel congestion

Overview of data link layer

For the physical layer, it is mainly to connect different devices and transmit bit stream. The next part introduces the data link layer. First of all, the data link layer is located in the penultimate layer of the OSI seven layer model, that is, the upper layer of the physical layer, which is located in the TCP / IP four layer modelNetwork interface layer

Fundamentals of computer network (1)

The data link solves the following three main problems

  • Package into frames
  • Transparent transmission
  • Error detection

Package into frames

  • “Frame” is the basic unit of data in data link layer (just as bit is the unit of physical layer data)
  • The sender adds special marks before and after a piece of data in the network layer to form a “frame”
  • The receiver recognizes the “frame” according to the specific mark before and after

The following is a diagram to understand the process of packaging into frames

  • Firstly, some IP datagrams are transmitted to the data link layer at the network layer,
  • When the data is received by the data link layer, it is regarded as the data of the data frame, and then special marks are added before and after the data to indicate that it is the head and tail of the data frame
  • From the beginning to the end of the frame is the length of the data frame

In the physical layer, the data frame represents a lot of bit streams composed of 0 and 1. The frame header and tail mentioned above are specific control characters (specific bitstreams)

Frame headerThe bit stream of is:SOH: 00000001 (soh is the control character)

Frame tailThe bit stream of is:EOT:00000100

Fundamentals of computer network (1)

What if the frame data also happens to have the same bit stream as the beginning or tail of the frame

This needs to be mentioned belowTransparent transmission

Transparent transmission

The problem mentioned above can be solved by transparent transmission. Before we introduce transparent transmission, let’s take a look at what is“transparent

Transparency is a very important term in the computer field

For example, when we design an API, we often say that if your API is well designed, the operation of the underlying API is transparent to the API caller. Another example is the data link layer and the physical layer. For the data link layer, the work of the physical layer is transparent. The physical layer only needs to provide some APIs for the data link layer to use. To put it bluntly:A transaction that actually exists, but it doesn’t seem to exist. To use the concept of transparency in the data link layer is to control the characters in the frame data, but to treat them as nonexistent ones

So how does the data link layer do it? Even if the control character is in the frame data, it can still act as if it doesn’t know?

Suppose that there is a control character at the end of the frame data. If the data link layer does not use transparent transmission, then the receiver may regard the control character in the frame data as the tail of the data frame, so as to identify the wrong frame.Therefore, the data link layer will process the control characters in the frame data specially

Fundamentals of computer network (1)

The way to deal with this is to add the control character before itEscape character, belowESCIt’s the escape character. In this way, after receiving the data frame, the receiver will first determine whether there is an escape character in front of the control character in the frame data. If there is an escape character, the control character will not be regarded as a control character. What if there are escape characters in the frame data? The escape character can be re escaped once

Fundamentals of computer network (1)
In fact, we usually use “” as an escape character. If you want to output “\”, you can add escape characters before the two backslashes, which means that neither of them is an escape character “\ \”

Error detection

The physical layer only transmits the bit stream and cannot control whether there is an error (if there is some interference in the process of transmitting the bit stream in the physical layer, such as lightning). It will affect the transmission of bit stream, which is not detected by the physical layer)

The data link layer is responsible for error detection

Error detection error in data link layer

This part mainly introduces the third problem of data link layer: error detection

  • Parity check code
  • Cyclic redundancy check code (CRC)
Parity check code

Parity check codeIt is a very simple method to detect whether there is transmission error in bit stream. In this method, a bit is added to the end of the bit stream to detect whether there is an error in the bit stream. Suppose the test is to transmit the 8-bit bit bit stream “00110010”

  • First add “1” to the bit stream
  • When the receiving end receives the bit stream, it will detect whether there is any error in the bit stream according to the bit added later
  • This 1 is obtained by adding the 8-bit streams in the front edge to get 3. Because 3 is odd, we add 1 to the 8-bit bit bit stream to indicate that this is an odd numberParity bit

If we want to transmit the bit stream “00111010”, then the bit added later should be “0”, because the result of adding the 8 bits is 4, which is an even number. Let’s take a look at how to detect errors through this parity check code. Assuming that the bit stream “00110010” is to be transmitted at this time, it is necessary to add “1” to the tail. Suppose an error occurs in the transmission process, and the receiver receives “00010010”. At this time, the receiver will check by parity check code. The parity check code calculated by the receiver is “0”, which is not equal to “1”, indicating that there is an error in the transmission process of this bit stream

I believe you are smart enough to see that there is a limitation here. Suppose you still want to transmit “00110010”, and the bit added in the tail is “1”. Suppose that the receiver receives “000000 10”. After calculation, the receiver finds that the parity bit at the back should be “1”. At this time, the last parity bit is “1”. Then it will be considered that the data is OK, but the data is actually wrong.So when a bit stream has two bit errors, the parity check code cannot detect the error

Cyclic redundancy check code (CRC)

Cyclic redundancy check code is a widely used error detection algorithm

  • It is a method to generate fixed bit parity check codes based on the data transmitted or saved (fixed bits, which may be 1 bit or multi bit)
  • It can detect errors that may occur after data transmission or saving
  • Its process is similar to parity check code. It first computes and generates some numbers, which are appended to the data
  • When the receiving end receives the data, it will judge whether the received data has errors according to the number attached to the back

Before understanding the CRC algorithm, let’s first understand:Module “2” division

  • Module “2” division is binary division
  • It is similar to arithmetic division, but division is not borrowed and is actually XOR operation
To put it simply, XOR: 0 XOR 0 = 0; 0 XOR 1 = 1; 1 XOR 0 = 1; 1 XOR 1 = 1
In other words, if the two bits are not the same, the result of XOR is 1, and the opposite is 0

Let’s look at an example of module “2” division

Fundamentals of computer network (1)

After understanding module “2” division, you can understand the whole process of CRC. CRC has three main steps

  • Select a polynomial for verificationG(x)At the end of the datar0
  • The data after r zeros will be added, and theModule “2” divisionDivided by polynomialBit string
  • The remainder is filled in the position of R 0 in the original dataVerifiable bit string

It’s easy to look at the text description, which is a direct example

Use CRC to calculate the verifiable bit string of “101001”

The calculation is based on the three steps mentioned above to calculate CRC

(1) First, a polynomial g (x) is selected for verification, and R zeros are added to the end of the data

What is g (x)?

G (x) may be a polynomial below

Fundamentals of computer network (1)

Bit string is to extract the constant term of polynomial and get the bit string 1101. Adding r zeros to the tail of the data is actually adding the highest order zeros to the tail. Therefore, adding three zeros after “101001” will result in “101001”000

This g (x) polynomial is not a random search. We can find some common G (x) in Wikipedia

Fundamentals of computer network (1)

(2) Divide the data with R zeros by the bit string of polynomials by modulo “2”

Fundamentals of computer network (1)

Through the calculation above, the remainder is obtained“001”And then proceed to step three

(3) The remainder is filled in the position of R 0 of the original data to get a verifiable bit string

In other words, the original “101001” will be changed000”Fill in “101001001”The last one is the final verifiable bit string to be sent. The above process is completed at the sender. After the verifiable bit string is checked out by the sender, it can send the bit stream to the receiver. After receiving the bit stream, it can receive the bit stream. The process of verification is the same,The receiver divides the received data by the bit string of G (x), and judges whether there is an error according to the remainder. If there is no error, the remainder obtained should be 0. If it is not 0, it indicates that the data is in error during transmission

Fundamentals of computer network (1)

Above is the whole process of CRC algorithm

  • In fact, the error detection capability of CRC is related to the order r of the bit string (the more zeros are added to the bit string, the stronger the detection capability is. For example, if the order is 1, a parity check bit is added after the data transmission, which will degenerate into the parity check code described above)
  • The data link layer only detects the data and does not correct it (if the data link layer finds the wrong data, it will directly discard it)

MTU (maximum transmission unit)

MTU

Maximum transmission unit MTU(Maximum Transmission Unit)

The data frames in the data link layer are not infinite (therefore, MTU describes the largest data frame that can be transmitted)

Fundamentals of computer network (1)

Benefits of setting up MTU

If the data frame is too large or too small, the transmission efficiency will be affected (the MTU of the commonly used Ethernet is generally1500 bytes

In the previous understanding of the performance of the computer network, introducedtime delay

Total delay = transmission delay + propagation delay + queuing delay + processing delay

If the data frame is too large, the total delay will increase, which will lead to the sending end and the receiving end processing information for a long time

If it is too small, if it is too small, if one byte is sent each time, then 1500 bytes need to be sent 1500 times. Although the total delay of each data transmission is reduced, but the repetition of 1500 times will also affect the communication efficiency, so the data transmission efficiency will be affected if the data frame is too large or too small

Path MTU

Suppose computer a transmits data to computer B, which needs to go through several small networks. If computer a transmits data to computer B, who decides the MTU of the path? As shown in the figure below

Fundamentals of computer network (1)

The number between the computer and the small network and between the small network and the small network is MTU. Then the MTU of the whole path is affected by the smallest MTU, which is called MTUBuckets effect 。 So the MTU of the entire path is 1492

Detailed explanation of Ethernet protocol

The data encapsulation, transparent transmission, error detection and MTU in the data link layer are introduced. After understanding this, we can not know how the data link layer performs data transmission,Ethernet protocolIt is a very common protocol in data link layer. When learning the protocol of a specific layer, we hope to shield some details of other layers. For example, when we study the protocol of data link layer, we don’t need to pay attention to how the physical layer transmits the bit stream. We can even think that the bit stream is transmitted directly from the data link layer of one machine to the data link layer of another machine Understanding

Fundamentals of computer network (1)

Suppose there is one belowNetwork topologyThere are three computers a, B and C, which are connected through a router. Suppose a needs to send data to C. how does the data arrive at C? How does the router know to whom computer a’s data is to be sent? This is what we need to know in this part

Fundamentals of computer network (1)

This part mainly consists of two main contents

  • MAC address
  • Ethernet protocol

MAC address

  • MAC address (physical address, hardware address)
  • Each device has a unique MAC address (which can be interpreted as the ID card of the device)
  • MAC address total48Bit, usually withhexadecimalexpress
  • It can be done throughifconfig -a(Windows uses ipconfig / all) to view the addresses of all hardware devices on this computer

Fundamentals of computer network (1)

Ethernet protocol

  • Ethernet is a kind of widely usedLANtechnology
  • Ethernet is a protocol used in data link layer
  • This can be done using EthernetAdjacent equipmentData frame transmission of
Ethernet data format

Fundamentals of computer network (1)

It consists of five parts

  • Destination address, source address: the first two parts are the MAC address mentioned above, and the lower part of 6 indicates that it takes 6 bytes (48 bits)
  • typeThe type indicates which protocol the frame data isIf it is network layer data, its type is 0800; if frame data is ARP request or response data, its type is 0806; if it is RARP protocol data, its type is 8035
  • Frame data: is the specific data sent
  • CRCThis is what I mentioned earlierCyclic redundancy check code
MAC address table

The MAC address table is amappingThe MAC address will be mapped to the hardware interface. Understand the MAC address table, you can solve the problem mentioned at the beginning

Fundamentals of computer network (1)

When a wants to send a message to C, there is a MAC address table in router e, which records which interface each MAC address is mapped to. So the whole process of sending data from a to C is:

  • A sends data frame through network card
  • When the data frame arrives at the router, the router takes out the first 6 bytes (destination address)
  • The router matches the MAC address table to find the corresponding network interface
  • The router sends data frames through the interface to which the destination address matches

Fundamentals of computer network (1)

If the MAC address table does not know which hardware interface of C is, what should I do?

Fundamentals of computer network (1)

The process of this problem is:

  • Router e checks the MAC address table and finds that there is no information about MAC address C
  • E willradio broadcastPackets from a to interfaces other than a
  • E will receive a response from B and C,And record the MAC address

For complex network topology, data transmission across devices cannot be solved through MAC address table

Fundamentals of computer network (1)

Because only the data transmission before adjacent physical nodes can be carried out through MAC address table, if a wants to send data to C, it cannot be completed by relying on MAC address table (E can only know the addresses of a, D and F). solveData transmission across devicesYou need to learn more about the network layer

It is the core competitiveness of a technical person to look for invariance in the rapidly changing technology. Unity of knowledge and practice, combination of theory and Practice

Fundamentals of computer network (1)