A method and apparatus for packet ordering
By dynamically allocating sorting channels and determining whether data packets need to be sorted based on data stream identifiers and sequence indices, the problem of resource waste in existing technologies is solved, achieving efficient utilization of sorting resources and reducing equipment costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2021-01-08
- Publication Date
- 2026-08-04
AI Technical Summary
In data center networks, existing technologies that configure sorting channels for each data stream lead to resource waste and increased equipment costs, especially when there are a large number of data streams that need to be sorted, making it impossible to effectively share sorting resources.
By dynamically allocating sorting channels, determining whether data packets need to be sorted based on data stream identifiers and sequence indices, sharing sorting resources, and releasing unused channels, resource utilization can be improved.
This reduces the demand for sorting resources, improves the utilization rate of sorting resources, and reduces equipment costs.
Smart Images

Figure CN116686270B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a data packet sorting method and apparatus. Background Technology
[0002] As the bandwidth and scale of data center networks continue to expand, the number of data streams within the network is increasing. To improve the performance of data center networks, source servers typically distribute multiple data packets from the same data stream across multiple switching paths using load balancing to mitigate sudden congestion on the switches. However, because the forwarding delays of these multiple switching paths are not entirely the same, the order in which these multiple data packets arrive at the destination server is inconsistent with the order in which they were sent from the source server.
[0003] To address the aforementioned issues, existing technologies provide a packet sorting mechanism. Specifically, a sorting channel is statically configured for each data stream in the destination server. The destination server stores data packets received from the same data stream in the corresponding sorting channel and sorts the data packets of that data stream based on that sorting channel. However, this method is only suitable for networks with a small number of data streams requiring sorting. For networks with a large number of data streams requiring sorting, configuring a sorting channel for each data stream would require a significant amount of sorting resources, thus greatly increasing equipment costs. Summary of the Invention
[0004] This application provides a data packet sorting method and apparatus, which can realize the sharing of sorting resources by different data streams, thereby improving the utilization rate of sorting resources and reducing equipment costs.
[0005] To achieve the above objectives, this application adopts the following technical solution:
[0006] Firstly, a data packet sorting method is provided, applied to a network interface card (NIC) including at least one sorting channel. The method includes: receiving a first data packet and obtaining a first data stream identifier and a first sequence index from the first data packet. The first data stream identifier identifies a first data stream, the first data packet is a data packet of the first data stream, and the first sequence index indicates the sending order of the first data packet in the first data stream, i.e., the order of the first data packet in the first data stream when the source server sends the first data stream; when it is determined, based on the first data stream identifier and the first sequence index, that is, when there is no corresponding sorting channel for the first data stream identifier, allocating a first sorting channel for the first data stream identifier from at least one sorting channel; storing the data packets (including the first data packet) of the first data stream identifier received within a first time period in the first sorting channel, and sorting the data packets of the first data stream identifier based on the first sorting channel, which can be done after some data packets of the first data stream identifier arrive, or after all data packets of the first data stream identifier arrive; when no data packets of the first data stream identifier are received within a second time period, it can be considered that the transmission of the first data stream identifier has ended, at which point the first sorting channel can be released, and the second time period is later than the first time period.
[0007] In the above technical solution, when the first data packet is received, the first data stream identifier and the first sequence index can be obtained from the first data packet. When it is determined that the first data packet needs to be sorted based on the first data stream identifier and the first sequence index, a first sorting channel is allocated to the first data stream identifier, and the data packets of the first data stream identifier received within the first time period are sorted based on the first sorting channel. Afterwards, if no data packets of the first data stream identifier are received within the second time period, it can be considered that the transmission of the first data stream identifier has ended, thereby releasing the first sorting channel. In this way, the first sorting channel can be dynamically allocated to different data stream identifiers in different time periods, so that different data streams share the first sorting channel in different time periods, thereby greatly reducing the demand for sorting resources, improving the utilization rate of sorting resources, and thus reducing equipment costs.
[0008] In one possible implementation of the first aspect, determining that the first data packet needs to be sorted based on the first data stream identifier and the first sequence index includes: querying a preset correspondence based on the first data stream identifier to obtain first indication information, the preset correspondence being used to indicate the target sequence index of the target data packet for the desired sorting of each of the multiple data stream identifiers, i.e., multiple data streams identified by the multiple data stream identifiers all have data packets being transmitted within the same time period, or the network interface card (NIC) can receive data packets from the multiple data streams within the same time period; the first indication information is used to indicate the target sequence index of the target data packet for the desired sorting of the first data stream identifier, and the first data stream can be any of the multiple data streams; when the target sequence index indicated by the first indication information is different from the first sequence index, it is determined that the first data packet needs to be sorted, for example, the first indication information is used to indicate the target sequence number of the target data packet for the desired sorting of the first data stream identifier. Further, the method also includes: when the first sequence index of the first data packet is the same as the target sequence index, i.e., the first data packet is the target data packet for the desired sorting of the first data stream identifier, it is determined that the first data packet does not need to be sorted; in addition, the NIC can also directly output the first data packet. In the above possible implementations, by determining whether the received first data packet needs to be sorted, storing the first data packet in the first sorting channel when sorting is required, and directly outputting the first data packet when sorting is not required, the storage space occupied by the first sorting resource can be further reduced.
[0009] In one possible implementation of the first aspect, if the preset correspondence does not contain first indication information, the method further includes: when the first sequence index of the first data packet is different from the starting sequence index, i.e., the first data packet is not the starting data packet of the first data stream identifier, then it is determined that the first data packet needs to be sorted. The first sequence index is used to indicate the sending order of the first data packet in the first data stream, and the starting sequence index refers to the sequence index of the first data packet in the sending order corresponding to the source server; when the first sequence index is the same as the starting sequence index, i.e., the first data packet is the starting data packet of the first data stream identifier, then it is determined that the first data packet does not need to be sorted. At this time, the network card can also directly output the first data packet. In the above possible implementation, by determining whether the first data packet needs to be sorted, and storing the first data packet in the first sorting channel when it is subsequently determined that sorting is required, and directly outputting the first data packet when sorting is not required, the storage space occupied by the first sorting resource can be further reduced.
[0010] In one possible implementation of the first aspect, when it is determined that the first data packet does not need to be sorted, the method further includes: storing, according to the first order index of the first data packet, a target order index of the target data packet indicating the desired sorting of the first data stream identifier in the preset correspondence; for example, the first indication information is used to indicate the next order index of the first order index; or, after sorting the data packets of the first data stream identifier, updating the first indication information according to the maximum order index of the sorted data packets; for example, the updated first indication information is used to indicate the next order index of the maximum order index. In the above possible implementations, by storing or updating the first indication information in the preset correspondence, the freshness and accuracy of the preset correspondence can be guaranteed, thereby facilitating the sorting determination of subsequently received data packets.
[0011] In one possible implementation of the first aspect, at least one sorting channel includes multiple sorting channels. Allocating a first sorting channel for a first data stream identifier from the at least one sorting channel includes: allocating a first sorting channel for the first data stream identifier from the multiple sorting channels, wherein the first sorting channel is any sorting channel among the multiple sorting channels for which a data stream identifier has not been assigned. In the above possible implementation, by allocating a first sorting channel when it is determined that the first data packet needs to be sorted and the first data stream identifier does not have a corresponding sorting channel, different data streams in different time periods can share the first sorting channel, thereby improving the utilization rate of the first sorting channel.
[0012] In one possible implementation of the first aspect, sorting the data packets identified by the first data stream based on the first sorting channel includes: when the first sorting channel contains multiple data packets with consecutive sequential indices, and these sequential indices are greater than and consecutive to a target sequential index, sorting the multiple data packets according to the size relationship of the sequential indices, where the target sequential index is the sequential index of the target data packet to be sorted; furthermore, when a target data packet is received, the network interface card can output the target data packet and the sorted multiple data packets sequentially, that is, after outputting the target data packet, directly outputting the sorted multiple data packets. In the above possible implementation, by sorting the multiple data packets stored in the first sorting channel when they meet the above conditions, it can be ensured that the multiple data packets can be output as soon as possible, thereby avoiding the storage of a large number of data packets in the sorting channel and reducing the storage space occupied by the sorting channel.
[0013] In one possible implementation of the first aspect, the method further includes: if no data packet of the first data stream identifier is received within the second time period, it can be considered that the transmission of the first data stream identifier has ended, and at this time, the first indication information in the preset correspondence can be deleted. In the above possible implementation, if no data packet of the first data stream identifier is received within the second time period, it indicates that the transmission of the first data stream has ended. By deleting the first indication information in the preset correspondence, the network card can enable the network card to store the indication information of other data stream identifiers in the preset correspondence. In this way, the preset correspondence can be dynamically used to indicate the order of data streams in different time periods, thereby improving the utilization rate of the preset correspondence.
[0014] In a second aspect, a data packet sorting apparatus is provided, comprising: a receiving unit for receiving a first data packet; a determining unit for obtaining a first data stream identifier and a first sequence index from the first data packet, and determining that the first data packet needs to be sorted based on the first data stream identifier and the first sequence index, wherein the first data stream identifier is used to identify a first data stream, and the first data packet is a data packet of the first data stream; an allocation unit for allocating a first sorting channel for the first data stream identifier from at least one sorting channel when the first data packet needs to be sorted and the first data stream identifier does not have a corresponding sorting channel; a sorting unit for storing data packets of the first data stream identifier received within a first time period in the first sorting channel, and sorting the data packets of the first data stream identifier based on the first sorting channel; and a releasing unit for releasing the first sorting channel when no data packets of the first data stream identifier are received within a second time period, wherein the second time period is later than the first time period.
[0015] In one possible implementation of the second aspect, the determining unit is further configured to: query a preset correspondence based on the first data stream identifier to obtain first indication information, wherein the preset correspondence is used to indicate the target order index of the target data packet for the desired sorting of each data stream identifier in multiple data stream identifiers within the same time period, and the first indication information is used to indicate the target order index of the target data packet for the desired sorting of the first data stream identifier; when the target order index indicated by the first indication information is different from the first order index, it is determined that the first data packet needs to be sorted. Further, the determining unit is also configured to: when the first order index of the first data packet is the same as the target order index, i.e., the first data packet is the target data packet for the desired sorting in the first data stream identifier, it is determined that the first data packet does not need to be sorted; in this case, the device may further include: an output unit for outputting the first data packet.
[0016] In one possible implementation of the second aspect, if the first indication information is not present in the preset correspondence, the determining unit is further configured to: when the first sequence index of the first data packet is different from the starting sequence index, i.e., the first data packet is not the starting data packet of the first data stream identifier, then determine that the first data packet needs to be sorted, the first sequence index is used to indicate the sending order of the first data packet in the first data stream, and the starting sequence index refers to the sequence index of the first data packet in the sending order corresponding to the source server; when the first sequence index is the same as the starting sequence index, i.e., the first data packet is the starting data packet of the first data stream identifier, then determine that the first data packet does not need to be sorted; at this time, the device may further include: an output unit, configured to output the first data packet.
[0017] In one possible implementation of the second aspect, the determining unit is further configured to: when it is determined that the first data packet does not need to be sorted, store the target order index of the target data packet for indicating the sorting expectation of the first data stream identifier in a preset correspondence according to the first order index of the first data packet; or, after sorting the data packets of the first data stream identifier, update the first indication information according to the maximum order index of the sorted data packets.
[0018] In one possible implementation of the second aspect, at least one sorting channel includes multiple sorting channels, and the allocation unit is further configured to: allocate a first sorting channel for a first data stream identifier from the multiple sorting channels, wherein the first sorting channel is any sorting channel among the multiple sorting channels for which no data stream identifier has been allocated.
[0019] In one possible implementation of the second aspect, the sorting unit is further configured to: when the first sorting channel includes multiple data packets with consecutive sequential indices, and the sequential index is greater than and consecutive to the target sequential index, sort the multiple data packets according to the size relationship of the sequential indices, wherein the target sequential index is the sequential index of the target data packet to be sorted. Further, the apparatus also includes: an output unit configured to, upon receiving the target data packet, sequentially output the target data packet and the sorted multiple data packets, that is, output the sorted multiple data packets after outputting the target data packet.
[0020] In one possible implementation of the second aspect, the determining unit is further configured to: indicate the end of the first data stream transmission when no data packet of the first data stream identifier is received within the second time period, and delete the first indication information in the preset correspondence.
[0021] In another aspect of this application, a chip is provided, which includes the data packet sorting device provided in the second aspect or any possible implementation thereof, for example, the chip is a network interface card (NIC).
[0022] In another aspect of this application, a server is provided, the server including a network interface card (NIC) and a processor, the NIC being used to send data packets to the processor, the NIC including the data packet sorting device provided in the second aspect or any possible implementation thereof.
[0023] In another aspect of this application, a computer-readable storage medium is provided, which stores instructions that, when executed on a device, cause the device to perform the data packet sorting method provided by the first aspect or any possible implementation thereof.
[0024] In another aspect of this application, a computer program product is provided that, when the computer program product is run on a device, causes the device to execute the data packet sorting method provided by the first aspect or any possible implementation thereof.
[0025] It is understood that any of the packet sorting devices, servers, computer storage media or computer program products provided above are used to execute the packet sorting method provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects of the packet sorting method provided above, and will not be repeated here. Attached Figure Description
[0026] Figure 1 This application provides a schematic diagram of the structure of a data center network according to an embodiment of the present application.
[0027] Figure 2 This application provides a schematic diagram of the structure of a server according to an embodiment of the present application.
[0028] Figure 3 A flowchart illustrating a data packet sorting method provided in an embodiment of this application;
[0029] Figure 4 A flowchart illustrating another data packet sorting method provided in an embodiment of this application;
[0030] Figure 5 This is a schematic diagram of the structure of a network interface card (NIC) provided in an embodiment of this application;
[0031] Figure 6 This is a schematic diagram of the structure of a data packet sorting device provided in an embodiment of this application;
[0032] Figure 7 This is a schematic diagram of another data packet sorting device provided in an embodiment of this application. Detailed Implementation
[0033] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple. Furthermore, embodiments of this application use terms such as "first" and "second" to distinguish identical or similar items with essentially the same function and effect. For example, the first threshold and the second threshold are merely to distinguish different thresholds and do not limit their order. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order.
[0034] It should be noted that, in this application, the terms "exemplary" or "for example" are used to indicate that something is being described as an example, illustration, or illustration. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0035] Figure 1 This is a schematic diagram of a data center network structure provided as an embodiment of this application. See also... Figure 1 This data center network comprises an access layer, an aggregation layer, and a core layer. The access layer includes multiple access nodes, the aggregation layer includes multiple aggregation nodes, and the core layer includes multiple core nodes. The downlink ports of the access nodes are connected to the servers that need to exchange data traffic, the uplink ports of the access nodes are connected to the downlink ports of the aggregation nodes, and the uplink ports of the aggregation nodes are connected to the core nodes. The aggregation and access layers can be divided into multiple pods. A pod can include multiple access nodes and multiple aggregation nodes, and each access node is fully connected to multiple aggregation nodes. Multiple core nodes connected to the same aggregation node can be called a core plane, and each core plane can be connected to different aggregation nodes in different pods. Figure 1 The example provided is based on a network consisting of 3 pods, with each pod containing 3 access nodes and 4 aggregation nodes, and each core plane containing 2 core nodes. Figure 1The access nodes can be represented as A1 to A9, the aggregation nodes can be represented as B1 to B12, the core nodes can be represented as C1 to C8, and the three pods can be represented as pod1 to pod3.
[0036] When data traffic is exchanged between servers connected to different access nodes within a pod, it can be achieved through an aggregation node within the same pod as the access node. For example, if access node A1 and access node A3 need to exchange data traffic, access node A1 can send the data stream from its connected server to access node A3 through aggregation node B1. When data traffic is exchanged between servers connected to access nodes in different pods, it can be achieved through an aggregation node within the same pod as the access node, and a core node connected to the aggregation node. For example, if access node A1 and access node A5 need to exchange data traffic, access node A1 can send the data stream from its connected server to aggregation node B1, which forwards it to core node C1, and then C1 sends it to access node A5 through aggregation node B5.
[0037] Typically, when a source server exchanges data traffic using load balancing (LB), this load balancing can include packet-based balancing. Packet-based balancing involves distributing multiple data packets from a data stream across multiple transmission paths according to a specific load distribution principle; that is, multiple data packets from the same data stream are transmitted to the destination server through different transmission paths. In packet-based balancing, because the forwarding delays of these multiple paths are not entirely the same, the order in which the multiple data packets arrive at the destination server is inconsistent with the order in which they were sent from the source server. Therefore, the destination server needs to sort the data packets received from different paths to obtain the initial order of the data packets in the data stream. For example, in... Figure 1In the data center network shown, if the server connected to access node A2 is the source server and the server connected to access node A5 is the destination server, then there are a total of 8 paths from the source server to the destination server. The source server transmits the data packets of a data stream to access node A2 using packet balancing. Access node A2 can evenly distribute the data packets of this data stream to aggregation nodes B1 to B4 within the same pod. B1 evenly distributes the received data packets to the core nodes C1 and C2 connected to it, and C1 and C2 then send them to B5. Similarly, B2, B3, and B4 forward the data packets to B6, B7, and B8 respectively. Then, B5, B6, B7, and B8 send the received data packets to access node A5, and A5 transmits the received data packets to the destination server. The packet sorting in this article refers to the sorting of data packets in the data stream transmitted using packet balancing.
[0038] It should be noted that the above Figure 1 The data center network shown is merely exemplary. This application embodiment does not specifically limit the number of pods included in the data center network, the number of aggregation nodes and access nodes in each pod, the number of core planes included in the network, or the number of core nodes in each core plane. Furthermore, the number of core nodes in different core planes of the network may be the same or different, and the number of aggregation nodes and access nodes in different pods may be the same or different; this application embodiment does not specifically limit these aspects.
[0039] Figure 2This is a schematic diagram of a server structure provided in an embodiment of the application. The server may include a processor 201, a memory 202, and a network interface card (NIC) 203. The processor 201 performs various functions of the server by running or executing software programs and / or modules stored in the memory, and by accessing data stored in the memory. The processor may include one or more modules, such as a central processing unit (CPU) and a network processor (NP). The network processor may be implemented using an application-specific integrated circuit (ASIC) or a field-programmable gate array (FPGA) chip. The memory 202 can be used to store data, software programs, and modules, and may be implemented using any type of volatile or non-volatile memory or a combination thereof, such as static random access memory, electrically erasable programmable read-only memory, erasable programmable read-only memory, programmable read-only memory, read-only memory, magnetic storage, flash memory, magnetic disk, or optical disk. The network interface card 203 can be a network interface controller (NIC). The server can send data streams to access nodes in the data center network through the network interface card 203, and can also receive data sent by access nodes in the data center network through the network interface card 203.
[0040] Those skilled in the art will understand that Figure 2 The server structure shown is not intended to limit its structure. In practical applications, the server may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0041] Figure 3 This is a flowchart illustrating a data packet sorting method provided in an embodiment of this application. This method can be applied to... Figure 2 The method for the network interface card of the server shown includes the following steps.
[0042] S301: Receive the first data packet and obtain the first data stream identifier and the first sequence index from the first data packet.
[0043] The network interface card (NIC) can be the NIC of the destination server in the transmission path from the source server to the destination server. That is, it's the NIC of the server used to receive the data stream. This data stream can be a data stream divided according to a 5-tuple; for example, data packets with the same 5-tuple are considered as data packets in the same data stream. Here, the 5-tuple refers to the source IP address, source port, destination IP address, destination port, and protocol number. This NIC can be used to receive one or more data streams, which can be data streams sent by one or more source servers using packet balancing in load balancing. The first data stream identifier is used to represent the first data stream, which can be any of the one or more data streams. The first sequence index is used to indicate the sending order of the first data packet, that is, the sending order of the first data packet within the first data stream when the source server of the first data stream sends the first data stream.
[0044] Specifically, when the source server of the first data stream sends the first data stream to the destination server through the data center network in a packet-balanced manner, multiple data packets in the first data stream are transmitted to the network card through different transmission paths. The first data packet can be any of the multiple data packets, so the network card can receive the first data packet and obtain the first data stream identifier and the first sequence index from the first data packet. For example, if the first data packet includes a flow identifier flag and an index flag, the network card can determine the first data stream identifier and the first sequence index according to the flow identifier flag and the index flag, respectively.
[0045] S302: Determine whether the first data packet needs to be sorted based on the first data stream identifier and the first sequence index. If sorting is required, execute S303a; if sorting is not required, execute S303b.
[0046] In one possible embodiment, a preset correspondence is queried based on a first data stream identifier to obtain first indication information. This preset correspondence is used to indicate the target order index of the target data packet for the desired sorting of each data stream identifier among a plurality of data stream identifiers. The first indication information is used to indicate the target order index of the target data packet for the desired sorting of the first data stream identifier. Whether the first data packet needs to be sorted is determined based on the first indication information, that is, whether the first data packet needs to be sorted is determined based on whether the target order index indicated by the first indication information is the same as the first order index of the first data packet. For ease of description, the target order index of the target data packet for the desired sorting is referred to as sorting information below.
[0047] In the preset correspondence, the multiple data stream identifiers within the same time period can refer to the identifiers of multiple data streams that occur concurrently within a certain time period, that is, the multiple data streams all transmit data packets within the same time period, or the network card can receive data packets from the multiple data streams within the same time period.
[0048] Alternatively, the preset mapping relationship can be a pre-set mapping relationship between data flow identifiers and the target order index of their desired sorting target data packets. The network interface card (NIC) can integrate a buffer or memory, and a storage space can be pre-configured in the buffer or memory to store the preset mapping relationship. The capacity of the preset mapping relationship can also be pre-set; for example, the preset mapping relationship can be set to store the mapping relationship between each data flow identifier out of 32000 (32K) data flow identifiers and the sorting information of their data packets.
[0049] Furthermore, the sorting information of a data stream identifier can refer to the target order index of the target data packet with the current sorting expectation within that data stream identifier. Therefore, the sorting information of a data stream identifier can refer to the target order index of the target data packet with the current sorting expectation within that data stream identifier. For example, if the first data stream identifier is Flow_ID1, and data packets with order indices No.1 and No.2 in Flow_ID1 have already been output in order (e.g., the network card has already output them to the processor of the destination server), then the target order index of the target data packet with the current sorting expectation is No.3.
[0050] Specifically, the network interface card (NIC) can query the preset mapping relationship based on the first data flow identifier. If the preset mapping relationship includes the sorting information of the data packets corresponding to the first data flow identifier, the NIC can obtain first indication information from the preset mapping relationship to indicate the sorting information of the data packets corresponding to the first data flow identifier. The first indication information is used to indicate the target order index of the target data packets with the desired sorting in the first data flow identifier. If the first order index of the first data packet is different from the target order index, it is determined that the first data packet needs to be sorted; if the first order index is the same as the target order index, it is determined that the first data packet does not need to be sorted, and thus the first data packet can be directly output to the processor of the destination server. For example, if the first data flow identifier is Flow_ID1, and the data packets with order indices No.1 and No.2 in Flow_ID1 have already been output in order (for example, the NIC has already output them to the processor of the destination server), then the target order index of the target data packet with the desired sorting is No.3, and thus the first indication information can be used to indicate No.3.
[0051] Optionally, after querying the preset correspondence based on the first data stream identifier, if the preset correspondence does not contain the first indication information, the network interface card (NIC) can also determine whether the first data packet needs to be sorted based on the first sequence index of the first data packet. Here, the sequence index of a data packet indicates the sending order of the data packet, that is, the order in which the source server sends multiple data packets of the data stream. The first sequence index is used to indicate the sending order of the first data packet in the first data stream. Specifically, when the first sequence index of the first data packet is the same as the starting sequence index, it is determined that the first data packet does not need to be sorted, and the first data packet can be directly output; when the first sequence index is different from the starting sequence index, it is determined that the first data packet needs to be sorted. It should be noted that the starting sequence index refers to the sequence index of the first data packet in the sending order corresponding to the source server. This sequence index can be a data packet sequence number; for example, the data packet sequence number corresponding to the starting sequence index can be 1.
[0052] S303a: When it is determined that the first data packet needs to be sorted, a first sorting channel is allocated for the first data stream identifier from at least one sorting channel. Determining that the first data packet needs to be sorted may include determining that the first data packet needs to be sorted based on first indication information, and determining that the first data packet needs to be sorted based on a first sequence index and a start sequence index of the first data packet.
[0053] Specifically, when it is determined that the first data packet needs to be sorted, and there is currently no corresponding sorting channel for the first data stream identifier, the network interface card (NIC) can allocate a first sorting channel for the first data stream identifier from multiple sorting channels, and store the first data packet in the first sorting channel. The first sorting channel is any sorting channel among the multiple sorting channels that has not been allocated a data stream identifier. That is, the first sorting channel can be considered as the one allocated by the NIC for the first data stream identifier when it first receives a data packet that needs to be sorted.
[0054] It should be noted that these multiple sorting channels can be pre-configured. For example, the network card may integrate a buffer or memory, and a storage space can be pre-configured in the buffer or memory as these multiple sorting channels. The number of these multiple sorting channels can also be pre-configured; for example, the number of multiple sorting channels can be set to 2000 (2K).
[0055] S303b: When it is determined that the first data packet does not need to be sorted, first indication information is stored in the preset correspondence according to the first order index of the first data packet. Determining that the first data packet does not need to be sorted may include determining that the first data packet does not need to be sorted according to the first indication information, and determining that the first data packet does not need to be sorted according to the first order index and the starting order index of the first data packet.
[0056] Specifically, when it is determined that the first data packet does not need to be sorted according to the first indication information, the preset mapping relationship already stores the first indication information used to indicate the sorting information of the data packets of the first data stream identifier. At this time, the network card can update the first indication information in the preset mapping relationship according to the first sequence index of the first data packet. For example, the first indication information can be updated to the next sequence index used to indicate the first sequence index. For example, if the first sequence index of the first data packet is No.1, the first indication information can be updated to the target index of the target data packet with the desired sorting in the first data stream identifier is No.2.
[0057] When it is determined that the first data packet does not need to be sorted based on its first sequence index and starting sequence index, the preset mapping does not contain first indication information for indicating the sorting information of the data packet identifying the first data stream. In this case, the network interface card (NIC) can add first indication information to the preset mapping based on the first sequence index of the first data packet. For example, it can add first indication information to the preset mapping to indicate the next sequence index of the first sequence index. For instance, if the first sequence index of the first data packet is No. 1, then first indication information can be added to the preset mapping, where the first indication information indicates that the target index of the target data packet for which the sorting expectation of the first data stream identifier is No. 2.
[0058] In addition, in both of the above situations, the network card can also directly output the first data packet, that is, the network card can output the first data packet to the processor of the destination server.
[0059] S304: Store the data packets of the first data stream identifier received within the first time period in the first sorting channel, and sort the data packets of the first data stream identifier based on the first sorting channel.
[0060] When the network interface card (NIC) receives other data packets with the first data stream identifier within the first time period, the NIC can determine whether each data packet needs to be sorted according to the processing method described in S301-S302 above. If it is determined that the data packet needs to be sorted, it is stored in the first sorting channel; if it is determined that the data packet does not need to be sorted, the data packet is output, and the first indication information in the preset correspondence is updated. The first time period can refer to the time period from the first time the NIC receives a data packet with the first data stream identifier to the last time it receives a data packet with the first data stream identifier. For example, if the first data stream identifier includes 100 data packets, then the first time period can refer to the time period from the first data packet to the 100th data packet received by the NIC.
[0061] When the network interface card (NIC) sorts data packets of the first data stream identifier based on the first sorting channel, the NIC can sort them after a portion of the data packets of the first data stream identifier have arrived, or after all the data packets of the first data stream identifier have arrived. When sorting after a portion of the data packets of the first data stream identifier have arrived, the NIC can complete the sorting of all the data packets of the first data stream identifier through multiple sorting operations.
[0062] In one possible embodiment, sorting the data packets identified by the first data stream based on the first sorting channel may include: when the first sorting channel includes multiple data packets with consecutive sequential indices, where the sequential index is greater than and consecutive to the target sequential index, sorting the multiple data packets according to the size relationship of the sequential index, for example, sorting the multiple data packets in ascending order or descending order of the sequential index, where the target sequential index is the sequential index of the target data packet to be sorted. Thus, when the target data packet is received, the network interface card (NIC) can sequentially output the target data packet and the sorted multiple data packets, that is, after outputting the target data packet, directly outputting the sorted multiple data packets. For example, if the target sequential index is No. 4, the number of multiple data packets is 4, and their corresponding sequential indices are No. 6, No. 7, No. 8, and No. 5, then No. 6, No. 7, No. 8, and No. 5 are all greater than No. 4 and consecutive to No. 4. Therefore, the NIC can sort these 4 data packets in ascending order of their sequential indices, that is, arrange them as No. 5, No. 6, No. 7, and No. 8. Subsequently, when the network card receives target data packet No. 4, it can output the target data packet and these four data packets to the processor of the destination server in the order of No. 4, No. 5, No. 6, No. 7 and No. 8.
[0063] Furthermore, when the network card outputs multiple sorted data packets, it can also update the first indication information in the preset mapping relationship based on the largest sequential index among the multiple data packets. For example, if the largest sequential index is No. 8, the network card updates the first indication information in the preset mapping relationship to No. 9, which is used to indicate the target sequential index of the target data packet for the first data stream identifier to be sorted.
[0064] S305: Release the first sorting channel when no data packet identified by the first data stream is received within the second time period.
[0065] After the network interface card (NIC) outputs a data packet with the first data stream identifier for the first sorting channel, if no other data packets with the first data stream identifier are received within the second time period, it indicates that the first data stream transmission has ended, and the NIC can release the first sorting channel. The second time period is later than the first time period. Subsequently, when the NIC receives data packets from other data streams and needs to sort those data packets, it can reallocate the first sorting channel to those other data streams for data packet sorting. This allows the same sorting channel to be used dynamically to sort data packets from different time periods, thereby improving the utilization rate of the sorting channel.
[0066] It should be noted that the second time period can be set in advance. Those skilled in the art can set the preset duration based on experience or actual needs. For example, the second time period can be 5 minutes or 10 minutes, etc. This application embodiment does not impose specific limitations on this.
[0067] Further, see Figure 4 The method also includes: S306. S306 and S305 can be performed in any order. Figure 4 The example given is S306 located after S305.
[0068] S306: When no data packet of the first data stream identifier is received within the second time period, delete the first indication information in the preset correspondence.
[0069] After the network interface card (NIC) outputs multiple data packets for the first sorting channel, if no other data packets for the first data stream identifier are received within the second time period, it indicates that the first data stream transmission has ended. The NIC can then delete the first indication information in the preset mapping relationship, that is, delete the first indication information used to indicate the sorting information of the data packets for the first data stream identifier, thereby freeing up storage space in the preset mapping relationship. For example, the network interface card can delete the first indication information in the preset mapping relationship after releasing the first sorting channel. Subsequently, when the NIC receives data packets from other data streams and needs to sort the data packets, it can store the indication information corresponding to the other data stream identifiers in the preset mapping relationship, that is, store the sorting information of the data packets for the other data stream identifiers in the preset mapping relationship. This allows the preset mapping relationship to be dynamically used to indicate the sorting of data packets for data streams in different time periods, thereby improving the utilization rate of the preset mapping relationship.
[0070] For ease of understanding, the following will be used as an example. Figure 5 Taking the network card shown as an example, the data packet sorting method provided in this application embodiment will be illustrated. Figure 5As shown, the network interface card (NIC) may include a flow table management unit 401, a sorting determination unit 402, and a channel management unit 403. The flow table management unit 401 can be used to manage the preset mapping relationship, such as storing or deleting first indication information corresponding to a first data flow identifier in the preset mapping relationship. The sorting determination unit 402 can be used to determine whether received data packets need to be sorted. For example, the sorting determination unit 402 can determine whether a first data packet needs to be sorted based on the first indication information obtained from the preset mapping relationship, and determine whether a first data packet needs to be sorted based on the first sequence index of the first data packet when the first indication information does not exist in the preset mapping relationship. The channel management unit 403 can be used to manage multiple sorting channels, such as allocating a first sorting channel to a first data flow identifier and releasing a first sorting channel.
[0071] Specifically, when the network interface card (NIC) receives a first data packet with a first data flow identifier, the flow table management unit 401 can query the preset correspondence based on the first data flow identifier. If the preset correspondence contains first indication information, the flow table management unit 401 can output the first indication information to the sorting judgment unit 402. If the preset correspondence does not contain first indication information, the flow table management unit 401 can notify the sorting judgment unit 402. When the sorting judgment unit 402 receives the first indication information, it determines whether the first data packet needs to be sorted based on the size relationship between the target order index indicated by the first indication information and the first order index of the first data packet. Alternatively, when the sorting judgment unit 402 determines that the preset correspondence does not contain first indication information, it determines whether the first data packet needs to be sorted based on the size of the first order index and the starting order index of the first data packet. If the sorting judgment unit 402 determines that the first data packet needs to be sorted, it stores the first data packet in the first sorting channel. If the sorting judgment unit 402 determines that the first data packet does not need to be sorted, it directly outputs the first data packet. At this time, the flow table management unit 401 can update or add the first indication information in the preset correspondence based on the first order index. When a first data stream identifier does not have a corresponding sorting channel, the channel management unit 403 can allocate a first sorting channel for the first data stream identifier. Subsequently, when the network interface card receives other data packets of the first data stream identifier, it can process them in the above manner until the first sorting channel includes multiple data packets with consecutive sequential indices. When the sequential index is greater than and consecutive to the target sequential index, the multiple data packets are sorted according to the size relationship of the sequential indices, and the sorted multiple data packets are output after the target data packet is output. After outputting the sorted multiple data packets, the flow table management unit 401 can also update the first indication information in the preset correspondence based on the largest sequential index among the multiple data packets. Finally, if no data packets of the first data stream identifier are received within the second time period, the channel management unit 403 can release the first sorting channel (optionally, the channel management unit 403 can notify the flow table management unit 401 that the first sorting channel has been released), and the flow table management unit 401 can also delete the first indication information in the preset correspondence.
[0072] In this embodiment, the preset correspondence can be used to indicate the sorting information of multiple concurrent data stream identifiers. When a data packet of the first data stream identifier is received within a first time period, it can be determined whether the data packet needs to be sorted based on the first indication information corresponding to the first data stream identifier in the preset correspondence. If sorting is required, the data packet is stored in the first sorting channel allocated to the first data stream identifier and sorted. If no data packet of the first data stream identifier is received within a second time period, the first sorting channel is released. This allows the first sorting channel to be dynamically allocated to different data stream identifiers within different time periods, enabling different data streams within different time periods to share the first sorting channel. Furthermore, by dynamically managing multiple sorting channels and the preset correspondence using this method, each sorting channel can be dynamically shared by multiple data streams within different time periods. Simultaneously, multiple data streams within different time periods can also share the preset correspondence, thereby significantly reducing sorting resources and consequently reducing equipment costs.
[0073] The above primarily describes the solutions provided in this application from the perspective of the network interface card (NIC). It is understood that, in order to achieve the aforementioned functions, the NIC includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, in conjunction with the network elements and algorithm steps of the various examples described in the embodiments disclosed herein, the present invention can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0074] This application embodiment can divide the network interface card (NIC) into functional modules according to the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0075] When dividing each function into modules according to its corresponding function. Figure 6A possible structural diagram of the data packet sorting device involved in the above embodiments is shown. This device can be a network interface card (NIC) and includes: a receiving unit 501, a determining unit 502, an allocation unit 503, a sorting unit 504, and a releasing unit 505. The receiving unit 501 is used to perform the step of receiving a first data packet and other data packets with a first data stream identifier within a first time period in S301 of the above method embodiment; the determining unit 502 is used to perform S301 of the above method embodiment, obtaining the first data stream identifier and the first sequence index from the first data packet, S302, and other technical processes described herein; the allocation unit 503 is used to perform S303a of the above method embodiment; the sorting unit 504 is used to perform S304 of the above method embodiment; and the releasing unit 505 performs S305 of the above method embodiment. Further, the device may also include an output unit 506; wherein the output unit 506 is used to perform the step of outputting the first data packet and / or multiple sorted data packets. Further, the functional structure shown in this device is similar to... Figure 5 The correspondence between the units of the network card shown can be: Unit 502 can correspond to... Figure 5 The functions of the flow table management unit 401 and the sorting judgment unit 402 are combined, and the allocation unit 503 and the release unit 505 can correspond to the functions of the channel management unit 403.
[0076] In terms of hardware implementation, the aforementioned determining unit 502, allocation unit 503, sorting unit 504 and release unit 505 can be processors, receiving unit 501 can be a receiver, and output unit 506 can be a transmitter. The transmitter and receiver can form a communication interface.
[0077] Figure 7 The diagram shows a possible structural schematic of the data packet sorting device involved in the above embodiments provided in this application. The device can be a network interface card (NIC) and includes a processor 512, a communication interface 513, a memory 511, and a bus 514. The processor 512, communication interface 513, and memory 511 are interconnected via the bus 514. In this application embodiment, the processor 512 is used to control and manage the operation of the device. For example, the processor 512 is used to execute the step of obtaining the first data stream identifier and the first sequence index from the first data packet in S301 of the above method embodiment, S302-S306, and / or other processes using the technology described herein. The communication interface 513 is used to support the device in communication, such as supporting the device to receive the first data packet, output the first data packet, and / or output multiple sorted data packets. The memory 511 is used to store the program code and data of the device.
[0078] The processor 512 can be a microprocessor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, etc. The bus 514 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
[0079] In this embodiment, when a first data packet is received, a first data stream identifier and a first sequence index can be obtained from the first data packet. When it is determined that the first data packet needs to be sorted based on the first data stream identifier and the first sequence index, a first sorting channel is allocated to the first data stream identifier, and the data packets of the first data stream identifier received within a first time period are sorted based on the first sorting channel. Subsequently, if no data packets of the first data stream identifier are received within a second time period, it can be considered that the transmission of the first data stream identifier has ended, thereby releasing the first sorting channel. In this way, the first sorting channel can be dynamically allocated to different data stream identifiers within different time periods, so that different data streams within different time periods can share the first sorting channel, thereby greatly reducing the demand for sorting resources, improving the utilization rate of sorting resources, and thus reducing equipment costs.
[0080] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0081] In another embodiment of this application, a chip is also provided for executing the data packet sorting method provided herein. For example, the chip can be... Figure 5 The network card, or the chip, includes Figure 6 or Figure 7 The data packet sorting device shown.
[0082] In another embodiment of this application, a server is also provided, the structure of which can be as follows: Figure 2 As shown, the server may include a processor 201 and a network interface card (NIC) 203; wherein, the NIC 203 can be used to send data packets to the processor 201, and the NIC 203 can be any of the NICs or data packet sorting devices provided above, used to execute the data packet sorting method provided herein. Optionally, the server may also include a memory 202.
[0083] In another embodiment of this application, a computer-readable storage medium is also provided, which stores instructions that, when executed by at least one processor of a device, cause the device to perform the packet sorting method provided herein.
[0084] In another embodiment of this application, a computer program product is also provided, the computer program product including computer-executable instructions stored in a computer-readable storage medium; at least one processor of the device can read the computer-executable instructions from the computer-readable storage medium, and the at least one processor executes the computer-executable instructions to cause the device to implement the packet sorting method provided herein.
[0085] Finally, it should be noted that the above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method of packet ordering, characterized by, In a network interface card (NIC) of a server used in a data center network, the NIC includes multiple sorting channels, each of which is dynamically shared by multiple data streams within different time periods. The method includes: Receive a first data packet and obtain a first data stream identifier and a first sequence index from the first data packet, wherein the first data stream identified by the first data stream identifier is any one of multiple data streams received within the same time period; When it is determined that the first data packet needs to be sorted based on the first data stream identifier and the first sequence index, a first sorting channel is allocated for the first data stream identifier from the plurality of sorting channels. The first sorting channel is any sorting channel among the plurality of sorting channels that has not been allocated a data stream identifier. The data packets of the first data stream identifier received within the first time period are stored in the first sorting channel, and the data packets of the first data stream identifier are sorted based on the first sorting channel. If no data packet identified by the first data stream is received within the second time period, the first sorting channel is released. The second time period is later than the first time period.
2. The method of claim 1, wherein, The step of determining that the first data packet needs to be sorted based on the first data stream identifier and the first sequence index includes: The first indication information is obtained by querying a preset correspondence based on the first data stream identifier. The preset correspondence is used to indicate the target order index of the target data packet for the sorting expectation of each data stream identifier in the plurality of data stream identifiers. The first indication information is used to indicate the target order index of the target data packet for the sorting expectation of the first data stream identifier. When the target sequence index indicated by the first indication information is different from the first sequence index, it is determined that the first data packet needs to be sorted.
3. The method of claim 2, wherein, The method further includes: When the target order index indicated by the first indication information is the same as the first order index, it is determined that the first data packet does not need to be sorted.
4. The method of claim 2, wherein, If the first indication information does not exist in the preset correspondence, the method further includes: When the first order index of the first data packet is different from the starting order index, it is determined that the first data packet needs to be sorted. When the first order index of the first data packet is the same as the starting order index, it is determined that the first data packet does not need to be sorted.
5. The method of claim 2, wherein, The method further includes: When it is determined that the first data packet does not need to be sorted, the target order index of the target data packet indicating the sorting expectation of the first data stream identifier is stored in the preset correspondence according to the first order index of the first data packet; or... After sorting the data packets identified by the first data stream, the first indication information is updated according to the maximum order index of the sorted data packets.
6. The method of claim 1, wherein, The step of sorting the data packets identified by the first data stream based on the first sorting channel includes: When the first sorting channel includes multiple data packets with consecutive sequential indices, and the sequential index is greater than and consecutive to the target sequential index, the multiple data packets are sorted according to the size relationship of the sequential indices. The target sequential index is the sequential index of the target data packet to be sorted.
7. The method of claim 6, wherein, The method further includes: Upon receiving the target data packet, the target data packet and the sorted data packets are output sequentially.
8. The method according to any one of claims 2-5, characterized in that, The method further includes: If no data packet with the first data stream identifier is received within the second time period, the first indication information in the preset correspondence is deleted.
9. A data packet ordering apparatus, characterized by comprising: As a network interface card (NIC) of a server in a data center network, the NIC includes multiple sorting channels, each of which is dynamically shared by multiple data streams within different time periods. The device includes: The receiving unit is used to receive the first data packet; The determining unit is configured to obtain a first data stream identifier and a first sequence index from the first data packet, and determine that the first data packet needs to be sorted according to the first data stream identifier and the first sequence index, wherein the first data stream identified by the first data stream identifier is any one of the multiple data streams received within the same time period; The allocation unit is configured to allocate a first sorting channel for the first data stream identifier from the plurality of sorting channels when the first data packet needs to be sorted, wherein the first sorting channel is any sorting channel among the plurality of sorting channels for which no data stream identifier has been allocated; The sorting unit is used to store the data packets of the first data stream identifier received within a first time period in the first sorting channel, and sort the data packets of the first data stream identifier based on the first sorting channel. The release unit is used to release the first sorting channel when no data packet of the first data stream identifier is received within a second time period, the second time period being later than the first time period.
10. The apparatus of claim 9, wherein, The determining unit is further configured to: The first indication information is obtained by querying a preset correspondence based on the first data stream identifier. The preset correspondence is used to indicate the target order index of the target data packet for the sorting expectation of each data stream identifier in the plurality of data stream identifiers. The first indication information is used to indicate the target order index of the target data packet for the sorting expectation of the first data stream identifier. When the target sequence index indicated by the first indication information is different from the first sequence index, it is determined that the first data packet needs to be sorted.
11. The apparatus of claim 10, wherein, The determining unit is further configured to: When the target order index indicated by the first indication information is the same as the first order index, it is determined that the first data packet does not need to be sorted.
12. The apparatus of claim 10, wherein, If the first indication information does not exist in the preset correspondence, the determining unit is further configured to: When the first order index of the first data packet is different from the starting order index, it is determined that the first data packet needs to be sorted. When the first order index of the first data packet is the same as the starting order index, it is determined that the first data packet does not need to be sorted.
13. The apparatus of claim 10, wherein, The determining unit is further configured to: When it is determined that the first data packet does not need to be sorted, the target order index of the target data packet indicating the sorting expectation of the first data stream identifier is stored in the preset correspondence according to the first order index of the first data packet; or... After sorting the data packets identified by the first data stream, the first indication information is updated according to the maximum order index of the sorted data packets.
14. The apparatus of claim 9, wherein, The sorting unit is also used for: When the first sorting channel includes multiple data packets with consecutive sequential indices, and the sequential index is greater than and consecutive to the target sequential index, the multiple data packets are sorted according to the size relationship of the sequential indices. The target sequential index is the sequential index of the target data packet to be sorted.
15. The apparatus of claim 14, wherein, The device further includes: The output unit is used to sequentially output the target data packet and the sorted data packets when the target data packet is received.
16. The apparatus of any one of claims 10-13, wherein, The determining unit is further configured to: If no data packet with the first data stream identifier is received within the second time period, the first indication information in the preset correspondence is deleted.
17. A server, characterized by The server includes a network interface card (NIC) and a processor, the processor being used to receive data packets sent by the NIC, the NIC including the data packet sorting device according to any one of claims 9-16.
18. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on the device, cause the device to perform the data packet sorting method according to any one of claims 1-8.