An overview of the content of the article


Understand computer networks and their classification

What is a computer network

Computer networks consist mainly of interconnected general-purpose, programmable hardware through which different types of data can be transmitted and which can support a wide and growing range of applications

  • Computer networks are not just software concepts, but also hardware devices (network cards, network cables, routers).
  • Computer networks are not only information communication, but also can support a wide range of applications

Classification of computer networks

1, according to the scope of the role of the network, computer networks can be divided into

  • A wide area network (WAN)
  • Metropolitan area network (MAN)
  • A local area network (LAN)

2. Computer networks can be classified according to the users they serve

  • Public network (a network that can be joined by anyone who wants to pay or join)
  • Private network (a network set up by certain departments or individuals to meet specific business needs. The army, railways, banks, companies, they all have their own private networks.

A brief history of computer networking

The history of the Internet

There are three stages in the history of the Internet:


Stage 1: single network ARPANET

This stage is mainly some computers through the switch connection, this time the computer through the connection of the switch, you can directly complete the exchange of information, and the connection of the computer is not much

Stage two: Three-tier structure Internet

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


Stage 3: Multi-level ISP Internet

ISP (Internet Service Provider) : Internet Service Provider (China Telecom, China Unicom and China Mobile are all famous Internet Service providers in China)

At the top are the backbone ISPs, which include the three main Internet service providers mentioned above. Trunk ISPs in China can connect with trunk ISPs in the United States, Australia and Europe. For example, the mobile network is called China Mobile in China, Beijing Mobile in Beijing, and Shanghai Mobile in Shanghai. These are regional ISPs. Regional ISPs are mainly responsible for providing regional network services


Can see international Internet line through this website: https://live.infrapedia.com


A brief history of Internet development in China

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


With the development of the Internet in China, China has also established several public computer networks that can carry out international information exchange, among which five public computer networks are the largest

  • China Telecom Internet (CHINANET)
  • China Unicom Internet (UNINET)
  • China Mobile Internet (CMNET)
  • China Education and Research Computer Network (CERNET)
  • China Science and Technology Network (CSTNET)

Our outbound traffic is mainly through these five networks for overseas information access. 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
  • Ding Lei founded netease in 1997
  • Wang Zhidong founded Sina in 1998
  • Tencent was founded in 1998 by Ma Huateng and Zhang Zhidong
  • Jack Ma founded Alibaba in 1999
  • Robin Li founded Baidu in 2000

These deeds have also promoted the development of the Internet in China

The hierarchy of computer networks

Basic principles of hierarchy design

Before we look at the basic principles of computer hierarchical design, let’s first understand why computer networks need to use hierarchical design

Suppose you have two computers, A and B. They are connected through A computer network. Can you imagine what kind of problem the computer network solves here

  • Ensure smooth data paths
  • Identification object computer
  • Destination computer state
  • Whether the data is wrong

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

Let’s look at an example of one of the hierarchies we use on the web today


Basic principles of hierarchy design
  • The layers are independent of each other: a layer does not need to know how its upper and lower layers are implemented, it only needs to know how it provides services through interfaces. The coupling degree between layers is very low

  • Each layer has enough flexibility: Because computer networks are constantly evolving, each layer is designed with enough flexibility to accommodate future changes

  • Complete decoupling between layers: that is, the change of the upper and lower layers of a layer does not affect the stability of the current layer (although this is the principle of computer hierarchy design, in fact, if we design a relatively large system, we can use these principles for reference, which is the charm of the bottom layer of the computer).

OSI seven layer model

Computer networks have a seven-tier model, which is defined by international standards


The OSI seven-tier model was designed to be the standard that computers around the world would follow, and then encourage them to use it to easily connect and exchange data. In fact, the OSI had a hard time marketizing because the TCP/IP model was running successfully around the world when the OSI standard was developed. Therefore, the OSI seven-layer model has only obtained theoretical research results, but has not been successfully promoted in the market. As a result, OSI did not eventually become the widely used standard model

There are several reasons why OSI has not been accepted by the market
  • OSI experts lack practical experience (they design based on theory and lack experience in actual production environments). Unity of knowledge and action, theory must be combined with practice.
  • The development cycle of OSI standards is too long, and the equipment manufactured according to OSI standards cannot enter the market in time
  • The OSI model was not designed properly and some functions were repeated in multiple layers

TCP/IP four-tier model

The following is the mapping between OSI 7-layer model and TCP/IP 4-layer model:

Note: The right side shows some protocols used by each layer in the TCP/IP four-layer model

The practical application of TCP/IP four layer model

Suppose computers A and B are connected through A router. Computer A will communicate with the router through layer 4 of TCP/IP. Data from computer A will arrive at the router through the network interface layer and the network interface layer (in the router, only the network layer and the network interface layer can reach the router). The router will route and forward the data to Computer B, which will receive the data through four layers from the bottom up. This is an example of the TCP/IP layer 4 model in action


In addition, you can also use layering to understand the different layers


Network topology of the modern Internet

Understanding network topology can help us form an image of the computer network in our mind, which is helpful for us to learn further. The network topology of the modern Internet is divided into two parts

  1. edges
  2. The core part of the

edges

Is mainly refers to the normal users can direct contact with the part, such as at home, or at the mall the network used in the company, is part of the edge of the computer network (mobile phone, computer, intelligent home appliances in the home, the way through wired or wireless connection router, the router connected to a local gateway, then the gateway to connect to the region’s ISP)


Above is a network topology for a home network, below is a network topology for an enterprise


The core part of the

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


These backbone ISPs are connected to each other and to other backbone ISPs in other countries and regions through international routers, which are the core of the Internet. Among them, there are a lot of submarine cables, trans-regional cables and other communication equipment, which are mainly laid by China Unicom and China Telecom. Some of the equipment used by them is from China’s Huawei, so Huawei has a certain position in the communications field

The above is a simple legend of the core and edge parts of the network topology. If the core and edge parts are connected, the whole network topology is very complex


Although it is necessary to have a certain understanding of the network topology when learning the computer network, we will not be aware of the existence of these network topologies when we use the network at ordinary times. We don’t know where the backbone ISP is, where the regional ISP is, or even where the gateway is. We can only know which router we are in contact with more. This is mainly because we usually use the computer network from the perspective of a user. If we look at the Internet from the user’s point of view, there are more models, such as client-server (C/S) model

For client-server (C/S) mode, in the Internet, there are many devices connected through the Internet, but we don’t need to be aware of the details in the Internet. If we want to use a service and make a request directly from our OWN PC, the request will be routed to where the service is provided. When the server receives the request, it will respond and the local PC will receive the reply. This is client-server (C/S) mode. There is no need to be aware of the details of the network when the client seeks the service and when the server provides the service


Performance indicators of computer networks

Understanding the performance indicators of the network helps you evaluate or judge the quality or speed of the network. Before getting to know it, do a brief understanding of the commonly used units of measurement (rate).


Why is the test peak speed of 100M/s fiber only 12M/s?

First, because the common unit of network is Mbps100M/s = 100Mbps = 100Mbit/s
There is a base for converting bits to bytes, 8 bits equals 1 byte, so:100Mbit/s = (100/8)MB/s  = 12.5MB/s
Copy the code

Time delay

Time delay can be subdivided into

  • Send time delay
  • Queuing delay
  • Propagation delay
  • To deal with time delay
Send time delay

It is mainly the time that the local machine stays in the local machine when the network is sent

Transmission delay = Data length (bit)/Transmission rate (bit/s)
Data length: this is determined by the user. For example, if you want to download a 100M video, this 100M is the length of the dataSend rate: is determined by the network card (the better the performance of the network card, the faster the send rate)Copy the code
Propagation delay
Transmission delay = Transmission path length/Transmission rate (bit/s)Transmission path length: For example, when data is sent from Beijing to Shanghai, the path is relatively short. If Beijing were to send data to the United States, the data would have to travel through an undersea cable to reach the United States, a long routePropagation rate: This is limited by transmission media (e.g., copper wire, optical fiber)Copy the code
Queuing delay

The time a packet is waiting to be processed in a network device

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

To deal with time delay

The time it takes for a packet to reach the device or destination machine to be processed

If we get to a server that’s not performing well, maybe the packet gets to it, and it takes a while to process our packet

So evaluating the time index of the computer network, the total delay is

Total delay = transmission delay + propagation delay + queuing delay + processing delayCopy the code

To evaluate the time index of computer network, besides delay, there is another index: round trip time RRT

  • Route-Trip Time (RTT) is an important indicator to evaluate network quality
  • RTT indicates the round-trip time of data packets in end-to-end communication
  • You can run the ping command to view the RTT

Ping an IP address in Guangzhou (the right most column is the round trip time)


Ping an IP address from the United States

(Obviously this round trip time is quite long)

Physical Layer Overview

The role of the physical

In the OSI seven-tier model, the physical layer is at the bottom of the hierarchy. For the TCP/IP four-tier model, it belongs to the lowest network interface layer. What the physical layer does is

  • Connect different physical devices (such as routers to computers via network cables)
  • Transmit bitstream (bitstream is high and low level like 0 and 1, or digital signal)

Transmission medium

The media connecting different physical devices includes wired media and wireless media. Wired media includes

Twisted-pair cable

Coaxial cable

Optical fiber

Wireless media: infrared (remote control), wireless, laser

bitstream

High level represents 1, low level represents 0,For the high level and low level changes, a bit stream can be formed

Basic concepts of channel

  • A channel is a medium that transmits information in one direction
  • A communication circuit usually consists of a receiving channel and a transmitting channel
  • There are two channels because the direction of the message is different from the direction of the message

A communication line, both sending and receiving, what if it causes a conflict?


This problem, in fact, has been solved in the physical layer. According to the channel, the communication circuit can be divided into

  • Simplex communication channel
  • Half duplex communication channel
  • Full duplex communication channel
Simplex communication channel
  • Can only communicate in one direction, no feedback in the opposite direction of the channel
  • Cable television, radio, etc., are simplex communication channels, ie one party sends, the other party receives
Half duplex communication channel
  • Both parties can send and receive messages
  • Both parties cannot send or receive at the same time
Full duplex communication channel
  • Both parties can send and receive messages simultaneously
  • Network cables These are full-duplex communication channels

Divide – reuse technology

If two computers communicate, there will be a communication line between them. In this communication circuit, a sending channel and a receiving channel may be used. Consider a situation where there are a lot of computers, and they all need to be connected, and there are a lot of sending channels and receiving channels, and most of the time, they are not active. This leads to low channel utilization. Therefore, the technology of division – reuse is proposed to improve the utilization rate of channel

How does divide – use – multiplexing improve channel utilization?

Multiple computers connected to the multiplexer, the other side of the computer connected to the divider. Through the multiplexer and divider, the two devices can share a sending channel and a receiving channel, thus greatly improving the utilization of the channel

Note: If many computers send and receive information frequently over the channel, the channel will be congested

Overview of data link layer

For the physical layer, it is mainly to connect different devices and transmit bitstreams. The following is the introduction of the data link layer. First, the data link layer is located at the penultimate layer of the OSI seven-layer model, which is the upper layer of the physical layer, and the network interface layer of the TCP/IP four-layer model


The data link layer mainly solves the following three problems

  • Encapsulated into a frame
  • Transparent transmission
  • Error detection

Encapsulated into a frame

  • A frame is the basic unit of data link layer data (just as bits are units of physical layer data).
  • The sender adds a specific marker before and after a piece of data at the network layer to form a “frame”
  • The receiver identifies the “frame” according to the specific mark before and after it.

Below is a diagram to understand the process of framing

  • Some “IP datagrams” are first transmitted at the network layer to the data link layer,
  • When receiving the data, the data link layer regards it as the data of the data frame, and then adds special marks before and after the data to indicate that this 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

Data frames represent a stream of bits of zeros and ones at the physical level. The first and last frames mentioned above are specific control characters (specific bitstreams).

The bitstream at the beginning of the frame is: SOH: 00000001 (SOH is the control character)

The bit stream at the end of the frame is: EOT: 00000100


What if the frame data also happens to have the same bit stream at the beginning or end of the frame

This requires the transparent transport mentioned below

Transparent transmission

The above mentioned problem can be solved by transparent transmission. Before introducing transparent transport, take a look at what “transparent” is

“Transparency” is a very important term in computing

For example, when we design an API, we often say, if you design the API well enough, then the operation of the underlying API is transparent to the caller of the API. Another example is the data link layer and the physical layer. For the data link layer, the work of the physical layer is transparent, and the physical layer only needs to provide some API for the data link layer to use. To put it bluntly: an actual transaction that appears not to exist. Using the concept of transparency at the data link layer is to control characters in the frame data but treat them as if they are not present

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

Suppose there is a control character at the end of the frame in the frame data. If the data link layer does not use transparent transmission, then the receiver is likely to regard the control character at the end of the frame as the end of the data frame, thus identifying the wrong frame. Therefore, the data link layer performs special processing on the control characters in the frame data


This is done by adding an escape character to the control character, which is the escape character below ESC. 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, and if so, it will not treat the control character as a control character. What if an escape character also appears in the frame data? Escape the escaped characters again

In fact, in ordinary programming, “\” is generally regarded as an escape character. If you want to print “\ “, add an escape character to both backslashes to indicate that neither of them is an escape character.

Error detection

The physical layer simply transmits the stream of bits and has no control over whether something goes wrong (if something interferes with the stream, such as lightning). Will affect the transmission of bitstream, the physical layer is not aware of)

