Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Operating system network _ _ network foundation

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

OSI seven-layer model

OSI: open system interconnection model, is a relatively complete network architecture.

There are seven layers from bottom to top, which are physical layer, data link layer, network layer, transport layer, session layer, presentation layer and application layer. Among them, the first four layers are related to the operating system level related to data transmission services, and the latter three layers are used to provide services to users.

Physical layer: the lowest layer of the physical layer, belonging to the hardware level, is mainly designed to the transmission of electrical signals, physical interfaces, electrical characteristics and so on.

Data link layer: the data link layer is mainly responsible for adding information such as MAC [1] packet header to the data packet in the process of data transmission; at the same time, the data link layer also has the function of error detection and correction (carrier sensing multiple access). Once the data transmission error, you can ask to retransmit the packet to correct the data.

Network layer: the network layer is responsible for adding IP [2] packet headers to the data packet, and the IP of sending and receiving needs to be added, which is used to select the path, that is, the path of data transmission. Because the data may be sent across multiple network segments, through the transit of multiple routers.

Transport layer: what the transport layer needs to do is to determine the reliability of the transport protocol. The common transport protocols are TCP and UDP [3]. At the same time, determine the port number. Each transport protocol has its own specific port number. There are 65525 ports under Linux.

Session layer: determine whether network services pass through the session layer

Presentation layer: data is digitized and transformed into information that can be used by the computer, and functions such as encryption and compression are realized at the same time.

Application layer: provide user interface

[1]: the MAC address is used to determine a host in the local area network. The communication between the local area networks is realized by the switch, and the switch can only identify the MAC address.

[2]: the IP address is the unique identification of the host on the network, and the communication on the network is realized by the router through the judgment of IP.

[3]: both TCP (Transmission Control Protocol) and UDP (user Datagram Protocol) belong to the transport protocol. The transmission speed of UDP is faster, but it is not connection-oriented, nor does it guarantee reliability, which can lead to data loss. Applications using UDP protocol need to complete the process of packet loss retransmission and message sorting; TCP is a connection-oriented and reliable protocol, and the transmission is more secure and reliable. This is like sending a message on QQ, usually using the UDP protocol, because it does not care whether it is sent successfully, does not detect, and fails to send information after no network, while like a large online game, the data is transmitted using the TCP protocol!

Although the OSI model is quite perfect, because the implementation of the OSI protocol is too complex, the efficiency is very low, and the tomographic division is not reasonable, and some functions appear repeatedly in many levels, the OSI model is only a theoretical model in the end, and has not been put into practice. Of course, there are other business management reasons.

At the same time, with the coverage of the Internet all over the world, TCP/IP protocol has gradually become a practical international standard. TCP/IP protocol is a four-layer model, but there is also a five-layer model, which includes the physical layer into this model. Here we are based on the discussion of the protocol stack, which is not related to hardware, so the four-layer model prevails here. (we can simply think of the protocol stack here as a pure software concept, which only involves logic and data.)

TCP/IP four-layer model

The corresponding relationship between OSI model and TCP/IP four-layer model is as above. Each layer calls the network provided by its lower layer to complete its own needs, and the functions of each layer are as follows:

Application layer: the application layer is user-oriented and belongs to the layer of communication between applications, which requires that data communication must conform to some logic. Common services or protocols include http and https, talnet, DNS, SMTP, FTP, proxy server, etc.

Transport layer: the function of the transport layer is basically the same as that of the corresponding transport layer in the OSI model, which is used to ensure the data transmission mode, TCP or UDP, and to determine that the data has been delivered and received, ensuring the sequential transmission of data packets and the integrity of the data.

Internet layer: provides basic data packets, encapsulates headers, and enables packets to be sent to the target host (across network segments, but not guaranteed to be received correctly). There are three important protocols: IP, IGMP, ICMP [1]

Network interface layer / link layer: the network interface layer actually sends data, and encapsulates the MAC address packet header for the data. This layer manages the actual network media and solves the data transmission between Lans. (in fact, TCP/IP does not define the protocol of this layer, and each network participating in the interconnection uses its own physical layer and data link layer protocols, and then connects to the network interface layer of TCP/IP)

The address resolution protocol ARP works at this layer.

[1]: IGMP-- > Internet Group Management Protocol; ICMP-- > Internet Control message Protocol; IP-- > Internet Protocol

ICMP: usually the ping command we use sends a packet to an IP address and determines whether the local IP is connected to the IP by receiving a response.

Local area network

All hosts in the local area network share the same main line, and all the information is sent to the line, which can be received by all hosts. When the host analyzes that the packet is not for itself, it is directly discarded, and the discarding process is not visible to the upper layer.

Local area network can be divided into Ethernet and token ring network.

Ethernet: all hosts can send data to the shared line; data conflicts are scheduled by algorithms.

