CN114979038A - Data packet filtering method and device - Google Patents

Data packet filtering method and device Download PDF

Info

Publication number
CN114979038A
CN114979038A CN202210549960.8A CN202210549960A CN114979038A CN 114979038 A CN114979038 A CN 114979038A CN 202210549960 A CN202210549960 A CN 202210549960A CN 114979038 A CN114979038 A CN 114979038A
Authority
CN
China
Prior art keywords
sequence number
data packet
list
network port
packet
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.)
Pending
Application number
CN202210549960.8A
Other languages
Chinese (zh)
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.)
Hangzhou Kangjisen Automation Technology Co ltd
Original Assignee
Hangzhou Kangjisen Automation Technology 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 Hangzhou Kangjisen Automation Technology Co ltd filed Critical Hangzhou Kangjisen Automation Technology Co ltd
Priority to CN202210549960.8A priority Critical patent/CN114979038A/en
Publication of CN114979038A publication Critical patent/CN114979038A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/55Prevention, detection or correction of errors
    • H04L49/552Prevention, detection or correction of errors by ensuring the integrity of packets received through redundant connections
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/32Flow control; Congestion control by discarding or delaying data units, e.g. packets or frames
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/34Flow control; Congestion control ensuring sequence integrity, e.g. using sequence numbers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • H04L49/9057Arrangements for supporting packet reassembly or resequencing
    • 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)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses a data packet filtering method and device, and belongs to the field of communication. The data packet filtering method provided by the application comprises the following steps: receiving a first data packet through a first network port; determining a sequence number corresponding to the first data packet; under the condition that the sequence number corresponding to the first data packet is matched with the recorded sequence number, discarding the first data packet; under the condition that the sequence number corresponding to the first data packet does not match the recorded sequence number, reserving the first data packet; and the recorded sequence number is a sequence number corresponding to the data packet received and reserved through the second network port.

Description

