[go: up one dir, main page]

CN113645140A - Message statistical method, device, storage medium and network equipment - Google Patents

Message statistical method, device, storage medium and network equipment Download PDF

Info

Publication number
CN113645140A
CN113645140A CN202110761695.5A CN202110761695A CN113645140A CN 113645140 A CN113645140 A CN 113645140A CN 202110761695 A CN202110761695 A CN 202110761695A CN 113645140 A CN113645140 A CN 113645140A
Authority
CN
China
Prior art keywords
message
session identifier
preset
linked list
storage address
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN202110761695.5A
Other languages
Chinese (zh)
Other versions
CN113645140B (en
Inventor
刘志来
卢士鹏
米岩
周宝星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dawning Information Industry Beijing Co Ltd
Original Assignee
Dawning Information Industry Beijing Co Ltd
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 Dawning Information Industry Beijing Co Ltd filed Critical Dawning Information Industry Beijing Co Ltd
Priority to CN202110761695.5A priority Critical patent/CN113645140B/en
Publication of CN113645140A publication Critical patent/CN113645140A/en
Application granted granted Critical
Publication of CN113645140B publication Critical patent/CN113645140B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/02Topology update or discovery
    • 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
    • H04L45/742Route cache; Operation thereof
    • 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
    • H04L45/745Address table lookup; Address filtering
    • H04L45/7453Address table lookup; Address filtering using hashing
    • 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
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses a statistical method, a device, a storage medium and a network device of a message, wherein the statistical method of the message comprises the following steps: acquiring a first message and acquiring a first session identifier of a session to which the first message belongs; storing the first session identifier into a first storage address of a preset table, establishing a first linked list by taking a first byte number of the first message as a table head, and sending a reading command to a preset memory, wherein the first storage address corresponds to the first session identifier; if the second message is acquired when the write command is not returned from the preset memory, inserting a second byte number of the second message into the first linked list, wherein the second message and the first message have the same first session identifier; when a write command returned by the preset memory is acquired, counting the number of bytes and the number of messages according to the first linked list, so that the read-write times of the memory are reduced, and the throughput capacity of the network equipment is improved.

Description

Message statistical method, device, storage medium and network equipment
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and an apparatus for packet statistics, a storage medium, and a network device.
Background
In the Field of ethernet communication, a network device usually uses an FPGA (Field Programmable Gate Array) chip to store session information, and in practical applications, because a session established by a message stream of a certain network device may be as high as ten million and information included in one session may exceed ten million levels, storage in the FPGA overflows, the session information needs to be stored in a DDR SDRAM (Double Data Rate SDRAM).
However, if the number of messages and the number of bytes of a session need to be counted, and each time a message is received, the number of messages and the number of bytes in the DDR SDRAM need to be read out first, then a new number of messages and the number of bytes are added, and then the messages are written back to the DDR SDRAM.
Disclosure of Invention
The application provides a message statistical method, a message statistical device, a storage medium and network equipment, which can reduce the read-write times of a memory, thereby improving the throughput capacity of the network equipment.
In a first aspect, the present application provides a statistical method for a packet, where the statistical method for a packet includes:
acquiring a first message and acquiring a first session identifier of a session to which the first message belongs;
storing the first session identifier into a first storage address of a preset table, establishing a first linked list by taking a first byte number of the first message as a table header, and sending a reading command to a preset memory, wherein the first storage address corresponds to the first session identifier;
if a second message is acquired when the write command is not returned from the preset memory, inserting a second byte number of the second message into the first linked list, wherein the second message and the first message have the same first session identifier;
and when the write command returned by the preset memory is acquired, counting the number of bytes and the number of messages according to the first linked list.
In the above embodiment, the first session identifier is used as an index, the first linked list is established by using the byte number of the first message as a header, and a read command is sent to the memory, when the memory does not return a write command, the byte number of the second message having the same first session identifier as the first message is inserted into the first linked list, and a read command is not needed to be sent to the memory.
In one embodiment, the preset table is a hash table, and the statistical method further includes:
and calculating the hash value of the first session identifier according to a preset hash function to obtain the first storage address.
In the above embodiment, the hash table is a data structure, and the time complexity of insertion or lookup is O (1), that is, the target can be found after one calculation, so that the session identifier is stored by using the hash table, and the table lookup speed can be increased.
In an embodiment, the writing command carries an original byte number and an original message number, and the counting of the byte number and the message number according to the first linked list specifically includes:
accumulating the original byte number and all byte numbers stored in the first linked list to count the byte numbers;
and accumulating the original message number and the node number of the first linked list to count the message number.
In the above embodiment, since the first linked list stores the byte numbers of the multiple messages of the same session, when the memory returns the write command, the byte numbers of the multiple messages and the original byte number are directly accumulated, and the original message number and the node number of the first linked list are accumulated, so that the statistics of the byte numbers and the message numbers of the multiple messages can be completed, and the times of reading and writing the memory can be significantly reduced.
In an embodiment, the storing the first session identifier in a first storage address of a preset table specifically includes:
judging whether a second session identifier is stored in the first storage address, wherein the second session identifier is any session identifier different from the first session identifier;
if the first storage address stores a second session identifier, storing the first message into a preset cache region;
and if the first storage address does not store the second session identifier, storing the session identifier into the first storage address.
In the above embodiment, when the hash collision occurs, the first packet is stored in the preset cache region, and after the packet processing in the first storage address is completed, the first packet is taken out from the preset cache for processing, so that the processing of the next packet can be prevented from being affected, and the performance of the network device can be improved.
In an embodiment, after storing the first packet in a preset buffer, the statistical method further includes:
and when the first storage address is emptied, reading the first message from the preset cache region, and executing the step of storing the first message into the first storage address of a preset table.
In the above embodiment, when the first storage address is cleared, the first packet is read from the preset cache region to perform the statistical work of the packet stream, so that the statistical work of any packet stream is not affected.
In an embodiment, storing the first packet in a preset buffer specifically includes:
establishing a message table in the preset cache region according to the first session identifier, and storing the first message into the message table; if a third message is obtained, storing the third message into the message table, wherein the third message and the first message have the same first session identifier;
after the first message is stored in a preset buffer area, the method further includes: when the first storage address is emptied, reading the first message from the preset cache region, executing the step of storing the first session identifier into the first storage address of a preset table, and establishing a first linked list by taking the first byte number of the first message as a table header; and reading the third message from the message table, and inserting a third byte number of the third message into the first linked list.
In the above embodiment, the session identifier is used as an index in the preset cache region to build the table, and all messages of the message stream can be taken out without traversing all messages in the preset cache region, so that the processing speed is increased, and the processor resource is saved.
In an embodiment, inserting the second byte number of the second packet into the first linked list specifically includes:
and inserting the second byte number of the second message into the first linked list from the head of the first linked list.
In the embodiment, the data is inserted from the head of the linked list, so that the time for traversing the nodes can be saved, the processing resource is saved, and the insertion efficiency is improved.
In a second aspect, the present application further provides a device for counting packets, where the device for counting packets includes:
the device comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first message and acquiring a first session identifier of a session to which the first message belongs;
the processing module is used for storing the first session identifier into a first storage address of a preset table, establishing a first linked list by taking a first byte number of the first message as a table header, and sending a reading command to a preset memory, wherein the first storage address corresponds to the first session identifier;
the inserting module is used for inserting a second byte number of a second message into the first linked list if the second message is acquired when the write command is not returned from the preset memory, wherein the second message and the first message have the same first session identifier;
and the counting module is used for counting the number of bytes and the number of messages according to the first linked list when the write command returned by the preset memory is acquired.
In a third aspect, the present application further provides a computer-readable storage medium, where a plurality of instructions are stored, and the instructions are adapted to be loaded by a processor to perform any of the above statistical methods for a packet.
In a fourth aspect, the present application further provides a network device, including a processor and a memory, where the memory stores a computer program, and the processor is configured to use the computer program stored in the memory for any one of the above message statistical methods.
The statistical method is applied to network equipment, a first linked list is established by taking a first session identifier as an index and taking the byte number of the first message as a header, a read command is sent to a memory, when the memory does not return a write command, the byte number of a second message with the same first session identifier as the first message is inserted into the first linked list, the read command is not needed to be sent to the memory, when the memory returns the write-back command, the statistics of the message number and the byte number is directly carried out according to the first linked list, the statistics of the session message is not influenced, the times of reading and writing the memory are obviously reduced, and the throughput capacity of the network equipment is improved.
Drawings
The technical solution and other advantages of the present application will become apparent from the detailed description of the embodiments of the present application with reference to the accompanying drawings.
Fig. 1 is a schematic flow chart of a statistical method for a packet according to an embodiment of the present application.
Fig. 2 is a schematic structural diagram of a hash table provided in the embodiment of the present application.
Fig. 3 is another schematic flow chart of the statistical method for packets according to the embodiment of the present application.
Fig. 4 is a schematic view of an application scenario of the statistical method for a packet according to the embodiment of the present application.
Fig. 5 is a schematic structural diagram of a message statistics apparatus according to an embodiment of the present application.
Fig. 6 is a schematic structural diagram of a network device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. In the drawings, elements having similar structures are denoted by the same reference numerals. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the description of the present application, it is to be understood that the terms "first", "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, features defined as "first", "second", may explicitly or implicitly include one or more of the described features. In the description of the present application, "a plurality" means two or more unless specifically limited otherwise.
The embodiment of the application provides a message statistical method, a message statistical device, a storage medium and network equipment.
Referring to fig. 1, fig. 1 is a schematic flow chart of a statistical method for a packet according to an embodiment of the present application, where the statistical method mainly includes steps S101 to S104, and the description of each step is as follows:
s101, acquiring a first message and acquiring a first session identifier of a session to which the first message belongs.
With the continuous development of network technology, because ethernet has the characteristics of easy integration, low cost, long transmission distance and the like, in order to expand network functions to realize remote control and a more efficient data transmission function, more and more network devices need to be connected to the ethernet, and therefore programmable logic devices such as an FPGA based on the ethernet are receiving more and more attention. Taking FPGA as an example, in an actual network, the number of sessions established through a message stream of a certain network device is very large, and information included in one session may exceed ten million orders of magnitude, at this time, the FPGA cannot store therein, and the session information needs to be stored in DDR SDRAM (hereinafter referred to as DDR).
After receiving a message through an ethernet interface, an FPGA may first determine a session according to a five-tuple of the message (including a source IP, a destination IP, a protocol number, a source port number, and a destination port number of the message), where the messages having the same five-tuple belong to the same message stream, that is, belong to the same session, each session has an ID (session identifier), and in order to count the message stream and the byte number of the message stream, the number of the messages having the same ID and the byte number may be accumulated according to the ID as an index to count the number of the messages and the byte number in the stream, and then may be used for current limiting or warning.
S102, storing the first session identification into a first storage address of a preset table, establishing a first linked list by taking the first byte number of the first message as a table head, and sending a reading command to a preset memory, wherein the first storage address corresponds to the first session identification.
In this embodiment, the preset table may be a hash table, and the method may further include: and calculating the hash value of the first session identifier according to a preset hash function to obtain a first storage address.
It is easy to understand that the hash table is a data structure directly accessed according to a Key value (Key value), for example, given a table M, there is a function f (Key), and an address of a Key recorded in the table is obtained by substituting a function into any given Key value Key, where the function f (Key) is equivalent to a preset hash function in the present application, the present application does not limit a specific function form, the first session identifier is equivalent to a Key value, and the first storage address can be obtained by substituting the first session identifier into the preset hash function. Moreover, the hash table is a data structure, and the time complexity of insertion or search is O (1), i.e. the target can be found after one calculation, thereby improving the table look-up speed.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a hash table according to an embodiment of the present disclosure, as shown in fig. 2, an entry 110 of the hash table 100 may be used to store a session identifier and a linked list address, where the linked list 111 includes a plurality of nodes 1111, and the nodes 1111 are composed of a data field 1111-1 and a pointer field 1111-2, for example, in the embodiment, the number of bytes may be stored in the data field 1111-1.
In this embodiment, the step of storing the first session identifier in the first storage address of the preset table may include: judging whether a second session identifier is stored in the first storage address, wherein the second session identifier is any session identifier different from the first session identifier; if the first storage address stores the second session identifier, storing the first message into a preset cache region; and if the first storage address does not store the second session identifier, storing the first session identifier into the first storage address.
Specifically, if a second session identifier different from the first session identifier is stored in the first storage address, it means that a hash collision occurs, that is, the hash values calculated according to the first session identifier and the second session identifier may be the same, and at this time, a hash collision may be caused. For example, if the preset hash function intercepts the session identifier, for example, the session identifier is 28 bits, and the calculated hash value is 8 bits intercepted from the session identifier, there may be a case where the two session identifiers have the same intercepted value. At this time, in order to avoid affecting the processing of the next message, the first message may be stored in the preset buffer area, and after the message processing in the first storage address is completed, the first message is taken out from the preset buffer area for processing, so that the occurrence of a blocking condition can be avoided, and the performance of the network device is improved.
Specifically, after the first message is stored in the preset buffer, the statistical method may further include: and after the first storage address is emptied, reading the first message from the preset cache region, and executing the operation of storing the first session identifier into the first storage address of the preset table.
It is easy to understand that, after the DDR returns a write command, the memory address should be cleared after the packet statistics of the session corresponding to the second session identifier is completed, so as to facilitate the subsequent packet statistics. For example, the storage addresses corresponding to the session identifiers of session a and session B are the same, when the messages of session a are counted and the messages of session B are not counted yet, the messages of session a are stored in the preset buffer area, when the messages of session B are counted, the storage address is cleared, the messages of session a in the preset buffer area are read out for counting, and then the operations of storing the session identifiers of session a in the storage address, building a linked list and the like are performed.
In this embodiment, the step of "storing the first message in the preset buffer" may specifically include: establishing a message table in a preset cache area according to the first session identifier, and storing the first message into the message table; and if the third message is obtained, storing the third message into a message table, wherein the third message and the first message have the same first session identifier. After the first packet is stored in the preset buffer area, the statistical method may further include: when the first storage address is cleared, the step S102 is executed, the third packet is read from the packet table, and the number of bytes of the third packet is inserted into the first linked list.
It is easy to understand that, usually, when a session is established between two network devices, a large number of messages may be continuously generated, after a first message is stored in a preset buffer, a plurality of messages belonging to the same session as the first message, that is, messages having the same first session identifier may also be obtained, meanwhile, messages of other sessions may also be stored in the preset buffer, if all messages are irregularly stored in the preset buffer, when a first storage address is cleared, all messages in the preset buffer need to be traversed, and then all messages having the same first session identifier can be read, which is relatively low in efficiency. Therefore, when the message is stored in the preset buffer area, a message table can be established according to the session identifier of the message, all messages with the same session identifier are stored in one message table, for example, the message table is established by taking the first session identifier as an index, if a third message with the same first session identifier as the first message is subsequently obtained, the third message is directly stored in the message table, when the first storage address is emptied, the first session identifier is stored in the first storage address, a first linked list is established by taking the first byte number of the first message as a header, and then all messages in the message table are sequentially read and inserted into the first linked list.
S103, if a second message is obtained when the write command is not returned from the preset memory, inserting a second byte number of the second message into the first linked list, wherein the second message and the first message have the same first session identifier.
The messages with the same session identification belong to the same session, a second byte number of a second message of the same session with the first message is directly inserted into the first linked list without sending a read command to the preset memory, when the preset memory responds to the read command sent by the first message and returns a write command, the statistics of the first message and the second message of the same session can be directly completed according to the first linked list, and compared with the current statistical method that each message needs to send the read command to the preset memory, the method can reduce the times of reading and writing the memory, thereby improving the throughput capacity of the network equipment.
Specifically, step S103 may specifically include: and inserting the second byte number of the second message into the first linked list from the head of the first linked list.
It is easy to understand that the data insertion linked list can be inserted from the head, the middle and the tail, and considering that the traversal from the head is needed when the data insertion is performed from the middle and the tail, the second byte number can be directly inserted from the head, so that the processor resource is saved, and the insertion efficiency is improved.
And S104, when the write command returned by the preset memory is acquired, counting the number of bytes and the number of messages according to the first linked list.
Wherein, the write command carries the original byte number and the original message number, and step S104 may mainly include: accumulating the original byte number and all byte numbers stored in the first linked list to count the byte numbers; and accumulating the original message number and the node number of the first linked list to count the message number.
It is easy to understand that the byte number of each message with the same session identifier is stored in the first linked list, and the first linked list has the node number of how many messages are obtained altogether, so when the DDR returns a write command carrying the original byte number and the original message number, the original byte number is added to all the byte numbers stored in the first linked list to obtain the total byte number, and the original message number is added to the node number of the first linked list to obtain the total message number.
It can be known from the foregoing that, in this embodiment, a method for counting packets is provided, where a first packet is obtained, a first session identifier of a session to which the first packet belongs is obtained, the first session identifier is then stored in a first storage address of a preset table, a first linked list is established with a first byte number of the first packet as a header, and a read command is sent to a preset memory, where the first storage address corresponds to the first session identifier, and if a second packet is obtained when a write command is not returned from the preset memory, a second byte number of the second packet is inserted into the first linked list, and the second packet and the first packet have the same first session identifier.
Referring to fig. 3, fig. 3 is another schematic flow chart of the statistical method for a packet provided in the embodiment of the present application, and a specific flow of the statistical method for a packet provided in the embodiment may be as follows:
s201, a first message is obtained, and a first session identifier of a session to which the first message belongs is obtained.
After receiving a message through an ethernet interface, an FPGA may first determine a session according to a five-tuple of the message (including a source IP, a destination IP, a protocol number, a source port number, and a destination port number of the message), where the messages having the same five-tuple belong to the same message stream, that is, belong to the same session, each session has an ID (session identifier), and in order to count the message stream and the byte number of the message stream, the number of the messages having the same ID and the byte number may be accumulated according to the ID as an index to count the number of the messages and the byte number in the stream, and then may be used for current limiting or warning.
S202, calculating a hash value of the first session identifier by using a preset hash function to obtain a first storage address.
It is easy to understand that the hash table is a data structure directly accessed according to a Key value (Key value), for example, given a table M, there is a function f (Key), and an address of a Key recorded in the table is obtained by substituting a function into any given Key value Key, where the function f (Key) is equivalent to a preset hash function in the present application, the present application does not limit a specific function form, the first session identifier is equivalent to a Key value, and the first storage address can be obtained by substituting the first session identifier into the preset hash function.
S203, judging whether a first storage address of the preset hash table stores a second session identifier, wherein the second session identifier is any session identifier different from the first session identifier, if yes, executing a step S204, and if not, executing a step S206.
Specifically, if a second session identifier different from the first session identifier is stored in the first storage address, it means that a hash collision occurs, that is, the hash values calculated according to the first session identifier and the second session identifier may be the same, and at this time, a hash collision may be caused. For example, if the preset hash function intercepts the session identifier, for example, the session identifier is 28 bits, and the calculated hash value is 8 bits intercepted from the session identifier, there may be a case where the two session identifiers have the same intercepted value.
And S204, storing the first message into a preset cache region.
When the hash collision occurs, in order to avoid affecting the processing of the next message, the first message may be stored in the preset cache region, and after the message processing in the first storage address is completed, the first message is taken out from the preset cache region for processing, so that the occurrence of a blocking condition can be avoided, and the performance of the network device is improved.
For example, as shown in fig. 4, fig. 4 is an application scenario diagram of the statistical method for messages provided in the embodiment of the present application, when a message a is obtained, a Hash value calculated according to a session Identifier (ID) of the message a is Hash2, but the current Hash2 is not empty, so as to avoid affecting the processing of subsequent messages, the message a is first stored in a preset buffer, such as a Random Access Memory (RAM) in the figure.
S205, when the first storage address is cleared, reading the first message from the preset buffer area, and executing the step S206.
It is easy to understand that, after the DDR returns a write command, the memory address should be cleared after the packet statistics of the session corresponding to the second session identifier is completed, so as to facilitate the subsequent packet statistics. For example, the storage addresses corresponding to the session identifiers of session a and session B are the same, when the messages of session a are counted and the messages of session B are not counted yet, the messages of session a are stored in the preset buffer area, when the messages of session B are counted, the storage address is cleared, the messages of session a in the preset buffer area are read out for counting, and then the operations of storing the session identifiers of session a in the storage address, building a linked list and the like are performed.
In this embodiment, step S204 may specifically include: establishing a message table in a preset cache area according to the first session identifier, and storing the first message into the message table; and if the third message is obtained, storing the third message into a message table, wherein the third message and the first message have the same first session identifier.
After the first packet is stored in the preset buffer area, the statistical method may further include: when the first storage address is cleared, the step S206 is executed, the third packet is read from the packet table, and the byte number of the third packet is inserted into the first linked list.
It is easy to understand that, usually, when a session is established between two network devices, a large number of messages may be continuously generated, after a first message is stored in a preset buffer, a plurality of messages belonging to the same session as the first message, that is, messages having the same first session identifier may also be obtained, meanwhile, messages of other sessions may also be stored in the preset buffer, if all messages are irregularly stored in the preset buffer, when a first storage address is cleared, all messages in the preset buffer need to be traversed, and then all messages having the same first session identifier can be read, which is relatively low in efficiency. Therefore, when the message is stored in the preset buffer area, a message table can be established according to the session identifier of the message, all messages with the same session identifier are stored in one message table, for example, the message table is established by taking the first session identifier as an index, if a third message with the same first session identifier as the first message is subsequently obtained, the third message is directly stored in the message table, when the first storage address is emptied, the first session identifier is stored in the first storage address, a first linked list is established by taking the first byte number of the first message as a header, and then all messages in the message table are sequentially read and inserted into the first linked list.
S206, storing the session identification into a first storage address, establishing a first linked list by taking the first byte number of the first message as a header, and sending a read command to a preset memory.
S207, if a second message is obtained when the write command is not returned from the preset memory, and the second message and the first message have the same session identifier, inserting the second byte number of the second message into the first linked list.
It is easy to understand that the messages with the same session identifier all belong to the same session, the second byte number of the second message with the same session as the first message is directly inserted into the first linked list without sending a read command to the preset memory, when the preset memory responds to the read command sent by the first message and returns a write command, the statistics of the first message and the second message with the same session can be directly completed according to the first linked list.
Specifically, step S207 may specifically include: and inserting the second byte number of the second message into the first linked list from the head of the first linked list.
It is easy to understand that the data insertion linked list can be inserted from the head, the middle and the tail, and considering that the traversal from the head is required when the data insertion is performed from the middle and the tail, the second byte number can be directly inserted from the head, so that the processing resource is saved, and the insertion efficiency is improved.
And S208, when the write command returned by the preset memory is acquired, counting the number of bytes and the number of messages according to the first linked list.
Wherein, the write command carries the original byte number and the original message number, and step S104 may mainly include: accumulating the original byte number and all byte numbers stored in the first linked list to count the byte numbers; and accumulating the original message number and the node number of the first linked list to count the message number.
It is easy to understand that the byte number of each message with the same session identifier is stored in the first linked list, and the number of the obtained messages is the same as the number of the nodes of the first linked list, so that when the DDR returns a write command carrying the original byte number and the original message number, the original byte number is added to all the byte numbers stored in the first linked list to obtain the total byte number, and the original message number is added to the node number of the first linked list to obtain the total message number.
From the above, this embodiment provides a statistical method for packets, which includes obtaining a first packet, obtaining a first session identifier of a session of the first packet, then calculating a hash value of the first session identifier using a preset hash function to obtain a first storage address, then determining whether a second session identifier is stored in the first storage address of a preset hash table, if so, storing the first packet in a preset buffer, when the first storage address is cleared, reading the first packet from the preset buffer, thereby avoiding affecting the processing of subsequent packets when a hash collision occurs, improving the performance of a network device, if not, storing the session identifier in the first storage address, establishing a first linked list using a first byte number of the first packet as a header, sending a read command to a preset memory, and if a write command is not returned from the preset memory, obtaining the second packet, and when the write command returned by the preset memory is acquired, counting the number of bytes and the number of messages according to the first linked list, so that the correctness of message counting is not influenced, the read-write times of the memory can be reduced, and the throughput capacity of the network equipment is improved.
According to the method described in the foregoing embodiment, this embodiment will be further described from the perspective of a statistical apparatus of a packet, and the statistical apparatus of the packet may be specifically implemented as an independent entity, and may also be implemented by being integrated in a network device.
Referring to fig. 5, fig. 5 specifically describes a statistical apparatus for a packet according to an embodiment of the present application, where the statistical apparatus 10 for a packet includes an obtaining module 11, a processing module 12, an inserting module 13, and a statistical module 14, where:
(1) acquisition module 11
The obtaining module 11 is configured to obtain the first message, and obtain a first session identifier of a session to which the first message belongs.
In this embodiment, the statistical apparatus 10 may further include a calculating module, configured to calculate a hash value of the first session identifier according to a preset hash function, so as to obtain the first storage address.
(2) Processing module 12
The processing module 12 is configured to store the first session identifier in a first storage address of the preset table, establish a first linked list with a first byte number of the first packet as a header, and send a read command to the preset memory, where the first storage address corresponds to the first session identifier.
In this embodiment, the processing module 12 may be mainly configured to: judging whether the first storage address stores a second session identifier, wherein the second session identifier is any session identifier different from the first session identifier; if the first storage address stores the second session identifier, storing the first message into a preset cache region; and if the first table storage address does not store the second session identifier, storing the session identifier into the first storage address.
Further, the processing module 12 is specifically further configured to: and when the first storage address is emptied, reading the first message from the preset cache region, and storing the first message into the first storage address of the preset table and subsequent steps.
Further, the processing module 12 may be further configured to: establishing a message table in a preset cache area according to the first session identifier, and storing the first message into the message table; if the third message is obtained, storing the third message into a message table, wherein the third message and the first message have the same first session identifier;
after the first message is stored in the preset cache region, when the first storage address is emptied, reading the first message from the preset cache region, executing the step of storing the first session identifier in the first storage address of the preset table, and establishing a first linked list by taking the first byte number of the first message as a table header; and reading a third message from the message table, and inserting a third byte number of the third message into the first linked list.
(3) Plug-in module 13
The inserting module 13 is configured to insert a second byte number of the second packet into the first linked list if the second packet is acquired when the write command is not returned from the preset memory, where the second packet and the first packet have the same first session identifier.
In this embodiment, the insertion module 13 may specifically be configured to: and inserting the second byte number of the second message into the first linked list from the head of the first linked list.
(4) Statistics module 14
And the counting module 14 is configured to count the number of bytes and the number of messages according to the first linked list when the write command returned by the preset memory is acquired.
In this embodiment, the write command carries an original byte number and an original message number, and the statistical module 14 is specifically configured to: accumulating the original byte number and all byte numbers stored in the first linked list to count the byte numbers; and accumulating the original message number and the node number of the first linked list to count the message number.
As can be seen from the above, this embodiment provides a message statistics apparatus, in which the message statistics apparatus 10 obtains a first message through an obtaining module 11, and obtains a first session identifier of a session to which the first message belongs, then a processing module 12 stores the first session identifier in a first storage address of a preset table, and establishes a first linked list using a first byte number of the first message as a header, and sends a read command to a preset memory, where the first storage address corresponds to the first session identifier, and if a write command is not returned from the preset memory, and a second message is obtained, an inserting module 13 inserts a second byte number of the second message into the first linked list, where the second message and the first message have the same first session identifier, and when a write command returned from the preset memory is obtained, a statistics module 14 performs statistics on the byte number and the message number according to the first linked list, thereby reducing the read-write frequency of the memory, the throughput capacity of the network equipment is improved.
In addition, an embodiment of the present application further provides a network device, as shown in fig. 6, a network device 600 includes a processor 601 and a memory 602. The processor 601 is electrically connected to the memory 602.
The memory 602 may be configured to store software programs and modules, such as the statistical method of messages and corresponding program instructions/modules in the foregoing embodiments, and the processor 601 executes various functional applications and data processing by operating the software programs and modules stored in the memory 602, that is, implements a communication data saving function. The memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 602 may further include memory located remotely from the processor 601, which may be connected to the network device 600 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The processor 601 is a control center of the network device 600, connects various parts of the entire device using various interfaces and lines, and performs various functions of the network device 600 and processes data by running or executing software programs and/or modules stored in the memory 602 and calling data stored in the memory 602, thereby performing overall monitoring of the device. Optionally, processor 601 may include one or more processing cores; in some embodiments, processor 601 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 610.
In addition, the network device may further include an RF circuit for receiving and transmitting electromagnetic waves, and implementing interconversion of the electromagnetic waves and electrical signals, thereby communicating with a communication network or other devices. The RF circuitry may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption/decryption chips, Subscriber Identity Module (SIM) cards, memory, and so forth. The RF circuitry may communicate with various networks, such as the internet, an intranet, a wireless network, or with other devices over a wireless network. The wireless network may comprise a cellular telephone network, a wireless local area network, or a metropolitan area network. The wireless network may use various communication standards, protocols, and technologies, for example, the wireless network may be an ethernet network using an ethernet protocol.
In this embodiment, the processor 601 in the network device 600 loads instructions corresponding to processes of one or more application programs into the memory 602 according to the following steps, and the processor 601 runs the application programs stored in the memory 602, thereby implementing various functions:
acquiring a first message and acquiring a first session identifier of a session to which the first message belongs;
storing the first session identifier into a first storage address of a preset table, establishing a first linked list by taking a first byte number of the first message as a table head, and sending a reading command to a preset memory, wherein the first storage address corresponds to the first session identifier;
if the second message is acquired when the write command is not returned from the preset memory, inserting a second byte number of the second message into the first linked list, wherein the second message and the first message have the same first session identifier;
and when a write command returned by the preset memory is acquired, counting the number of bytes and the number of messages according to the first linked list.
The network device may be any terminal device having a communication function, such as a smart phone, a tablet computer, a notebook computer, and the like.
In specific implementation, the above modules may be implemented as independent entities, or may be combined arbitrarily to be implemented as the same or several entities, and specific implementation of the above modules may refer to the foregoing method embodiments, which are not described herein again.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor. To this end, embodiments of the present application provide a storage medium including network device executable instructions. The network device executable instructions, when executed by a network device processor, perform the steps of any of the statistical methods for providing messages according to the embodiments of the present application.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium may execute the steps in any of the statistical methods for a packet provided in the embodiments of the present application, beneficial effects that can be achieved by any of the statistical methods for a packet provided in the embodiments of the present application may be achieved, which are detailed in the foregoing embodiments and will not be described herein again.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
In summary, although the present application has been described with reference to the preferred embodiments, the above-described preferred embodiments are not intended to limit the present application, and those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present application, so that the scope of the present application shall be determined by the appended claims.

Claims (10)

1. A statistical method of messages is characterized in that the statistical method of messages comprises the following steps:
acquiring a first message and acquiring a first session identifier of a session to which the first message belongs;
storing the first session identifier into a first storage address of a preset table, establishing a first linked list by taking a first byte number of the first message as a table header, and sending a reading command to a preset memory, wherein the first storage address corresponds to the first session identifier;
if a second message is acquired when the write command is not returned from the preset memory, inserting a second byte number of the second message into the first linked list, wherein the second message and the first message have the same first session identifier;
and when the write command returned by the preset memory is acquired, counting the number of bytes and the number of messages according to the first linked list.
2. The packet statistical method according to claim 1, wherein the preset table is a hash table, and the statistical method further comprises:
and calculating the hash value of the first session identifier according to a preset hash function to obtain the first storage address.
3. The method according to claim 1, wherein the write command carries an original byte number and an original message number, and the counting of the byte number and the message number according to the first linked list specifically includes:
accumulating the original byte number and all byte numbers stored in the first linked list to count the byte numbers;
and accumulating the original message number and the node number of the first linked list to count the message number.
4. The message statistical method according to claim 1, wherein the storing the first session identifier in a first storage address of a preset table specifically includes:
judging whether a second session identifier is stored in the first storage address, wherein the second session identifier is any session identifier different from the first session identifier;
if the first storage address stores a second session identifier, storing the first message into a preset cache region;
and if the first storage address does not store the second session identifier, storing the session identifier into the first storage address.
5. The message statistic method according to claim 4, wherein after the storing the first message into a preset buffer, the statistic method further comprises:
and when the first storage address is emptied, reading the first message from the preset cache region, and executing the step of storing the first message into the first storage address of a preset table.
6. The message statistical method according to claim 4, wherein storing the first message in a preset buffer specifically includes:
establishing a message table in the preset cache region according to the first session identifier, and storing the first message into the message table; if a third message is obtained, storing the third message into the message table, wherein the third message and the first message have the same first session identifier;
after the first message is stored in a preset buffer area, the method further includes: when the first storage address is emptied, reading the first message from the preset cache region, executing the step of storing the first session identifier into the first storage address of a preset table, and establishing a first linked list by taking the first byte number of the first message as a table header; and reading the third message from the message table, and inserting a third byte number of the third message into the first linked list.
7. The packet statistical method according to claim 1, wherein a second byte number of the second packet is inserted into the first linked list, and specifically includes:
and inserting the second byte number of the second message into the first linked list from the head of the first linked list.
8. A message statistic device, wherein the message statistic device comprises:
the device comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first message and acquiring a first session identifier of a session to which the first message belongs;
the processing module is used for storing the first session identifier into a first storage address of a preset table, establishing a first linked list by taking a first byte number of the first message as a table header, and sending a reading command to a preset memory, wherein the first storage address corresponds to the first session identifier;
the inserting module is used for inserting a second byte number of a second message into the first linked list if the second message is acquired when the write command is not returned from the preset memory, wherein the second message and the first message have the same first session identifier;
and the counting module is used for counting the number of bytes and the number of messages according to the first linked list when the write command returned by the preset memory is acquired.
9. A computer-readable storage medium having stored thereon a plurality of instructions adapted to be loaded by a processor to perform the statistical method of messages according to any one of claims 1 to 7.
10. A network device, characterized in that it comprises a processor and a memory, in which a computer program is stored, said processor being adapted to execute the statistical method of messages according to any one of claims 1 to 7 by calling said computer program stored in said memory.
CN202110761695.5A 2021-07-06 2021-07-06 Message statistical method, device, storage medium and network equipment Active CN113645140B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110761695.5A CN113645140B (en) 2021-07-06 2021-07-06 Message statistical method, device, storage medium and network equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110761695.5A CN113645140B (en) 2021-07-06 2021-07-06 Message statistical method, device, storage medium and network equipment

Publications (2)

Publication Number Publication Date
CN113645140A true CN113645140A (en) 2021-11-12
CN113645140B CN113645140B (en) 2023-04-07

Family

ID=78416846

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110761695.5A Active CN113645140B (en) 2021-07-06 2021-07-06 Message statistical method, device, storage medium and network equipment

Country Status (1)

Country Link
CN (1) CN113645140B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114499889A (en) * 2022-02-24 2022-05-13 成都北中网芯科技有限公司 Method suitable for network processing chip to store ultra-large specification session
CN115174446A (en) * 2022-07-21 2022-10-11 天翼云科技有限公司 Network traffic statistical method and device and electronic equipment
CN115622945A (en) * 2022-09-15 2023-01-17 新华三信息安全技术有限公司 A message processing method and device

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070266037A1 (en) * 2004-11-05 2007-11-15 Data Robotics Incorporated Filesystem-Aware Block Storage System, Apparatus, and Method
US20120124294A1 (en) * 2007-12-06 2012-05-17 Fusion-Io, Inc. Apparatus, system, and method for destaging cached data
CN103593477A (en) * 2013-11-29 2014-02-19 华为技术有限公司 Collocation method and device of Hash database
CN104484281A (en) * 2014-12-26 2015-04-01 杭州华三通信技术有限公司 Data storage method, data search method, data storage device and data search device
CN109274593A (en) * 2018-08-31 2019-01-25 新华三信息安全技术有限公司 A kind of information storage means and device
CN109670083A (en) * 2018-12-13 2019-04-23 武汉中元华电科技股份有限公司 A kind of FPGA realization device and method based on dynamic memory distribution storage HASH chained list
CN109962861A (en) * 2019-03-28 2019-07-02 新华三信息安全技术有限公司 A kind of message statistical method and device
CN110166318A (en) * 2019-05-15 2019-08-23 杭州迪普科技股份有限公司 A kind of data statistical approach and device
CN110806986A (en) * 2019-11-04 2020-02-18 盛科网络(苏州)有限公司 Method, device and storage medium for improving message storage efficiency of network chip
CN112948313A (en) * 2021-03-01 2021-06-11 杭州迪普科技股份有限公司 Session data management method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070266037A1 (en) * 2004-11-05 2007-11-15 Data Robotics Incorporated Filesystem-Aware Block Storage System, Apparatus, and Method
US20120124294A1 (en) * 2007-12-06 2012-05-17 Fusion-Io, Inc. Apparatus, system, and method for destaging cached data
CN103593477A (en) * 2013-11-29 2014-02-19 华为技术有限公司 Collocation method and device of Hash database
CN104484281A (en) * 2014-12-26 2015-04-01 杭州华三通信技术有限公司 Data storage method, data search method, data storage device and data search device
CN109274593A (en) * 2018-08-31 2019-01-25 新华三信息安全技术有限公司 A kind of information storage means and device
CN109670083A (en) * 2018-12-13 2019-04-23 武汉中元华电科技股份有限公司 A kind of FPGA realization device and method based on dynamic memory distribution storage HASH chained list
CN109962861A (en) * 2019-03-28 2019-07-02 新华三信息安全技术有限公司 A kind of message statistical method and device
CN110166318A (en) * 2019-05-15 2019-08-23 杭州迪普科技股份有限公司 A kind of data statistical approach and device
CN110806986A (en) * 2019-11-04 2020-02-18 盛科网络(苏州)有限公司 Method, device and storage medium for improving message storage efficiency of network chip
CN112948313A (en) * 2021-03-01 2021-06-11 杭州迪普科技股份有限公司 Session data management method and device

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114499889A (en) * 2022-02-24 2022-05-13 成都北中网芯科技有限公司 Method suitable for network processing chip to store ultra-large specification session
CN114499889B (en) * 2022-02-24 2023-06-30 成都北中网芯科技有限公司 Method suitable for network processing chip to store oversized conversation
CN115174446A (en) * 2022-07-21 2022-10-11 天翼云科技有限公司 Network traffic statistical method and device and electronic equipment
CN115174446B (en) * 2022-07-21 2023-11-03 天翼云科技有限公司 Network traffic statistics method and device and electronic equipment
CN115622945A (en) * 2022-09-15 2023-01-17 新华三信息安全技术有限公司 A message processing method and device

Also Published As

Publication number Publication date
CN113645140B (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN113645140B (en) Message statistical method, device, storage medium and network equipment
CN116418893A (en) Data management method and corresponding device
CN103188042B (en) A kind of matching process of IP packet and coupling accelerator
CA3064969C (en) State switching method, network device and terminal device
CN114265788A (en) A device, method, device and medium for memory management
US20220311773A1 (en) Method and device for communication between microservices
CN119299370A (en) Flow table aging method based on RoCEv2 message and its application
US9923794B2 (en) Method, apparatus, and system for identifying abnormal IP data stream
CN114448858B (en) Message broadcasting method, device, network equipment and storage medium
CN115396345A (en) Flow measuring method, device and related equipment
CN116506355B (en) Processing method for unloading flow chart storage and related device
CN115996203B (en) Network traffic domain division method, device, equipment and storage medium
CN117579512A (en) Message communication method, device, electronic equipment and storage medium
CN114172831B (en) Brute force cracking method, system, computer and storage medium
CN114567614B (en) Method and device for realizing ARP protocol processing based on FPGA
CN112532610B (en) Intrusion prevention detection method and device based on TCP segmentation
CN115988574A (en) Data processing method, system, device and storage medium based on flow table
CN115297082A (en) ARP protocol processing method and system based on cooperation of FPGA and eBPF
CN115913784A (en) Network attack defense system, method and device and electronic equipment
WO2022222693A1 (en) Message processing method and apparatus, electronic device, and computer-readable storage medium
CN115412333A (en) Message data processing method and device and electronic equipment
CN112312514A (en) Method, device and equipment for accessing network and computer readable storage medium
CN107295539A (en) A kind of surfing flow service condition method for pushing and device
CN111163100A (en) Data structure, communication method, device, storage medium and equipment
CN119363642B (en) Flow table processing method, flow table processing system and network card

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant