Network - First introduction to the network

Network basics

Itaru Mori

The background of computer network

Independent mode: computers are independent of each other

image-20230803232559586

Early computers were independent of each other. Each computer carries customer data, so the following disadvantages will occur:

  • Data transfer between computers is expensive. When the data processed by computer A needs to be processed on computer B or C, the data of computer A needs to be copied to the hardware that can carry the data, and then the data is copied to computer B through the hardware before the data can be processed.
  • In order to improve efficiency, early business will be divided into different computers. Since the computers are independent of each other, it may happen that Xiao Ming completed business one on computer A and needs to use computer B to complete business two. At this time, he wants to Xiao Li, who uses computer B, needs to wait until Xiao Ming finishes using computer B before he can use it.

Network interconnection: multiple computers are connected together to complete data sharing

image-20230804104042476

  • Everyone uses their own computer, but they can switch freely between businesses at any time, and shared data is centrally managed by the server.

image-20230804110343822

  • With the advancement of the times, the number of computers is increasing, and they can be connected together through switches and routers to form a local area network (LAN).

image-20230804111331445

  • With economic globalization, the scope of computer networks has expanded to the world, forming wide area networks. In fact, WAN and LAN are relative concepts. WAN can be regarded as a relatively large LAN.

Understand network protocols

  • An agreement is an agreement
  • The transmission media between computers are optical signals and electrical signals. Information such as 0 and 1 is represented by "frequency" and "strength". In order to transmit various different information, the data format of both parties needs to be agreed upon. i.e. abide by the same agreement

  • Adhering to the same agreement reduces communication costs.

  • There are various computer manufacturers, operating systems, and hardware devices, so there are also many types of computers. At this time, it is necessary to agree on a common standard, and everyone must abide by this agreement and successfully complete network communication at the computer level.

Here is an example: Chinese is spoken in China, English is spoken in the United States, and Japanese is spoken in Japan. When Chinese people communicate with Americans or Japanese, they cannot use only one language. Maybe Chinese people communicate with Americans in English, and Chinese people use English to communicate with Americans. People use Chinese to communicate with Japanese people. But if everyone jointly abides by an "agreement" and the whole world can communicate in Chinese, then the communication cost will be reduced in the above situation.

A first introduction to network protocols

Protocol layering

  • The purpose of designing the network protocol stack into a layered structure is to decouple the layers.
  • Divide modules with concentrated functions and high coupling into one layer to enhance their maintainability and scalability.

OSI seven-layer model

  • The OSI (Open System Interconnection) seven-layer network model is called the Open System Interconnection Reference Model, which is a logical definition and specification;
  • The network is logically divided into 7 layers. Each layer has related and corresponding physical devices, such as routers and switches;
  • 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, reliable communication can be achieved between different systems and different networks;
Number of layers Layer name Function Overview of functions of each layer
7 Application layer Application-specific protocols
6 presentation layer Conversion between device inherent data format and network standard data format image-20230804155607791
5 session layer Communication management. Responsible for establishing and breaking communication connections (logical paths for data flow). Manages the layers below the transport layer. image-20230804160055733
4 transport layer Manages data transfer between two nodes. Responsible for reliable transmission (ensuring that data is transmitted reliably image-20230804160221933
3 Network layer Address management and routing image-20230804160513114
2 data link layer Transport and identify data frames between interconnected devices image-20230804160550943
1 physical layer "0" and "1" represent the voltage level, the flashing of the light, and the specifications of the connector and network cable. image-20230804160717343
  • In fact, the OSI seven-layer model is complex and impractical, so we learn through the TCP/IP four-layer model.

TCP/IP four-layer model

  • TCP/IP is synonymous with a group of protocols, which also includes many protocols that form the TCP/IP protocol cluster.
  • The TCP/IP communication protocol adopts a 5-layer hierarchical structure. Each layer calls the network provided by the next layer to complete its own needs.
  • Physical layer : Responsible for the transmission method of optical/electrical signals. For example, the common network cable (twisted pair) of Ethernet, the coaxial cable used by early Ethernet (now mainly used for cable TV), optical fiber, and current wifi wireless The network uses electromagnetic waves, etc., which all belong to the concept of the physical layer. The capabilities of the physical layer determine the maximum transmission rate, transmission distance, anti-interference, etc. The hub (Hub) works at the physical layer
  • 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 is detected from the network line is counted as the start of a new frame), conflict detection (if a conflict is detected Automatic retransmission), data error checking, etc. There are standards such as Ethernet, Token Ring, and Wireless LAN. The switch (Switch) works at the data link layer.
  • Network layer : Responsible for address management and routing. For example, in the IP protocol, a host is identified by its IP address, and the data transmission line (routing) between two hosts is planned through the routing table. Router ( Router) works at the network layer
  • Transport layer : Responsible for data transmission between two hosts. Such as Transmission Control Protocol (TCP), which can ensure that data is sent reliably from the source host to the target host.
  • 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 mainly for the application layer