Data packet filtering method and device
Technical Field
The application belongs to the field of communication, and particularly relates to a data packet filtering method and device.
Background
With the requirement for higher reliability of network communication among various devices, it is very common to use a redundant network manner for network communication. The redundant network mode for network communication refers to that a plurality of networks simultaneously transmit and receive data packets, and when a plurality of repeated data packets are received, the receiving equipment filters the repeated data packets and only one of the repeated data packets is reserved.
In the related art, taking two redundant networks as an example, a method for filtering duplicate packets for the redundant networks generally includes: maintaining a sliding window according to the sequence number in the data packet; receiving and reserving the data packet when the sequence number of the data packet is within a specified range, and adjusting the sequence number range specified by the sliding window according to the sequence number of the data packet; the data packet is discarded when the sequence number of the data packet is out of a specified range, wherein the specified range refers to the sequence number range specified by the sliding window.
However, the related art is limited by network transmission delay, packet loss and other factors, and the repeated data packets cannot be effectively filtered under the condition that the sequence number of the data packets is disordered due to data packet disorder, packet loss and the like.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method and an apparatus for filtering a data packet, which can solve the problem in the related art that a duplicate data packet cannot be effectively filtered when a sequence number of the data packet is disordered.
In a first aspect, an embodiment of the present application provides a data packet filtering method, where the method includes:
receiving a first data packet through a first network port;
determining a sequence number corresponding to the first data packet;
under the condition that the sequence number corresponding to the first data packet is matched with the recorded sequence number, discarding the first data packet;
when the sequence number corresponding to the first data packet does not match the recorded sequence number, reserving the first data packet;
and the recorded sequence number is a sequence number corresponding to the data packet received and reserved through the second network port.
In a second aspect, an embodiment of the present application provides a data packet filtering apparatus, including:
the device comprises a receiving module, a determining module, a discarding module and a retaining module;
the receiving module is used for receiving a first data packet through a first network port;
the determining module is configured to determine a sequence number corresponding to the first data packet;
the discarding module is configured to discard the first data packet when a sequence number corresponding to the first data packet matches a recorded sequence number;
the reservation module is configured to reserve the first data packet when the sequence number corresponding to the first data packet does not match the recorded sequence number;
and the recorded sequence number is a sequence number corresponding to the data packet received and reserved through the second network port.
In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, where the memory stores a program or instructions, and the program or instructions, when executed by the processor, implement the steps of the method according to the first aspect.
In a fourth aspect, embodiments of the present application provide a readable storage medium on which a program or instructions are stored, which when executed implement the steps of the method according to the first aspect.
In the embodiment of the application, a first data packet is received through a first network port; determining a sequence number corresponding to the first data packet; under the condition that the sequence number corresponding to the first data packet is matched with the recorded sequence number, discarding the first data packet; under the condition that the sequence number corresponding to the first data packet does not match the recorded sequence number, reserving the first data packet; and the recorded sequence number is a sequence number corresponding to the data packet received and reserved through the second network port. Thus, in an application scenario where the sequence numbers of the data packets are confused, when the sequence number corresponding to the first data packet received through the first network port matches the recorded sequence number, it is described that the data packet overlapping with the first data packet has been received and retained by the second network port, and at this time, the first data packet may be discarded; under the condition that the sequence number corresponding to the first data packet received by the first network port is not matched with the recorded sequence number, the data packet repeated with the first data packet is not received and reserved through the second network port, and at the moment, the first data packet can be reserved, so that under the condition that the sequence number of the data packet is disordered, the data packet corresponding to the recorded sequence number can be discarded, and the filtering of the repeated data packet can be effectively realized.
Drawings
Fig. 1-1 is a schematic structural diagram of an application scenario in which network communication is performed between devices in an industrial automation control field in a redundant network manner according to an embodiment of the present application;
fig. 1-2 are schematic flow charts of a packet filtering method provided by an embodiment of the present application;
FIG. 2 is a schematic flow chart diagram of another packet filtering method provided in an embodiment of the present application;
FIG. 3 is a schematic flow chart diagram of another packet filtering method provided by an embodiment of the present application;
fig. 4 is a schematic structural diagram of a first list and a second list provided in an embodiment of the present application;
FIG. 5 is a schematic flow chart diagram of another packet filtering method provided by an embodiment of the present application;
FIG. 6 is a schematic flow chart diagram of another packet filtering method provided in an embodiment of the present application;
FIG. 7 is a schematic flow chart diagram of another packet filtering method provided by an embodiment of the present application;
fig. 8 is a schematic structural diagram of a packet filtering apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Description of reference numerals: 101-an upper computer; 102-a controller; 103-gateway.
Detailed Description
The technical solutions in the embodiments of the present application will be described clearly below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of the present disclosure.
The terms first, second and the like in the description and in the claims of the present application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the application are capable of operation in sequences other than those illustrated or described herein, and that the terms "first," "second," etc. are generally used in a generic sense and do not limit the number of terms, e.g., a first term can be one or more than one. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.
The applicant has noticed that the related art is limited by network transmission delay, packet loss and other factors, and the repeated data packets cannot be effectively filtered under the condition that the sequence number of the data packet is disordered due to the occurrence of data packet disorder, packet loss and the like. For example, in an application scenario where the same packets are received through two networks, the two networks use the same sliding window, the width of the sliding window is 50, and after a packet with a sequence number of 100 is received through any one of the two networks, the specified sequence number range of the sliding window may be adjusted to [101,150], at this time, when a duplicate packet with a sequence number of 100 is received through the other network of the two networks, the duplicate packet with a sequence number of 100 cannot be received because its sequence number is outside the specified sequence number range [101,150] of the sliding window, and filtering of the duplicate packet is implemented. In practical applications, the sequence number of the next received packet may be 101 without the sequence number of the packet being confused, and if the sequence number of the packet is confused, for example, the sequence number of the next packet received through any of the two networks is 10, the packet with the sequence number of 10 cannot be received because its sequence number is outside the specified sequence number range [101,150] of the sliding window, so that the packet is lost and the duplicate packets cannot be filtered effectively.
Based on this, the packet filtering method provided by the embodiment of the present application improves the function of the window lists corresponding to the two networks, and the list is a window list for discarding the packet with the specified sequence number, compared with the sliding window for receiving the packet with the specified sequence number in the related art. For example, when a first packet is received through a first network, the first packet may be retained and a first sequence number corresponding to the first packet may be recorded in a second list corresponding to a second network, and then, when a packet that is duplicated with the first packet is received again through the second network, since the first sequence number corresponding to the first packet is recorded in the second list corresponding to the second network, the duplicated packet may be discarded according to the sequence number recorded in the second list, so that filtering of duplicated packets is effectively achieved by discarding the packet with the specified sequence number.
In addition, the list in the embodiment of the application is used for discarding the data packet with the specified sequence number, and the characteristic is not limited by the disorder of the sequence number of the data packet, and the repeated data packet can be effectively filtered even if the sequence number of the data packet is disordered. For example, for a first network of the two networks, after receiving and retaining a packet with sequence number 100 via the first network, sequence number 100 may be recorded in a corresponding second list of the second network. At this time, if the sequence number of the data packet is disordered, for example, the sequence number of the next data packet received through the first network is 10, because the sequence number 10 is not recorded in the first list corresponding to the first network, the data packet with the sequence number of 10 received through the first network may be retained, and the sequence number of 10 may be recorded in the second list corresponding to the second network, so that the data packet with the sequence number of 10 received through the second network later is discarded, so that, in the case of disordered sequence numbers of the data packets, the duplicated data packets are discarded through the recorded sequence numbers in the lists, and the filtering of duplicated data packets is effectively realized.
The following describes the packet filtering method provided in the embodiment of the present application in detail through specific embodiments and application scenarios thereof with reference to the accompanying drawings.
It can be understood that, in a scenario of filtering a received redundant duplicate data packet, the data packet filtering method provided in the embodiment of the present application may be specifically applied to each receiving device in an industrial control system.
For example, as shown in fig. 1-1, in an industrial control system, an upper computer 101 may communicate with a controller 102 through an SNETA port and an SNETB port, and in a case that the upper computer receives a duplicate data packet sent by the controller through the SNETA port and the SNETB port, the data packet filtering method provided in the embodiment of the present application may be applied to the upper computer to filter the duplicate data packet received by the upper computer; under the condition that the controller receives the repeated data packets sent by the upper computer through the SNETA port and the SNETB port, the data packet filtering method provided by the embodiment of the application can be applied to the controller and is used for filtering the repeated data packets received by the controller.
For another example, as shown in fig. 1-1, in an industrial control system, the controller 102 may communicate with the gateway 103 through an INETA port and an INETB port, and in a case that the gateway receives a duplicate packet sent by the controller through the INETA port and the INETB port, the packet filtering method provided in the embodiment of the present application may be applied to the gateway to filter the duplicate packet received by the gateway; under the condition that the controller receives the repeated data packets sent by the gateway through the INETA port and the INETB port, the data packet filtering method provided by the embodiment of the application can be applied to the controller to filter the repeated data packets received by the controller.
Of course, the data packet filtering method provided in this embodiment of the present application may also be used in other types of receiving devices in the communication field, and this application is not limited in this respect.
Fig. 1-2 are schematic flow charts of a packet filtering method according to an embodiment of the present disclosure.
As shown in fig. 1-2, the method for filtering a data packet according to the embodiment of the present application may include:
step 110: receiving a first data packet through a first network port;
step 120: determining a sequence number corresponding to the first data packet;
step 130: discarding the first data packet when the sequence number corresponding to the first data packet matches the recorded sequence number;
step 140: under the condition that the sequence number corresponding to the first data packet does not match the recorded sequence number, reserving the first data packet;
and the recorded sequence number is a sequence number corresponding to the data packet received and reserved through the second network port.
In step 110, the first packet may be a packet received by the first network port. Specifically, the data packet filtering method provided in this embodiment may be applied to a receiving device, where the receiving device communicates with a sending device through a first network port and a second network port, the first network port and the second network port are backup network ports for each other, and a first data packet received through the first network port and a second data packet received through the second network port may be duplicated. The data packet filtering method provided by the embodiment of the application can be used for filtering the data packet received by the first network port and the data packet received by the second network port, and one part of repeated data packets is reserved.
In step 120, in the process of determining the sequence number corresponding to the first data packet, the first data packet itself carries the sequence number of the data packet, and the sequence number corresponding to the first data packet may be determined directly through information carried by the first data packet itself.
In steps 130 and 140, the matching manner between the sequence number corresponding to the first data packet and the recorded sequence number may be: under the condition that one sequence number in the recorded sequence numbers is the same as the sequence number corresponding to the first data packet, the sequence number corresponding to the first data packet is matched with the recorded sequence number; and under the condition that the recorded serial numbers are different from the serial number corresponding to the first data packet, the serial number corresponding to the first data packet is not matched with the recorded serial number.
In step 130 and step 140, it can be understood that since the recorded sequence numbers include: when the sequence number corresponding to the first data packet matches the recorded sequence number, indicating that the data packet received by the second network port and repeated with the first data packet has been reserved, and discarding the first data packet received by the first network port; and under the condition that the sequence number corresponding to the first data packet does not match the recorded sequence number, indicating that the second network port has not received and retains the data packet which is duplicated with the first data packet, and retaining the first data packet received by the first network port at the moment. Therefore, under the condition of receiving the repeated data packets through the first network port, the repeated data packets can be effectively filtered, and only one data packet is reserved.
Furthermore, it can be understood that, in the related art, since a packet within a specified range of sequence numbers is received through a sliding window, in the case where the packet sequence number is confused, it may occur that the sequence number of the next packet to be received is located outside the specified range of the sliding window and thus the packet cannot be received and retained, and a duplicate packet cannot be filtered effectively. However, compared with the sliding window for receiving the specified sequence number in the related art, in the embodiment of the present application, in an application scenario where the sequence number of the packet is scrambled, in the case that the sequence number corresponding to the first packet received through the first network port matches the recorded sequence number, it indicates that the first packet has been received and retained by the second network port, and at this time, the first packet received by the first network port may be discarded; under the condition that the sequence number corresponding to the first data packet received by the first network port is not matched with the recorded sequence number, the situation that the data packet repeated with the first data packet is not received and reserved through the second network port is indicated, and the first data packet received by the first network port can be reserved at the moment.
According to the data packet filtering method provided by the embodiment of the application, a first data packet is received through a first network port; determining a sequence number corresponding to the first data packet; under the condition that the sequence number corresponding to the first data packet is matched with the recorded sequence number, discarding the first data packet; when the sequence number corresponding to the first data packet does not match the recorded sequence number, reserving the first data packet; and the recorded sequence number is a sequence number corresponding to the data packet received and reserved through the second network port. Thus, in an application scenario where the sequence numbers of the data packets are confused, when the sequence number corresponding to the first data packet received through the first network port matches the recorded sequence number, it is described that the data packet overlapping with the first data packet has been received and retained by the second network port, and at this time, the first data packet may be discarded; under the condition that the sequence number corresponding to the first data packet received by the first network port is not matched with the recorded sequence number, the data packet which is repeated with the first data packet is not received and reserved through the second network port, and the first data packet can be reserved at the moment.
In a specific embodiment, before receiving the first packet through the first network port, the packet filtering method provided in this embodiment further includes: the recorded sequence number is recorded by a first list.
For example, as shown in fig. 2, in a case that the sequence number corresponding to the first data packet does not match the recorded sequence number, the data packet filtering method provided in the embodiment of the present application may include:
step 210: receiving a first data packet through a first network port;
step 220: determining a sequence number corresponding to the first data packet;
step 230: discarding the first data packet when the sequence number corresponding to the first data packet matches the sequence number in the first list;
step 240: under the condition that the sequence number corresponding to the first data packet does not match with the sequence number in the first list, reserving the first data packet;
the sequence number in the first list is a sequence number corresponding to a data packet received and retained through the second network port.
Step 210 may refer to the specific content of step 110; step 220 may refer to the details of step 120; step 230 may refer to the details of step 130; step 240 may refer to the details of step 140.
In this way, the sequence number corresponding to the data packet received and retained through the second network port may be recorded in the first list in advance, so that the sequence number corresponding to the first data packet may be directly matched with the first list subsequently.
As shown in fig. 2, the method for filtering a data packet according to the embodiment of the present application may further include:
step 250: when the sequence number corresponding to the first data packet does not match with the sequence number in the first list, putting the sequence number corresponding to the first data packet into a second list;
the second list is used for recording sequence numbers corresponding to data packets received and reserved by the first network port.
Step 250 may be performed simultaneously with step 240, or step 250 may be performed before or after step 240.
In step 250, for example, the first packet has a sequence number of 100, and the sequence number of 100 may be recorded in the second list. Under the condition that a second network port receives a first data packet with the sequence number 100 subsequently, the sequence number 100 is recorded in the second list, which indicates that the data packet with the sequence number 100 has been received and retained by the first network port, and at this time, the second data packet with the sequence number 100 received by the second network port can be discarded, so that the filtering function of the second list corresponding to the second network port is realized, and the subsequent filtering of repeated data packets received by the second network port is facilitated.
For example, in a specific embodiment, the process of filtering the second data packet received by the second network port and the process of filtering the first data packet received by the first network port are similar, as shown in fig. 3, the data packet filtering method provided in this embodiment of the present application may include:
step 310: receiving a second data packet through a second network port;
step 320: determining a sequence number corresponding to the second data packet;
step 330: discarding the second data packet if the sequence number corresponding to the second data packet matches a sequence number in a second list;
step 340: and under the condition that the sequence number corresponding to the second data packet does not match with the sequence number in the second list, reserving the second data packet and putting the sequence number corresponding to the second data packet into the first list.
Wherein step 310 may be performed after step 250. Alternatively, step 310 may be performed simultaneously with step 250. Alternatively, step 310 may be performed before step 250, which is not specifically limited in this application.
In step 320, in the process of determining the sequence number corresponding to the second data packet, the second data packet itself carries the sequence number of the data packet, and the sequence number corresponding to the second data packet may be determined directly through the sequence number carried by the second data packet itself.
In step 330 and step 340, the matching manner between the sequence number corresponding to the second packet and the sequence number recorded in the second list may be: when one sequence number in the sequence numbers recorded in the second list is the same as the sequence number corresponding to the second data packet, the sequence number corresponding to the second data packet is matched with the sequence number recorded in the second list; and under the condition that the sequence numbers recorded in the second list are all different from the sequence number corresponding to the second data packet, the sequence number corresponding to the second data packet is not matched with the sequence number recorded in the second list.
It can be understood that since the sequence numbers recorded in the second list include: when the sequence number corresponding to the second packet matches the sequence number recorded in the second list, it indicates that the first packet received by the first network port and repeated with the second packet has been retained, and at this time, the second packet is discarded; and in the case that the sequence number corresponding to the second data packet does not match the sequence number recorded in the second list, indicating that the first network port has not received and retained the first data packet duplicated with the second data packet, and retaining the second data packet at this time. Therefore, under the condition that the repeated data packets are received through the second network port, the repeated data packets can be effectively filtered, and only one data packet is reserved.
In addition, in order to avoid that the data packet with a specific sequence number cannot be reserved, in the process of initializing the first list and the second list, the initial values recorded in the first list and the second list are values which are preset and are outside a normal value range of the sequence number of the data packet. The following examples are given.
Fig. 4 is a schematic structural diagram of a first list and a first list provided in an embodiment of the present application.
In a specific embodiment, the first list is provided with N positions for recording the serial number, and the second list is provided with M positions for recording the serial number. Wherein, N and M are positive integers, and N and M can be the same or different.
For example, still taking the controller 102 in fig. 1-1 as an example for description, in a case that the controller receives a duplicate packet sent by an upper computer through a SNETA port and a SNETB port, the method for filtering a data packet provided in the embodiment of the present application may be applied to the controller, where the first network port may be a SNETA port, and the second network port may be a SNETB port.
As shown in fig. 4, N and M may be 10, the first list corresponding to the SNETA port may contain 10 locations for recording sequence numbers, and the second list corresponding to the SNETB port may contain 10 locations for recording sequence numbers.
Alternatively, still taking the controller 102 in fig. 1-1 as an example for illustration, in a case that the controller receives a duplicate packet sent by the gateway through the INETA port and the INETB port, the packet filtering method provided in the embodiment of the present application may be applied to the controller, where the first network port may be the INETA port, the second network port may be the INETB port, as shown in fig. 4, N and M may be 10, the first list corresponding to the INETA port may include 10 locations for recording the sequence number, and the second list corresponding to the INETB port may include 10 locations for recording the sequence number.
As shown in fig. 4, the controller creates two lists (one for each of SNETA and SNETB) for each upper computer object according to the IP address, each upper computer object corresponds to two lists, each list includes 10 storage locations for recording the sequence number of the data packet, and the lists can be used for storing the sequence number of the data packet that needs to be discarded by the corresponding network. Similarly, the controller also opens up two lists (one each for INETA and INETB) for each gateway object according to the IP address, and each gateway object corresponds to two lists, each list includes 10 storage locations for recording the sequence numbers of packets, and is available for storing the sequence numbers of packets that need to be discarded by the corresponding network.
Of course, N and M may also be other values such as 7, 8, 9, etc., and the present application is again not particularly limited.
As shown in fig. 5, before receiving the first data packet through the first network port in step 110, the data packet filtering method provided in this embodiment of the present application further includes:
step 510: setting N initial values in N storage positions of the first list respectively;
step 520: setting M initial values in M storage positions of the second list respectively;
and N and M are positive integers, and the initial value is a preset value which is out of a normal value range of the serial number of the data packet.
Wherein step 510 and step 520 may be performed before step 110.
For example, N may be 10, the first list may include 10 positions for recording sequence numbers, and the 10 sequence numbers recorded in the first list may be all set to an initial value 0xFFFFFFFF, where the initial value 0 xffffffffff is a preset value outside a normal range of values of sequence numbers of the data packets. Of course, the initial value may be other values than 0xFFFFFFFF, and the application is not particularly limited.
It can be understood that the initial value is a preset value outside the normal range of values of the sequence number of the packet. In other words, when the sequence numbers of the packets are numbered, there is generally no packet whose sequence number is an initial value. For example, assuming that the initial value is a preset value (e.g. 10) within a normal range of sequence numbers of the packets, before receiving the packets, the sequence number 10 is an initial value recorded in the first list and the second list, and then the first packet with the sequence number 10 received by the first network port or the second packet with the sequence number 10 received by the second network port is discarded, so that the packet with the sequence number 10 cannot be filtered effectively. The data packet with the specific sequence number can be effectively prevented from being reserved by setting the initial value to be the preset value outside the normal value range of the sequence number of the data packet, and the data packet with any sequence number can be effectively filtered.
Furthermore, it was mentioned above that the number of recorded sequence numbers in the second list is a limited number (i.e. M), and in case that more than M data packets are received at the first network port, the number of recorded sequence numbers in the second list also exceeds M. In order to avoid that the storage locations in the second list are not enough to record a large number of serial numbers, the embodiment of the present application may also use M locations in the second list in a cyclic manner by overwriting the original serial numbers in the list, so as to perform the resetting of the serial numbers in the second list. The following examples are given.
In the case that M storage locations in the second list have respectively recorded M sequence numbers corresponding to data packets that are received and retained by the first network port, the step 150 described above includes placing the sequence number corresponding to the first data packet into the second list, where the step includes:
and the sequence number corresponding to the first data packet is placed at the first position in the M positions of the second list in a mode of covering the original sequence number in the second list.
It will be appreciated that each of the M locations in the second list may be recycled to avoid that the storage locations in the second list are not sufficient to record a large number of sequence numbers.
For example, M is 10, and when 10 data packets received by the first network port have been reserved, 10 sequence numbers corresponding to the data packets received by the first network port are recorded in the second list, and at this time, the sequence number corresponding to the first data packet may be placed in the first position of the M positions in the second list in a manner of covering the original sequence number in the first position in the second list. And so on, if the next retained data packet is also the first data packet received by the first network port, the sequence number corresponding to the first data packet may be placed in the second position of the M positions in the second list in a manner of covering the original sequence number in the second position in the second list.
That is, when the serial number in the second list is updated each time, the storage location required for updating the serial number is shifted backward by one location, and the original serial number is covered from the first location to the mth location in the M locations in a loop until the original serial number is covered from the first location after the mth location.
In this way, the sequence numbers in the second list are reset in a manner of overwriting the original sequence numbers in the second list, so that M positions in the second list can be recycled, and the storage positions in the second list are prevented from being insufficient for recording a large number of sequence numbers.
Similarly, in the embodiment of the present application, the serial numbers in the first list may also be reset in a manner of covering the original serial numbers in the first list, so that all N positions in the first list may be recycled, thereby avoiding that the storage positions in the first list are not enough to record a large number of serial numbers.
In another specific embodiment, in order to improve the reliability of the filtered data packet, as shown in fig. 5, after the first data packet is retained in step 140, the data packet filtering method provided in this embodiment further includes:
step 610: under the condition that N continuous first data packets are reserved, setting continuous receiving counting information N of a first network port as N;
the first data packets may include N data packets, and the N data packets are all reserved when the N data packets are continuously received through the first network port, where the continuous reception count information N of the first network port is set to N;
step 620: when the continuous reception count information N of the first network port is N, the sequence number recorded in the first list is cleared, and the continuous reception count information N of the first network port is reset to 0.
In the foregoing step 620, the clearing of the sequence numbers recorded in the first list may be to delete all the sequence numbers recorded in the first list, or may also be to replace all the sequence numbers recorded in the first list with initial values, and specifically, N initial values (the initial value may be 0 xffffffffffff) may be recorded in N storage locations of the first list, respectively, which is not limited in this application.
Wherein the continuous reception count information n of the first network port may indicate the number of data packets that are continuously received and retained by the first network port; the continuous receiving count information N of the first network port is less than or equal to N. And under the condition that N continuous data packets received by the first network port are reserved, setting continuous receiving count information of the first network port as N, wherein N is a positive integer less than or equal to N.
Similarly, the continuous reception count information of the second network port may be set to M in a case where M consecutive packets received by the second network port are reserved, where M is a positive integer less than or equal to M. Wherein the continuous reception count information M of the second network port may indicate the number of data packets continuously received and retained by the second network port, and the continuous reception count information M of the second network port is less than or equal to M.
In a case where the next packet of the first packet is received and retained by the second network port (for example, in a case where the continuous reception count information of the second network port is equal to 1), the continuous reception count information of the first network port is interrupted, and at this time, the continuous reception count information of the first network port may be reset to 0.
In step 620, in case that N consecutive data packets received by the first network port are reserved, the consecutive reception count information of the first network port may be N. Since the continuous reception count information of the first network port is less than or equal to N, when the continuous reception count information of the first network port is N, the continuous reception count information of the first network port may be reset to 0, and the continuous reception count may be restarted.
In step 620, in the case that the continuous reception count information of the first network port is N, the reason for clearing the sequence numbers recorded in the first list includes the following two aspects:
firstly, under the condition that the second network port is permanently disconnected, the sequence numbers recorded in the first list are cleared, so that the condition that data packets corresponding to the sequence numbers recorded in the first list cannot be received by the first network port and the second network port and are all lost due to the recorded sequence numbers in the first list can be avoided;
second, since N packets have been received consecutively by the first network port, the sequence numbers of the N packets are recorded in the second list, and the duplicate packets received by the second network port and overlapping with the N packets are discarded directly. Therefore, the sequence number recorded in the first list is at least the data packet before the N data packets and the data packet received by the second network port, and the sequence number recorded in the first list is invalid, so that the sequence number recorded in the first list can be directly cleared.
In this way, when the continuous reception count information of the first network port is N, the continuous reception count information of the first network port is reset to 0, and the sequence numbers recorded in the first list are cleared, so that it is possible to prevent that the data packets corresponding to the sequence numbers recorded in the first list are not received by the first network port and the second network port and are all lost when the second network port is permanently disconnected, and to improve reliability of filtering the data packets.
Similarly, in order to improve the reliability of the filtered data packet, after the second data packet is retained, the data packet filtering method provided in the embodiment of the present application further includes:
setting continuous receiving counting information M of a second network port to be M under the condition that continuous M second data packets are reserved;
the second data packets may include M second data packets, and the M second data packets are all reserved when the M second data packets are continuously received through the second network port, where the continuous reception count information M of the second network port is set to M;
when the continuous reception count information of the second network port is M, the sequence number recorded in the second list is cleared, and the continuous reception count information M of the second network port is reset to 0.
In this way, when the continuous reception count information of the second network port is M, the continuous reception count information of the second network port is reset to 0, and the sequence numbers recorded in the second list are cleared, so that it is possible to prevent that the data packets corresponding to the sequence numbers recorded in the second list are not received by the first network port and the second network port and are all lost when the first network port is permanently disconnected, and to improve reliability of filtering the data packets.
In addition, in practical applications, for two packets with the same sequence number, the first network port that receives the packet first may directly receive and retain the packet, for example, for the first network port that has received the packet with the sequence number, since the sequence number is in the second list, the packet with the sequence number may be always received and retained by the first network port. A second network port that receives the data packet may then be understood as a data packet that after at least N packets can receive and retain the sequence number again through the second network port. For example, for the second network port, in case that N consecutive data packets received by the first network port are retained, the data packets of the sequence number can be received again and retained through the second network port only if the sequence number in the second list is covered.
In a specific embodiment, since the duplicate packets received by the first network port and the second network port are the same, it is difficult to determine whether the packet is received through the first network port or the second network port based on the information carried by the packet itself. Based on this, after receiving the first data packet in step 110, the data packet filtering method provided in the embodiment of the present application further includes:
determining a target network port for receiving the first data packet according to the hardware states of the first network port and the second network port; the target network port is one of a first network port and a second network port;
determining, based on the target network port, that the first packet is a packet received by a first network port.
Determining that a target network port receiving the first data packet is a first network port according to a hardware state of the first network port, thereby determining that the first data packet is a data packet received by the first network port; alternatively, the destination network port receiving the first data packet may be determined to be the second network port according to the hardware state of the second network port, so as to determine that the first data packet is the data packet received by the second network port. The hardware state of the network port may be a chip pin state, a high-low level state, and the like, and the present application is not limited specifically.
In this way, it can be effectively determined whether the first packet is a packet received by the first network port or a packet received by the second network port according to the hardware states of the first network port and the second network port, so as to subsequently select the first list corresponding to the first network port or the second list corresponding to the second network port to filter the first packet.
In practical application, in a scene of filtering received redundant repeated data packets, the data packet filtering method provided by the embodiment of the application can be specifically applied to each receiving device in an industrial control system. For example, as shown in fig. 1-1, in an industrial control system, an upper computer 101 may communicate with a controller 102 through an SNETA port and an SNETB port, and in a case that the controller receives a duplicate packet sent by the upper computer through the SNETA port and the SNETB port, the data packet filtering method provided in the embodiment of the present application may be applied to the controller to filter the duplicate packet received by the controller. The following is an example of fig. 7.
Fig. 7 is a schematic flow chart of a packet filtering method according to an embodiment of the present application.
As shown in fig. 7, the method for filtering a data packet according to the embodiment of the present application may include:
step 701: receiving a target data packet;
wherein the destination data packet comprises at least one of: a packet received by the SNETA port and a packet received by the SNETB port.
Step 702: determining the type of the target data packet;
in step 702, the target packet may be a packet received by a SNETA port or a packet received by a SNETB port;
in step 702, the type of the target packet can be determined according to the hardware states of the SNETA port and the SNETB port;
in step 702, in case the target packet may be a packet received by the SNETA port, step 703 is performed;
in step 702, in case the target packet may be a packet received by the SNETB port, step 709 is performed.
Step 703: determining whether the sequence number corresponding to the target data packet is matched with the sequence number recorded in the filtering window corresponding to the SNETA port;
in step 703, the filtering window corresponding to the SNETA port may be a window list for recording sequence numbers corresponding to the packets received and retained through the SNETB port;
in step 703, if the sequence number corresponding to the target packet matches the sequence number recorded in the filtering window corresponding to the SNETA port, step 704 is executed;
in step 703, in case the sequence number corresponding to the target packet does not match the sequence number recorded in the filtering window corresponding to the SNETA port, step 705 and step 706 are executed.
Step 704: the destination packet is discarded.
Step 705: the destination data packet is retained.
Step 706: recording the sequence number corresponding to the target data packet at a corresponding position in the SNETB port filtering window based on the sequence number corresponding to the target data packet;
wherein, step 706 can be executed simultaneously with step 705, or step 706 is executed before step 705, or step 706 is executed after step 705.
Step 707: under the condition that N continuous data packets received by the SNETA port are reserved, the continuous receiving count information of the SNETA port is N;
wherein step 707 is performed after step 705 and step 706.
Step 708: clearing the sequence number recorded in the filtering window corresponding to the SNETA port, and resetting the continuous receiving counting information of the SNETA port to 0;
wherein step 708 is performed after step 707.
Step 709: determining whether the sequence number corresponding to the target data packet is matched with the sequence number recorded in the filtering window corresponding to the SNETB port;
in step 709, the filtering window corresponding to the SNETB port may be a window list for recording sequence numbers corresponding to packets received and retained through the SNETA port;
in step 709, if the sequence number corresponding to the target packet matches the sequence number recorded in the filtering window corresponding to the SNETB port, execute step 704;
in step 709, in case that the sequence number corresponding to the target packet does not match the sequence number recorded in the filtering window corresponding to the SNETB port, step 705 and step 710 are executed.
Step 710: recording the sequence number corresponding to the target data packet at a corresponding position in an SNETA port filtering window based on the sequence number corresponding to the target data packet;
wherein, step 710 may be executed simultaneously with step 705, or step 710 may be executed before step 705, or step 710 may be executed after step 705.
Step 711: under the condition that M continuous data packets received by the SNETB port are reserved, the continuous receiving count information of the SNETB port is M;
wherein step 711 is performed after step 705 and step 710.
Step 712: clearing the sequence number recorded in the filtering window corresponding to the SNETB port, and resetting the continuous receiving counting information of the SNETB port to 0;
wherein step 712 is performed after step 711.
Thus, in an application scenario where the sequence numbers of the packets are confused, because the sequence number corresponding to the packet received and retained by the SNETB port is recorded in the filtering window corresponding to the SNETA port, when the sequence number corresponding to the target packet received by the SNETA port matches the sequence number recorded in the filtering window corresponding to the SNETA port, it is indicated that the target packet has been received and retained by the SNETA port, and at this time, the target packet received by the SNETA port may be discarded; under the condition that the sequence number corresponding to the target data packet received by the SNETA port is not matched with the sequence number recorded in the filtering window corresponding to the SNETA port, the target data packet is not received and reserved by the SNETB port, and the target data packet received by the SNETA port can be reserved at the moment, so that under the condition that the sequence number of the data packet is disordered, repeated data packets can be discarded through the sequence number recorded in the filtering window corresponding to the SNETA port, and the filtering of repeated data packets is effectively realized;
similarly, in an application scenario where the sequence number of the packet is confused, since the sequence number corresponding to the packet received and retained by the SNETA port is recorded in the filtering window corresponding to the SNETB port, when the sequence number corresponding to the target packet received by the SNETB port matches the sequence number recorded in the filtering window corresponding to the SNETB port, it is indicated that the target packet has been received and retained by the SNETA port, and at this time, the target packet received by the SNETB port may be discarded; under the condition that the sequence number corresponding to the target data packet received by the SNETB port is not matched with the sequence number recorded in the filtering window corresponding to the SNETB port, the target data packet is not received and reserved by the SNETA port, and the target data packet received by the SNETB port can be reserved at the moment.
It should be noted that, in the packet filtering method provided in the embodiment of the present application, the execution main body may be a packet filtering device, or a control module in the packet filtering device for executing the packet filtering method. In the embodiment of the present application, a method for performing packet filtering by using a packet filtering device is taken as an example, and a packet filtering device for packet filtering provided in the embodiment of the present application is described.
Fig. 8 is a schematic structural diagram of a packet filtering apparatus according to an embodiment of the present application.
As shown in fig. 8, a packet filtering apparatus 800 provided in this embodiment of the present application may include: a receiving module 801, a determining module 802, a discarding module 803, and a retaining module 804;
the receiving module 801 is configured to receive a first data packet through a first network port;
the determining module 802 is configured to determine a sequence number corresponding to the first data packet;
the discarding module 803 is configured to discard the first data packet when the sequence number corresponding to the first data packet matches the recorded sequence number;
the reserving module 804 is configured to reserve the first data packet when the sequence number corresponding to the first data packet does not match the recorded sequence number;
and the recorded sequence number is a sequence number corresponding to a data packet which is received and reserved through a second network port.
According to this application embodiment provides a data packet filter equipment, includes: the device comprises a receiving module, a determining module, a discarding module and a retaining module; the receiving module is used for receiving a first data packet through a first network port; the determining module is configured to determine a sequence number corresponding to the first data packet; the discarding module is configured to discard the first data packet when a sequence number corresponding to the first data packet matches a recorded sequence number; the reservation module is configured to reserve the first data packet when the sequence number corresponding to the first data packet does not match the recorded sequence number; and the recorded sequence number is a sequence number corresponding to a data packet which is received and reserved through a second network port. Thus, in an application scenario where the sequence numbers of the data packets are confused, when the sequence number corresponding to the first data packet received through the first network port matches the recorded sequence number, it is described that the data packet overlapping with the first data packet has been received and retained by the second network port, and at this time, the first data packet may be discarded; under the condition that the sequence number corresponding to the first data packet received by the first network port is not matched with the recorded sequence number, the data packet repeated with the first data packet is not received and reserved through the second network port, and at the moment, the first data packet can be reserved, so that under the condition that the sequence number of the data packet is disordered, the data packet corresponding to the recorded sequence number can be discarded, and the filtering of the repeated data packet can be effectively realized.
Optionally, the data packet filtering apparatus provided in this embodiment of the present application further includes:
a recording module, configured to record the recorded sequence number through a first list before receiving the first data packet through the first network port.
In this way, the sequence number corresponding to the data packet received and retained through the second network port may be recorded in the first list in advance, so that the sequence number corresponding to the first data packet may be directly matched with the first list subsequently.
Optionally, the data packet filtering apparatus provided in this embodiment of the present application further includes:
the recording module is used for placing the sequence number corresponding to the first data packet into a second list under the condition that the sequence number corresponding to the first data packet is not matched with the recorded sequence number;
the second list is used for recording sequence numbers corresponding to data packets received and reserved by the first network port.
Therefore, the filtering function of the second list corresponding to the second network port is realized, and the subsequent filtering of the repeated data packet received by the second network port is facilitated.
Optionally, in the data packet filtering apparatus provided in the embodiment of the present application,
the receiving module is further configured to receive a second data packet through a second network port;
the determining module is further configured to determine a sequence number corresponding to the second data packet;
the discarding module is further configured to discard the second data packet if the sequence number corresponding to the second data packet matches a sequence number in a second list;
the reserving module is further used for reserving the second data packet under the condition that the sequence number corresponding to the second data packet does not match with the sequence number in the second list;
the recording module is further configured to place the sequence number corresponding to the second data packet into the first list when the sequence number corresponding to the second data packet does not match the sequence number in the second list.
Therefore, under the condition that the repeated data packets are received through the second network port, the repeated data packets can be effectively filtered, and only one data packet is reserved.
Optionally, in the data packet filtering apparatus provided in this embodiment of the present application, the first list is provided with N storage locations for recording serial numbers, and the second list is provided with M storage locations for recording serial numbers;
the data packet filtering device provided by the embodiment of the application further comprises a first setting module, wherein the first setting module is used for:
setting N initial values in N storage positions of the first list respectively; setting M initial values in M storage positions of the second list respectively; and N and M are positive integers, and the initial value is a preset value which is out of a normal value range of the serial number of the data packet.
Therefore, the initial value is preset to be a value outside the normal value range of the serial number of the data packet, the data packet with a specific serial number can be effectively prevented from being reserved, and the data packet with any serial number can be effectively filtered.
Optionally, in the data packet filtering apparatus provided in the embodiment of the present application, the recording module is specifically configured to: and under the condition that M storage positions in the second list respectively record M serial numbers corresponding to the data packets which are received and reserved by the first network port, the serial number corresponding to the first data packet is placed at the first position in the M positions in the second list in a mode of covering the original serial number in the second list.
In this way, the serial numbers in the second list are reset in a mode of covering the original serial numbers in the second list, so that all M positions in the second list can be recycled, and the condition that the storage positions in the second list are not enough for recording a large number of serial numbers is avoided.
Optionally, in the data packet filtering device provided in this embodiment of the present application, the number of the first data packets includes N, and the data packet filtering device provided in this embodiment of the present application further includes:
the second setting module is used for setting the continuous receiving counting information of the first network port to be N under the condition that the continuous N first data packets are reserved;
a clearing module, configured to clear the sequence number recorded in the first list when the continuous reception count information of the first network port is N;
the second setting module is further configured to reset the continuous reception count information of the first network port to 0 when the continuous reception count information of the first network port is N and the sequence number recorded in the first list is cleared.
In this way, when the continuous reception count information of the first network port is N, the continuous reception count information of the first network port is reset to 0, and the sequence numbers recorded in the first list are cleared, so that it is possible to prevent that the data packets corresponding to the sequence numbers recorded in the first list are not received by the first network port and the second network port and are all lost when the second network port is permanently disconnected, and to improve reliability of filtering the data packets.
Optionally, in the data packet filtering device provided in this embodiment of the present application, the number of the second data packets includes M, and the data packet filtering device provided in this embodiment of the present application further includes:
the third setting module is used for setting the continuous receiving counting information of the second network port as M under the condition that continuous M second data packets are reserved;
the clearing module is further configured to clear the sequence number recorded in the second list when the continuous reception count information of the second network port is M.
The third setting module is further configured to reset the continuous reception count information of the second network port to 0 when the continuous reception count information of the second network port is M and the sequence number recorded in the second list is cleared.
In this way, when the continuous reception count information of the second network port is M, the continuous reception count information of the second network port is reset to 0, and the sequence numbers recorded in the second list are cleared, so that it is possible to prevent that the data packets corresponding to the sequence numbers recorded in the second list are not received by the first network port and the second network port and are all lost when the first network port is permanently disconnected, and to improve reliability of filtering the data packets.
The packet filtering device in the embodiment of the present application may be a device, or may be a component, an integrated circuit, or a chip in a terminal. The device can be mobile electronic equipment or non-mobile electronic equipment. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a Personal Digital Assistant (PDA), and the like, and the non-mobile electronic device may be a server, a Network Attached Storage (NAS), a Personal Computer (PC), a Television (TV), a teller machine or a self-service machine, and the like, and the embodiments of the present application are not particularly limited.
The packet filtering device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, and embodiments of the present application are not limited specifically.
The data packet filtering device provided in this embodiment of the present application can implement each process implemented in the foregoing method embodiment, and is not described here again to avoid repetition.
As shown in fig. 9, an electronic device 900 is further provided in this embodiment of the present application, where the electronic device 900 includes a processor 901 and a memory 902, where the memory stores a program or an instruction, and the program or the instruction, when executed by the processor, implements each process of the foregoing method embodiment, and can achieve the same technical effect, and for avoiding repetition, details are not repeated here.
The embodiments of the present application further provide a readable storage medium, where a program or an instruction is stored, and when the program or the instruction is executed by a processor, the program or the instruction implements the processes of the foregoing method embodiments, and can achieve the same technical effects, and in order to avoid repetition, details are not repeated here.
The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer-readable storage medium, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and so on.
The embodiment of the present application further provides a chip, where the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to execute a program or an instruction to implement each process of the foregoing method embodiment, and the same technical effect can be achieved.
It should be understood that the chips mentioned in the embodiments of the present application may also be referred to as system-on-chip, system-on-chip or system-on-chip, etc.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Further, it should be noted that the scope of the methods and apparatus of the embodiments of the present application is not limited to performing the functions in the order illustrated or discussed, but may include performing the functions in a substantially simultaneous manner or in a reverse order based on the functions involved, e.g., the methods described may be performed in an order different than that described, and various steps may be added, omitted, or combined. In addition, features described with reference to certain examples may be combined in other examples.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation. Based on such understanding, the technical solutions of the present application may be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present application.
While the present embodiments have been described with reference to the accompanying drawings, it is to be understood that the invention is not limited to the precise embodiments described above, which are meant to be illustrative and not restrictive, and that various changes may be made therein by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A method for packet filtering, comprising:
receiving a first data packet through a first network port;
determining a sequence number corresponding to the first data packet;
discarding the first data packet when the sequence number corresponding to the first data packet matches the recorded sequence number;
under the condition that the sequence number corresponding to the first data packet does not match the recorded sequence number, reserving the first data packet;
and the recorded sequence number is a sequence number corresponding to the data packet received and reserved through the second network port.
2. The method of claim 1, wherein prior to receiving the first packet through the first network port, the method further comprises:
the recorded sequence number is recorded by a first list.
3. The method of claim 2, wherein in case that the sequence number corresponding to the first packet does not match the recorded sequence number, the method further comprises:
putting the sequence number corresponding to the first data packet into a second list;
the second list is used for recording sequence numbers corresponding to data packets received and reserved by the first network port.
4. The method of claim 3, wherein after placing the sequence number corresponding to the first packet in the second list, the method further comprises:
receiving a second data packet through a second network port;
determining a sequence number corresponding to the second data packet;
discarding the second packet if the sequence number corresponding to the second packet matches a sequence number in a second list;
and under the condition that the sequence number corresponding to the second data packet does not match with the sequence number in the second list, reserving the second data packet and putting the sequence number corresponding to the second data packet into the first list.
5. The method of claim 3, wherein the first list has N storage locations for recording serial numbers, and wherein the second list has M storage locations for recording serial numbers;
prior to receiving the first data packet through the first network port, the method further comprises:
setting N initial values in N storage positions of the first list respectively;
setting M initial values in M storage positions of the second list respectively;
and N and M are positive integers, and the initial value is a preset value which is out of a normal value range of the serial number of the data packet.
6. The method of claim 5, wherein, in a case that M storage locations in the second list have respectively recorded M sequence numbers corresponding to packets received and retained by the first network port, the placing the sequence number corresponding to the first packet in the second list comprises:
and the sequence number corresponding to the first data packet is placed at the first position in the M positions of the second list in a mode of covering the original sequence number in the second list.
7. The method of claim 6, wherein the number of first packets comprises N, and wherein after retaining the first packets, the method further comprises:
under the condition that N continuous first data packets are reserved, setting continuous receiving counting information of a first network port as N;
when the continuous reception count information of the first network port is N, the sequence number recorded in the first list is cleared, and the continuous reception count information of the first network port is reset to 0.
8. A packet filtering device, comprising: the device comprises a receiving module, a determining module, a discarding module and a retaining module;
the receiving module is used for receiving a first data packet through a first network port;
the determining module is configured to determine a sequence number corresponding to the first data packet;
the discarding module is configured to discard the first data packet when the sequence number corresponding to the first data packet matches the recorded sequence number;
the reservation module is configured to reserve the first data packet when the sequence number corresponding to the first data packet does not match the recorded sequence number;
and the recorded sequence number is a sequence number corresponding to the data packet received and reserved through the second network port.
9. An electronic device comprising a processor and a memory, the memory having stored thereon a program or instructions which, when executed by the processor, carry out the steps of the method according to any one of claims 1 to 7.
10. A readable storage medium, characterized in that it stores thereon a program or instructions which, when executed, implement the steps of the method according to any one of claims 1-7.
CN202210549960.8A 2022-05-20 2022-05-20 Data packet filtering method and device Pending CN114979038A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210549960.8A CN114979038A (en) 2022-05-20 2022-05-20 Data packet filtering method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210549960.8A CN114979038A (en) 2022-05-20 2022-05-20 Data packet filtering method and device

