Session processing method, device, equipment and storage medium
Technical Field
Embodiments of the present invention relate to network technologies, and in particular, to a session processing method, apparatus, device, and storage medium.
Background
With the increasing popularity of mobile internet, the network scale is continuously enlarged. Because most of the traditional network devices are delivered and deployed in the form of closed hardware, the limitations of the architecture evolution of the existing computer network are more and more highlighted in the presence of rich network applications. In this regard, it is possible to reduce the network device cost by using general-purpose hardware such as x86 and virtualization technology to carry a very versatile software process. For example, the functions of the network equipment can be independent of dedicated hardware through software and hardware decoupling and function abstraction, resources can be fully and flexibly shared, and rapid development and deployment of new services are realized.
In the prior art, when a message is processed, a service is embedded into a certain processing flow of a kernel protocol stack through a mount point based on a kernel. When each message is forwarded, each message information is stored as a corresponding session node, and the session node which is over time is deleted by a segmented traversal mode, for example, by traversing ten thousand session nodes each time, so as to perform maintenance over time.
However, in the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
when session nodes are traversed in a segmented manner, most of potentially traversed session nodes in ten thousand session nodes are not overtime, and the overtime session nodes can be traversed after a long time, for example, if the traversal needs 600 seconds, if a certain session node is overtime after traversing for the next time after 1 second, the session node needs to be traversed after the next traversal, that is, 600 seconds, so that the overtime maintenance efficiency of the session is greatly reduced, and the performance loss is increased.
Disclosure of Invention
The embodiment of the invention provides a session processing method, a session processing device, session processing equipment and a storage medium, so as to improve the session overtime maintenance efficiency, save equipment resources and improve the processing performance.
In a first aspect, an embodiment of the present invention provides a session processing method, including:
when detecting that a session node corresponding to a currently received message is not stored in a cache unit set, creating the session node corresponding to the message, determining a first absolute timeout time based on the current time and a relative timeout time corresponding to the session node, and storing the first absolute timeout time and information of the message in the created session node;
determining a target cache unit corresponding to the session node according to the scheduling start time and the first absolute timeout time corresponding to the cache unit set, and storing the created session node into the target cache unit;
the cache unit set comprises a plurality of sequentially arranged cache units, and the cache units are sequentially and circularly scheduled according to the arrangement order so as to perform overtime maintenance on the session nodes stored in each cache unit.
In a second aspect, an embodiment of the present invention further provides a session processing apparatus, including:
a session node creating module, configured to create a session node corresponding to a currently received packet when it is detected that a session node corresponding to the packet is not stored in a cache unit set, determine a first absolute timeout time based on a current time and a relative timeout time corresponding to the session node, and store the first absolute timeout time and information of the packet in the created session node;
a session node storage module, configured to determine a target cache unit corresponding to the session node according to the scheduling start time and the first absolute timeout time that correspond to the cache unit set, and store the created session node in the target cache unit;
the cache unit set comprises a plurality of sequentially arranged cache units, and the cache units are sequentially and circularly scheduled according to the arrangement order so as to perform overtime maintenance on the session nodes stored in each cache unit.
In a third aspect, an embodiment of the present invention further provides an apparatus, where the apparatus includes:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the steps of a session processing method as provided by any embodiment of the invention.
In a fourth aspect, the embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the session processing method provided in any embodiment of the present invention.
The embodiment of the invention has the following advantages or beneficial effects:
when detecting that the session node corresponding to the currently received message is not stored in the cache unit set, creating the session node corresponding to the message, determining a first absolute timeout time corresponding to the session node, and determining a target cache unit corresponding to the session node according to the first absolute timeout time and a scheduling start time corresponding to the cache unit set, so that the session node can be stored in a corresponding target cache unit based on the first absolute timeout time, and the session node can be scheduled when the first absolute timeout time is reached. All created session nodes are stored in the cache unit set based on the sequence of the first absolute timeout time, so that the cache units can be sequentially and circularly scheduled based on the arrangement sequence of the cache units in the cache unit set, and when the first absolute timeout time is reached, the session nodes in the cache units can be scheduled just, so that the session nodes which are overtime can be deleted in time, the session timeout maintenance efficiency is improved, the equipment resources are saved, and the processing performance is improved.
Drawings
Fig. 1 is a flowchart of a session processing method according to an embodiment of the present invention;
FIG. 2 is an example of a cache unit set according to an embodiment of the present invention;
fig. 3 is a flowchart of a session processing method according to a second embodiment of the present invention;
fig. 4 is a flowchart of a session maintenance method according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of a session processing apparatus according to a third embodiment of the present invention;
fig. 6 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a session processing method according to an embodiment of the present invention, which is applicable to creating a session node for storing message information and storing the created session node when a message is received, so that overtime maintenance can be performed in time. The method may be performed by a session handling apparatus, which may be implemented by means of software and/or hardware, integrated in a network device. The method specifically comprises the following steps:
s110, when detecting that the session node corresponding to the currently received message is not stored in the cache unit set, creating the session node corresponding to the message, determining a first absolute timeout time based on the current time and the relative timeout time corresponding to the session node, and storing the first absolute timeout time and the information of the message in the created session node.
The cache unit may be pre-allocated to store the session node. Each buffer element may correspond to a slot to schedule the buffer element within the slot. The cache unit set may be composed of a plurality of cache units. The cache unit set in this embodiment may exist in a data structure form of an array or a linked list, but is not limited to the data structure form, for example, when the cache unit set is the cache unit linked list, the cache units may be sequentially scheduled based on the form of the linked list. Each cache unit in this embodiment may store one or more session nodes, and the specific number of the session nodes may be predetermined based on the space size of the cache unit. The session node may refer to a node for storing information of each packet. The information of the message may include, but is not limited to, a source IP (Internet Protocol, Protocol for interconnection between networks) address, a source port, a destination IP address, a destination port, and a transport layer Protocol. Each message in this embodiment corresponds to a session node to store information of the message. The relative timeout time corresponding to the session node may refer to an effective time of the created session node relative to the current time, so as to avoid a situation that the corresponding session node is always stored when there is no interaction between the client and the server, thereby reducing performance loss.
Specifically, if a packet is currently received, it is detected whether a session node storing information of the packet exists in the current cache unit set, and if the packet does not exist, it indicates that the packet is received for the first time, for example, a Transmission Control Protocol (TCP) is a SYN (synchronization sequence number) packet, and at this time, a memory may be allocated, and a session and a corresponding session node may be created. In this embodiment, the first absolute timeout time and the message information are stored in the session node, so that the session node can be maintained overtime more conveniently and subsequently according to the first absolute timeout time.
Illustratively, determining the first absolute timeout time based on the current time and the relative timeout time corresponding to the session node may include: and adding the current time and the relative timeout time corresponding to the session node, and determining the addition result as the first absolute timeout time. For example, if the current time is 4 o 'clock and the relative timeout period corresponding to a session node is 1 minute, the first absolute timeout period corresponding to the session node is 4 o' clock and 1 minute. In addition, in this embodiment, the current time and the relative timeout time may be converted into the same time unit, and then the times may be added.
S120, determining a target cache unit corresponding to the session node according to the scheduling start time and the first absolute timeout time corresponding to the cache unit set, and storing the created session node into the target cache unit; the cache unit set comprises a plurality of sequentially arranged cache units, and each cache unit is sequentially and circularly scheduled according to the arrangement order so as to perform overtime maintenance on the session node stored in each cache unit.
The scheduling start time may refer to a start time of scheduling the cache unit set, that is, a call time of a first cache unit in the cache unit set that is to be scheduled at the beginning, for example, if cyclic scheduling is started for each cache unit in the cache unit set at 4 o 'clock, the scheduling start time is 4 o' clock.
Specifically, the buffer units in the buffer unit set are sequentially and circularly scheduled at the scheduling starting time. According to the scheduling starting time and the first absolute timeout time, the cache unit which is being scheduled when the first absolute timeout time is reached can be determined, the cache unit serves as a target cache unit, the session node which stores the message information and the first absolute timeout time is stored in the target cache unit, and therefore when the target cache unit is scheduled, the current time reaches the first absolute timeout time, overtime maintenance can be timely performed on the target cache unit, waiting for too long time is not needed, and maintenance efficiency is improved.
Exemplarily, determining a target cache unit corresponding to the session node according to the scheduling start time and the first absolute timeout time corresponding to the cache unit set may include: determining the difference between the first absolute timeout time and the scheduling start time corresponding to the cache unit set as delay time; dividing the delay time by the cycle period corresponding to the cache unit set, and taking the obtained remainder as the offset time; and dividing the offset time by the scheduling time corresponding to the cache unit, taking the obtained calculation result as the target ordinal number, and determining the cache unit corresponding to the target ordinal number in the cache unit set as the target cache unit.
The cycle period may refer to a time required to schedule all the buffer units in the buffer unit set. The scheduling time may refer to a time required to schedule one buffer unit. Illustratively, the maximum timeout time of the session node is 600 seconds, so that the loop period can be set to 600 seconds, and the scheduling time corresponding to each cache unit is 1 millisecond, that is, the set of cache units contains 600000 cache units. Specifically, if the schedule start time is 4 o ' clock, the first absolute timeout time is 4 o ' clock 15 minutes, and the current time is 4 o ' clock 11 minutes, the delay time between the first absolute timeout time and the schedule start time is 15 minutes, i.e., 900 seconds. The delay time of 900 seconds divided by the cycle period of 600 seconds yields a quotient of 1 and a remainder of 300 seconds, indicating that scheduling is required at the 300 th second in the second cycle. The offset time 300 seconds is divided by the scheduling time 1 millisecond, and the obtained result is 300000, at this time, the 300000-th cache unit in the cache unit set can be used as the target cache unit.
For example, in this embodiment, the sequence number of the currently-scheduled cache unit may also be determined according to the current time and the scheduling start time, a difference between the first absolute timeout time and the current time is obtained, a ratio between the difference and the scheduling time is used as a sequence number offset, the sequence number of the currently-scheduled cache unit and the sequence number offset are added, and an obtained result is the target sequence number. For example, if the scheduling start time is 4 o 'clock, and the current time is 4 o' clock and 11 minutes, the serial number of the currently scheduled cache unit is 60000, and the difference between the first absolute timeout time 4 o 'clock 15 and the current time 4 o' clock and 11 minutes is 240000 milliseconds; the sequence number offset is 240000 ms divided by 1 ms to 240000, then the target sequence number is 240000 plus 60000 to equal 300000, i.e. the 300000 th cache unit in the cache unit set is the target cache unit.
Illustratively, storing the created session node in the target cache unit may include: acquiring the number of session nodes contained in a target cache unit; if the number of the session nodes is smaller than the preset number, the created session nodes are stored in a target cache unit; and if the number of the session nodes is equal to the preset number, storing the created session nodes into the next cache unit of the target cache unit.
The preset number may refer to the number of session nodes that the cache unit can store at most. The preset number may be preset according to the service requirement and the space size and/or scheduling speed of the buffer unit. Illustratively, the preset number may be set to 1000 so that all stored session nodes can be scheduled within 1 millisecond of the scheduling time.
Specifically, before the created session nodes are stored in the target cache unit, it is necessary to determine that the number of session nodes included in the current target cache unit is smaller than a preset number, if so, it indicates that the target cache unit can continue to store the session nodes, and at this time, the created session nodes can be directly stored in the target cache unit; if not, the target cache unit is indicated to be full of memory, and the session nodes cannot be stored continuously, at this time, a next cache unit of the target cache unit can be obtained based on the arrangement sequence in the cache unit set, and the created session nodes are stored in the next cache unit when the number of the session nodes included in the next cache unit is smaller than the preset number. It should be noted that, if the target cache unit is the last cache unit in the cache unit set, the next cache unit is the first cache unit in the cache unit set. Because the scheduling time required by each cache unit is short, the created session node is stored to the next cache unit of the target cache unit, and the session node can be maintained in time, so that the processing performance is improved.
According to the technical scheme of the embodiment, when it is detected that a session node corresponding to a currently received message is not stored in a cache unit set, a session node corresponding to the message is created, a first absolute timeout time corresponding to the session node is determined, and a target cache unit corresponding to the session node is determined according to the first absolute timeout time and a scheduling start time corresponding to the cache unit set, so that the session node can be stored into a corresponding target cache unit based on the first absolute timeout time, and the session node can be scheduled when the first absolute timeout time is reached. All created session nodes are stored in the cache unit set based on the sequence of the first absolute timeout time, so that the cache units can be sequentially and circularly scheduled based on the arrangement sequence of the cache units in the cache unit set, and when the first absolute timeout time is reached, the session nodes in the cache units can be scheduled just, so that the session nodes which are overtime can be deleted in time, the session timeout maintenance efficiency is improved, the equipment resources are saved, and the processing performance is improved.
On the basis of the foregoing technical solution, the step S110 of detecting that no session node corresponding to the currently received packet is stored in the cache unit set may include: when a current processor receives a message through a DPDK interface of a preset data plane development kit, analyzing the currently received message to obtain message information; detecting whether a session node containing message information exists in a cache unit set corresponding to a current processor; if not, determining that the session node corresponding to the currently received message is not stored in the cache unit set.
The traditional method for processing messages through the Linux kernel protocol stack cannot meet the speed requirement for processing massive messages. In this embodiment, a data Plane development kit (dpdk) may be used to replace network data packet processing in a conventional Linux system by using user mode driving, and bypass a Linux kernel protocol stack, thereby increasing the packet processing speed. This embodiment adopts a CPU (Central Processing Unit) affinity method to make each data core independent. Where CPU affinity may refer to binding each conversation thread to a CPU so that it may run directly on the bound CPU. Fig. 2 shows an example of a set of cache units. As shown in fig. 2, a corresponding cache unit set is established on each processor, so that the scheduling of each cache unit is per CPU, that is, each CPU core independently has its own cache unit set, thereby avoiding performance loss caused by thread switching.
Specifically, the messages can be received in real time by calling a DPDK interface of a preset data plane development kit, and the kernel protocol stack is bypassed by user mode driving, so that the message processing speed is increased. When a message is received, the message information can be obtained by analyzing the currently received message, the message information is matched with the message information in each session node stored by the current processor, and if the matching is successful, the message is not received for the first time, and the corresponding session node is established; if the matching fails, the message is received for the first time, so that the session node corresponding to the message is not stored in the cache unit set, and the session node can be created in real time.
On the basis of the above technical solution, performing sequential circular scheduling on each cache unit according to the ranking order may include: sequentially taking each cache unit in the cache unit set as a current cache unit for scheduling; when detecting that the session nodes are stored in the current cache unit which is currently scheduled, taking the stored session nodes as the current session nodes one by one; detecting whether the current time is greater than or equal to a first absolute timeout time in the current session node; if yes, deleting the current session node; if not, updating the current session node to perform overtime maintenance on the next session node.
Specifically, each buffer unit is sequentially and circularly scheduled at the scheduling start time. In this embodiment, each cache unit may be sequentially scheduled as a current cache unit based on the arrangement order of each cache unit in the cache unit set, and one cache unit is scheduled based on each scheduling time, for example, timeout maintenance is performed once every millisecond, and 600 seconds are required for the end of traversal of the entire cache unit set. When the current cache unit is scheduled, whether session nodes are stored in the current cache unit or not needs to be detected, if yes, traversal and overtime maintenance can be performed on each session node in sequence based on the storage sequence, namely, each session node can be used as the current session node, whether the current time is greater than or equal to the first absolute overtime time stored in the current session node or not is detected, if yes, the session node is overtime, the session node can be deleted at the moment, and the next session node is updated to be the current session node so as to perform overtime maintenance on the next session node. If not, the session node is not overtime, at this time, the cache unit corresponding to the current session node needs to be determined again based on the first absolute overtime time, and the current session node is switched to the cache unit after the determination for storage, so that the current time is matched with the first absolute overtime time, then the next session node can be updated to the current session node, and the overtime maintenance is continuously performed on the next session node until all the session nodes in the current cache unit are traversed and completed. If the current cache unit does not store the session node, traversing of the next cache unit can be performed after the interval scheduling time.
On the basis of the above technical solution, the method may further include: when detecting that a session node corresponding to a currently received message is stored in the cache unit set, updating a first absolute timeout time stored in the session node according to the current time and a relative timeout time corresponding to the session node; and updating the target cache unit corresponding to the session node according to the updated first absolute timeout time, and switching the session node to the updated target cache unit for storage.
Specifically, after a corresponding session node is established based on a first packet of a session, when a packet of the session is subsequently received, a new session node does not need to be created again, but the first absolute timeout time stored in the session node is updated, that is, the current time when the packet of the session is received again and the relative timeout time are added, and the addition result is used as the updated first absolute timeout time. Based on the same determination mode of the target cache unit, the target cache unit corresponding to the session node is determined again according to the updated first absolute timeout time, and the session node is placed in the updated target cache unit for storage, so that the scheduling time of the target cache unit is matched with the updated first absolute timeout time, the update process of the session node is achieved more conveniently, and the performance loss is reduced.
Example two
Fig. 3 is a flowchart of a session processing method according to a second embodiment of the present invention, where the present embodiment optimizes the storage content of the session node based on the above embodiment, and further optimizes the update mode of the session node based on the optimization. Wherein explanations of the same or corresponding terms as those of the above-described embodiments are omitted.
Referring to fig. 3, the session processing method provided in this embodiment specifically includes the following steps:
s210, detecting whether a session node corresponding to the currently received message is stored in the cache unit set, and if not, entering S220; if yes, the process proceeds to S240.
S220, creating a session node corresponding to the message, determining a first absolute timeout time and a second absolute timeout time based on the current time and the relative timeout time corresponding to the session node, storing the first absolute timeout time, the second absolute timeout time and the information of the message in the created session node, and going to S230.
The first absolute timeout time may be used to record an absolute timeout time corresponding to a newly received message in the session; the second absolute timeout time may be used to record a call time corresponding to a cache unit of the storage session node.
Specifically, when a session node is created, it indicates that a first packet of the session is currently received, and at this time, a first absolute timeout time and a second absolute timeout time determined based on the current time are the same, that is, the addition result of the current time and the relative timeout time corresponding to the session node may be determined as the first absolute timeout time and the second absolute timeout time, and the two absolute timeout times and packet information are stored in the session node.
S230, determining a target cache unit corresponding to the session node according to the scheduling start time and the first absolute timeout time corresponding to the cache unit set, storing the created session node into the target cache unit, and returning to the S210.
Specifically, since the first absolute timeout time and the second absolute timeout time are the same, the target cache unit may be determined based on the first absolute timeout time, or may be determined based on the second absolute timeout time.
S240, updating the first absolute timeout stored in the session node according to the current time and the relative timeout corresponding to the session node, and proceeding to S250.
Specifically, when the session node corresponding to the currently received packet is stored in the cache unit set, it indicates that the session corresponding to the packet has been created in advance, and the timeout time of the session needs to be delayed, at this time, the first absolute timeout time stored in the session node may be updated based on the current time of the currently received packet, that is, the addition result of the current time and the relative timeout time is used as the updated first absolute timeout time. It should be noted that the second absolute timeout time does not need to be updated at this time.
S250, detecting whether the current time is greater than or equal to the second absolute timeout time, if so, entering S260; if not, the process proceeds to S210.
Specifically, whether to update the storage location of the session node is determined by comparing the current time with the size of the second absolute timeout time stored in the session node. When the current time is less than the second absolute timeout time, it indicates that the time for maintaining the session node overtime has not been reached currently, and at this time, the operation of step S210 may be directly returned to execute without replacing the storage location of the session node, so that after the second absolute timeout time is reached, the location may be updated when a new packet is received, so that the location of the session node is updated every interval of time, thereby avoiding updating the location of the session node once every time a packet is received, further reducing performance loss, and improving maintenance efficiency.
And S260, updating the second absolute timeout time into the updated first absolute timeout time, updating the target cache unit corresponding to the session node according to the updated second absolute timeout time, and switching the session node into the updated target cache unit for storage.
Specifically, when the current time is greater than or equal to the second absolute timeout time, it indicates that the session node needs to be deleted overtime currently, but the session node does not actually time out, so that the storage location of the session node needs to be updated. And the second absolute timeout time is updated to the updated first absolute timeout time, and based on the similar determination mode of the target cache unit, the target cache unit is determined again according to the updated second absolute timeout time, and the session node is stored in the updated target cache unit again, so that the session node is prevented from being maintained overtime at the moment.
According to the technical scheme of the embodiment, the first absolute timeout time and the second absolute timeout time are stored in the session node, so that when a new message of a certain session is received, the location of the session node can be updated after the second absolute timeout time of the session is reached, the situation that the location of the session node is updated once every message is received is avoided, the performance loss is further reduced, and the maintenance efficiency is improved.
On the basis of the above technical solution, as shown in fig. 4, the session node may be maintained for timeout based on the following steps S310 to S380:
s310, taking the first cache unit in the cache unit set as the current cache unit.
Specifically, based on the arrangement order of the buffer units in the buffer unit set, the first buffer unit is taken as the current buffer unit, so that the first buffer unit is scheduled when the start time is scheduled.
S320, detecting whether a session node is stored in the current cache unit which is currently scheduled; if so, the process proceeds to S330, otherwise, the process proceeds to S380.
S330, taking the first session node stored in the current cache unit as the current session node.
Specifically, the first session node is taken as the current session node to perform timeout maintenance based on the storage order of the session nodes stored in the cache unit.
S340, detecting whether the current time is larger than or equal to the first absolute timeout time in the current session node; if yes, the process proceeds to S350, otherwise, the process proceeds to S360.
S350, delete the current session node, and proceed to S370.
Specifically, when the current time is greater than or equal to the first absolute timeout time stored in the current session node, it indicates that the current session node actually has timed out, and at this time, the current session node needs to be deleted, so that the timeout maintenance can be performed in time.
And S360, updating the second absolute timeout time in the current session node to the first absolute timeout time in the current session node, re-determining the cache unit corresponding to the current session node according to the updated second absolute timeout time, switching the current session node to the re-determined cache unit for storage, and entering S370.
Specifically, when the current time is less than a first absolute timeout time stored in the current session node, it indicates that the current session node is not timeout, but a second absolute timeout time stored in the current session node is reached, at this time, the storage location of the current session node needs to be updated, that is, the second absolute timeout time is updated to be the first absolute timeout time, and the cache unit corresponding to the current session node is re-determined according to the updated second absolute timeout time, and the current session node is switched from the current cache unit to the cache unit after re-determination for storage, so that the session node can be maintained overtime when the first absolute timeout time is reached.
And S370, taking the next session node in the current cache unit as the current session node, and returning to the step S340.
Specifically, based on the sequence of the session nodes, the next session node of the current session node may be updated to be the current session node, and the operations in steps S340-S360 are performed, so that the next session node may be maintained for a timeout, and the operation in S380 may be performed until all the session nodes in the current cache unit are traversed.
And S380, taking the next cache unit in the cache unit set as the current cache unit, and returning to the step S320.
Specifically, based on the arrangement order of the buffer units, the next buffer unit of the current buffer unit is taken as the current buffer unit, and the operations of steps S320-S370 are returned to be executed to schedule the next buffer unit. When the current cache unit is the last cache unit in the cache unit set, the corresponding next cache unit is the first cache unit in the cache unit set, so that the cyclic scheduling of each cache unit is realized, and the maintenance efficiency is greatly improved.
The following is an embodiment of a session processing apparatus provided in an embodiment of the present invention, which belongs to the same inventive concept as the session processing methods of the above embodiments, and reference may be made to the above embodiment of the session processing method for details that are not described in detail in the embodiment of the session processing apparatus.
EXAMPLE III
Fig. 5 is a schematic structural diagram of a session processing apparatus according to a third embodiment of the present invention, where this embodiment is applicable to creating a session node for storing packet information and storing the created session node when a packet is received, so that a real-time timeout maintenance can be performed, and the apparatus specifically includes: a session node creation module 410 and a session node storage module 420.
The session node creating module 410 is configured to, when it is detected that a session node corresponding to a currently received packet is not stored in the cache unit set, create a session node corresponding to the packet, determine a first absolute timeout time based on a current time and a relative timeout time corresponding to the session node, and store the first absolute timeout time and information of the packet in the created session node; a session node storage module 420, configured to determine a target cache unit corresponding to a session node according to a scheduling start time and a first absolute timeout time corresponding to the cache unit set, and store the created session node in the target cache unit; the cache unit set comprises a plurality of sequentially arranged cache units, and each cache unit is sequentially and circularly scheduled according to the arrangement order so as to perform overtime maintenance on the session node stored in each cache unit.
Optionally, the apparatus further comprises: the session node detection module is used for: when a current processor receives a message through a DPDK interface of a preset data plane development kit, analyzing the currently received message to obtain message information; detecting whether a session node containing message information exists in a cache unit set corresponding to a current processor; if not, determining that the session node corresponding to the currently received message is not stored in the cache unit set.
Optionally, the session node creation module 410 includes: a first absolute timeout time determination unit configured to: and adding the current time and the relative timeout time corresponding to the session node, and determining the addition result as the first absolute timeout time.
Optionally, the session node storage module 420 includes: a target cache unit determination unit to: determining the difference between the first absolute timeout time and the scheduling start time corresponding to the cache unit set as delay time; dividing the delay time by the cycle period corresponding to the cache unit set, and taking the obtained remainder as the offset time; and dividing the offset time by the scheduling time corresponding to the cache unit, taking the obtained calculation result as the target ordinal number, and determining the cache unit corresponding to the target ordinal number in the cache unit set as the target cache unit.
Optionally, the session node storage module 420 includes: the session node storage unit is used for acquiring the number of session nodes contained in the target cache unit; if the number of the session nodes is smaller than the preset number, the created session nodes are stored in a target cache unit; and if the number of the session nodes is equal to the preset number, storing the created session nodes into the next cache unit of the target cache unit.
Optionally, the apparatus further comprises:
the first absolute timeout time updating module is used for updating the first absolute timeout time stored in the session node according to the current time and the relative timeout time corresponding to the session node when detecting that the session node corresponding to the currently received message is stored in the cache unit set;
and the target cache unit updating module is used for updating the target cache unit corresponding to the session node according to the updated first absolute timeout time, and switching the session node to the updated target cache unit for storage.
Optionally, the session node creating module 410 is further specifically configured to: determining a first absolute timeout time and a second absolute timeout time based on the current time and the relative timeout time corresponding to the session node, and storing the first absolute timeout time, the second absolute timeout time and the message information in the created session node, wherein the currently determined first absolute timeout time is the same as the second absolute timeout time;
correspondingly, the target cache unit updating module is specifically configured to: detecting whether the current time is greater than or equal to a second absolute timeout time; if so, updating the second absolute timeout time to the updated first absolute timeout time, updating the target cache unit corresponding to the session node according to the updated second absolute timeout time, and switching the session node to the updated target cache unit for storage.
Optionally, the apparatus further comprises: a buffer unit scheduling module, configured to:
sequentially taking each cache unit in the cache unit set as a current cache unit for scheduling;
when detecting that the session nodes are stored in the current cache unit which is currently scheduled, taking the stored session nodes as the current session nodes one by one;
detecting whether the current time is greater than or equal to a first absolute timeout time in the current session node;
if yes, deleting the current session node;
if not, updating the current session node to perform overtime maintenance on the next session node.
Optionally, the apparatus further comprises:
a buffer unit scheduling module, configured to:
and the cache unit re-determination module is used for updating the second absolute timeout time in the current session node to the first absolute timeout time in the current session node before updating the current session node, re-determining the cache unit corresponding to the current session node according to the updated second absolute timeout time, and switching the current session node to the re-determined cache unit for storage.
The session processing device provided by the embodiment of the invention can execute the session processing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects for executing the session processing method.
Example four
Fig. 6 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention. Fig. 6 illustrates a block diagram of an exemplary device 12 suitable for use in implementing embodiments of the present invention. The device 12 shown in fig. 6 is only an example and should not bring any limitations to the functionality and scope of use of the embodiments of the present invention.
As shown in FIG. 6, device 12 is in the form of a general purpose computing device. The components of device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 6, and commonly referred to as a "hard drive"). Although not shown in FIG. 6, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with device 12, and/or with any devices (e.g., network card, modem, etc.) that enable device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, the device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via the network adapter 20. As shown, the network adapter 20 communicates with the other modules of the device 12 via the bus 18. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 16 executes various functional applications and data processing by executing programs stored in the system memory 28, for example, to implement a session processing method provided by the embodiment of the present invention, the method includes:
when detecting that the session node corresponding to the currently received message is not stored in the cache unit set, creating the session node corresponding to the message, determining first absolute timeout time based on the current time and the relative timeout time corresponding to the session node, and storing the first absolute timeout time and the information of the message in the created session node;
determining a target cache unit corresponding to the session node according to the scheduling start time and the first absolute timeout time corresponding to the cache unit set, and storing the created session node into the target cache unit;
the cache unit set comprises a plurality of sequentially arranged cache units, and each cache unit is sequentially and circularly scheduled according to the arrangement order so as to perform overtime maintenance on the session node stored in each cache unit.
Of course, those skilled in the art will appreciate that the processor may also implement the solution of the method for determining the reserved inventory provided by any embodiment of the present invention.
EXAMPLE five
This fifth embodiment provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements the steps of a session processing method provided in any of the embodiments of the present invention, the method including:
when detecting that the session node corresponding to the currently received message is not stored in the cache unit set, creating the session node corresponding to the message, determining first absolute timeout time based on the current time and the relative timeout time corresponding to the session node, and storing the first absolute timeout time and the information of the message in the created session node;
determining a target cache unit corresponding to the session node according to the scheduling start time and the first absolute timeout time corresponding to the cache unit set, and storing the created session node into the target cache unit;
the cache unit set comprises a plurality of sequentially arranged cache units, and each cache unit is sequentially and circularly scheduled according to the arrangement order so as to perform overtime maintenance on the session node stored in each cache unit.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer-readable storage medium may be, for example but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It will be understood by those skilled in the art that the modules or steps of the invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and optionally they may be implemented by program code executable by a computing device, such that it may be stored in a memory device and executed by a computing device, or it may be separately fabricated into various integrated circuit modules, or it may be fabricated by fabricating a plurality of modules or steps thereof into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.