image-20230804161310874

  • For the physical layer, we think less, so it can often be called the TCP/IP four-layer model.

  • As you can see from the above figure, the OSI seven-layer model also corresponds to the TCP/IP five-layer model. The application layer, presentation layer, and session layer of OSI correspond to the application layer. Most of the protocols of the application layer model are targeted at applications.

  • Most of the protocols at the transport layer and network layer are targeted at the operating system. The protocols at these two layers require all types of OS to comply, so the protocols are implemented internally by the OS. Then there will be a large number of system calls between the transport layer, network layer and application layer.

  • Devices with upper-layer protocols must also have lower-layer protocols

Therefore, the following conclusions can be drawn:

  • For a host, its operating system kernel implements content from the transport layer to the physical layer
  • For a router, it implements from network layer to physical layer
  • For a switch, it implements from the data link layer to the physical layer
  • For hubs, it only implements the physical layer
  • In fact, it is not absolute. There are still many switches that also implement network layer forwarding;. Many routers also implement part of the transport layer (such as port forwarding)

Basic process of network transmission

protocol header

  • Protocols exist at each layer, and each protocol has its own protocol header
  • Protocols are usually expressed through protocol headers
  • When each piece of data passes through different protocol layers, the header of the corresponding layer needs to be added.
  • The protocol header is used to identify the same protocol layer of different hosts and is used for identification to facilitate unpacking and separation.
  • Message = header + payload
  • Encapsulation: The process of adding the current layer header to the payload
  • Unpacking: The process of separating headers from payload
  • Decommissioning: The process of handing the payload to a specified protocol for unpacking

Here I will introduce the network communication process between two hosts on the same network segment.

image-20230804172238548

  • A piece of data is entered by a user from one host and then transmitted to another host through the network. The data passes through the application layer, transport layer, network layer, link layer, etc. in sequence. And the data needs to go through the process of encapsulation, unpacking and distribution.

  • Data is entered into the application layer from the upper layer, and the data needs to be added with the header corresponding to the application layer. form a message. At this point the data is the payload

  • Send the message to the transport layer. At this time, the payload = data + application layer header, and the message at this layer = transport layer header + payload.

  • Transmit data from one host to another host via Ethernet. Since the transmitted data contains headers of different protocol layers, the data needs to be unpacked and separated for use at this time.

in conclusion

  • The protocols at each layer must have corresponding headers, and which protocol needs to be handed over to the upper layer based on its current payload is a problem that each layer needs to face.

  • The lower layer packet must have the upper layer protocol header

  • File transfer data from hosts across network segments must pass through one or more routers from one computer to another.

  • Different protocol layers have different names for data packets. In the transport layer, it is called a segment, in the network layer, it is called a datagram, and in the link layer, it is called a frame.

  • When application layer data is sent to the network through the protocol stack, each layer of protocol must add a data header (header), called encapsulation (Encapsulation)

  • The header information contains information such as how long the header is, how long the payload is, what the upper layer protocol is, etc.

  • The data is encapsulated into frames and sent to the transmission medium. After reaching the destination host, each layer of protocol strips off the corresponding header, and hands the data to the corresponding upper layer protocol for processing based on the "upper layer protocol field" in the header.

##Address management in the network

Know IP addresses

  • IP address is the address used to identify different hosts in the network in the IP protocol;
  • IP addresses include IP4 and IP6. For IPv4, the IP address is a 4-byte, 32-bit integer
  • We usually also use "dotted decimal" strings to represent IP addresses, such as 192.168.0.1; each number separated by dots represents a byte, and the range is 0 - 255;
  • The packet contains source IP and destination IP

Know the MAC address

  • MAC addresses are used to identify connected nodes in the data link layer
  • The length is 48 bits and 6 bytes. It is generally represented by a hexadecimal number plus a colon (for example: 08:00:27:03:fb:19)
  • The network card is determined when it leaves the factory and cannot be modified. The mac address is usually unique (the mac address in the virtual machine is not the real mac address and may conflict; some network cards also support user configuration of the mac address)
ifconfig checks host address

Represented by hexadecimal numbers plus colon (for example: 08:00:27:03:fb:19)

  • The network card is determined when it leaves the factory and cannot be modified. The mac address is usually unique (the mac address in the virtual machine is not the real mac address and may conflict; some network cards also support user configuration of the mac address)
ifconfig checks host address

image-20230804185556918

Guess you like

Origin blog.csdn.net/m0_71841506/article/details/132110902