Publications (1)

Publication Number Publication Date
CN114979038A true CN114979038A (en) 2022-08-30

Family

ID=82985845

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210549960.8A Pending CN114979038A (en) 2022-05-20 2022-05-20 Data packet filtering method and device

Country Status (1)

Country Link
CN (1) CN114979038A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108494676A (en) * 2018-03-21 2018-09-04 广州多益网络股份有限公司 Data transmission method, device, data transmitting/receiving equipment, system and storage medium
CN113259256A (en) * 2021-07-15 2021-08-13 全时云商务服务股份有限公司 Repeating data packet filtering method and system and readable storage medium
WO2022033349A1 (en) * 2020-08-10 2022-02-17 华为技术有限公司 Methods and devices for indicating and determining sequence number
CN114095876A (en) * 2021-11-08 2022-02-25 青岛海尔科技有限公司 Broadcast data processing method and device, storage medium and electronic device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108494676A (en) * 2018-03-21 2018-09-04 广州多益网络股份有限公司 Data transmission method, device, data transmitting/receiving equipment, system and storage medium
WO2022033349A1 (en) * 2020-08-10 2022-02-17 华为技术有限公司 Methods and devices for indicating and determining sequence number
CN113259256A (en) * 2021-07-15 2021-08-13 全时云商务服务股份有限公司 Repeating data packet filtering method and system and readable storage medium
CN114095876A (en) * 2021-11-08 2022-02-25 青岛海尔科技有限公司 Broadcast data processing method and device, storage medium and electronic device

