The invention relates to identification of predefined patterns in digital data. More particularly, the invention relates to a scheme for identifying a string of data using a multi-stage searching technique.
In recent years computer networks have changed many aspects of life. For example, in a few short years, the Internet has changed the manner in which information is sent and received, the way goods and services are bought and sold, and the way that financial matters are handled. Standard applications such as web browsers and protocols such as Transmission Control Protocol/Internet Protocol (TCP/IP) have become integral to the success of networks.
In order to provide more information and services to more people and to more places, networks have become easier to use and more reliable. However, making the network operate smoothly requires a high degree of interoperability, scalability and platform independence. One aspect of networking is policy enforcement. Policy enforcement provides a way to give some types of traffic, such as real-time video, priority over other, less important traffic, such as electronic mail. Policy enforcement can also provide intrusion detection.
Policy enforcement has been provided with general purpose computers, fixed-function appliances, and/or switches and routers. General purpose computers that provide policy enforcement typically include two or more network interface cards (NICs) that provide multiple connections to the network. Policy enforcement is provided by the processor of the general purpose computer. However, general purpose computers are not developed to perform high-speed operations on network packets. Because of this policy enforcement with general purpose computers is a bottleneck to network performance.
In an attempt to overcome the performance limitations of using general purpose computers for policy enforcement, fixed-function devices specifically designed to support policy enforcement have been developed. Typically, these fixed-function appliances have a processor and/or customized hardware and two or more NICs. While fixed-function appliances can be fast enough for some network operations, scalability is restricted.
Switches and routers have been used to provide policy enforcement. However, switches and routers typically do not have sufficient processing power to provide policy enforcement in addition to switching and routing functionality. The processors of the switches and routers must be used for both policy enforcement and for switching and/or routing functionality, which decreases network performance. Alternatively, switches and routers can be designed with more powerful processors, which increases the cost of the switches and routers.
A method and apparatus for searching for a string of data matching a predetermined string of data is described. A first stage search is performed on the data. The first stage search identifies one or more potential strings of interest having a pattern matching a portion of the predetermined string. A second stage search is performed on the data corresponding to the one or more potential strings of interest to determine whether a match exists. In one embodiment the first stage search is performed by a first processor and the second stage search is performed by a second processor. In another embodiment, the first stage search and the second stage search are performed by a single processor if performed in sequence.
The invention is illustrated by way of example, and not by way of limitation in the figures of the accompanying drawings in which like reference numerals refer to similar elements.
A method and apparatus for searching for predetermined strings in network data is described. In the following description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the invention. It will be apparent, however, to one skilled in the art that the invention can be practiced without these specific details. In other instances, structures and devices are shown in block diagram form in order to avoid obscuring the invention.
Reference in the specification to “one embodiment” or “an embodiment” means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the invention. The appearances of the phrase “in one embodiment” in various places in the specification are not necessarily all referring to the same embodiment.
Methods and apparatuses for searching data for one or more predefined strings are disclosed. In one embodiment, the data is part of network traffic; however, any data can be searched as described herein. In one embodiment, the string search is a multi-stage search where the stages of the search are performed by different hardware components; however, multiple stages can be performed by a single hardware component.
In one embodiment in a first search stage, a first processor performs a comparison of blocks of incoming data to determine whether the blocks potentially represent the beginning of one of the predetermined strings. If the beginning of a predetermined string is identified, a second processor performs a further search to determine whether the string matches one of the predetermined strings. Because the first processor searches only for the beginning of the predetermined string, the first stage comparison can be performed quickly, which improves network performance as compared to more detailed string searching in which the entire string is compared. Thus, the first processor operates as a filter on the blocks of incoming data.
The second stage is performed by second processor, which allows the first processor to search for potential matching strings in another packet. Thus, the first and second stages allow the search to be pipelined. Because many strings do not match the one or more predetermined strings, the more detailed search performed by the second processor is performed on a subset of packets, which increases network performance as compared to more detailed searches on all network data.
Network 100 can be any interconnection of computers and other electronic devices. For example, network 100 can be the Internet, a wide area network (WAN), a local area network (LAN), etc. Network 100 can communicate data using any appropriate protocol, for example, TCP/IP.
Classification engines 110 and 130 are coupled to network 100. In one embodiment, classification engines 100 and 130 are coupled to receive packets from network 100. In an alternative embodiment, classification engines 110 and 130 can also transmit packets to network 100. Classification engine 110 is coupled to policy processor 150 and to classification engine 120. Policy processor 150 is also coupled to classification engine 120. In one embodiment, classification engine 120 outputs processed packets. In an alternative embodiment, classification engine 120 can send and receive packets. In one embodiment, “packet” refers to a set of data independent of the protocol used to communicate the data.
Classification engine 130 is coupled to policy processor 150 and to classification engine 140. Policy processor 150 is also coupled to classification engine 140. In one embodiment, classification engine 140 outputs processed packets. In an alternative embodiment, classification engine 140 can send and receive packets. In alternative embodiments, multiple policy processors can be used.
In general terms, the string search technique described herein operates on a classification/action model. One or more classification engines classify network packets and one or more policy engines perform an action on the packet based on the classification. In one embodiment, string searches are performed in two stages. In the first stage, a classification engine operates as an abstract filter to identify locations in input data where potential string matches may exist. In the second stage, a policy processor performs actual pattern matching in the locations identified by the classification engine [reported by a classification engine]. Thus, detailed searching is performed by a policy processor that is not required to process all network packets. This pipelined approach to searches of network traffic provides increased network performance as compared to non-pipelined searches.
Prior to searching, an initialization is performed. In one embodiment, initialization includes building a tree structure describing the strings to be searched for and a look up table to be used in the first stage of the search. In one embodiment, the tree structure is used to define a non-deterministic finite automaton (NDFA) that is represented by a directed graph; however, other representations of the strings to be searched for can also be used.
In one embodiment, the nodes of the directed graph illustrated in
In one embodiment, for each string to be searched for, two or more entries exist in look up table 300, the remaining entries (e.g., 0, −1, NULL) indicate that the two-byte combination does not match the beginning of a string of interest. Multiple look up tables can also be used. For strings having three or more characters where the first three characters are not a wildcard (i.e., not wildcard indicators), two entries exist in look up table 300 for each string. One entry corresponds to the first and second characters in the string and the second entry corresponds to the second and third characters in the string. Three characters can either start on a word boundary or in the second byte of the word. If packet starts on word boundary the first and second characters are used to for the first stage. If packet starts in the second byte of the word, the second and third characters are used for the first stage search. This avoids many false positives, which increases the overall performance of the search.
When a classification engine receives a packet of data, the packet is stored in a buffer. In one embodiment, the memory used for string searches is a shared memory accessible by one or more classification engines and one or more policy processors; however, separate memories can also be used. The first two-byte block is compared to a corresponding entry in look up table 300. For example, if the first two-byte block (the first byte and the second byte) is “00,” which corresponds to the first entry (labeled 305) in table 300, the table entry indicates that “00” does not correspond to a string of interest.
The second two-byte block (the third byte and the fourth byte) are compared to a table entry in a similar manner. For example, if the second two-byte block is “GE,” the corresponding entry (labeled 320) indicates that “GE” does correspond to a string of interest. Entry 320 in table 300 indicates the corresponding node (e.g., 202) of the directed graph 290. In one embodiment, the table entry indicates the node corresponding to the first character of the two-character block; however, other nodes can also be used (e.g., the third character of a three character block).
Table 300 also includes other entries corresponding to the directed graph of
The entries of table 300 can include multiple nodes of directed graph 290. For example, if a string of interest begins with “ETC” the two-byte block of “ET” corresponds to “ETC” and to “GET.” Table 300 can also include entries not shown in
In one embodiment, when one of the first three characters in a string of three or more characters is a wildcard, more than two entries exist in look up table 300 for each string because the wildcard indicates that multiple characters correspond to the start of a string to be searched for. The necessary number of entries are made in look up table 300 during initialization. For example, if a string to be searched for begins with “GE*” one entry is made for “GE” and entries are made for each combination of “E” and another characters.
In one embodiment, when a string to be searched for contains two or three characters, the first two characters are used for the first stage search. When a string contains a single character, look up table 300 contains entries for a wildcard before the character and a wildcard after the character.
In one embodiment, if the string to be searched for contains four or more characters, the second, third and fourth characters of a string to be searched for are used as entries in look up table 300. As described below in greater detail with respect to
In one embodiment, data is accessed assuming 4-byte boundary alignment. However, packets that are to be searched may not be aligned on 4-byte boundaries, or may not be a 4-byte multiple in size. When a 4-byte block of data is not available from a packet, preceding or subsequent characters are used to provide a 4-byte block of data. For example, if a packet of data is six bytes in length, the first four bytes are searched as described above. The final four bytes of the packet are used for the second block of data. This results in two bytes being compared twice.
In one embodiment, if a packet is less than four bytes, the packet is processed using the second stage search. In an alternative embodiment, the first stage search processes four bytes and packets of four bytes or less are processed using the first stage search.
First stage search report 400 also includes an entry for each potential string of interest identified. In one embodiment, the entries include a seed identifier that identifies the blocks of data corresponding to a potential string of interest. For example, “204” in field 420 and “230” in field 460. The seed offset is the character where the second stage search begins. The first stage search report also includes a seed offset value that indicates an offset from the beginning of the packet to the potential string of interest. For example, “20” in field 450, which indicates that the potential string of interest starts at block 20 of the packet, and “54” in field 490.
In one embodiment, the first stage search report also includes the character before and the character after the seed. For example, “G” in field 430 and “T” in field 440 are the characters before and after, respectively, the seed having seed identifier 100. Similarly, “X” in field 470 and “O” in field 480 are the characters before and after, respectively, the seed having seed identifier 200.
In one embodiment, the first stage search report is sent to policy processor 150 along with a pointer to, or other indication of, the packet corresponding to the first stage search report. Policy processor 150 performs the second stage of searching as described in greater detail below based on the first stage search report. If the first stage search report indicates that no potential strings of interest exist in a packet, the packet is not further processed by policy processor 150.
In one embodiment, each queue entry includes the directed graph node field 510 that corresponds to the current state of the search, next byte to compare field 520 indicates the next byte in the packet to compare (BC in the pseudocode below), and length of match so far field 530 indicates the number of bytes of the potential string that have matched so far.
In the beginning of the second stage there are two sources of states that are present in the queue: the states carried over from the previous packet and new states generated by the policy processor based on the first stage report for the new packet.
In one embodiment, the second stage of searching is performed according to the following pseudocode:
When placing states in the queue, the policy processor checks the children of the nodes included in the states in the queue. If a node has a child node that accepts a zero length input, the child is placed in the queue with the current node being processed. In one embodiment, states are added until a node is found having a child with a non-zero length. When a state is enqueued, the policy processor checks the state to determine whether it is a terminating (final) state for a string. If so a match is reported by, for example, executing a callback function or some other form of notification.
For the following example, a first packet being processed contains the following characters:
XYZGET1481910ABCGET14XYZTHENPO
and a second packet being processed contains the following characters:
STXYZ=ABC . . .
A classification engine receives the first packet and stores the first packet in a buffer. The first two-byte block (XY) is accessed and the corresponding entry in look up table 300 is checked. Because XY does not correspond to the beginning of a string of interest, the classification engine continues processing without generating a first stage search report entry with the character before the seed and the character after the seed. The second two-byte block (ZG) similarly does not correspond to the beginning of a string of interest.
The third two-byte block (ET) does correspond to the beginning of a string of interest as indicated by entry 310 of table 300. Entry 310 indicates that “ET” corresponds to node 204 of directed graph 290. The classification engine generates a first stage search report entry indicating that a potential string of interest corresponding to node 204 that begins at byte 4 of the first packet.
The first packet is similarly processed by the classification engine until the sixteenth byte (GE) is reached. Entry 320 of table 300 indicates that “GE” corresponds to node 202 of directed graph 290. The classification engine generates a first stage search report entry indicating a potential string of interest corresponding to node 202 that begins at byte 16 of the first packet.
Processing continues in a similar manner in the classification engine until the twenty-eighth byte (PO) is reached. Entry 340 of table 300 indicates that “PO” corresponds to node 230 of directed graph 290. The classification engine generates a first stage search report entry indicating a potential string of interest corresponding to node 230 that begins at byte 28 of the first packet. Because “PO” is at the end of the first packet, the first stage search report is generated and the policy engine 150 is notified that the first stage search report is complete. In one embodiment, the search report and the first packet are stored in shared memory accessible by one or more classification engines and one or more policy processors; however, other memory configurations can also be used.
The classification engine processes the second packet in the same manner as the first packet. Because the second packet does not contain any potential strings of interest, a first stage search report is generated indicating that no potential strings of interest were found in the second packet during the first stage search. The first stage search report for the second packet and the second packet are sent to the policy processor. If a potential string of interest overlaps to the second packet, the policy processor searches the second packet for strings of interest.
The policy processor further processes the first packet based on the first stage search report for the first packet while the classification engine performs a first stage search for the second packet and possibly other packets. Thus, the two stage processing allows detailed searches to be performed only when a potential match is identified, which increases performance as compared to more detailed search techniques. A two stage search using two processors allows parallel operation, which increases overall search performance.
In one embodiment, the policy processor performs a byte-by-byte comparison based on the entries to the queue. Based on the first stage search report for the first packet, the queue has three entries indicating the three potential matches described above. Starting with the first potential string of interest (ET), the policy processor compares the checks the preceding character “G” as indicated by the first stage search report. The policy processor also compares next byte in the packet (“1”) with the child node of node 204, which indicates a wildcard. Because “1” satisfies the wildcard condition of the child node the queue entry is updated to indicate that the subsequent byte also matches the nodes of directed graph 290.
Processing continues through node 208 (for “1481910”), node 210 (for “A”), node 212 (for “B”) and node 214 (for “C”). Because node 214 is a final node and the path from node 200 to node 214 is matched by the first packet, the policy processor generates an indication of a matched string.
The second queue entry is processed in a similar manner by the policy processor. Processing beings at node 206 of directed graph 290. The path from node 200 to node 224 is satisfied by the data in the first packet. At node 224, the policy processor generates an indication of a matched string.
The third queue entry is processed in a similar manner by the policy processor. The policy processor begins at node 230 as indicated by the queue entry. However, at the end of the first packet (“O”), processing of the potential string of interest is not completed. Because the potential string of interest carries over into the second packet, which has no potential strings of interest as determined by the classification engine, the policy processor processes the second packet that would otherwise not be processed.
The last two bytes of the first packet and the first nine bytes of the second packet satisfy nodes 200 through 246 of directed graph 290. At node 224, the policy processor generates an indication of a matched string.
If match is found, the policy processor generates a message indicating that a string of interest has been identified. In one embodiment, the policy processor does not forward a packet having a string of interest and generates a message to a network management device to generate a warning indicating that a string of interest has been identified in a packet. Other information, for example, packet number, packet source, packet destination, can be included in the message.
If a packet is not processed by the policy processor (i.e., no potential matches found in the first stage and no overlapping searches from previous packets), the packet is output by the policy processor. In one embodiment, the packet is output to a network and sent to the packet's originally intended destination. In alternative embodiments, the packet can be sent to a classification engine or second policy processor for further processing, or the packet can be sent to a network component, for example, a router or a switch.
In the foregoing specification, the invention has been described with reference to specific embodiments thereof. It will, however, be evident that various modifications and changes can be made thereto without departing from the broader spirit and scope of the invention. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.
This U.S. Patent application is a continuation of U.S. patent application No. 09/361,347 filed Jul. 26, 1999 now U.S. Pat. No. 6,493,698.
Number | Name | Date | Kind |
---|---|---|---|
5130797 | Murakami et al. | Jul 1992 | A |
5452451 | Akizawa et al. | Sep 1995 | A |
5680568 | Sakamura | Oct 1997 | A |
5745745 | Tada et al. | Apr 1998 | A |
5778368 | Hogan et al. | Jul 1998 | A |
5781772 | Wilkinson et al. | Jul 1998 | A |
5812549 | Sethu | Sep 1998 | A |
5907837 | Ferrel et al. | May 1999 | A |
5978797 | Yianilos | Nov 1999 | A |
6014659 | Wilkinson et al. | Jan 2000 | A |
6018524 | Turner et al. | Jan 2000 | A |
6052122 | Sutcliffe et al. | Apr 2000 | A |
6157955 | Narad et al. | Dec 2000 | A |
6195661 | Filepp et al. | Feb 2001 | B1 |
6199100 | Filepp et al. | Mar 2001 | B1 |
6279038 | Hogan et al. | Aug 2001 | B1 |
6381649 | Carlson | Apr 2002 | B1 |
6389031 | Chao et al. | May 2002 | B1 |
6401117 | Narad et al. | Jun 2002 | B1 |
6421730 | Narad et al. | Jul 2002 | B1 |
6470336 | Matsukawa et al. | Oct 2002 | B1 |
6493698 | Beylin | Dec 2002 | B1 |
6578076 | Putzolu | Jun 2003 | B1 |
6598034 | Kloth | Jul 2003 | B1 |
6625689 | Narad et al. | Sep 2003 | B2 |
6643362 | Hogan et al. | Nov 2003 | B2 |
6665725 | Dietz et al. | Dec 2003 | B1 |
6701338 | Narad et al. | Mar 2004 | B2 |
6792502 | Pandya et al. | Sep 2004 | B1 |
6859841 | Narad et al. | Feb 2005 | B2 |
7191433 | Narad et al. | Mar 2007 | B2 |
20010016925 | Bucher et al. | Aug 2001 | A1 |
20020103899 | Hogan et al. | Aug 2002 | A1 |
20030005103 | Narad et al. | Jan 2003 | A1 |
20030046423 | Narad et al. | Mar 2003 | A1 |
20030061332 | Narad et al. | Mar 2003 | A1 |
20030120621 | McDaniel et al. | Jun 2003 | A1 |
20030123447 | Smith | Jul 2003 | A1 |
20030177118 | Moon et al. | Sep 2003 | A1 |
20040139070 | Dysart et al. | Jul 2004 | A1 |
20040143655 | Narad et al. | Jul 2004 | A1 |
20040148382 | Narad et al. | Jul 2004 | A1 |
Number | Date | Country | |
---|---|---|---|
20030204493 A1 | Oct 2003 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 09361347 | Jul 1999 | US |
Child | 10132926 | US |