[go: up one dir, main page]

WO2024183410A1 - Hardware flow table aging method and apparatus, software flow table aging method and apparatus, and electronic device - Google Patents

Hardware flow table aging method and apparatus, software flow table aging method and apparatus, and electronic device Download PDF

Info

Publication number
WO2024183410A1
WO2024183410A1 PCT/CN2023/140365 CN2023140365W WO2024183410A1 WO 2024183410 A1 WO2024183410 A1 WO 2024183410A1 CN 2023140365 W CN2023140365 W CN 2023140365W WO 2024183410 A1 WO2024183410 A1 WO 2024183410A1
Authority
WO
WIPO (PCT)
Prior art keywords
flow table
hit
aging
driver software
flow
Prior art date
Application number
PCT/CN2023/140365
Other languages
French (fr)
Chinese (zh)
Inventor
李盼
李易
吴绍华
刘珂
邹明
卢士鹏
文旭
Original Assignee
天翼云科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 天翼云科技有限公司 filed Critical 天翼云科技有限公司
Publication of WO2024183410A1 publication Critical patent/WO2024183410A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4411Configuring for operating with peripheral devices; Loading of device drivers
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the technical field of smart network cards, and in particular to a hardware flow table aging method, a software flow table aging method, a device and an electronic device.
  • the first method is that the hardware device calculates to determine the flow table to be aged, and the driver software performs the aging operation.
  • the second method is that the hardware device records the usage of the flow table, and the driver software interacts with the hardware device to obtain the usage of the flow table and then calculates to determine whether the flow table needs to be aged. In this method, the driver software can only obtain the usage of one flow table each time it interacts with the hardware device.
  • the driver software must interact with the hardware device once for each flow table aging judgment, and the number of interactions is large and time-consuming.
  • the present application aims to propose a hardware flow table aging method, a software flow table aging method, an apparatus and an electronic device to solve the current problem that the driver software and the hardware device interact frequently and time-consumingly during flow table aging.
  • a hardware flow table aging method is applied to a hardware device of a smart network card, comprising:
  • the hit table Periodically record the hit records of multiple flow tables in the hardware device, and generate a hit table for each flow table based on the hit records;
  • the hit table contains multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
  • the target flow table is deleted.
  • the method further includes:
  • the identification bit is a bit.
  • periodically record hit records of multiple flow tables in the hardware device including:
  • the hit situation of each flow table is recorded in turn, and the hit situation of each flow table is written into the corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit situation of the flow table;
  • the current hit list is sent to the driver software of the smart network card at every preset time interval;
  • Each identification bit segment includes at least one identification bit.
  • the hardware flow table aging method of the present application has the following advantages:
  • the present application periodically records the hit records of multiple flow tables and generates a hit table for each flow table;
  • the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
  • the hit table in the current cycle is sent to the driver software of the smart network card to drive the driver software to determine the target flow table to be aged; in response to the aging instruction sent by the driver software, the target flow table is deleted.
  • the driver software can obtain the hit records of multiple flow tables after only a few interactions with the hardware device, so as to make aging judgments on each flow table, which greatly reduces the number of interactions between the driver software and the hardware device and the time spent on the interactions, thereby improving efficiency.
  • Another purpose of this application is to provide a software flow table aging method to solve the current flow table aging problem.
  • the problem is that the driver software interacts with the hardware device frequently and takes a long time.
  • a software flow table aging method is applied to driver software of an intelligent network card, comprising:
  • the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
  • An aging instruction is sent to the hardware device of the smart network card, where the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
  • the method further comprises:
  • the method further comprises:
  • determining the target flow table to be aged includes:
  • the target flow table is determined based on the difference between the last use time of the candidate flow table and the current time.
  • the last use time of each flow table is determined by:
  • the last use time of the most recent update of the flow table is used as the last use time
  • the first preset value is different from the second preset value.
  • update the last used time of the flow table including:
  • determining the target flow table based on the difference between the last use time of the candidate flow table and the current time includes:
  • the candidate flow table whose difference exceeds the aging threshold is determined as the target flow table.
  • Another object of the present application is to provide a hardware flow table aging device to solve the problem that the current flow table aging has a large number of interactions between the driver software and the hardware device and takes a long time.
  • a hardware flow table aging device applied to a hardware device of a smart network card, comprises:
  • a generation module is used to periodically record hit records of multiple flow tables and generate a hit table for each flow table;
  • the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
  • a hit table sending module used to send the hit table in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged;
  • the deletion module is used to delete the target flow table in response to the aging instruction sent by the driver software.
  • the hardware flow table aging device has the same advantages as the above-mentioned hardware flow table aging method over the prior art, which will not be described in detail here.
  • Another object of the present application is to provide a software flow table aging device to solve the problem that the current flow table aging has a large number of interactions between the driver software and the hardware device and takes a long time.
  • a software flow table aging device is applied to the driver software of an intelligent network card, comprising:
  • a receiving module is used to receive a hit table in the current cycle sent by the hardware device of the smart network card;
  • the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
  • a determination module used to determine a target flow table to be aged based on the values of multiple identification bits of the hit table in the current cycle
  • the instruction sending module is used to send an aging instruction to the hardware device of the smart network card, and the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
  • Another object of the present application is to provide an electronic device to solve the current problem that when the flow table is aged, the driver software and the hardware device interact frequently and time-consumingly.
  • An electronic device comprising:
  • a processor a memory, and a computer program stored in the memory and executable on the processor, When the processor executes the program, any of the above hardware flow table aging methods is implemented, or any of the above software flow table aging methods is implemented.
  • Another object of the present application is to provide a computer-readable storage medium to solve the problem that the number of interactions between the driver software and the hardware device is large and time-consuming when the current flow table is aged.
  • the electronic device When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any of the above-mentioned hardware flow table aging methods, or execute any of the above-mentioned software flow table aging methods.
  • FIG1 shows a flowchart of a method for aging a hardware flow table according to an embodiment of the present application
  • FIG2 shows an example diagram of a process for a hardware device of a smart network card of the present application to generate a hit table
  • FIG4 shows a flowchart of steps for determining a target flow table to be aged in a software flow table aging method according to another embodiment of the present application
  • FIG6 shows a schematic structural diagram of a hardware flow table aging device according to an embodiment of the present application.
  • FIG. 7 shows a schematic structural diagram of another software flow table aging device according to an embodiment of the present application.
  • Smart NIC also known as intelligent network adapter, provides network data transmission function and also provides built-in programmable and configurable hardware acceleration engine.
  • data transmission data with certain common characteristics or attributes passing through the same network at the same time can be called a flow.
  • the collection of policy table entries for one or more specific flows is called a flow table, which is responsible for the search and forwarding of data packets.
  • the hardware device and driver software in the smart network card store multiple flow tables.
  • the data packet is first matched with the flow table in the hardware device. If the match is successful, the action corresponding to the matched flow table is executed (for example, forwarding to a specific path). If the match fails, the hardware device sends the data packet to the open virtual switching standard (Open vSwitch, OVS) of the driver software to generate a new flow table rule.
  • Open vSwitch Open vSwitch, OVS
  • OpenFlow is a new network communication protocol used for communication between controllers and forwarders in software-defined network architectures.
  • a core concept of software-defined networks is "separation of forwarding and control". To achieve separation of forwarding and control, it is necessary to establish a communication interface standard between the controller and the forwarder, allowing the controller to directly access and control the forwarding plane of the forwarder.
  • the OpenFlow protocol architecture consists of a controller, a switch, and a secure channel. The controller deploys the corresponding flow table on the forwarder through the interface, and the forwarder guides the forwarding of data packets through the flow table, thereby achieving control over the forwarding plane.
  • Open vSwitch is a virtual switch that supports multi-layer data forwarding and is suitable for the open network communication protocol (OpenFlow).
  • the flow table of the smart network card hardware device needs to delete the flow table that has not been used for a long time through aging to free up space.
  • the hardware device counts and calculates the usage of the flow table, determines the flow table to be aged, adds the flow table to the aging queue, and then sends the aging queue to the driver software, which performs the aging operation.
  • the second method is that the hardware device counts the usage of the flow table, and the driver software periodically obtains the message statistics of each flow table from the hardware to determine whether there is a message hit, and then performs calculations to determine the flow table to be aged and executes the aging operation.
  • the driver software can only obtain the usage of one flow table at a time when interacting with the hardware. Therefore, the number of interactions with the hardware device corresponds to the number of flow tables on the hardware device. Periodically determine whether all flow tables need to be aged, which requires more interactions with the hardware and takes a long time.
  • an embodiment of the present application provides a flow table aging method with simple hardware implementation and a small number of interactions, so as to improve the efficiency of flow table aging.
  • FIG. 1 shows a flowchart of the steps of a hardware flow table aging method according to an embodiment of the present application. The method is applied to a hardware device of a smart network card, as shown in FIG. 1 , and includes:
  • Step S101 periodically record the hit records of multiple flow tables in the hardware device, and generate a hit table for each flow table based on the hit records; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit.
  • the hardware device of the smart network card periodically records the hit records of each flow table, generates and stores the hit table of each flow table.
  • the hardware device stores the hit table under a fixed path, and when generating the hit records of each flow table in the current cycle, the corresponding identification bit of the stored hit table is updated.
  • the standard for the hardware device to determine whether each flow table is hit is: whether the flow table matches the data packet within the cycle. As long as the flow table matches the data packet, the flow table is considered to be hit.
  • the hit table contains hit information of each flow table, but does not contain hit count information.
  • the identification bit is a bit.
  • the hardware device of the smart network card can generate a bit table, which includes multiple bits, each bit corresponds to a flow table, and the value of each bit represents whether the corresponding flow table is hit.
  • a bit is the smallest unit of data in a current computer system.
  • a data structure that uses a bit array to store specific data can be called a bit table.
  • the hit table in this application can be regarded as a bit table.
  • each identification bit in the hit table that is, the bit is usually 0 or 1.
  • the value of the bit is 0, which indicates that the corresponding flow table is not hit, and the value of the bit is 1, which indicates that the corresponding flow table is hit.
  • the hardware device When the hardware device records the hit records of each flow table in the current cycle, if the flow table hit count is greater than or equal to one, the corresponding bit value in the hit table is recorded as 1; if the flow table hit count is zero, the corresponding bit value in the hit table is recorded as 0.
  • the duration of one cycle is in the range of microseconds to milliseconds.
  • the length of a cycle for the smart network card to record hit records of each flow table is in the microsecond to millisecond level.
  • FIG. 2 shows an example flow chart of the hardware device of the smart network card of the present application generating a hit table.
  • the data packet arrives at the hardware device and the hardware device After the data packet matches the flow table, the hardware device records the hit record of the flow table, generates a hit table and updates the value of the corresponding identification bit in the hit table.
  • the hardware device can record the hit in the form of a bit table, record the value of the bit corresponding to the flow table as 1, and record the value of the bit corresponding to other unmatched flow tables as 0.
  • the bit table in which all flow tables in the current cycle are recorded is used as the hit table in the current cycle.
  • Step S102 Send the hit table generated in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged.
  • the hardware device After the hardware device completes recording the hit records of each flow table in a cycle, it sends the generated hit table to the driver software, and the driver software performs calculations based on the hit table to determine the target flow table to be aged, wherein the target flow table is a flow table that has not been hit.
  • the hardware device records the hit records of each flow table in the form of a bit table. After completing the recording within a cycle, the multiple bits corresponding to the multiple flow tables are divided into groups of N to obtain one or more bit tables, and the one or more bit tables are sent to the driver software.
  • the hardware device sends the hit list to the Data Plane Development Kit (DPDK) module of the driver software.
  • DPDK Data Plane Development Kit
  • the Data Plane Development Kit refers to a collection of libraries and drivers for fast packet processing configured by the virtual switch.
  • multiple bits in the hit table may be divided into groups of 8.
  • the driver software After receiving the hit table, the driver software calculates the difference between the last use time and the current time of each flow table based on the hit records of each flow table, determines the flow tables whose difference exceeds the aging threshold, and uses these flow tables as target flow tables to be aged.
  • the driver software After determining the target flow table to be aged, the driver software sends an aging instruction to the hardware device.
  • the aging instruction is used to instruct the hardware device to perform aging on the target flow table to be aged, and the aging instruction at least includes the number of the target flow table to be aged.
  • Step S103 In response to the aging instruction sent by the driver software, the target flow table is deleted.
  • the hardware device After receiving the aging instruction sent by the driver software, the hardware device obtains the number of the target flow table to be aged contained in the aging instruction, retrieves the target flow table based on the number, and deletes it from the hardware device.
  • the hit table generated in the current cycle is sent to the driver of the smart network card.
  • the hardware flow table aging method provided in the embodiment of the present application further includes:
  • the hit table generated in the current cycle is subjected to target processing to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
  • the hit table generated in the current cycle is processed in a targeted manner so as to record in the next cycle.
  • the hardware device can delete the hit table generated in the current cycle, generate a new hit table when recording the next cycle, and write the hit status of the corresponding flow table in the identification bit of the new hit table.
  • the hardware device can initialize the identification bits of the hit table generated in the current cycle, that is, initialize the values of the identification bits in the hit table generated in the current cycle to the target value, such as 0, and retain the table of the hit table.
  • the target value such as 0,
  • the hardware device can initialize the identification bits of the hit table generated in the current cycle, that is, initialize the values of the identification bits in the hit table generated in the current cycle to the target value, such as 0, and retain the table of the hit table.
  • the hardware device can initialize the identification bits of the hit table generated in the current cycle, that is, initialize the values of the identification bits in the hit table generated in the current cycle to the target value, such as 0, and retain the table of the hit table.
  • periodically recording hit records of multiple flow tables in a hardware device includes: in a current cycle, recording the hit status of each flow table in turn, and writing the hit status of each flow table into a corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit status of the flow table;
  • the current hit list is sent to the driver software of the smart network card at every preset time interval;
  • Each identification bit segment includes at least one identification bit.
  • the hardware device of the smart network card sends the hit list to the driver software in segments.
  • the hardware device may send the current hit list to the driver software at preset time intervals within the current cycle.
  • the preset time may be less than one cycle, or may be equal to one cycle, and is set based on actual application requirements and is not limited here.
  • the preset time is set to m.
  • the hardware device continues to write the hit table from the time point at which the hit table is written to the time point m until the time point m, the multiple target identification bits written during this period are sent to the driver software.
  • the multiple target identification bits written between time point m and time point 2m are sent to the driver software; or, at the next time point 2m, the multiple target identification bits written between time point 0 and time point 2m are sent to the driver software.
  • the hardware device when sending a hit table to the driver software, can segment the multiple identification bits in the hit table in the current cycle according to a preset length after writing each identification bit in the hit table of the current cycle, and send the segmented multiple identification bit segments to the driver software of the smart network card.
  • each identification bit segment includes at least one identification bit.
  • the hit table with completed records is segmented according to the length of 2k identification bits as a segment, and multiple hit table segments consisting of 2k identification bits are obtained, and then the hit table segments are sent to the driver software in sequence, or sent to the driver software in batches.
  • the embodiment of the present application periodically records the hit records of multiple flow tables and generates a hit table for each flow table;
  • the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
  • the hit table in the current cycle is sent to the driver software of the smart network card, so that the driver software determines the target flow table to be aged; in response to the aging instruction sent by the driver software, the target flow table is deleted.
  • the driver software can obtain the hit records of multiple flow tables with only a few interactions with the hardware device (far less than the number of flow tables), thereby making aging judgments on each flow table, greatly reducing the number and time of interactions between the driver software and the hardware device.
  • FIG. 3 shows a flowchart of another method for aging a software flow table according to an embodiment of the present application. The method is applied to the driver software of the smart network card, as shown in FIG. 3 , including:
  • Step S301 receiving a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit.
  • the driver software of the smart network card receives a hit table of hit records of each flow table in the current cycle sent by the hardware device, and performs aging judgment on each flow table based on the hit table.
  • the hit table may be in the form of a bit table.
  • Bit is the smallest unit of data in current computer systems.
  • a data structure that uses a bit array to store specific data can be called a bit table.
  • the value of a bit is usually 0 or 1.
  • a bit value of 0 indicates that the corresponding flow table is not hit and may need to be aged.
  • a bit value of 1 indicates that the corresponding flow table is hit and does not need to be aged.
  • the driver software receives the hit list sent by the hardware device through the data plane development kit module.
  • the data plane development kit module refers to a collection of libraries and drivers for fast packet processing configured by the virtual switch.
  • the data plane development kit module includes an aging thread and an unloading thread.
  • the aging thread is used to receive the hit table and perform aging judgment, and the unloading thread is used to delete the target flow table to be aged in the driver software.
  • the driver software When receiving the hit list sent by the hardware device, the driver software first drives the aging thread, and the aging thread polls the system and calls the corresponding interface to receive the hit list.
  • Step S302 Determine the target flow table to be aged based on the values of multiple identification bits of the hit table in the current cycle.
  • the driver software of the smart network card After receiving the hit table, the driver software of the smart network card obtains the value of each identification bit in the hit table and determines the target flow table. For example, the flow table corresponding to the identification bit value of 0 is determined as the target flow table.
  • the target flow table may also be determined from the flow table corresponding to the value of the flag bit being 1.
  • the last use time of the corresponding flow table can be updated based on the value of each identification bit, and the difference between the last use time of each flow table and the current time can be calculated, and the flow table whose difference exceeds the aging threshold is determined as the target flow table to be aged.
  • the number of the target flow table may be sent to the unloading thread to perform the aging operation.
  • Step S303 Send an aging instruction to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
  • the driver software After the driver software determines the target flow table to be aged, it sends an aging instruction to the hardware device, the aging instruction is used to instruct the hardware device to perform aging of the target flow table to be aged.
  • the aging instruction at least includes the target flow table to be aged. The ID of the target flow table.
  • the offload thread sends an aging instruction to the hardware device.
  • the hardware device After receiving the aging instruction, the hardware device obtains the number of the target flow table to be aged contained in the aging instruction, and retrieves the target flow table based on the number for deletion.
  • FIG. 4 shows a flowchart of steps of determining a target flow table to be aged in a software flow table aging method according to another embodiment of the present application, as shown in FIG. 4 , including:
  • Step S401 determine the flow table corresponding to the second preset value of the flag as a candidate flow table, and determine the last use time of the candidate flow table.
  • the second preset value is 0.
  • the driver software of the smart network card After receiving the hit table of each flow table in the current cycle, the driver software of the smart network card obtains multiple identification bits in the hit table and determines a candidate flow table based on the value of the corresponding identification bit.
  • the candidate flow table refers to a candidate flow table to be aged.
  • the flow table whose corresponding identification bit value is 0 is determined as the candidate flow table. If the value of the flow table corresponding identification bit is 0, it means that the flow table has not been hit in the current cycle, so aging judgment is required.
  • Step S402 Determine the target flow table based on the difference between the last use time of the candidate flow table and the current time.
  • the last use time of each candidate flow table is obtained, and the difference between the last use time of each candidate flow table and the current time is calculated.
  • the candidate flow table is determined as a target flow table to be aged.
  • the last usage time of each flow table is determined in the following manner, including: when the value of the corresponding identification bit of the flow table is a first preset value, updating the last usage time of the flow table; when the value of the corresponding identification bit of the flow table is a second preset value, using the last usage time of the most recent update of the flow table as the last usage time; wherein the first preset value is different from the second preset value.
  • the first preset value may be 1, and the second preset value may be 0.
  • updating the last use time of the flow table includes:
  • the driver software updates the last use time of the target flow table.
  • the driver software queries the receiving time when the hit table of the flow table is received, and then updates the receiving time to the last use time of the flow table.
  • the flow table is G
  • the received hit table contains the identification bit written to the flow table G
  • its receiving time s is recorded, and s is used as the last use time of the flow table G.
  • determining the target flow table based on the difference between the last use time of the candidate flow table and the current time includes:
  • the candidate flow table whose difference exceeds the aging threshold is determined as the target flow table.
  • the candidate flow table is determined as a target flow table to be aged.
  • the target flow table to be aged is aged.
  • the flow table aging method further includes: adding the target flow table to an aging list, the aging list being used to store numbers of flow tables to be aged in the driver software;
  • Both the hardware device and driver software of the smart network card store multiple flow tables.
  • driver software not only stores the same flow table as the hardware device, but also can store flow tables that are not stored in the hardware device.
  • the aging thread of the driver software determines the target flow table to be aged, it adds the number of the target flow table to the aging list.
  • the aging list may store the numbers of one or more target flow tables to be aged.
  • the aging thread sends the aging list to the uninstall thread, and the uninstall thread retrieves the target flow table to be aged contained in the aging list from all flow tables stored in the driver software, and deletes it.
  • the flow table aging method further includes: updating the flow table associated with the target flow table.
  • the uninstall thread of the driver software updates the flow table associated with the deleted target flow table.
  • the updating of the flow table associated with the deleted target flow table may be to release the association relationship between the flow table and the target flow table, or to delete the content corresponding to the target flow table in the associated flow table.
  • the embodiment of the present application receives a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table hits; based on the values of multiple identification bits of the hit table in the current cycle, the target flow table to be aged is determined; an aging instruction is sent to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to age the target flow table.
  • the driver software determines whether the target flow table is hit by the value of the corresponding identification bit, and then updates the last usage time of the target flow table, the target flow table to be aged is determined based on the difference between the last usage time and the current time.
  • the driver software can obtain the usage status of all flow tables after interacting with the hardware device once, and then make an aging judgment, which greatly reduces the number of interactions between the driver software and the hardware device and the time spent on aging judgment.
  • Figure 5 shows an example flow chart of the software flow table aging method of another embodiment of the present application.
  • the data packet arrives at the hardware device and is matched with the flow table.
  • the hardware device records the hit records of each flow table, and when the flow table is matched, the value of the corresponding bit is recorded as 1, and when the flow table is not matched, the value of the corresponding bit is recorded as 0.
  • a hit table is generated, which includes multiple bits, each bit corresponding to a flow table, and the hit table is sent to the data plane development kit module of the driver software.
  • the driver software data plane development kit module drives the aging thread.
  • the aging thread determines the last usage time of each flow table based on the values of multiple bits of the hit table in the current cycle.
  • the last use time of the first flow table is updated; for the second flow table corresponding to the value of the identification bit is 0, the last use time of the second flow table's most recent update is used as the last use time of the second flow table.
  • the aging thread queries the hit table received in the current cycle for the receiving time corresponding to the first flow table, and then updates the last use time of the first flow table to the receiving time.
  • the last use time of the second flow table is queried and the difference between the last use time of the second flow table and the current time is calculated.
  • the second flow table is determined to be a target flow table that needs to be aged, and the number of the target flow table is added to the aging list.
  • the aging thread sends the aging list to the uninstallation thread, so that the uninstallation thread performs the aging operation.
  • the offloading thread sends an aging instruction to the hardware device, where the aging instruction is used to instruct the hardware device to perform aging of the target flow table to be aged.
  • the hardware device After receiving the aging instruction, the hardware device deletes the target flow table to be aged.
  • the uninstall thread retrieves the target flow table to be aged from all flow tables stored in the driver software, deletes it, and then updates the flow table associated with the deleted target flow table.
  • FIG. 6 shows a schematic diagram of the structure of a hardware flow table aging device according to an embodiment of the present application, the device is applied to a hardware device of a smart network card, and includes:
  • a generating module 601 is used to periodically record hit records of multiple flow tables and generate a hit table for each flow table;
  • the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
  • the hit table sending module 602 is used to send the hit table in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged;
  • the deleting module 603 is used to delete the target flow table in response to the aging instruction sent by the driver software.
  • the deletion module 603 includes:
  • the target processing module is used to perform target processing on the hit table generated in the current cycle to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
  • the generating module 601 includes:
  • the writing module is used to record the hit status of each flow table in turn in the current cycle, and write the hit status of each flow table into the corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit status of the flow table.
  • the hit list sending module 602 includes:
  • a first sending submodule is used to send the current hit table to the driver software of the smart network card at preset intervals within the current cycle;
  • the second sending submodule is used to segment multiple identification bits in the hit table in the current cycle according to a preset length after the writing of each identification bit in the hit table in the current cycle is completed, and send the multiple identification bit segments obtained by segmentation to the driver software of the smart network card; wherein each identification bit segment includes at least one identification bit.
  • FIG. 7 shows a schematic diagram of the structure of another software flow table aging device according to an embodiment of the present application.
  • Figure 1 shows the driver software of the device applied to the smart network card, including:
  • the receiving module 701 is used to receive the hit table in the current cycle sent by the hardware device of the smart network card;
  • the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
  • a determination module 702 configured to determine a target flow table to be aged based on values of multiple identification bits of the hit table in a current cycle
  • the instruction sending module 703 is used to send an aging instruction to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
  • the device further includes:
  • An adding module is used to add the target flow table to the aging list, and the aging list is used to store the numbers of the flow tables to be aged in the driver software;
  • a first deletion submodule used for deleting a target flow table in the driver software
  • the device further includes:
  • the update module is used to update the flow table associated with the target flow table.
  • the determination module 702 includes:
  • a first determination submodule is used to determine a flow table corresponding to a preset value of a flag bit as a candidate flow table, and determine the last use time of the candidate flow table;
  • a second determination submodule configured to determine a target flow table based on a difference between the last use time of the candidate flow table and the current time
  • the first determining submodule includes:
  • a first updating submodule configured to update the last usage time of the flow table when the value of the corresponding identification bit of the flow table is a first preset value
  • the second updating submodule is used to use the last usage time of the most recent update of the flow table as the last usage time when the value of the corresponding identification bit of the flow table is a second preset value; wherein the first preset value is different from the second preset value.
  • the first updating submodule includes:
  • a query submodule is used to query the reception time when the hit table of the flow table is received
  • the last used time update submodule is used to update the last used time of the flow table to the receiving time.
  • the second determining submodule includes:
  • the target flow table determination submodule is used to determine the candidate flow table whose difference exceeds the aging threshold as the target flow table.
  • an embodiment of the present application further provides an electronic device, including:
  • a processor a memory, and a computer program stored in the memory and executable on the processor.
  • the processor executes the program, the hardware flow table aging method of any one of the above-mentioned embodiments 1 is implemented, or the software flow table aging method of any one of the above-mentioned embodiments 2 is implemented.
  • an embodiment of the present application also provides a computer-readable storage medium, including: when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the hardware flow table aging method of any one of the above-mentioned embodiments one, or execute the software flow table aging method of any one of the above-mentioned embodiments two.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Stored Programmes (AREA)