The data link layer is responsible for error detection

Error detection at the data link layer is incorrect

This part mainly introduces the third problem to be solved at the data link layer: error detection in detail, which mainly includes two parts:

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

Parity code is a very simple way to detect transmission errors in a bit stream. This method detects errors in the bit stream by adding a bit bit to the end of the bit stream. Suppose the test wants to transmit an 8-bit bit stream called “00110010”

  • We first add the “1” bit to the end of the bitstream
  • When the receiver receives the bitstream, it detects whether there is an error in the bitstream based on the added bit
  • The 1 is the sum of the preceding 8-bit bitstreams to get 3. Since 3 is odd, we add 1 to the end of the 8-bit bitstream to indicate that this is a parity bit

If we want to transmit the bitstream “00111010”, then the following bits should be “0”, because the sum of the eight bits is 4, which is an even number. Let’s take a look at how to use the parity check code to detect errors. Suppose you want to transmit the bit stream “00110010”, then you need to add the bit bit “1” at the end. If an error occurs during transmission and the receiver receives “00010010”, the receiver will use the parity check code for verification. The parity code calculated by the receiver is “0”, which is different from “1”, indicating that an error occurs during the transmission of the bit stream

As you are smart enough to see, there is a limitation here. Suppose you still want to transmit “00110010” and add “1” to the tail. Assume that 00000010 is received by the receiving end. After the calculation, the receiving end finds that the parity bit behind it is 1, but the last parity bit is 1. In this case, the receiving end considers that the data is ok, but in fact, the data is faulty. So when a two-digit error occurs in the bitstream, the parity code does not detect the error

