hierarchical structure of computer network

Table of contents

1. Why stratification

2. OSI seven-layer reference model

3. TCP/IP reference model

4. Five-layer reference model

1. Application layer

2. Transport layer

3. Network layer

4. Data link layer

5. Physical layer

5. Common protocols at each layer

6. Processing of data packets at each layer

1. Why split data?

1. Who is segmenting the data?

2. Why does the data link layer need to limit the data size?

3. Benefits of splitting large data packets into small data packets

4. How big should the data package be?

2. Encapsulation of data packets at each layer


1. Why stratification

In the early days of the computer network, two computers were connected using network cables, and data could be exchanged in a specified way. Obviously, there was no need to think too much about layering at this time.

With the development of the network, simply put, there are these problems:

  • I am a developer of network applications. How can I use network interaction data conveniently?

  • If different processes on a computer all have network requirements, how do they know which data is for them, and how can they achieve mutual communication between processes on the network?

  • How do two computers identify each other, how do they know each other's address, how do one computer route to the remote computer through the target IP address, and find an optimal path to transmit data?

  • What material should be selected as the physical transmission medium for network data and what physical interface should be used?

It is not difficult to solve these problems. You only need to specify a network protocol. Certain digits are specific data, certain digits are used for error detection in physical transmission, and certain digits are IP addresses and port numbers.

But after this solution, there are two problems:

  • All these functions of the network are coupled in a protocol. This protocol is too large and has little room for modification. Fields can only be added continuously as the network develops until it is completely unusable.
  • Developers need to face such complex network data and manually handle details from physical transmission error detection to data packet merging for the same communication. Development efficiency is very low.

So a more reasonable way is to standardize a set of network hierarchical structures:

  • Communication on the network can basically be split into these steps from top to bottom:

    The network application provides data, sends data to the target process of the target host, the data passes through routers and switches in the network, the data interacts with the computer through the network card, and the data is transmitted on physical media

  • Because from bottom to top, they are oriented to the physical media, two adjacent network devices, host to host (source IP to destination IP), and source process to target process.

  • In this way, network devices that serve different functions are divided into different levels. What each level does is specified, and the rest can be implemented by the device itself.

    Therefore, network layering also shields the heterogeneous differences of network devices.

2. OSI seven-layer reference model

  • Application layer: Responsible for providing a unified interface for applications to use the network
  • Presentation layer: Responsible for converting network data into a format compatible with other systems.
  • Session layer: Responsible for establishing, managing and interrupting communication sessions between presentation layer entities
  • Transport layer: Responsible for end-to-end data transmission (between host processes)
  • Network layer: responsible for data routing, forwarding, and fragmentation
  • Data link layer: Responsible for data encapsulation and framing, error detection, and MAC addressing
  • Physical layer: Responsible for transmitting bit stream data frames in the physical medium

It is just a layering of theoretical concepts and no specific solutions are given.

3. TCP/IP reference model

4. Five-layer reference model

Combining the advantages of OSI and TCP/IP, a five-layer model is proposed. This is the most widely used reference model.

From top to bottom, the goal of communication becomes clearer and clearer. From the bottom up, the goals of communication become more and more general.

1. Application layer

Application layer tasks:

  • Transfer network application data between different hosts on the network
  • You only need to provide data that conforms to the application layer agreement between both parties.

应用层工作在操作系统的用户态,而传输层及以下则工作在内核态,中间借助Socket来交接数据

2. Transport layer

Transport layer tasks:

  • 在网络上两台主机的进程间提供数据传输服务
  • Identification using source port number and destination port number

3. Network layer

Network layer tasks:

  • Select appropriate inter-network routing and switching nodes on the network to specify the path for the data link layer
  • Identification using source IP and destination IP

网络层本身没有传输数据包的能力,它只是给每台网络设备额外分配了一个可修改的、逻辑上的地址,用于找到不同的子网,借助数据链路层来实现数据包传输

Addressing and routing

The network layer is responsible for transmitting data between two network devices. How to find the target device? Use IP address.

It is obviously unrealistic to traverse all network devices in the world to match IP addresses, so the IP address is divided into two parts, similar to an index:

  • Network number, responsible for indicating which subnet the IP belongs to
  • Host number, responsible for representing different hosts under the same subnet