Abstract

The present application belongs to the technical field of smart network interface cards, and provides a hardware flow table aging method and apparatus, a software flow table aging method and apparatus, and an electronic device. The method comprises: periodically recording hit records of a plurality of flow tables, and generating a hit table of each flow table, wherein the hit table comprises a plurality of flag bits, each flag bit corresponds to one flow table, and the value of the flag bit is used for representing whether the corresponding flow table is hit or not; sending the hit table in the current period to driver software of a smart network interface card, so as to drive the driver software to determine a target flow table to be aged; and in response to a received aging instruction, deleting the target flow table. Therefore, hit records of a plurality of flow tables can be acquired after driver software and a hardware device performs interaction only a few times, so that determination about aging of the flow table can be performed, the number of times of interaction between the driver software and the hardware device is reduced, the interaction time consumption caused thereby is reduced, and the efficiency is improved.

Description

硬件流表老化方法、软件流表老化方法、装置及电子设备Hardware flow table aging method, software flow table aging method, device and electronic equipment
本申请要求在2023年03月06日提交中国专利局、申请号为202310205465.X、发明名称为“硬件流表老化方法、软件流表老化方法、装置及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed with the China Patent Office on March 6, 2023, with application number 202310205465.X, and invention name “Hardware flow table aging method, software flow table aging method, device and electronic device”, the entire contents of which are incorporated by reference in this application.
技术领域Technical Field
本申请涉及智能网卡技术领域,特别是涉及一种硬件流表老化方法、软件流表老化方法、装置及电子设备。The present application relates to the technical field of smart network cards, and in particular to a hardware flow table aging method, a software flow table aging method, a device and an electronic device.
背景技术Background Art
智能网卡的硬件设备和驱动软件中存在流表,当数据包匹配硬件设备中的流表失败时,会上送到驱动软件生成新的流表规则。当连接无效空闲或者连接断开时,则需要通过老化的方式删除长期不使用的流表以释放硬件设备的空间。There are flow tables in the hardware and driver software of the smart network card. When a data packet fails to match the flow table in the hardware device, it will be sent to the driver software to generate new flow table rules. When the connection is invalid or disconnected, it is necessary to delete the flow table that has not been used for a long time through aging to free up space on the hardware device.
目前的流表老化主要由两种方式实现:Currently, flow table aging is mainly achieved in two ways:
第一种,由硬件设备计算以确定待老化的流表,由驱动软件执行老化操作。第二种,由硬件设备记录流表的使用情况,驱动软件与硬件设备交互获取该流表的使用情况后进行计算以确定该流表是否需要老化。该种方法下,驱动软件每一次与硬件设备交互仅能够获取一个流表的使用情况。The first method is that the hardware device calculates to determine the flow table to be aged, and the driver software performs the aging operation. The second method is that the hardware device records the usage of the flow table, and the driver software interacts with the hardware device to obtain the usage of the flow table and then calculates to determine whether the flow table needs to be aged. In this method, the driver software can only obtain the usage of one flow table each time it interacts with the hardware device.
这就导致目前的流表老化一方面对硬件设备复杂度要求较高,另一方面驱动软件对每一个流表老化的判断都要与硬件设备交互一次,交互次数较多、耗时较长。As a result, the current flow table aging has high requirements on the complexity of hardware devices. On the other hand, the driver software must interact with the hardware device once for each flow table aging judgment, and the number of interactions is large and time-consuming.
发明内容Summary of the invention
有鉴于此,本申请旨在提出一种硬件流表老化方法、软件流表老化方法、装置及电子设备,以解决目前的流表老化时驱动软件与硬件设备交互次数较多、耗时较长的问题。In view of this, the present application aims to propose a hardware flow table aging method, a software flow table aging method, an apparatus and an electronic device to solve the current problem that the driver software and the hardware device interact frequently and time-consumingly during flow table aging.
为达到上述目的,本申请的技术方案是这样实现的:To achieve the above purpose, the technical solution of this application is implemented as follows:
一种硬件流表老化方法,应用于智能网卡的硬件设备,包括:A hardware flow table aging method is applied to a hardware device of a smart network card, comprising:
周期性记录硬件设备中多个流表的命中记录,并基于命中记录生成各个流表的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中; Periodically record the hit records of multiple flow tables in the hardware device, and generate a hit table for each flow table based on the hit records; the hit table contains multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
将当前周期内生成的命中表发送至智能网卡的驱动软件,以驱动驱动软件确定待老化的目标流表;Sending the hit table generated in the current cycle to the driver software of the smart network card to drive the driver software to determine the target flow table to be aged;
响应于驱动软件发送的老化指令,对目标流表进行删除。In response to the aging instruction sent by the driver software, the target flow table is deleted.
可选地,在将当前周期内生成的命中表发送至智能网卡的驱动软件之后,方法还包括:Optionally, after sending the hit table generated in the current cycle to the driver software of the smart network card, the method further includes:
对当前周期内生成的命中表进行目标处理,以进行下一个周期中多个流表的命中情况的记录;其中,目标处理包括对当前周期内的命中表的删除,或对当前周期内的命中表中的标识位的初始化。The hit table generated in the current cycle is subjected to target processing to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
可选地,标识位为比特位。Optionally, the identification bit is a bit.
可选地,周期性记录硬件设备中多个流表的命中记录,包括:Optionally, periodically record hit records of multiple flow tables in the hardware device, including:
在当前周期内,依次记录每个流表的命中情况,并将各个流表的命中情况写入当前周期的命中表的对应标识位,以使标识位的值表征流表的命中情况;In the current cycle, the hit situation of each flow table is recorded in turn, and the hit situation of each flow table is written into the corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit situation of the flow table;
将当前周期内生成的命中表发送至智能网卡的驱动软件,包括:Send the hit table generated in the current cycle to the driver software of the smart network card, including:
在当前周期内,每间隔预设时间,将当前的命中表发送给智能网卡的驱动软件;In the current cycle, the current hit list is sent to the driver software of the smart network card at every preset time interval;
或,or,
在当前周期内的命中表中各个标识位写入完成后,将当前周期内的命中表中的多个标识位按照预设长度进行分段,将分段得到的多个标识位段发送至智能网卡的驱动软件;After each identification bit in the hit table in the current cycle is written, multiple identification bits in the hit table in the current cycle are segmented according to a preset length, and multiple identification bit segments obtained by segmentation are sent to the driver software of the smart network card;
其中,每个标识位段包括至少一个标识位。Each identification bit segment includes at least one identification bit.
相对于现有技术,本申请的硬件流表老化方法具有以下优势:Compared with the prior art, the hardware flow table aging method of the present application has the following advantages:
本申请通过周期性记录多个流表的命中记录,并生成各个流表的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中;将当前周期内的命中表发送至智能网卡的驱动软件,以驱动驱动软件确定待老化的目标流表;响应于驱动软件发送的老化指令,对目标流表进行删除。The present application periodically records the hit records of multiple flow tables and generates a hit table for each flow table; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit; the hit table in the current cycle is sent to the driver software of the smart network card to drive the driver software to determine the target flow table to be aged; in response to the aging instruction sent by the driver software, the target flow table is deleted.
由于硬件设备记录多个流表的命中表发送至驱动软件,使得驱动软件与硬件设备进行少数几次交互便可以获取到多个流表的命中记录,以此进行各个流表的老化判断,大大减少了驱动软件与硬件设备之间的交互次数和引起所产生的交互耗时,从而提高了效率。Since the hardware device records the hit tables of multiple flow tables and sends them to the driver software, the driver software can obtain the hit records of multiple flow tables after only a few interactions with the hardware device, so as to make aging judgments on each flow table, which greatly reduces the number of interactions between the driver software and the hardware device and the time spent on the interactions, thereby improving efficiency.
本申请的另一目的在于提供一种软件流表老化方法,以解决目前的流表老化 时驱动软件与硬件设备交互次数较多、耗时较长的问题。Another purpose of this application is to provide a software flow table aging method to solve the current flow table aging problem. The problem is that the driver software interacts with the hardware device frequently and takes a long time.
为达到上述目的,本申请的技术方案是这样实现的:To achieve the above purpose, the technical solution of this application is implemented as follows:
一种软件流表老化方法,应用于智能网卡的驱动软件,包括:A software flow table aging method is applied to driver software of an intelligent network card, comprising:
接收智能网卡的硬件设备发送的当前周期内的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中;Receive the hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
基于当前周期内的命中表的多个标识位的值,确定待老化的目标流表;Determine a target flow table to be aged based on values of multiple identification bits of the hit table in the current cycle;
向智能网卡的硬件设备发送老化指令,老化指令用于指示硬件设备进行目标流表的老化。An aging instruction is sent to the hardware device of the smart network card, where the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
可选地,方法还包括:Optionally, the method further comprises:
将目标流表添加至老化列表,老化列表用于存储驱动软件中待老化的流表的编号;Add the target flow table to the aging list, which is used to store the numbers of the flow tables to be aged in the driver software;
将位于驱动软件中的目标流表进行删除。Delete the target flow table in the driver software.
可选地,方法还包括:Optionally, the method further comprises:
对目标流表所关联的流表进行更新。Update the flow table associated with the target flow table.
可选地,基于当前周期内的命中表的多个标识位的值,确定待老化的目标流表,包括:Optionally, based on the values of multiple identification bits of the hit table in the current cycle, determining the target flow table to be aged includes:
将标识位的值为第二预设值所对应的流表确定为候选流表,并确定候选流表的最后使用时间;Determine the flow table corresponding to the second preset value of the flag bit as a candidate flow table, and determine the last use time of the candidate flow table;
基于候选流表的最后使用时间与当前时间的差值,确定目标流表。The target flow table is determined based on the difference between the last use time of the candidate flow table and the current time.
可选地,各个流表的最后使用时间是通过以下方式确定的,包括:Optionally, the last use time of each flow table is determined by:
在流表对应标识位的值为第一预设值的情况下,更新流表的最后使用时间;When the value of the flag corresponding to the flow table is the first preset value, updating the last use time of the flow table;
在流表对应标识位的值为第二预设值的情况下,将流表最近一次更新的最后使用时间作为最后使用时间;When the value of the flag corresponding to the flow table is the second preset value, the last use time of the most recent update of the flow table is used as the last use time;
其中,第一预设值与第二预设值不同。The first preset value is different from the second preset value.
可选地,更新流表的最后使用时间,包括:Optionally, update the last used time of the flow table, including:
查询接收到流表的命中表时的接收时刻;Query the receiving time when the hit table of the flow table is received;
将流表的最后使用时间更新为接收时刻。Update the last usage time of the flow table to the receiving time.
可选地,基于候选流表的最后使用时间与当前时间的差值,确定目标流表,包括:Optionally, determining the target flow table based on the difference between the last use time of the candidate flow table and the current time includes:
将差值超过老化阈值的候选流表,确定为目标流表。The candidate flow table whose difference exceeds the aging threshold is determined as the target flow table.
软件流表老化方法与上述的硬件流表老化方法相对于现有技术所具有的优 势相同,在此不做赘述。The advantages of the software flow table aging method over the above hardware flow table aging method over the prior art are: The situation is the same, so I won’t go into details here.
本申请的另一目的在于提出一种硬件流表老化装置,以解决目前的流表老化时驱动软件与硬件设备交互次数较多、耗时较长的问题。Another object of the present application is to provide a hardware flow table aging device to solve the problem that the current flow table aging has a large number of interactions between the driver software and the hardware device and takes a long time.
为达到上述目的,本申请的技术方案是这样实现的:To achieve the above purpose, the technical solution of this application is implemented as follows:
一种硬件流表老化装置,应用于智能网卡的硬件设备,包括:A hardware flow table aging device, applied to a hardware device of a smart network card, comprises:
生成模块,用于周期性记录多个流表的命中记录,并生成各个流表的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中;A generation module is used to periodically record hit records of multiple flow tables and generate a hit table for each flow table; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
命中表发送模块,用于将当前周期内的命中表发送至智能网卡的驱动软件,以驱动驱动软件确定待老化的目标流表;A hit table sending module, used to send the hit table in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged;
删除模块,用于响应于驱动软件发送的老化指令,对目标流表进行删除。The deletion module is used to delete the target flow table in response to the aging instruction sent by the driver software.
硬件流表老化装置与上述的硬件流表老化方法相对于现有技术所具有的优势相同,在此不做赘述。The hardware flow table aging device has the same advantages as the above-mentioned hardware flow table aging method over the prior art, which will not be described in detail here.
本申请的另一目的在于提出一种软件流表老化装置,以解决目前的流表老化时驱动软件与硬件设备交互次数较多、耗时较长的问题。Another object of the present application is to provide a software flow table aging device to solve the problem that the current flow table aging has a large number of interactions between the driver software and the hardware device and takes a long time.
为达到上述目的,本申请的技术方案是这样实现的:To achieve the above purpose, the technical solution of this application is implemented as follows:
一种软件流表老化装置,应用于智能网卡的驱动软件,包括:A software flow table aging device is applied to the driver software of an intelligent network card, comprising:
接收模块,用于接收智能网卡的硬件设备发送的当前周期内的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中;A receiving module is used to receive a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
确定模块,用于基于当前周期内的命中表的多个标识位的值,确定待老化的目标流表;A determination module, used to determine a target flow table to be aged based on the values of multiple identification bits of the hit table in the current cycle;
指令发送模块,用于向智能网卡的硬件设备发送老化指令,老化指令用于指示硬件设备进行目标流表的老化。The instruction sending module is used to send an aging instruction to the hardware device of the smart network card, and the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
软件流表老化装置与上述的硬件流表老化方法相对于现有技术所具有的优势相同,在此不做赘述。The advantages of the software flow table aging device and the above-mentioned hardware flow table aging method over the prior art are the same, and will not be described in detail here.
本申请的另一目的在于提出一种电子设备,以解决目前的流表老化时驱动软件与硬件设备交互次数较多、耗时较长的问题。Another object of the present application is to provide an electronic device to solve the current problem that when the flow table is aged, the driver software and the hardware device interact frequently and time-consumingly.
为达到上述目的,本申请的技术方案是这样实现的:To achieve the above purpose, the technical solution of this application is implemented as follows:
一种电子设备,包括:An electronic device, comprising:
处理器、存储器以及存储在存储器上并可在处理器上运行的计算机程序,处 理器执行程序时实现上述任一项的硬件流表老化方法,或实现上述任一项的软件流表老化方法。A processor, a memory, and a computer program stored in the memory and executable on the processor, When the processor executes the program, any of the above hardware flow table aging methods is implemented, or any of the above software flow table aging methods is implemented.
电子设备与上述的硬件流表老化方法相对于现有技术所具有的优势相同,在此不做赘述。The advantages of the electronic device and the above-mentioned hardware flow table aging method over the prior art are the same, which will not be elaborated here.
本申请的另一目的在于提出一种计算机可读存储介质,以解决目前的流表老化时驱动软件与硬件设备交互次数较多、耗时较长的问题。Another object of the present application is to provide a computer-readable storage medium to solve the problem that the number of interactions between the driver software and the hardware device is large and time-consuming when the current flow table is aged.
为达到上述目的,本申请的技术方案是这样实现的:To achieve the above purpose, the technical solution of this application is implemented as follows:
一种计算机可读存储介质,包括:A computer-readable storage medium comprising:
当存储介质中的指令由电子设备的处理器执行时,使得电子设备能够执行上述任一项的硬件流表老化方法,或执行上述任一项的软件流表老化方法。When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any of the above-mentioned hardware flow table aging methods, or execute any of the above-mentioned software flow table aging methods.
计算机可读存储介质与上述的硬件流表老化方法相对于现有技术所具有的优势相同,在此不做赘述。The advantages of the computer-readable storage medium and the above-mentioned hardware flow table aging method over the prior art are the same, which will not be described in detail here.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
构成本申请的一部分的附图用来提供对本申请的进一步理解,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
图1示出了本申请实施例的一种硬件流表老化方法的步骤流程图;FIG1 shows a flowchart of a method for aging a hardware flow table according to an embodiment of the present application;
图2示出了本申请智能网卡的硬件设备生成命中表的流程示例图;FIG2 shows an example diagram of a process for a hardware device of a smart network card of the present application to generate a hit table;
图3示出了本申请实施例的另一种软件流表老化方法的步骤流程图;FIG3 shows a flowchart of another method for aging a software flow table according to an embodiment of the present application;
图4示出了本申请又一实施例的一种软件流表老化方法确定待老化的目标流表步骤流程图;FIG4 shows a flowchart of steps for determining a target flow table to be aged in a software flow table aging method according to another embodiment of the present application;
图5示出了本申请又一实施例的软件流表老化方法流程示例图;FIG5 shows an example flow chart of a software flow table aging method according to another embodiment of the present application;
图6示出了本申请实施例的一种硬件流表老化装置的结构示意图;FIG6 shows a schematic structural diagram of a hardware flow table aging device according to an embodiment of the present application;
图7示出了本申请实施例的另一种软件流表老化装置的结构示意图。FIG. 7 shows a schematic structural diagram of another software flow table aging device according to an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以 相互组合。It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application may be Combine with each other.
智能网卡,也称智能网络适配器,提供网络数据传输功能同时还提供内置的可编程、可配置的硬件加速引擎。数据传输过程中,同一时间、经过同一网络中具有某种共同特征或属性的数据可以称之为一个流。一个或多个特定流的策略表项的集合被称之为流表,流表负责数据包的查找和转发。Smart NIC, also known as intelligent network adapter, provides network data transmission function and also provides built-in programmable and configurable hardware acceleration engine. During data transmission, data with certain common characteristics or attributes passing through the same network at the same time can be called a flow. The collection of policy table entries for one or more specific flows is called a flow table, which is responsible for the search and forwarding of data packets.
智能网卡中硬件设备和驱动软件存储有多个流表,数据传输过程中,数据包首先与硬件设备中的流表进行匹配,在匹配成功的情况下,执行匹配的流表对应的动作(例如转发至特定路径)。在匹配失败的情况下,硬件设备将该数据包发送至驱动软件的开放虚拟交换标准(Open vSwitch,OVS)生成新的流表规则。The hardware device and driver software in the smart network card store multiple flow tables. During data transmission, the data packet is first matched with the flow table in the hardware device. If the match is successful, the action corresponding to the matched flow table is executed (for example, forwarding to a specific path). If the match fails, the hardware device sends the data packet to the open virtual switching standard (Open vSwitch, OVS) of the driver software to generate a new flow table rule.
开放网络通信协议(OpenFlow)是一种新型网络通信协议,应用于软件定义网络架构中控制器和转发器之间的通信。软件定义网络的一个核心思想就是“转发、控制分离”,要实现转、控分离,就需要在控制器与转发器之间建立一个通信接口标准,允许控制器直接访问和控制转发器的转发平面。开放网络通信协议(OpenFlow)协议架构由控制器、交换机、以及安全通道组成,控制器通过接口在转发器上部署相应的流表,转发器通过流表来指导数据包的转发,从而实现对转发平面的控制。OpenFlow is a new network communication protocol used for communication between controllers and forwarders in software-defined network architectures. A core concept of software-defined networks is "separation of forwarding and control". To achieve separation of forwarding and control, it is necessary to establish a communication interface standard between the controller and the forwarder, allowing the controller to directly access and control the forwarding plane of the forwarder. The OpenFlow protocol architecture consists of a controller, a switch, and a secure channel. The controller deploys the corresponding flow table on the forwarder through the interface, and the forwarder guides the forwarding of data packets through the flow table, thereby achieving control over the forwarding plane.
开放虚拟交换标准(Open vSwitch,OVS)是指支持多层数据转发的虚拟交换机,适用于开放网络通信协议(OpenFlow)。Open vSwitch (OVS) is a virtual switch that supports multi-layer data forwarding and is suitable for the open network communication protocol (OpenFlow).
在连接无效、空闲或者断开的情况下,智能网卡硬件设备的流表需要通过老化的方式删除长期不使用的流表,以释放空间。When the connection is invalid, idle or disconnected, the flow table of the smart network card hardware device needs to delete the flow table that has not been used for a long time through aging to free up space.
现有技术中流表老化方式主要包括如下两种:There are two main flow meter aging methods in the prior art:
第一种,硬件设备对流表使用情况进行统计、以及运算,确定出待老化的流表后将该流表添加到老化队列,然后将老化队列发送至驱动软件,由驱动软件执行老化操作。First, the hardware device counts and calculates the usage of the flow table, determines the flow table to be aged, adds the flow table to the aging queue, and then sends the aging queue to the driver software, which performs the aging operation.
此种方式由于通过硬件设备完成流表的老化判断,需要进行时间和周期要求的运算,增加了硬件设备的复杂度。This method uses hardware devices to complete the aging judgment of the flow table, which requires calculations with time and cycle requirements, increasing the complexity of the hardware devices.
第二种,硬件设备对流表使用情况进行统计,驱动软件周期性从硬件获取各个流表的报文统计判断是否有报文命中,然后进行运算确定出待老化的流表后执行老化操作。The second method is that the hardware device counts the usage of the flow table, and the driver software periodically obtains the message statistics of each flow table from the hardware to determine whether there is a message hit, and then performs calculations to determine the flow table to be aged and executes the aging operation.
此种方式中,驱动软件与硬件交互一次只能获取一个流表的使用情况,如此,硬件设备上有多少流表就需要与硬件设备交互相应的次数。并且老化流程需要周 期性地判定所有流表是否需要老化,与硬件交互次数较多,耗时较长。In this way, the driver software can only obtain the usage of one flow table at a time when interacting with the hardware. Therefore, the number of interactions with the hardware device corresponds to the number of flow tables on the hardware device. Periodically determine whether all flow tables need to be aged, which requires more interactions with the hardware and takes a long time.
有鉴于此,本申请实施例提供一种硬件实现简单、且交互次数少的一种流表老化方法,以提高流表老化效率。In view of this, an embodiment of the present application provides a flow table aging method with simple hardware implementation and a small number of interactions, so as to improve the efficiency of flow table aging.
参照图1,图1示出了本申请实施例的一种硬件流表老化方法的步骤流程图,该方法应用于智能网卡的硬件设备,如图1,包括:Referring to FIG. 1 , FIG. 1 shows a flowchart of the steps of a hardware flow table aging method according to an embodiment of the present application. The method is applied to a hardware device of a smart network card, as shown in FIG. 1 , and includes:
步骤S101:周期性记录硬件设备中多个流表的命中记录,并基于命中记录生成各个流表的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中。Step S101: periodically record the hit records of multiple flow tables in the hardware device, and generate a hit table for each flow table based on the hit records; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit.
在本申请的实施例中,智能网卡的硬件设备周期性地记录各个流表的命中记录,生成各个流表的命中表并存储。硬件设备在固定路径下存储有命中表,在生成当前周期内各个流表的命中记录时,将存储的命中表的对应标识位进行更新。In an embodiment of the present application, the hardware device of the smart network card periodically records the hit records of each flow table, generates and stores the hit table of each flow table. The hardware device stores the hit table under a fixed path, and when generating the hit records of each flow table in the current cycle, the corresponding identification bit of the stored hit table is updated.
硬件设备判断各个流表是否被命中的标准为:周期内该流表是否与数据包发生匹配,只要该流表与数据包发生匹配则视为该流表被命中。The standard for the hardware device to determine whether each flow table is hit is: whether the flow table matches the data packet within the cycle. As long as the flow table matches the data packet, the flow table is considered to be hit.
命中表包含各个流表是否被命中的命中信息,不包含命中次数信息。The hit table contains hit information of each flow table, but does not contain hit count information.
可以理解地,在一个周期内流表命中次数大于等于一次则记录为被命中;在一个周期内流表命中次数为零次则记录为未被命中。It can be understood that if the number of flow table hits in a cycle is greater than or equal to one, it is recorded as a hit; if the number of flow table hits in a cycle is zero, it is recorded as a miss.
在一种可选的实施例中,标识位为比特位。In an optional embodiment, the identification bit is a bit.
智能网卡的硬件设备记录各个流表的命中记录后,可以生成比特表,比特表中包含多个比特位,每个比特位对应一个流表,各个比特位的值表征对应的流表是否被命中。After recording the hit records of each flow table, the hardware device of the smart network card can generate a bit table, which includes multiple bits, each bit corresponds to a flow table, and the value of each bit represents whether the corresponding flow table is hit.
比特是目前计算机系统里边数据的最小单位。由比特数组来存储特定数据的一种数据结构可以称之为比特表。本申请中的命中表可以视为一种比特表。A bit is the smallest unit of data in a current computer system. A data structure that uses a bit array to store specific data can be called a bit table. The hit table in this application can be regarded as a bit table.
其中,命中表中每个标识位,即比特位的值通常为0或1。其中,比特位的值为0则表征对应的流表未被命中,比特位的值为1则表明对应的流表被命中。The value of each identification bit in the hit table, that is, the bit is usually 0 or 1. The value of the bit is 0, which indicates that the corresponding flow table is not hit, and the value of the bit is 1, which indicates that the corresponding flow table is hit.
硬件设备在记录当前周期内的各个流表的命中记录时,流表命中次数大于等于一次则在命中表中将其对应的比特位的值记录为1;流表命中次数为零次则在命中表中将其对应的比特位的值记录为0。When the hardware device records the hit records of each flow table in the current cycle, if the flow table hit count is greater than or equal to one, the corresponding bit value in the hit table is recorded as 1; if the flow table hit count is zero, the corresponding bit value in the hit table is recorded as 0.
在一种可选的实施例中,一个周期的时间长度为微秒~毫秒级别。In an optional embodiment, the duration of one cycle is in the range of microseconds to milliseconds.
智能网卡记录各个流表的命中记录的一个周期的时间长度为微秒~毫秒级别。The length of a cycle for the smart network card to record hit records of each flow table is in the microsecond to millisecond level.
参照图2,图2示出了本申请智能网卡的硬件设备生成命中表的流程示例图,如图2所示,在智能网卡发生数据传输时,数据包到达硬件设备,与硬件设备中 的多个流表进行匹配。在数据包与流表匹配后,硬件设备记录该流表的命中记录,生成命中表并更新命中表中对应的标识位的值。Referring to FIG. 2 , FIG. 2 shows an example flow chart of the hardware device of the smart network card of the present application generating a hit table. As shown in FIG. 2 , when data transmission occurs in the smart network card, the data packet arrives at the hardware device and the hardware device After the data packet matches the flow table, the hardware device records the hit record of the flow table, generates a hit table and updates the value of the corresponding identification bit in the hit table.
示例地,数据包与某一流表匹配,则硬件设备可以以比特表的形式进行命中记录,将该流表对应的比特位的值记录为1,其他并未匹配的流表对应的比特位的值记录为0。将当前周期内所有流表均记录完成的比特表作为当前周期内的命中表。For example, if a data packet matches a certain flow table, the hardware device can record the hit in the form of a bit table, record the value of the bit corresponding to the flow table as 1, and record the value of the bit corresponding to other unmatched flow tables as 0. The bit table in which all flow tables in the current cycle are recorded is used as the hit table in the current cycle.
然后执行步骤S102。Then execute step S102.
步骤S102:将当前周期内生成的命中表发送至智能网卡的驱动软件,以驱动驱动软件确定待老化的目标流表。Step S102: Send the hit table generated in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged.
硬件设备完成一个周期内的各个流表命中记录的记录后,将生成的命中表发送至驱动软件,驱动软件基于该命中表进行计算以确定出待老化的目标流表。其中,目标流表是未被命中的流表。After the hardware device completes recording the hit records of each flow table in a cycle, it sends the generated hit table to the driver software, and the driver software performs calculations based on the hit table to determine the target flow table to be aged, wherein the target flow table is a flow table that has not been hit.
示例地,硬件设备以比特表的形式记录各个流表的命中记录,完成一个周期内的记录后,将对应多个流表的多个比特位按照N个一组的形式进行分割,得到一个或多个比特表,并将一个或多个比特表发送至驱动软件。For example, the hardware device records the hit records of each flow table in the form of a bit table. After completing the recording within a cycle, the multiple bits corresponding to the multiple flow tables are divided into groups of N to obtain one or more bit tables, and the one or more bit tables are sent to the driver software.
在一种具体实现中,硬件设备将命中表发送至驱动软件的数据平面开发套件模块(Data Plane Development Kit,DPDK)。数据平面开发套件是指虚拟交换机所配置的报文快速处理的库和驱动的集合。In a specific implementation, the hardware device sends the hit list to the Data Plane Development Kit (DPDK) module of the driver software. The Data Plane Development Kit refers to a collection of libraries and drivers for fast packet processing configured by the virtual switch.
在一种具体实现中,可以将命中表中多个比特位按照8个一组的形式进行分割。In a specific implementation, multiple bits in the hit table may be divided into groups of 8.
驱动软件接收到命中表后,基于各个流表的命中记录,对各个流表的最后使用时间与当前时间的差值进行计算,确定出该差值超过老化阈值的流表,将这些流表作为待老化的目标流表。After receiving the hit table, the driver software calculates the difference between the last use time and the current time of each flow table based on the hit records of each flow table, determines the flow tables whose difference exceeds the aging threshold, and uses these flow tables as target flow tables to be aged.
确定出待老化的目标流表后,驱动软件向硬件设备发送老化指令。该老化指令用于指示硬件设备进行待老化的目标流表的老化,老化指令中至少包括待老化的目标流表的编号。After determining the target flow table to be aged, the driver software sends an aging instruction to the hardware device. The aging instruction is used to instruct the hardware device to perform aging on the target flow table to be aged, and the aging instruction at least includes the number of the target flow table to be aged.
然后执行步骤S103。Then execute step S103.
步骤S103:响应于驱动软件发送的老化指令,对目标流表进行删除。Step S103: In response to the aging instruction sent by the driver software, the target flow table is deleted.
硬件设备接收驱动软件发送的老化指令后,获取老化指令中包含的待老化的目标流表的编号,基于该编号调取出目标流表,并将其从硬件设备中删除。After receiving the aging instruction sent by the driver software, the hardware device obtains the number of the target flow table to be aged contained in the aging instruction, retrieves the target flow table based on the number, and deletes it from the hardware device.
在一种可选的实施例中,将当前周期内生成的命中表发送至智能网卡的驱动 软件之后,本申请实施例提供的硬件流表老化方法还包括:In an optional embodiment, the hit table generated in the current cycle is sent to the driver of the smart network card. After the software, the hardware flow table aging method provided in the embodiment of the present application further includes:
对当前周期内生成的命中表进行目标处理,以进行下一个周期中多个流表的命中情况的记录;其中,目标处理包括对当前周期内的命中表的删除,或对当前周期内的命中表中的标识位的初始化。The hit table generated in the current cycle is subjected to target processing to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
智能网卡的硬件设备将当前周期内生成的命中表发送至驱动软件后,对当前周期内生成的命中表进行目标处理,以便进行下一个周期的记录。After the hardware device of the smart network card sends the hit table generated in the current cycle to the driver software, the hit table generated in the current cycle is processed in a targeted manner so as to record in the next cycle.
其中,目标处理是删除处理的情况下,硬件设备可以将当前周期内生成的命中表删除,在进行下一个周期的记录时生成新的命中表,并在新的命中表的标识位中写入对应的流表的命中情况。Among them, when the target processing is deletion processing, the hardware device can delete the hit table generated in the current cycle, generate a new hit table when recording the next cycle, and write the hit status of the corresponding flow table in the identification bit of the new hit table.
其中,目标处理是初始化处理的情况下,硬件设备可以将当前周期内生成的命中表的标识位进行初始化,也就是将当前周期内生成的命中表中标识位的值统一初始化为目标值,如0,而保留命中表的表格,在进行下一个周期的记录时,在该初始化后的命中表的标识位重新写入对应的流表的命中情况。Among them, when the target processing is initialization processing, the hardware device can initialize the identification bits of the hit table generated in the current cycle, that is, initialize the values of the identification bits in the hit table generated in the current cycle to the target value, such as 0, and retain the table of the hit table. When recording the next cycle, rewrite the hit status of the corresponding flow table in the identification bits of the initialized hit table.
在一种可选的实施例中,周期性记录硬件设备中多个流表的命中记录,包括:在当前周期内,依次记录每个流表的命中情况,并将各个流表的命中情况写入当前周期的命中表的对应标识位,以使标识位的值表征流表的命中情况;In an optional embodiment, periodically recording hit records of multiple flow tables in a hardware device includes: in a current cycle, recording the hit status of each flow table in turn, and writing the hit status of each flow table into a corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit status of the flow table;
将当前周期内生成的命中表发送至智能网卡的驱动软件,包括:Send the hit table generated in the current cycle to the driver software of the smart network card, including:
在当前周期内,每间隔预设时间,将当前的命中表发送给智能网卡的驱动软件;In the current cycle, the current hit list is sent to the driver software of the smart network card at every preset time interval;
或,or,
在当前周期内的命中表中各个标识位写入完成后,将当前周期内的命中表中的多个标识位按照预设长度进行分段,将分段得到的多个标识位段发送至智能网卡的驱动软件;After each identification bit in the hit table in the current cycle is written, multiple identification bits in the hit table in the current cycle are segmented according to a preset length, and multiple identification bit segments obtained by segmentation are sent to the driver software of the smart network card;
其中,每个标识位段包括至少一个标识位。Each identification bit segment includes at least one identification bit.
智能网卡的硬件设备在向驱动软件发送命中表时是分段发送的。The hardware device of the smart network card sends the hit list to the driver software in segments.
可选地,硬件设备在向驱动软件发送命中表时可以采取在当前周期内,每间隔预设时间将当前的命中表发送至驱动软件。Optionally, when sending the hit list to the driver software, the hardware device may send the current hit list to the driver software at preset time intervals within the current cycle.
在一种具体实现中,预设时间可以小于一个周期,也可以等于一个周期,基于实际应用需求设置,在此不做限定。In a specific implementation, the preset time may be less than one cycle, or may be equal to one cycle, and is set based on actual application requirements and is not limited here.
示例地,设定预设时间为m,在当前周期内,硬件设备从开始进行命中表的写入的时间点起,到时间点m的期间持续进行命中表的写入,直到到达时间点 m后,将该期间写入的多个目标标识位发送至驱动软件。到下一个时间点2m,再将从时间点m到时间点2m之间写入的多个目标标识位发送至驱动软件;或者,到下一个时间点2m,再将从时间点0到时间点2m之间写入的多个目标标识位发送至驱动软件。For example, the preset time is set to m. In the current cycle, the hardware device continues to write the hit table from the time point at which the hit table is written to the time point m until the time point m, the multiple target identification bits written during this period are sent to the driver software. At the next time point 2m, the multiple target identification bits written between time point m and time point 2m are sent to the driver software; or, at the next time point 2m, the multiple target identification bits written between time point 0 and time point 2m are sent to the driver software.
可以理解地,此处的示例仅是为了更好地说明本实施例,而非对本申请的唯一限定。It can be understood that the examples here are only for better illustrating the present embodiment, and are not the sole limitation of the present application.
可选地,硬件设备在向驱动软件发送命中表时可以采取在当前周期的命中表各个标识位写入完成后,将当前周期内的命中表中的多个标识位按照预设长度进行分段,将分段得到的多个标识位段发送至智能网卡的驱动软件。Optionally, when sending a hit table to the driver software, the hardware device can segment the multiple identification bits in the hit table in the current cycle according to a preset length after writing each identification bit in the hit table of the current cycle, and send the segmented multiple identification bit segments to the driver software of the smart network card.
预设长度可以基于实际应用需求设置,在此不做限定。在一种具体实现中,每个标识位段至少包括一个标识位。The preset length can be set based on actual application requirements and is not limited here. In a specific implementation, each identification bit segment includes at least one identification bit.
示例地,硬件设备在当前周期的命中表标识位全部写入完成后,也就是所有需要记录命中情况的流表的命中情况记录完成后,对记录完成的命中表按照2k个标识位为一个分段的长度进行分段,得到多个由2k个标识位组成的命中表分段,然后将命中表分段依次发送至驱动软件,或批量发送给驱动软件。For example, after the hardware device has completed writing all the hit table identification bits of the current cycle, that is, after the hit status of all flow tables that need to record the hit status is recorded, the hit table with completed records is segmented according to the length of 2k identification bits as a segment, and multiple hit table segments consisting of 2k identification bits are obtained, and then the hit table segments are sent to the driver software in sequence, or sent to the driver software in batches.
本申请实施例通过周期性记录多个流表的命中记录,并生成各个流表的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中;将当前周期内的命中表发送至智能网卡的驱动软件,以使驱动软件确定待老化的目标流表;响应于驱动软件发送的老化指令,对目标流表进行删除。The embodiment of the present application periodically records the hit records of multiple flow tables and generates a hit table for each flow table; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit; the hit table in the current cycle is sent to the driver software of the smart network card, so that the driver software determines the target flow table to be aged; in response to the aging instruction sent by the driver software, the target flow table is deleted.
由于硬件设备记录多个流表的命中表发送至驱动软件,使得驱动软件与硬件设备交互很少的次数(远小于流表的数量)便可以获取到多个流表的命中记录,以此进行各个流表的老化判断,大大减少了驱动软件与硬件设备之间的交互次数和耗时。Since the hardware device records the hit tables of multiple flow tables and sends them to the driver software, the driver software can obtain the hit records of multiple flow tables with only a few interactions with the hardware device (far less than the number of flow tables), thereby making aging judgments on each flow table, greatly reducing the number and time of interactions between the driver software and the hardware device.
参照图3,图3示出了本申请实施例的另一种软件流表老化方法的步骤流程图,该方法应用于智能网卡的驱动软件,如图3所示,包括:Referring to FIG. 3 , FIG. 3 shows a flowchart of another method for aging a software flow table according to an embodiment of the present application. The method is applied to the driver software of the smart network card, as shown in FIG. 3 , including:
步骤S301:接收智能网卡的硬件设备发送的当前周期内的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中。Step S301: receiving a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit.
智能网卡的驱动软件接收硬件设备发送的当前周期内各个流表命中记录的命中表,基于该命中表进行各个流表的老化判断。 The driver software of the smart network card receives a hit table of hit records of each flow table in the current cycle sent by the hardware device, and performs aging judgment on each flow table based on the hit table.
在一种可选的实施例中,命中表可以为比特表形式。In an optional embodiment, the hit table may be in the form of a bit table.
比特是目前计算机系统里边数据的最小单位。由比特数组来存储特定数据的一种数据结构可以称之为比特表。Bit is the smallest unit of data in current computer systems. A data structure that uses a bit array to store specific data can be called a bit table.
比特位的值通常为0或1。The value of a bit is usually 0 or 1.
比特位的值为0则表征对应的流表未被命中,可能需要被老化,比特位的值为1则表明对应的流表被命中,不需要进行老化。A bit value of 0 indicates that the corresponding flow table is not hit and may need to be aged. A bit value of 1 indicates that the corresponding flow table is hit and does not need to be aged.
在一种具体实现中,驱动软件通过数据平面开发套件模块接收硬件设备发送的命中表。In a specific implementation, the driver software receives the hit list sent by the hardware device through the data plane development kit module.
数据平面开发套件模块是指虚拟交换机所配置的报文快速处理的库和驱动的集合。The data plane development kit module refers to a collection of libraries and drivers for fast packet processing configured by the virtual switch.
数据平面开发套件模块包括老化线程和卸载线程,老化线程用于接收命中表并进行老化判断,卸载线程用于删除驱动软件中待老化的目标流表。The data plane development kit module includes an aging thread and an unloading thread. The aging thread is used to receive the hit table and perform aging judgment, and the unloading thread is used to delete the target flow table to be aged in the driver software.
驱动软件在接收硬件设备发送的命中表时,首先驱动老化线程,老化线程轮询系统并调用相应接口以接收命中表。When receiving the hit list sent by the hardware device, the driver software first drives the aging thread, and the aging thread polls the system and calls the corresponding interface to receive the hit list.
然后执行步骤S302。Then execute step S302.
步骤S302:基于当前周期内的命中表的多个标识位的值,确定待老化的目标流表。Step S302: Determine the target flow table to be aged based on the values of multiple identification bits of the hit table in the current cycle.
智能网卡的驱动软件接收到命中表后获取命中表中各个标识位的值,确定出目标流表,例如,将标识位的值为0所对应的流表确定为目标流表。After receiving the hit table, the driver software of the smart network card obtains the value of each identification bit in the hit table and determines the target flow table. For example, the flow table corresponding to the identification bit value of 0 is determined as the target flow table.
另一些实施例中,还可以从标识位的值为1所对应的流表中确定出目标流表。In some other embodiments, the target flow table may also be determined from the flow table corresponding to the value of the flag bit being 1.
其中,可以基于各个标识位的值更新对应流表的最后使用时间,并计算各个流表的最后使用时间与当前时间的差值,将该差值超过老化阈值的流表确定为待老化的目标流表。Among them, the last use time of the corresponding flow table can be updated based on the value of each identification bit, and the difference between the last use time of each flow table and the current time can be calculated, and the flow table whose difference exceeds the aging threshold is determined as the target flow table to be aged.
可以理解地,待老化的目标流表可以为一个,也可以为多个。It can be understood that there may be one or more target flow tables to be aged.
在一种具体实现中,老化线程确定出待老化的目标流表后,可以将目标流表的编号发送至卸载线程,以执行老化操作。In a specific implementation, after the aging thread determines the target flow table to be aged, the number of the target flow table may be sent to the unloading thread to perform the aging operation.
后执行步骤S303。Then execute step S303.
步骤S303:向智能网卡的硬件设备发送老化指令;老化指令用于指示硬件设备进行目标流表的老化。Step S303: Send an aging instruction to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
驱动软件确定出待老化的目标流表后,向硬件设备发送老化指令,该老化指令用于指示硬件设备进行待老化的目标流表的老化,该老化指令至少包括待老化 的目标流表的编号。After the driver software determines the target flow table to be aged, it sends an aging instruction to the hardware device, the aging instruction is used to instruct the hardware device to perform aging of the target flow table to be aged. The aging instruction at least includes the target flow table to be aged. The ID of the target flow table.
在一种具体实现中,卸载线程发送老化指令至硬件设备。In a specific implementation, the offload thread sends an aging instruction to the hardware device.
硬件设备接收到老化指令后,获取老化指令中包含的待老化的目标流表的编号,基于该编号调取出目标流表进行删除。After receiving the aging instruction, the hardware device obtains the number of the target flow table to be aged contained in the aging instruction, and retrieves the target flow table based on the number for deletion.
参照图4,图4示出了本申请又一实施例的一种软件流表老化方法确定待老化的目标流表的步骤流程图,如图4所示,包括:Referring to FIG. 4 , FIG. 4 shows a flowchart of steps of determining a target flow table to be aged in a software flow table aging method according to another embodiment of the present application, as shown in FIG. 4 , including:
步骤S401:将标识位的值为第二预设值所对应的流表确定为候选流表,并确定候选流表的最后使用时间。Step S401: determine the flow table corresponding to the second preset value of the flag as a candidate flow table, and determine the last use time of the candidate flow table.
在一种具体实现中,第二预设值为0。In a specific implementation, the second preset value is 0.
智能网卡的驱动软件在接收到当前周期内的各个流表的命中表后,获取命中表中的多个标识位,基于对应的标识位的值确定出候选流表。其中,候选流表是指候选的待进行老化判断的流表。After receiving the hit table of each flow table in the current cycle, the driver software of the smart network card obtains multiple identification bits in the hit table and determines a candidate flow table based on the value of the corresponding identification bit. The candidate flow table refers to a candidate flow table to be aged.
将对应标识位的值为0的流表确定为候选流表。流表对应标识位的值为0则代表该流表在当前周期内未被命中,故而需要进行老化判断。The flow table whose corresponding identification bit value is 0 is determined as the candidate flow table. If the value of the flow table corresponding identification bit is 0, it means that the flow table has not been hit in the current cycle, so aging judgment is required.
然后执行步骤S402。Then execute step S402.
步骤S402:基于候选流表的最后使用时间与当前时间的差值,确定目标流表。Step S402: Determine the target flow table based on the difference between the last use time of the candidate flow table and the current time.
确定出候选流表后,获取各个候选流表的最后使用时间,并计算各个候选流表的最后使用时间与当前时间的差值。After the candidate flow tables are determined, the last use time of each candidate flow table is obtained, and the difference between the last use time of each candidate flow table and the current time is calculated.
在候选流表的最后使用时间与当前时间的差值超过老化阈值的情况下,将候选流表确定为待老化的目标流表。When the difference between the last use time of the candidate flow table and the current time exceeds the aging threshold, the candidate flow table is determined as a target flow table to be aged.
在候选流表的最后使用时间与当前时间的差值未超过老化阈值的情况下,确定候选流表并非目标流表。When the difference between the last use time of the candidate flow table and the current time does not exceed the aging threshold, it is determined that the candidate flow table is not the target flow table.
其中,通过最后使用时间与当前时间的差值,可以让一些虽然需要被老化但是仍然可能被需要的流表再工作一段时间,以满足数据包的转发和发送,而让一些已经不被需要的流表进行老化。Among them, through the difference between the last used time and the current time, some flow tables that need to be aged but may still be needed can work for a period of time to meet the forwarding and sending of data packets, while some flow tables that are no longer needed can be aged.
在一种可选的实施例中,各个流表的最后使用时间是通过以下方式确定的,包括:在流表对应标识位的值为第一预设值的情况下,更新流表的最后使用时间;在流表对应标识位的值为第二预设值的情况下,将流表最近一次更新的最后使用时间作为最后使用时间;其中,第一预设值与第二预设值不同。In an optional embodiment, the last usage time of each flow table is determined in the following manner, including: when the value of the corresponding identification bit of the flow table is a first preset value, updating the last usage time of the flow table; when the value of the corresponding identification bit of the flow table is a second preset value, using the last usage time of the most recent update of the flow table as the last usage time; wherein the first preset value is different from the second preset value.
在一种具体实现中,第一预设值可以为1,第二预设值可以为0。 In a specific implementation, the first preset value may be 1, and the second preset value may be 0.
在流表对应标识位的值为1的情况下,则表示该流表在当前周期内被命中,则对该流表的最后使用时间进行更新。When the value of the corresponding identification bit of the flow table is 1, it means that the flow table is hit in the current cycle, and the last use time of the flow table is updated.
在流表对应标识位的值为0的情况下,表示该流表在当前周期内未被命中,则直接将该流表最近一次更新的最后使用时间作为该流表的最后使用时间,以进行老化判断。When the value of the flag bit corresponding to the flow table is 0, it means that the flow table has not been hit in the current cycle, and the last use time of the flow table's most recent update is directly used as the last use time of the flow table for aging judgment.
在一种可选的实施例中,更新流表的最后使用时间,包括:In an optional embodiment, updating the last use time of the flow table includes:
查询接收到流表的命中表时的接收时刻;Query the receiving time when the hit table of the flow table is received;
将流表的最后使用时间更新为接收时刻。Update the last usage time of the flow table to the receiving time.
在流表对应的标识位的值为第一预设值的情况下,驱动软件对目标流表的最后使用时间进行更新。When the value of the identification bit corresponding to the flow table is the first preset value, the driver software updates the last use time of the target flow table.
首先驱动软件查询接收到该流表的命中表时的接收时刻,然后将接收时刻更新为流表的最后使用时间。示例地,流表为G,在接收到的命中表中包含流表G被写入的标识位时,记录其接收时刻s,将s作为流表G的最后使用时间。First, the driver software queries the receiving time when the hit table of the flow table is received, and then updates the receiving time to the last use time of the flow table. For example, the flow table is G, and when the received hit table contains the identification bit written to the flow table G, its receiving time s is recorded, and s is used as the last use time of the flow table G.
在一种可选的实施例中,基于候选流表的最后使用时间与当前时间的差值,确定目标流表,包括:In an optional embodiment, determining the target flow table based on the difference between the last use time of the candidate flow table and the current time includes:
将差值超过老化阈值的候选流表,确定为目标流表。The candidate flow table whose difference exceeds the aging threshold is determined as the target flow table.
在候选流表的最后使用时间与当前时间的差值超过老化阈值的情况下,确定该候选流表为待老化的目标流表。对待老化的目标流表进行老化。When the difference between the last use time of the candidate flow table and the current time exceeds the aging threshold, the candidate flow table is determined as a target flow table to be aged. The target flow table to be aged is aged.
在一种可选的实施例中,流表老化方法还包括:将目标流表添加至老化列表,老化列表用于存储驱动软件中待老化的流表的编号;In an optional embodiment, the flow table aging method further includes: adding the target flow table to an aging list, the aging list being used to store numbers of flow tables to be aged in the driver software;
将位于驱动软件中的目标流表进行删除。Delete the target flow table in the driver software.
智能网卡的硬件设备和驱动软件均存储有多个流表。Both the hardware device and driver software of the smart network card store multiple flow tables.
可以理解地,驱动软件不仅存储有与硬件设备相同的流表,在此基础上还可以存储有硬件设备未存储的流表。It can be understood that the driver software not only stores the same flow table as the hardware device, but also can store flow tables that are not stored in the hardware device.
驱动软件的老化线程确定出待老化的目标流表后,将目标流表的编号添加至老化列表。After the aging thread of the driver software determines the target flow table to be aged, it adds the number of the target flow table to the aging list.
老化列表可以存储一个或多个待老化的目标流表的编号。The aging list may store the numbers of one or more target flow tables to be aged.
老化线程将老化列表发送至卸载线程,卸载线程在驱动软件存储的所有流表中调取出老化列表所包含的待老化的目标流表,并对其进行删除。The aging thread sends the aging list to the uninstall thread, and the uninstall thread retrieves the target flow table to be aged contained in the aging list from all flow tables stored in the driver software, and deletes it.
在一种可选的实施例中,流表老化方法还包括:对目标流表所关联的流表进行更新。 In an optional embodiment, the flow table aging method further includes: updating the flow table associated with the target flow table.
驱动软件的卸载线程在将软件中的待老化的目标流表删除后,对删除的目标流表所关联的流表进行更新。After deleting the target flow table to be aged in the software, the uninstall thread of the driver software updates the flow table associated with the deleted target flow table.
对删除的目标流表所关联的流表进行更新可以是解除其与目标流表的关联关系,也可以是对关联流表中存在的与目标流表对应的内容进行删除。The updating of the flow table associated with the deleted target flow table may be to release the association relationship between the flow table and the target flow table, or to delete the content corresponding to the target flow table in the associated flow table.
本申请实施例通过接收智能网卡的硬件设备发送的当前周期内的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中;基于当前周期内的命中表的多个标识位的值,确定待老化的目标流表;对智能网卡的硬件设备发送老化指令;老化指令用于指示硬件设备进行目标流表的老化。The embodiment of the present application receives a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table hits; based on the values of multiple identification bits of the hit table in the current cycle, the target flow table to be aged is determined; an aging instruction is sent to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to age the target flow table.
由于驱动软件通过对应标识位的值确定目标流表是否命中,进而更新目标流表的最后使用时间,基于最后使用时间和当前时间的差值确定出待老化的目标流表,使得驱动软件与硬件设备交互一次便可以获得所有流表的使用情况,进而做出老化判断,大大减少了驱动软件与硬件设备的交互次数和老化判断的耗时。Since the driver software determines whether the target flow table is hit by the value of the corresponding identification bit, and then updates the last usage time of the target flow table, the target flow table to be aged is determined based on the difference between the last usage time and the current time. The driver software can obtain the usage status of all flow tables after interacting with the hardware device once, and then make an aging judgment, which greatly reduces the number of interactions between the driver software and the hardware device and the time spent on aging judgment.
下面以一个示例具体说明本申请的流表老化方法的实现流程:The following is an example to illustrate the implementation process of the flow table aging method of the present application:
参照图5,图5示出了本申请又一实施例的软件流表老化方法流程示例图,如图5所示,首先智能网卡发生数据传输时,数据包到达硬件设备与流表进行匹配,硬件设备记录各个流表的命中记录,在流表被匹配的情况下将其对应的比特位的值记录为1,在流表未被匹配的情况下将其对应的比特位的值记录为0。Referring to Figure 5, Figure 5 shows an example flow chart of the software flow table aging method of another embodiment of the present application. As shown in Figure 5, first, when data transmission occurs on the smart network card, the data packet arrives at the hardware device and is matched with the flow table. The hardware device records the hit records of each flow table, and when the flow table is matched, the value of the corresponding bit is recorded as 1, and when the flow table is not matched, the value of the corresponding bit is recorded as 0.
完成当前周期内的所有流表的命中记录后,生成命中表,命中表包括多个比特位,每个比特位对应一个流表。并将该命中表发送至驱动软件的数据平面开发套件模块。After completing the hit records of all flow tables in the current cycle, a hit table is generated, which includes multiple bits, each bit corresponding to a flow table, and the hit table is sent to the data plane development kit module of the driver software.
驱动软件数据平面开发套件模块接收到命中表后,驱动老化线程。After receiving the hit list, the driver software data plane development kit module drives the aging thread.
老化线程基于当前周期内的命中表的多个比特位的值,确定各个流表的最后使用时间。The aging thread determines the last usage time of each flow table based on the values of multiple bits of the hit table in the current cycle.
其中,对于标识位的值为1所对应的第一流表,更新第一流表的最后使用时间;对于标识位的值为0所对应的第二流表,将第二流表最近一次更新的最后使用时间作为第二流表的最后使用时间。Among them, for the first flow table corresponding to the value of the identification bit is 1, the last use time of the first flow table is updated; for the second flow table corresponding to the value of the identification bit is 0, the last use time of the second flow table's most recent update is used as the last use time of the second flow table.
对于第一流表,老化线程查询当前周期内接收到的命中表中该第一流表对应的接收时刻,然后将第一流表的最后使用时间更新为该接收时刻。For the first flow table, the aging thread queries the hit table received in the current cycle for the receiving time corresponding to the first flow table, and then updates the last use time of the first flow table to the receiving time.
对于第二流表,是待进行老化判断的候选流表,查询第二流表的最后使用时间并计算第二流表的最后使用时间与当前时间的差值。 For the second flow table, which is a candidate flow table to be subjected to aging judgment, the last use time of the second flow table is queried and the difference between the last use time of the second flow table and the current time is calculated.
在第二流表的最后使用时间与当前时间的差值超过老化阈值的情况下,确定第二流表是需要进行老化的目标流表,并将目标流表的编号添加至老化列表。When the difference between the last use time of the second flow table and the current time exceeds the aging threshold, the second flow table is determined to be a target flow table that needs to be aged, and the number of the target flow table is added to the aging list.
接下来老化线程将老化列表发送至卸载线程,以使卸载线程执行老化操作。Next, the aging thread sends the aging list to the uninstallation thread, so that the uninstallation thread performs the aging operation.
卸载线程向硬件设备发送老化指令,该老化指令用于指示硬件设备进行待老化的目标流表的老化。The offloading thread sends an aging instruction to the hardware device, where the aging instruction is used to instruct the hardware device to perform aging of the target flow table to be aged.
硬件设备接收到老化指令后,对待老化的目标流表进行删除。After receiving the aging instruction, the hardware device deletes the target flow table to be aged.
同时,卸载线程在驱动软件中存储的所有流表中调取出待老化的目标流表,并对其进行删除,然后对删除的目标流表所关联的流表进行更新。At the same time, the uninstall thread retrieves the target flow table to be aged from all flow tables stored in the driver software, deletes it, and then updates the flow table associated with the deleted target flow table.
参照图6,图6示出了本申请实施例的一种硬件流表老化装置的结构示意图,该装置应用于智能网卡的硬件设备,包括:Referring to FIG. 6 , FIG. 6 shows a schematic diagram of the structure of a hardware flow table aging device according to an embodiment of the present application, the device is applied to a hardware device of a smart network card, and includes:
生成模块601,用于周期性记录多个流表的命中记录,并生成各个流表的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中;A generating module 601 is used to periodically record hit records of multiple flow tables and generate a hit table for each flow table; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
命中表发送模块602,用于将当前周期内的命中表发送至智能网卡的驱动软件,以驱动驱动软件确定待老化的目标流表;The hit table sending module 602 is used to send the hit table in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged;
删除模块603,用于响应于驱动软件发送的老化指令,对目标流表进行删除。The deleting module 603 is used to delete the target flow table in response to the aging instruction sent by the driver software.
在一种可选的实施例中,删除模块603,包括:In an optional embodiment, the deletion module 603 includes:
目标处理模块,用于对当前周期内生成的命中表进行目标处理,以进行下一个周期中多个流表的命中情况的记录;其中,目标处理包括对当前周期内的命中表的删除,或对当前周期内的命中表中的标识位的初始化。The target processing module is used to perform target processing on the hit table generated in the current cycle to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
在一种可选的实施例中,生成模块601,包括:In an optional embodiment, the generating module 601 includes:
写入模块,用于在当前周期内,依次记录每个流表的命中情况,并将各个流表的命中情况写入当前周期的命中表的对应标识位,以使标识位的值表征流表的命中情况。The writing module is used to record the hit status of each flow table in turn in the current cycle, and write the hit status of each flow table into the corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit status of the flow table.
在一种可选的实施例中,命中表发送模块602,包括:In an optional embodiment, the hit list sending module 602 includes:
第一发送子模块,用于在当前周期内,每间隔预设时间,将当前的命中表发送给智能网卡的驱动软件;A first sending submodule is used to send the current hit table to the driver software of the smart network card at preset intervals within the current cycle;
第二发送子模块,用于在当前周期内的命中表中各个标识位写入完成后,将当前周期内的命中表中的多个标识位按照预设长度进行分段,将分段得到的多个标识位段发送至智能网卡的驱动软件;其中,每个标识位段包括至少一个标识位。The second sending submodule is used to segment multiple identification bits in the hit table in the current cycle according to a preset length after the writing of each identification bit in the hit table in the current cycle is completed, and send the multiple identification bit segments obtained by segmentation to the driver software of the smart network card; wherein each identification bit segment includes at least one identification bit.
参照图7,图7示出了本申请实施例的另一种软件流表老化装置的结构示意 图,该装置应用于智能网卡的驱动软件,包括:Referring to FIG. 7 , FIG. 7 shows a schematic diagram of the structure of another software flow table aging device according to an embodiment of the present application. Figure 1 shows the driver software of the device applied to the smart network card, including:
接收模块701,用于接收智能网卡的硬件设备发送的当前周期内的命中表;命中表包含多个标识位,每个标识位对应一个流表,标识位的值用于表征对应的流表是否命中;The receiving module 701 is used to receive the hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table is hit;
确定模块702,用于基于当前周期内的命中表的多个标识位的值,确定待老化的目标流表;A determination module 702, configured to determine a target flow table to be aged based on values of multiple identification bits of the hit table in a current cycle;
指令发送模块703,用于向智能网卡的硬件设备发送老化指令;老化指令用于指示硬件设备进行目标流表的老化。The instruction sending module 703 is used to send an aging instruction to the hardware device of the smart network card; the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
在一种可选的实施例中,装置,还包括:In an optional embodiment, the device further includes:
添加模块,用于将目标流表添加至老化列表,老化列表用于存储驱动软件中待老化的流表的编号;An adding module is used to add the target flow table to the aging list, and the aging list is used to store the numbers of the flow tables to be aged in the driver software;
第一删除子模块,用于将位于驱动软件中的目标流表进行删除;A first deletion submodule, used for deleting a target flow table in the driver software;
在一种可选的实施例中,装置,还包括:In an optional embodiment, the device further includes:
更新模块,用于对目标流表所关联的流表进行更新。The update module is used to update the flow table associated with the target flow table.
在一种可选的实施例中,确定模块702,包括In an optional embodiment, the determination module 702 includes:
第一确定子模块,用于将标识位的值为预设值所对应的流表确定为候选流表,并确定候选流表的最后使用时间;A first determination submodule is used to determine a flow table corresponding to a preset value of a flag bit as a candidate flow table, and determine the last use time of the candidate flow table;
第二确定子模块,用于基于候选流表的最后使用时间与当前时间的差值,确定目标流表;A second determination submodule, configured to determine a target flow table based on a difference between the last use time of the candidate flow table and the current time;
在一种可选的实施例中,第一确定子模块,包括:In an optional embodiment, the first determining submodule includes:
第一更新子模块,用于在流表对应标识位的值为第一预设值的情况下,更新流表的最后使用时间;A first updating submodule, configured to update the last usage time of the flow table when the value of the corresponding identification bit of the flow table is a first preset value;
第二更新子模块,用于在流表对应标识位的值为第二预设值的情况下,将流表最近一次更新的最后使用时间作为最后使用时间;其中,第一预设值与第二预设值不同。The second updating submodule is used to use the last usage time of the most recent update of the flow table as the last usage time when the value of the corresponding identification bit of the flow table is a second preset value; wherein the first preset value is different from the second preset value.
在一种可选的实施例中,第一更新子模块,包括:In an optional embodiment, the first updating submodule includes:
查询子模块,用于查询接收到流表的命中表时的接收时刻;A query submodule is used to query the reception time when the hit table of the flow table is received;
最后使用时间更新子模块,用于将流表的最后使用时间更新为接收时刻。The last used time update submodule is used to update the last used time of the flow table to the receiving time.
在一种可选的实施例中,第二确定子模块,包括:In an optional embodiment, the second determining submodule includes:
目标流表确定子模块,用于将差值超过老化阈值的候选流表,确定为目标流表。 The target flow table determination submodule is used to determine the candidate flow table whose difference exceeds the aging threshold as the target flow table.
基于同一发明构思,本申请实施例还提供一种电子设备,包括:Based on the same inventive concept, an embodiment of the present application further provides an electronic device, including:
处理器、存储器以及存储在存储器上并可在处理器上运行的计算机程序,处理器执行程序时实现上述实施例一任一的硬件流表老化方法,或实现上述实施例二任一的软件流表老化方法。A processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the hardware flow table aging method of any one of the above-mentioned embodiments 1 is implemented, or the software flow table aging method of any one of the above-mentioned embodiments 2 is implemented.
基于同一发明构思,本申请实施例还提供一种计算机可读存储介质,包括:当存储介质中的指令由电子设备的处理器执行时,使得电子设备能够执行上述实施例一任一项的硬件流表老化方法,或执行上述实施例二任一项的软件流表老化方法。Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, including: when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the hardware flow table aging method of any one of the above-mentioned embodiments one, or execute the software flow table aging method of any one of the above-mentioned embodiments two.
以上仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和部件并不一定是本申请所必须的。For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and components involved are not necessarily required by the present application.
以上对本申请所提供的一种硬件流表老化方法、软件流表老化方法、装置及电子设备进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本申请的限制。 The above is a detailed introduction to a hardware flow table aging method, a software flow table aging method, a device and an electronic device provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims (15)

  1. 一种硬件流表老化方法,其特征在于,应用于智能网卡的硬件设备,所述方法包括:A method for aging a hardware flow table, characterized in that it is applied to a hardware device of a smart network card, and the method comprises:
    周期性记录所述硬件设备中多个流表的命中记录,并基于所述命中记录生成各个所述流表的命中表;所述命中表包含多个标识位,每个所述标识位对应一个所述流表,所述标识位的值用于表征对应的所述流表是否命中;Periodically record the hit records of multiple flow tables in the hardware device, and generate a hit table of each flow table based on the hit records; the hit table includes multiple identification bits, each identification bit corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table hits;
    将当前周期内生成的命中表发送至所述智能网卡的驱动软件,以驱动所述驱动软件确定待老化的目标流表;Sending the hit table generated in the current cycle to the driver software of the smart network card to drive the driver software to determine the target flow table to be aged;
    响应于所述驱动软件发送的老化指令,对所述目标流表进行删除。In response to the aging instruction sent by the driver software, the target flow table is deleted.
  2. 根据权利要求1所述的方法,其特征在于,在所述将当前周期内生成的命中表发送至所述智能网卡的驱动软件之后,所述方法还包括:The method according to claim 1, characterized in that after sending the hit table generated in the current cycle to the driver software of the smart network card, the method further comprises:
    对所述当前周期内生成的命中表进行目标处理,以进行下一个周期中多个所述流表的命中情况的记录;其中,所述目标处理包括对所述当前周期内的命中表的删除,或对所述当前周期内的命中表中的标识位的初始化。The hit table generated in the current cycle is subjected to target processing to record the hit conditions of multiple flow tables in the next cycle; wherein the target processing includes deleting the hit table in the current cycle, or initializing the identification bits in the hit table in the current cycle.
  3. 根据权利要求1所述的方法,其特征在于,所述标识位为比特位。The method according to claim 1 is characterized in that the identification bit is a bit.
  4. 根据权利要求1所述的方法,其特征在于,所述周期性记录所述硬件设备中多个流表的命中记录,包括:The method according to claim 1, characterized in that the periodic recording of hit records of multiple flow tables in the hardware device comprises:
    在所述当前周期内,依次记录每个所述流表的命中情况,并将各个所述流表的命中情况写入所述当前周期的命中表的对应标识位,以使所述标识位的值表征所述流表的命中情况;In the current cycle, the hit situation of each flow table is recorded in sequence, and the hit situation of each flow table is written into the corresponding identification bit of the hit table of the current cycle, so that the value of the identification bit represents the hit situation of the flow table;
    所述将当前周期内生成的命中表发送至所述智能网卡的驱动软件,包括:The step of sending the hit table generated in the current cycle to the driver software of the smart network card includes:
    在所述当前周期内,每间隔预设时间,将当前的命中表发送给所述智能网卡的驱动软件;In the current cycle, at a preset time interval, the current hit table is sent to the driver software of the smart network card;
    或,or,
    在所述当前周期内的命中表中各个所述标识位写入完成后,将所述当前周期内的命中表中的多个所述标识位按照预设长度进行分段,将分段得到的多个标识位段发送至所述智能网卡的驱动软件;After writing of each of the identification bits in the hit table in the current cycle is completed, the multiple identification bits in the hit table in the current cycle are segmented according to a preset length, and the multiple identification bit segments obtained by segmentation are sent to the driver software of the smart network card;
    其中,每个所述标识位段包括至少一个所述标识位。Each of the identification bit segments includes at least one identification bit.
  5. 一种软件流表老化方法,其特征在于,应用于智能网卡的驱动软件,所述方法包括:A software flow table aging method, characterized in that it is applied to driver software of an intelligent network card, and the method comprises:
    接收所述智能网卡的硬件设备发送的当前周期内的命中表;所述命中表包含多个 标识位,每个所述标识位对应一个流表,所述标识位的值用于表征对应的所述流表是否命中;Receive a hit table in the current cycle sent by the hardware device of the smart network card; the hit table contains multiple An identification bit, each of which corresponds to a flow table, and a value of the identification bit is used to indicate whether the corresponding flow table is hit;
    基于所述当前周期内的命中表的多个所述标识位的值,确定待老化的目标流表;向所述智能网卡的硬件设备发送老化指令,所述老化指令用于指示所述硬件设备进行所述目标流表的老化。Based on the values of the multiple identification bits of the hit table in the current cycle, a target flow table to be aged is determined; and an aging instruction is sent to the hardware device of the smart network card, where the aging instruction is used to instruct the hardware device to age the target flow table.
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method according to claim 5, characterized in that the method further comprises:
    将所述目标流表添加至老化列表,所述老化列表用于存储所述驱动软件中待老化的流表的编号;Adding the target flow table to an aging list, wherein the aging list is used to store numbers of flow tables to be aged in the driver software;
    将位于所述驱动软件中的所述目标流表进行删除。The target flow table located in the driver software is deleted.
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:The method according to claim 6, characterized in that the method further comprises:
    对所述目标流表所关联的流表进行更新。The flow table associated with the target flow table is updated.
  8. 根据权利要求5所述的方法,其特征在于,所述基于所述当前周期内的命中表的多个所述标识位的值,确定待老化的目标流表,包括:The method according to claim 5, characterized in that the determining the target flow table to be aged based on the values of the multiple identification bits of the hit table in the current cycle comprises:
    将所述标识位的值为第二预设值所对应的流表确定为候选流表,并确定所述候选流表的最后使用时间;Determine the flow table corresponding to the second preset value of the flag as a candidate flow table, and determine the last use time of the candidate flow table;
    基于所述候选流表的最后使用时间与当前时间的差值,确定所述目标流表。The target flow table is determined based on the difference between the last use time of the candidate flow table and the current time.
  9. 根据权利要求8所述的方法,其特征在于,各个所述流表的最后使用时间是通过以下方式确定的,包括:The method according to claim 8, characterized in that the last use time of each of the flow tables is determined by:
    在所述流表对应标识位的值为第一预设值的情况下,更新所述流表的最后使用时间;When the value of the flag corresponding to the flow table is a first preset value, updating the last use time of the flow table;
    在所述流表对应标识位的值为所述第二预设值的情况下,将所述流表最近一次更新的最后使用时间作为所述最后使用时间;When the value of the flag corresponding to the flow table is the second preset value, the last use time of the most recent update of the flow table is used as the last use time;
    其中,所述第一预设值与所述第二预设值不同。The first preset value is different from the second preset value.
  10. 根据权利要求9所述的方法,其特征在于,所述更新所述流表的最后使用时间,包括:The method according to claim 9, characterized in that the updating of the last usage time of the flow table comprises:
    查询接收到所述流表的命中表时的接收时刻;Query the reception time when the hit table of the flow table is received;
    将所述流表的最后使用时间更新为所述接收时刻。The last usage time of the flow table is updated to the receiving time.
  11. 根据权利要求8所述的方法,其特征在于,所述基于所述候选流表的最后使用时间与当前时间的差值,确定所述目标流表,包括:The method according to claim 8, characterized in that the determining the target flow table based on the difference between the last use time of the candidate flow table and the current time comprises:
    将所述差值超过老化阈值的所述候选流表,确定为所述目标流表。 The candidate flow table whose difference exceeds an aging threshold is determined as the target flow table.
  12. 一种硬件流表老化装置,其特征在于,应用于智能网卡的硬件设备,所述装置包括:A hardware flow table aging device, characterized in that it is applied to a hardware device of a smart network card, and the device comprises:
    生成模块,用于周期性记录多个流表的命中记录,并生成各个所述流表的命中表;所述命中表包含多个标识位,每个所述标识位对应一个所述流表,所述标识位的值用于表征对应的所述流表是否命中;A generation module, used to periodically record hit records of multiple flow tables and generate hit tables for each of the flow tables; the hit table includes multiple identification bits, each of the identification bits corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table hits;
    命中表发送模块,用于将当前周期内的所述命中表发送至所述智能网卡的驱动软件,以驱动所述驱动软件确定待老化的目标流表;A hit table sending module, used to send the hit table in the current cycle to the driver software of the smart network card, so as to drive the driver software to determine the target flow table to be aged;
    删除模块,用于响应于所述驱动软件发送的老化指令,对所述目标流表进行删除。The deleting module is used to delete the target flow table in response to the aging instruction sent by the driver software.
  13. 一种软件流表老化装置,其特征在于,应用于智能网卡的驱动软件,所述装置包括:A software flow table aging device, characterized in that it is applied to driver software of an intelligent network card, and the device comprises:
    接收模块,用于接收所述智能网卡的硬件设备发送的当前周期内的命中表;所述命中表包含多个标识位,每个所述标识位对应一个流表,所述标识位的值用于表征对应的所述流表是否命中;A receiving module, used to receive a hit table in the current cycle sent by the hardware device of the smart network card; the hit table includes multiple identification bits, each of which corresponds to a flow table, and the value of the identification bit is used to indicate whether the corresponding flow table hits;
    确定模块,用于基于所述当前周期内的命中表的多个所述标识位的值,确定待老化的目标流表;A determination module, configured to determine a target flow table to be aged based on the values of the plurality of identification bits of the hit table in the current cycle;
    指令发送模块,用于向所述智能网卡的硬件设备发送老化指令,所述老化指令用于指示所述硬件设备进行所述目标流表的老化。The instruction sending module is used to send an aging instruction to the hardware device of the smart network card, and the aging instruction is used to instruct the hardware device to perform aging of the target flow table.
  14. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    处理器、存储器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述程序时实现权利要求1至4任一项所述的硬件流表老化方法,或实现权利要求5至11任一项所述的软件流表老化方法。A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the hardware flow table aging method according to any one of claims 1 to 4 is implemented, or the software flow table aging method according to any one of claims 5 to 11 is implemented.
  15. 一种计算机可读存储介质,其特征在于,当所述存储介质中的指令由电子设备的处理器执行时,使得电子设备能够执行权利要求1至4任一项所述的硬件流表老化方法,或执行权利要求5至11任一项所述的软件流表老化方法。 A computer-readable storage medium, characterized in that when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the hardware flow table aging method described in any one of claims 1 to 4, or to execute the software flow table aging method described in any one of claims 5 to 11.