Cyclic redundancy Check code (CRC)

Cyclic redundancy check code is a widely used error detection algorithm

  • It is a method of generating a fixed digit check code (fixed digit, may be 1 bit, may be multi-digit) based on transmitted or saved data
  • It can detect errors that may occur after data is transferred or saved
  • The process is similar to that of a parity check code, in that it first computes and generates a number that is appended to the data
  • When the receiving end receives the data, it will judge whether there is an error in the received data according to the numbers attached to the back

Before we look at the cyclic redundancy check code algorithm, let’s first understand: modular “2” division

  • Modular “2” division is division in binary
  • Similar to arithmetic division, but without borrowing, division is actually an xor operation
To put it simply: 0 xor 0 = 0; 0 xor 1 = 1; 1 xor 0 = 1; 1 xor 1 = 1That is, if two bits are different, the result of xor is 1, and the opposite is 0Copy the code

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


Once you understand modular “2” division, you can understand the whole process of CRC, which consists of three main steps

  • Select a polynomial G(x) for verification and add r zeros to the end of the data
  • To add r zeros to the data, divide by the polynomial bit string using modular “2” division
  • The remainder is filled with r zeros of the original data to get a checkable bit string

Reading text description is easy to make people a face meng force, the following direct example

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

The following is based on the three steps of CRC calculation mentioned above