Similar Documents

Publication Publication Date Title
US11902096B2 (en) Collection of error packet information for network policy enforcement
JP5148707B2 (en) Queue formation method
CN112887405B (en) Intrusion prevention method, system and related equipment
US20210067534A1 (en) Counting syn packets
CN109167700B (en) Detection method and device for Segment Routing (SR) tunnel
CN107770092A (en) A kind of data transmission method, device, mobile terminal and storage medium
CN109039947B (en) Network packet duplication removing method and device, network distribution equipment and storage medium
CN114979038A (en) Data packet filtering method and device
CN103795705B (en) For the network and node of the time lock of the data packet of exchanging safety
CN111984582B (en) PCIE link training method, equipment and medium
CN110688628B (en) Multimedia information processing method and device and server
CN109597566A (en) A kind of reading data, storage method and device
CN107483635A (en) Service request processing method, processing system and message middleware
CN106293996B (en) Method of data synchronization, main equipment, alternate device and system
CN106385322A (en) Data group calling method, device and system
CN108156239A (en) The method and device that a kind of collaborative synchronizing white is shown
CN104994225B (en) A kind of short message sending control method and short message transmission control device
CN115687223A (en) Method and device for serial port communication of embedded equipment, embedded equipment and storage medium
CN111556104B (en) Seamless switching mode applied to multiple paths of acquired data
CN105656795A (en) Flow control method of virtual machine and physical machine
EP3562149A1 (en) Software upgrade method and device
US8041833B2 (en) Electronic network filter for classified partitioning
EP3223478A1 (en) Packet processing method and device, and storage medium
CN110740251B (en) Multi-camera synchronous stream taking method, device and system
CN103051568A (en) Message transmission method, device and switch

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