4. Data link layer

Tasks of the data link layer:

  • Within a network, forward data packets to the destination MAC address. Identification with the help of source MAC address and destination MAC address
  • Responsible for error detection of physical transmission

How to get the MAC address

When transmitting data across networks, a device is required to be between multiple networks at the same time, usually a router.

Then the router needs to know every device in the network, otherwise it will not be able to locate the network device through the IP address.

Every network device has a network card, and the network card has a unique MAC address.

The router learns the next destination IP address through the routing table, and then finds the destination MAC address through the "ARP protocol" to map it to the unique device.

How the data link layer transmits data

When data is transmitted between two adjacent nodes, the data link layer assembles the "IP datagrams" of the network layer into "frames" and transmits the frames on the link between two adjacent nodes.

5. Physical layer

Physical layer tasks:

  • Achieve transparent transmission of bit streams between adjacent nodes and shield specific transmission media and transmission methods

However, the physical layer has no way to give meaning to the bit stream, and there is no network protocol. There are only some transmission protocols between physical media.

5. Common protocols at each layer

  • Application layer: HTTP, DNS, FTP
  • Transport layer: TCP, UDP
  • Network layer: IP, RIP, ICMP, DHCP
  • Data link layer: ARP, RARP
  • physical layer

6. Processing of data packets at each layer

1. Why split data?

1. Who is segmenting the data?

Essential reasons:

  • The data is actually transmitted through the physical medium. The physical medium itself only transmits the data but does not process the data.
  • The data link layer hands the data to the physical layer for transmission, so it is the data link layer that specifies the size of the data packet.
  • Since the network layer uses the data link layer to transmit data, the network layer fragments the data to ensure that it meets the size requirements of the data link layer.

2. Why does the data link layer need to limit the data size?

If a large data packet is thrown directly into the network for transmission, there are these problems:

  • The data packet is very large and will occupy the network device resources of the source host for a long time.在发送它的期间,别的网络应用完全不能发送数据

    Because if the data of this packet is contaminated, the receiver cannot parse it normally.

  • Since the network has bandwidth limitations, it takes a long time to fully transfer to the target host.

    During this period, the router needs to receive it completely to verify it and then forward it.

    This means 大数据包不仅会造成网络严重拥堵,还会占用路由器的缓存资源that if the router cache is not enough, large packets cannot be fully received and cannot reach the target host.

  • This quick and easy approach will额外加大传输延迟在整个通信延迟中的比重

3. Benefits of splitting large data packets into small data packets

  • Small data packets can be sent continuously, which is equivalent to a pipeline mechanism, making good use of the resources of network equipment along the way and reducing the proportion of transmission delay in the entire communication delay.
  • Splitting the data inevitably requires numbering each small data packet, which allows the interspersed sending of multiple data packets that are not in communication, and has the ability to multiplex concurrent communication.
  • This can be done after the data packets are numbered. If an error or loss occurs in a certain packet, only the problematic data packet can be retransmitted instead of the entire large data packet, thus saving network resources.

4. How big should the data package be?

  • If the packet is too large, it has been discussed
  • If the data packet is too small, since the data packet must have header information, the data part will be too small, which will cause the actual data to account for a small proportion of the length of the entire data packet, reducing network utilization.

To make a compromise, the actual data part of an Ethernet frame is a maximum of 1500 and a minimum of 64.

The size of a standard Ethernet frame is 1518, of which 18 bytes are used for the frame header and frame trailer, and the remaining 1500 bytes are used to store the actual data.

2. Encapsulation of data packets at each layer

  • Application layer: The original data is encapsulated into the protocol and becomes an application layer message. At this time, the data packet is called a message.
  • Transport layer: Add a transport layer header to the application layer message, including the source port number, destination port number, and protocol field. At this time, the data packet is called a segment.
  • Network layer: Segment the data packet and add a network layer header to each piece, including source IP, destination IP, and protocol field. At this time, the data packet is called a packet.
  • Data link layer: Add frame header and frame tail to the data packet, including source MAC address, destination MAC address, and check sequence. At this time, the data packet is called a frame.

 

 

 

Guess you like

Origin blog.csdn.net/m0_62609939/article/details/131787738