Some basic concepts in the network

Important equipment for building a network

Hubs , switches (to build a LAN, you cannot build a network across LANs), routers (wifi is essentially a wireless router, and the essence of a router is to connect two LANs)

Some basic concepts of network communication

The IP address identifies the location of the network device

The port number identifies a specific application

protocol

Protocol is the concept of network communication. It has been agreed what format the data should be transmitted in. With this agreement, both parties can understand each other's meaning. For example, in our daily speech, "Mandarin", "Wuhu dialect", "Beijing dialect" words" also belong to the agreement.

Network communication is a relatively complicated matter. The requirement scenario is complicated, and the implementation function is relatively complicated. If the protocol is too complicated, the learning cost, use cost and maintenance cost are very high. Therefore, the actual method is: for this complex large protocol, split into several relatively simple small agreements.

As the protocol is divided into some small protocols, each protocol is responsible for a part of the function. At this time, the roles and functions of some protocols may be similar. For these small protocols, they are classified (layered). Network protocol is unfolded against a layered background

The benefits of protocol layering
Reduce the cost of learning and maintenance (encapsulation)
Flexible replacement for a certain layer of protocol

Protocol layered style
OSI seven-layer network model (actually not used, compared with the five-layer protocol, the application layer and transport layer have more presentation layers and session layers)
TCP/IP five-layer (four-layer) network model

Physical layer : It stipulates what kind of basic hardware equipment is used in network communication, such as network cables and network ports used for communication. The network cables and network ports are all of the same specification

Transport layer: only care about end-to-end transmission (start point to end point)

Network layer : mainly responsible for path planning, what kind of route is the most efficient for transmission.

Data link layer: mainly responsible for how to transmit between two adjacent nodes

Application layer : The application layer describes the data in the transport layer and how users want to use it

The basic flow of network data transmission (from the perspective of protocol layering) 

Take QQ as an example, A sends a hello to B

application layer

Sender: The user enters the string hello in the input box, and the qq application program forms a datagram with this string, assuming that the application layer protocol format of qq is (application layer data, each application program does not necessarily Same, there is a unified version, you can also define yourself): 
sender qq number; sending time; receiver qq number; message content

"Application layer datagram" is essentially a string that follows the agreed format. The program needs to call the API of the operating system and hand over the application layer datagram to the transport layer.

Transport layer (into the system kernel)

 In the transport layer, the above application layer data must be used to form the datagram of the transport layer. The
most well-known protocols used in the transport layer are UDP and TCP. If UDP is used here, a UDP datagram needs to be constructed (in the application layer Datagram based, plus a UDP header)

Network layer

The most well-known protocol at the network layer, the IP protocol, is based on the above datagrams and is packaged into an IP datagram

The basic five-tuple in a communication: source IP source port destination IP destination port protocol type

data link layer

The most well-known protocol at the data link layer is "Ethernet", based on the above datagrams packaged into an "Ethernet data frame"

physical layer

Convert the above binary data (a string of 0101) into electrical/optical signals, and then the data is actually sent out

The above process, from the application layer to the physical layer, layer by layer, from top to bottom , this process is called " encapsulation " (not object-oriented encapsulation)

receiver's job

physical layer

The network card receives the optical signal and the electrical signal. At the physical layer, the optical signal is converted into binary data, and the converted data is an Ethernet data frame

data link layer

Pass this data to the data link layer for analysis

Network layer

transport layer

 application layer

The above, from bottom to top, layer by layer analysis, this process is called "splitting".

In the entire network protocol, the protocol is divided into many layers. The upper layer protocol calls the lower layer protocol (the upper layer protocol passes the data to the lower layer for further encapsulation), and the lower layer protocol provides support for the upper layer protocol (the lower layer protocol parses the data and hands it to the upper layer).
Here There is a clear hierarchical relationship between several layers of protocols, and only two adjacent layers can interact (cannot interact across layers).

Guess you like

Origin blog.csdn.net/qq_62712350/article/details/130068923