(1) Firstly, select a polynomial G(x) for verification, and add R zeros to the tail of the data

What is G of x?

G of x could be a polynomial like this


Bit string is just extracting the constant terms of the polynomial, and you get bit string 1101. Adding r zeros to the tail of the data is essentially adding the highest order zeros to the tail. So add three zeros after “101001” to get “101001000”

This G(x) polynomial is not something you can just pick up, you can look it up on Wikipedia and you can find some common G(x) polynomials.


(2) Add r zeros after the data, divide by the polynomial bit string using modular “2” division


After the above calculation, the remainder is “001”, and then the third step

(3) Fill the remainder with r zeros of the original data to get a checkable bit string

That is, the original “101001000” is filled with “101001001”, the last is the final checkable bit string to be sent, the above process is completed at the sender, the sender through the checkable bit string, it can send the bit stream to the receiver. After receiving the bitstream, the receiver can perform verification. The verification process is the same. The receiving end divides the received data by the bit string of G(x) and determines whether there is any error according to the remainder. If there is no error, the remainder should be 0


This is the whole process of the cyclic redundancy check code (CRC) algorithm

  • In fact, the error detection capability of CRC is related to the order r of the bit string (the more 0s are added to the bit string, the stronger the detection capability will be. For example, if the order is 1, a check bit will be added after the transmitted data, which degenerates into the parity code introduced above).
  • The data link layer only detects data and does not correct it. (If the data link layer finds incorrect data, it directly discards it.)