PCT/CN2023/140365 2023-03-06 2023-12-20 Hardware flow table aging method and apparatus, software flow table aging method and apparatus, and electronic device WO2024183410A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310205465.XA CN116074247B (en) 2023-03-06 2023-03-06 Hardware flow table aging method, software flow table aging method, device and electronic equipment
CN202310205465.X 2023-03-06

Publications (1)

Publication Number Publication Date
WO2024183410A1 true WO2024183410A1 (en) 2024-09-12

Family

ID=86171630

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/140365 WO2024183410A1 (en) 2023-03-06 2023-12-20 Hardware flow table aging method and apparatus, software flow table aging method and apparatus, and electronic device

Country Status (2)

Country Link
CN (1) CN116074247B (en)
WO (1) WO2024183410A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116074247B (en) * 2023-03-06 2023-06-23 天翼云科技有限公司 Hardware flow table aging method, software flow table aging method, device and electronic equipment
CN116723162B (en) * 2023-08-10 2023-11-03 浪潮电子信息产业股份有限公司 A network first packet processing method, system, device, medium and heterogeneous equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005109592A (en) * 2003-09-29 2005-04-21 Nec Engineering Ltd Aging processing apparatus and aging processing method
US20170295035A1 (en) * 2014-06-25 2017-10-12 Hewlett Packard Enterprise Development Lp Selecting an optimal network device for reporting flow table misses upon expiry of a flow in a software defined network
CN109617779A (en) * 2018-12-19 2019-04-12 锐捷网络股份有限公司 Routing table maintenance method and device based on VTEP
CN112134806A (en) * 2020-09-30 2020-12-25 新华三大数据技术有限公司 Flow table aging time adjusting method and device and storage medium
CN114915587A (en) * 2022-05-10 2022-08-16 深圳星云智联科技有限公司 Flow table aging management method and related equipment
CN116074247A (en) * 2023-03-06 2023-05-05 天翼云科技有限公司 Hardware flow table aging method, software flow table aging method, device and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005109592A (en) * 2003-09-29 2005-04-21 Nec Engineering Ltd Aging processing apparatus and aging processing method
US20170295035A1 (en) * 2014-06-25 2017-10-12 Hewlett Packard Enterprise Development Lp Selecting an optimal network device for reporting flow table misses upon expiry of a flow in a software defined network
CN109617779A (en) * 2018-12-19 2019-04-12 锐捷网络股份有限公司 Routing table maintenance method and device based on VTEP
CN112134806A (en) * 2020-09-30 2020-12-25 新华三大数据技术有限公司 Flow table aging time adjusting method and device and storage medium
CN114915587A (en) * 2022-05-10 2022-08-16 深圳星云智联科技有限公司 Flow table aging management method and related equipment
CN116074247A (en) * 2023-03-06 2023-05-05 天翼云科技有限公司 Hardware flow table aging method, software flow table aging method, device and electronic equipment