Token Ring Network: whoever has a token can send data online, similar to a lock in thread communication.

Each local area network can be called a collision domain, the switch can divide the local area network into n, each small local area network can still communicate, but can reduce the collision.

The communication between the two Lans is realized through the router.

TCP/IP Protocol Stack and packet Encapsulation

1. Communication within the local area network

The TCP/IP protocol stack is divided into four parts: application layer, transport layer, Internet layer and link layer.

Each layer has its own agreement, as mentioned above. Taking FTP file transfer protocol as an example, this paper analyzes the communication process based on TCP/IP protocol in LAN.

The process of sending data:

For the four-tier model, the mechanisms below the transport layer are provided by the kernel, and the application layer is provided by the user process. Because the communication between the two hosts must rely on the lowest bit flow, the information in the application layer needs to be transferred from the top layer to the lowest layer. During this period, each protocol encapsulates the information process to be sent in the application layer (adding its own packet header in front of the data).

Any layer thinks that the content given to us by the upper layer is data, and we call all the data given to us by the previous layer as the payload of that layer.

The Appl header is related to the user data type, and Appl is the FTP header if the user is using the FTP file transfer protocol.

Different protocol layers have different terms for packets.

At the transport layer, it's called segment.

At the network layer it is called Datagram (datagram)

At the link layer / network interface layer, it is called frame.

When the data is encapsulated into a frame, it is sent to the transmission medium, and the data transmission process ends; after arriving at the destination host, each layer protocol strips the corresponding header, and finally the application layer user data is handed over to the application program for processing. this process is called data reception.

The process of receiving data:

The sending process of the data is encapsulated from top to bottom, so when the application determines to send the data, the encapsulation process is unique, and the protocol used is also determined.

In the process of data receiving, from the bottom up, it may be an one-to-many relationship, because when the lower layer obtains the data, it does not know which protocol should be handed over to the upper layer to unpack, so after the lower layer unpacks, when transmitting the payload upwards, the protocol corresponding to the payload must be judged.

When the data is received by the network interface layer, the payload of the data frame is determined according to the "upper layer protocol" field in the header of the Ethernet frame, and then handed over to the corresponding protocol to process. This is the case with the subsequent unpacking process, in other words, the Ethernet frame header and the IP header all contain the "upper layer protocol" field. When the packet is unpacked to the TCP header, the process to which the data should be given is determined according to the "port number" field of the header of the TCP packet, that is, each protocol in the user layer corresponds to a port number, which is the address that identifies different processes on the same host.

Note:

1. The same protocol layer thinks that it communicates directly with each other, and the upper layer does not know what the lower layer has done.

2. The application layer belongs to the user layer, which is provided by the user; the lower three layers belong to the Kernel layer, namely the kernel layer. The interface between the lower three layers belongs to the system call. The lower three layers are the real processes used to handle communication.

2. Communication between different network segments

For completeness, let's take the FTP file transfer protocol as an example, where the cross-segment is between Ethernet and token Ring.

The first thing we need to know is that if you need to communicate across network segments, you need a router to do so. There is not much difference between Ethernet and token Ring except for the mechanism to prevent conflicts when sending messages to the shared line.

Link layer:

The link layer has standards such as Ethernet and token Ring. The switch is a device working in the link layer, which can forward data frames between different link layer networks, but the frame format is different under different standards, so the switch has to remove the incoming packet from the link layer and re-encapsulate the new link layer before sending it out.

The main tasks of the link layer: responsible for the drive of the network card device, frame synchronization (which signal is detected on the network line as the start of the new frame), collision detection (if a conflict is detected, the data is automatically retransmitted), data error check

Network layer:

The IP protocol of the network layer is the basis of Internet. There are a large number of routers on Internet, which are responsible for choosing the appropriate path to forward packets according to the IP address. A router has the function of a switch. The packet headers at the link layer and network layer need to be removed and re-encapsulated.

IP protocol does not guarantee the reliability of transmission, data packets may be lost in the process of transmission, and reliability can be supported in upper layer protocols or applications. (transport layer TCP, or application) reliability is integrated, safe arrival, sequential arrival, complete arrival, non-repeatable.

IP: able to provide host-to-host services, provide software-level virtualization, from the user's point of view, still feel that they are communicating directly with the same layer. Similar virtualization features include (virtual memory, all files under Linux) IP can route traffic across network segments. For users, the underlying network differences are not felt.

The network layer is responsible for point-to-point communication, that is, communication between the host and the router, the router and the router, while the upward transport layer is responsible for end-to-end communication, that is, the communication between the host and the host. The transport layer can achieve the reliability of the IP layer transmission through the TCP protocol. If UDP is used in the transport layer, the application needs to complete the packet loss retransmission, message sorting and other work.

-muhuizz finishing

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report