Number Maximum transmission unit MTU

MTU

Maximum Transmission Unit (MTU)

Data link layer data frames are not infinite (hence MTU describes the maximum data frame that can be transmitted)


Benefits of setting MTU

Data frames that are too large or too small affect transmission efficiency (common Ethernet MTU is 1500 bytes)

In the previous understanding of computer network performance, the introduction of time delay

Total delay = transmission delay + propagation delay + queuing delay + processing delayCopy the code

If the data frame is too large, the total delay increases, which causes the sender and receiver to process the information too long

If the data frame is too small, it does not work either. Assuming that 1 byte is sent each time, 1500 bytes need to be sent 1500 times. Although the total delay of each data is reduced, the repetition of 1500 times will also affect the communication efficiency

The path MTU

Suppose computer A transmits data to computer B through multiple small networks. If computer A is sending data to computer B, who determines the MTU of the path? The following figure


The number between a computer and a small network and between a small network and a small network is MTU. Then, the MTU of the entire path is affected by the minimum MTU, which is called the bucket effect. So the MTU of the entire path is 1492

Ethernet protocol details

Frame encapsulation, transparent transmission, error detection, and MTU in the data link layer are described above. The Ethernet protocol is one of the most commonly used protocols in the data link layer. In learning a specific level of agreement, we are hoping to block other layer of some of the details, such as when we are learning the data link layer protocol, there is no need to focus on how the physical bitstream transmission, we can even think bitstream is directly by the data link layer of a machine transfer to another machine data link layer, so as to simplify the understanding


Suppose we have A network topology with three computers A, B and C, which are connected by A router. Suppose A needs to send data to C, how does the data get to C? How does the router know to whom computer A’s data is being sent? That’s what this section is about


This part mainly consists of two main contents

  • The MAC address
  • Ethernet protocol

The MAC address

  • MAC address (physical address, hardware address)
  • Each device has a unique MAC address.
  • A MAC address contains 48 digits and is usually expressed in hexadecimal notation
  • You can run ifconfig -a (Windows uses ipconfig /all) to view the addresses of all hardware devices on the local PC

Ethernet protocol

  • Ethernet is a widely used local area network technology
  • Ethernet is a protocol used at the data link layer
  • Ethernet can be used to transfer data frames between neighboring devices
Ethernet data format

It is mainly composed of five parts:

  • Destination address, source address: The first two parts are the MAC addresses mentioned in the preceding part. The bottom 6 indicates that the MAC address occupies 6 bytes (48 bits).
  • Type: The type indicates which protocol the frame data belongs to. In the case of network layer data, the type is 0800. If the frame data is ARP request or reply data, the type is 0806. If it is RARP data, the type is 8035
  • Frame data: is the specific data sent
  • CRC: This is the cyclic redundancy check code introduced earlier
The MAC address table

A MAC address table is a mapping that maps MAC addresses to hardware interfaces. Now that you know the MAC address table, you can solve the problem mentioned earlier


When ROUTER A wants to send A message to router C, router E has A MAC address table that records the interface to which each MAC address is mapped. So the whole process of A sending data to C is:

  • A Sends data frames through the network adapter
  • The data frame arrives at the router and the router retrieves the first 6 bytes (destination address)
  • The router matches the MAC address table and finds the corresponding network interface
  • The router sends the data frame through the interface that matches the destination address

What if the MAC address table does not know which hardware interface of C is?


The process of this question is:

  • Router E checks the MAC address table and finds no information about MAC address C
  • E broadcasts A’s packets to interfaces other than A
  • User E receives the response from user B and user C and records the MAC address

For a complex network topology, the MAC address table cannot be used to transfer data across devices


The MAC address table can only be used to transmit data before adjacent physical nodes. Therefore, if A wants to send data to C, the MAC address table cannot be used (E can only know the addresses of A, D, and F). Addressing data transfer across devices requires learning more about the network layer

It is the core competitiveness of a technician to seek invariance in the rapidly changing technology. Unity of knowledge and practice, theory and practice