Also Published As

Publication number Publication date
CN116074247B (en) 2023-06-23
CN116074247A (en) 2023-05-05

Similar Documents

Publication Publication Date Title
WO2024183410A1 (en) Hardware flow table aging method and apparatus, software flow table aging method and apparatus, and electronic device
US11616738B2 (en) Packet processing method and related device
JP3734704B2 (en) Packet classification engine
US7546399B2 (en) Store and forward device utilizing cache to store status information for active queues
US20050129040A1 (en) Shared adapter
CN112333099B (en) Routing method, device and storage medium of local multipath message
CN110912826B (en) Method and device for expanding IPFIX table items by using ACL
CN113472624A (en) Method for realizing virtual network data packet forwarding based on vDPA and application
US11316804B2 (en) Forwarding entry update method and apparatus in a memory
US10038571B2 (en) Method for reading and writing forwarding information base, and network processor
EP3920475A1 (en) Memory management method and apparatus
CN117955907B (en) Message processing method, virtual switch, device and storage medium
JP2008148133A (en) Communication equipment, control method thereof and program
EP1780976A1 (en) Methods and system to offload data processing tasks
US10817177B1 (en) Multi-stage counters
CN116074250B (en) Stream table processing method, system, device and storage medium
CN117857537A (en) Method, device, equipment and storage medium for breakpoint continuous transmission of storage flow of network card
CN107517161B (en) Network processor table lookup method, network processor and table lookup system
CN112637083B (en) Packet loss processing method, device, equipment and computer readable storage medium
CN114900456B (en) MAC address management device and method
JP2008085886A (en) Packet processing apparatus, packet processing method, and packet processing program
US20160142342A1 (en) Apparatus and method for fast search table update in a network switch
CN108347494B (en) MAC address aging processing method, network processor chip and communication equipment
US10963183B2 (en) Technologies for fine-grained completion tracking of memory buffer accesses
CN112511440A (en) Message forwarding method, system, storage medium and electronic equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23926104

Country of ref document: EP

Kind code of ref document: A1