BUFFER ALLOCATION AND USE FOR PACKET CLONING AND MANGLING
20170230311 · 2017-08-10
Inventors
Cpc classification
International classification
Abstract
A method of cloning and mangling a received data packet in which an unused space of a receiving buffer can be used to accommodate at least some generated clone packets. Additional memory-use efficiencies can be realized by employing scatter-gather lists in the process of clone-packet generation when the size of the received data packet exceeds a predetermined threshold size. The method enables the corresponding network device to improve the packet-processing speed and memory use compared to those achievable with the use of conventional methods.
Claims
1. A method of processing data packets at a network device, the method comprising: storing a received data packet in a first buffer of the network device; determining whether an unused space of the first buffer is larger than a first threshold size; and generating a first clone packet corresponding to the received data packet in a first portion of the unused space of the first buffer if the unused space is larger than the first threshold size.
2. The method of claim 1, further comprising generating the first clone packet corresponding to the received data packet in a second buffer of the network device if the unused space of the first buffer is not larger than the first threshold size.
3. The method of claim 2, further comprising generating a second clone packet corresponding to the received data packet in the second buffer if the unused space of the first buffer is smaller than the first threshold size, wherein the second clone packet has a different data content than the first clone packet and occupies a different portion of the second buffer than the first clone packet.
4. The method of claim 1, further comprising generating a second clone packet corresponding to the received data packet in a second portion of the unused space of the first buffer if the unused space of the first buffer is larger than the first threshold size, wherein the second clone packet has a different data content than the first clone packet.
5. The method of claim 1, wherein the step of generating comprises: generating a copy of the received data packet in the first portion of the unused space of the first buffer; and modifying at least a portion of the copy to generate the first clone packet.
6. The method of claim 1, wherein the step of generating comprises generating a scatter-gather list that refers to at least a portion of the received data packet stored in the first buffer.
7. The method of claim 6, wherein: the step of generating further comprises generating a block of data in the first portion of the unused space of the first buffer; and the scatter-gather list refers to the block of data.
8. The method of claim 6, further comprising: determining whether the unused space of the first buffer is larger than a second threshold size; and comparing a size of the received data packet with the second threshold size; and wherein generating the scatter-gather list is performed only if the size of the received data packet is larger than the second threshold size.
9. The method of claim 1, wherein the first clone packet differs from the received data packet in at least one of a header portion and a payload portion.
10. The method of claim 1, further comprising selecting the first buffer from a plurality of buffers of the network device based on a size of the received data packet, wherein the plurality of buffers comprises buffers of two or more different fixed sizes.
11. The method of claim 1, further comprising: generating in the first buffer a predetermined number of clone packets corresponding to the received data packet; and applying each of the clone packets to a respective network port of the network device for transmission to a respective external device.
12. The method of claim 11, wherein the predetermined number is greater than two.
13. The method of claim 11, further comprising transmitting the received data packet out of the first buffer of the network device using a network port of the network device that is different from a network port through which the received data packet was received by the network device.
14. The method of claim 13, further comprising: requesting a transmission confirmation from each respective external device; receiving the transmission confirmation from each respective external device; and freeing the first buffer and any other buffers referred to in a metadata list corresponding to the received data packet.
15. The method of claim 1, further comprising: generating a predetermined number of clone packets corresponding to the received data packet using at least two more buffers of the network device, wherein the at least two more buffers include the first buffer; and applying each of the clone packets to a respective network port of the network device for transmission to a respective external device.
16. The method of claim 1, further comprising: generating a predetermined number of clone packets corresponding to the received data packet using one or more buffers of the network device, wherein the one or more buffers do not include the first buffer; and applying each of the clone packets to a respective network port of the network device for transmission to a respective external device.
17. The method of claim 1, wherein the first portion of the unused space of the first buffer is located in a tail room of the first buffer with respect to the received data packet.
18. The method of claim 1, wherein the network device is an intelligent traffic classification manager.
19. A network device comprising a memory that includes a plurality of buffers, wherein the network device is operable to: store a received data packet in a first buffer of the plurality of buffers; determine whether an unused space of the first buffer is larger than a first threshold size; and generate a first clone packet corresponding to the received data packet in a first portion of the unused space of the first buffer if the unused space is larger than the first threshold size.
20. The network device of claim 19, wherein the network device is an intelligent traffic classification manager.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0004] Embodiments of the present invention are illustrated herein by way of example and are not limited by the accompanying figures, in which like references indicate similar elements. Elements in the figures are illustrated for simplicity and clarity and have not necessarily been drawn to scale. Various aspects, features, and benefits of the disclosed embodiments will become more fully apparent, by way of example, from the following detailed description that refers to the accompanying figures, in which:
[0005]
[0006]
[0007]
[0008]
[0009]
[0010]
[0011]
[0012]
DETAILED DESCRIPTION
[0013] Detailed illustrative embodiments of the present invention are disclosed herein. However, specific structural and functional details to which the disclosure refers are merely representative for purposes of describing example embodiments of the present invention. Embodiments of the present invention may be embodied in many alternative forms and should not be construed as limited to only the embodiments set forth herein.
[0014] As used herein, the singular forms “a,” “an,” and “the,” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It further will be understood that the terms “comprises,” “comprising,” “has,” “having,” “includes,” and/or “including” specify the presence of stated features, steps, or components, but do not preclude the presence or addition of one or more other features, steps, or components. It also should be noted that, in some alternative embodiments, certain functions or acts may occur out of the order indicated in the figures.
[0015] Disclosed herein are various embodiments of a method of cloning and mangling a received data packet in which the unused space of the receiving buffer can be used to accommodate at least some of the generated clone packets. Additional memory-use efficiencies can be realized by employing scatter-gather lists in the process of clone-packet generation when the size of the received data packet exceeds a predetermined threshold size. The disclosed method advantageously enables the corresponding network device to improve the packet-processing speed and memory use compared to those achievable with the use of conventional methods.
[0016] One embodiment of the present invention is a method of processing data packets at a network device. The method comprises the steps of: storing a received data packet in a first buffer of the network device; determining whether or not an unused space of the first buffer is larger than a first threshold size; and generating a first clone packet corresponding to the received data packet in a first portion of the unused space of the first buffer if the unused space is larger than the first threshold size.
[0017] Another embodiment of the present invention is a network device that includes a memory having a plurality of buffers. The network device is operable to: store a received data packet in a first buffer of the plurality of buffers; determine whether or not an unused space of the first buffer is larger than a first threshold size; and generate a first clone packet corresponding to the received data packet in a first portion of the unused space of the first buffer if the unused space is larger than the first threshold size.
[0018] Referring now to
[0019] An original data packet 110 includes a network (N/W) headers portion 112 and a payload portion 114. The operations 102-108 are applied to the original data packet 110 to generate the data packets 120, 130, 140, and 150, respectively.
[0020] The operation 102 generates the data packet 120 that includes (i) a copy of the network headers portion 112 as the network header and (ii) a payload portion 122. The payload portion 122 is generated by slicing the payload portion 114. As used herein, the term “slicing” refers to data removal, which causes the payload portion 122 to be smaller in size than the payload portion 114.
[0021] The operation 104 generates the data packet 130 that includes a network headers portion 132 and a payload portion 136. The network headers portion 132 is generated by inserting a sub-portion 134 to replace a corresponding sub-portion of the network headers portion 112. The payload portion 136 is generated from the payload portion 114 by masking data in a sub-portion 138 thereof. As used herein, the term “masking” refers to data modification that makes the data in the modified sub-portion undecodable at the destination node. An example masking operation may include replacing all data in the sub-portion 138 by zeros or encoding the data therein without providing the code key to the destination node.
[0022] The operation 106 generates the data packet 140 that includes a network headers portion 142 and a payload portion 146. The network headers portion 142 is generated by inserting a sub-portion 144 to replace a corresponding sub-portion of the network headers portion 112. The payload portion 146 is generated from the payload portion 114 by inserting a sub-portion 148 to replace a corresponding sub-portion of the payload portion 114.
[0023] The operation 108 generates the data packet 150 that includes a network headers portion 152 and a copy of the payload portion 114. The network headers portion 152 is generated by inserting a sub-portion 154 to replace a corresponding sub-portion of the network headers portion 112.
[0024]
[0025] In an example embodiment, the traffic-management device 232 is a data-recording device. The traffic-management device 234 is a network analyzer. The traffic-management device 236 is an intrusion detection/prevention device. The traffic-management device 238 is a secure-socket-layer (SSL) analyzer. In various alternative embodiments, fewer or other and/or additional traffic-management devices may similarly be connected to the ITCM 220.
[0026] In an example configuration, the ITCM 220 receives a data packet 202 through the network port VLAN5. The ITCM 220 temporarily stores in its internal memory (not shown in
[0027] In an example configuration, the ITCM 220 may generate the data packet 204 by applying to the data packet 202 an operation that is similar to one of the operations 104 and 106 (
[0028]
[0029] At step 302 of the method 300, the ITCM 220 receives a data packet, such as the data packet 202 (
[0030] As used herein, the term “buffer” refers to a portion of the device's electronic memory that is allocated as a temporary holding place for the data that are being sent to or received from an external device or system. Typically, a buffer has a fixed size selected from a plurality of predetermined fixed sizes. For example, the following buffer sizes may be used: 2048 (2 k) bytes, 4096 (4 k) bytes, 8192 (8 k) bytes, 16384 (16 k) bytes, 32768 (32 k) bytes, 65536 (64 k) bytes, and 131072 (128 k) bytes. In some embodiments, other predetermined buffer sizes may also be used.
[0031] The receiving network device, such as the ITCM 220, typically has a buffer pool having buffers of different fixed sizes. The received data packet is typically written into an empty or unused buffer selected from the buffer pool and having the smallest size that can accommodate the entire received data packet. For example, the Ethernet format may use a Maximum Transferable Unit (MTU) that is 1500 bytes in size. This particular MTU size can be accommodated by and the corresponding received data packet can temporarily be stored in a 2 k buffer. As another example, the Ethernet format allows the use of jumbo frames for which the MTU size is 9000 Bytes. This particular MTU size can be accommodated by and the corresponding received data packet can temporarily be stored in a 16 k buffer.
[0032] Steps 304-310 of the method 300 are directed at generating one or more new data packets based on the data packet received at step 302. As already indicated above, these one or more new data packets are generated by applying the respective packet-cloning and/or packet-mangling operations. Each of such new packets is hereafter referred to as a “clone packet.” The number of clone packets that are yet to be generated for the data packet received at step 302 is referred to herein as the “clone count.”
[0033] At step 304, the current clone count is checked. If the clone count is positive, then the processing of the method 300 is directed to step 306, and the current clone count is decremented by one. If the current clone count is zero, then the processing of the method 300 is directed to step 312.
[0034] At step 306, a separate dedicated buffer from the pool of available buffers is allocated for the next clone packet. A copy of the packet received at step 302 is then written into the allocated buffer.
[0035] At step 308, one or more desired packet-cloning and/or packet-mangling operations are applied to the packet copy generated at step 306, which packet copy is altered by these operations and thereby transformed into the corresponding clone packet. This clone packet remains stored in the same buffer, i.e., the buffer allocated at step 306.
[0036] At step 310, the clone packet generated at step 308 is transmitted out, e.g., by being applied to an appropriate one of the network ports VLAN1-VLAN4 of the ITCM 220 as indicated in
[0037] The processing loop comprising steps 304-310 is repeated until the clone count becomes zero. A person of ordinary skill in the art will understand that different packet-cloning and/or packet-mangling operations may be applied at different instances of step 308. As a result, different clone packets (e.g., as illustrated in
[0038] At step 312, the original data packet received at step 302 is released from the corresponding buffer, e.g., by being applied to the network port VLAN8 of the ITCM 220 as indicated in
[0039] One problem with the method 300 is that at least step 306 thereof proves to be very costly and/or non-optimal in terms of the processing speed and memory use. This problem becomes especially disadvantageously pronounced when the received data packets have relatively large sizes.
[0040] This and certain other problems in the pertinent art can be addressed, e.g., using various embodiments disclosed herein below. In particular, some embodiments are able to bypass step 306 by relying on the unutilized space in the initial receiving buffer, i.e., the buffer into which the originally received data packet is written at step 302 of the method 300. For example, for the packet size of 256 bytes and with the smallest available buffer being a 2 k buffer, the unutilized space in the buffer is going to be 1792 (=2048-256) bytes. As another example, for the packet size of 9000 bytes and with the available fixed buffer sizes being the same as those in the above-mentioned buffer-pool example, the unutilized space in the buffer is going to be 7384 (=16384-9000) bytes. As these examples illustrate, the size of the unutilized space may be sufficiently large to be able to accommodate at least some of the generated clone packets. Additional efficiencies can advantageously be realized by employing scatter gather lists in the process of clone-packet generation, e.g., as further detailed below.
[0041]
[0042] At step 402 of the method 400, the ITCM 220 receives a data packet, such as the data packet 202 (
[0043] At step 404, the size of the data packet received at step 402 is compared to a predetermined threshold size. If the packet size is greater than the predetermined threshold size, then the processing of the method 400 is directed to step 416. Otherwise, the processing of the method 400 is directed to step 406. In an example embodiment, the predetermined threshold size used at step 404 is 256 bytes. In alternative embodiments, other predetermined threshold sizes can also be used.
[0044] At step 406, the unutilized space in the buffer into which the received data packet was written at step 402 is compared with another predetermined threshold size. If the unutilized space is greater than the predetermined threshold size, then the processing of the method 400 is directed to step 408. Otherwise, the processing of the method 400 is directed to step 304 of the method 300 (
[0045] At step 408, an additional copy of the data packet received at step 402 is generated in the unutilized space of the same buffer.
[0046] At step 410, the copy generated at step 408 is appropriately modified to generate a corresponding clone packet, which remains stored in the same space. The modifications of the copy are performed, e.g., by applying a desired packet-cloning and/or packet-mangling operation. After the modifications are completed, the clone count is decremented by one.
[0047] At step 412, the clone packet generated at step 410 is transmitted out, e.g., by being applied to an appropriate one of the network ports VLAN1-VLAN4 of the ITCM 220 as indicated in
[0048] At step 414, the current clone count is checked. If the clone count is positive, then the processing of the method 400 is directed back to step 406. If the current clone count is zero, then the processing of the method 400 is directed to step 426.
[0049]
[0050] During a first pass through the processing loop 406-414 of the method 400, the clone packet 504 is generated in a respective portion of the tail room of the buffer. More specifically, at step 408 of the processing loop, a copy of the data packet 502 is created in that portion of the tail room. Then, at step 410 of the processing loop, this copy of the data packet 502 is modified, e.g., by applying to it an operation that is similar in part to the operation 106 (
[0051] During a second pass through the processing loop 406-414 of the method 400, the clone packet 506 is generated in a respective portion of the tail room of the buffer. More specifically, at step 408 of the processing loop, a copy of the data packet 502 is created in that portion of the tail room. Then, at step 410 of the processing loop, this copy of the data packet 502 is modified, e.g., by applying to it an operation that is similar to the operation 102 (
[0052] During an n-th pass through the processing loop 406-414 of the method 400, the clone packet 508 is generated in a respective portion of the tail room of the buffer. More specifically, at step 408 of the processing loop, a copy of the data packet 502 is created in that portion of the tail room. Then, at step 410 of the processing loop, this copy of the data packet 502 is modified, e.g., by applying to it an operation that is similar in part to the operation 104 (
[0053] Referring back to
[0054] At step 418, a new buffer is allocated for the clone packet(s) to be generated. If step 418 is not bypassed, then steps 420-422 are performed using this new buffer. However, if step 418 is bypassed, then steps 420-422 are performed using the unutilized space of the initial buffer allocated at step 402.
[0055] At step 420, a clone packet is created by executing the sub-steps of (i) generating, in the allocated buffer space, one or more blocks of modified data corresponding to the data packet received at step 402 and (ii) generating a respective scatter-gather list that appropriately links up portions of the data packet received at step 402 and the one or more blocks of the modified data generated at sub-step (i). After the scatter-gather list is generated, the clone count is decremented by one.
[0056] As known in the pertinent art, a scatter-gather list defines a memory read request configured to gather data written into two or more noncontiguous (e.g., scattered) areas of the memory. Typically, a scatter-gather list comprises a sequence of pointers, each of which gives the location in the memory and the length of a respective contiguous data segment. The memory read request executed in accordance with the scatter-gather list thus enables the linked-up data to be read out as if these data were stored in and read from a single contiguous area of the memory. The use of scatter-gather lists is advantageously capable of reducing demands on the memory resources when the linked-up data segments are relatively large.
[0057] At step 422, the clone packet generated at step 420 is transmitted out, e.g., by being applied to an appropriate one of the network ports VLAN1-VLAN4 of the ITCM 220 as indicated in
[0058] At step 424, the current clone count is checked. If the clone count is positive, then the processing of the method 400 is directed back to step 420. If the current clone count is zero, then the processing of the method 400 is directed to step 426.
[0059] At step 426, the original data packet received at step 402 is transmitted out, e.g., by being applied to the network port VLAN8 of the ITCM 220 as indicated in
[0060]
[0061] During a first pass through the processing loop 420-424 of the method 400, the clone packet 604 is generated in a respective portion of the tail room of the buffer 600. The data packet 604 comprises a scatter-gather (SG) list 620 containing a single pointer labeled SG1. The pointer SG1 of the SG list 620 points to the network headers portion 612 of the data packet 602. Since the SG list 620 does not contain any other pointers, the data packet 604 is a clone packet that is generated from the data packet 602 by completely slicing off the payload portion 614.
[0062] During a second pass through the processing loop 420-424 of the method 400, the clone packet 606 is generated in a respective portion of the tail room of the buffer 600. The data packet 606 comprises (i) an SG list 630 containing the pointers labeled SG1-SG3 and (ii) a data sector 632 that contains data used for masking a corresponding sub-portion of the payload portion 614. The pointer SG1 of the SG list 630 points to the network headers portion 612 of the data packet 602. The pointer SG2 of the SG list 630 points to the data sector 632. The pointer SG3 of the SG list 630 points to the payload portion 614. Hence, the data packet 606 is a clone packet that is generated from the data packet 602 by applying to it an operation that is similar in part to the operation 104 (
[0063] During an n-th pass through the processing loop 420-424 of the method 400, the clone packet 608 is generated in a respective portion of the tail room of the buffer 600. The data packet 608 comprises (i) an SG list 640 containing the pointers labeled SG1-SG4; (ii) a data sector 642 that contains data used for masking a corresponding sub-portion of the payload portion 614; and (iii) a data sector 644 that contains data used for replacing a corresponding sub-portion of the payload portion 614. The pointer SG1 of the SG list 640 points to the network headers portion 612 of the data packet 602. The pointer SG2 of the SG list 640 points to the data sector 642. The pointer SG3 of the SG list 640 points to the data sector 644. The pointer SG4 of the SG list 640 points to the payload portion 614. Hence, the data packet 608 is a clone packet that is generated from the data packet 602 by applying to it an operation that is similar in part to a combination of the operations 104 and 106 (
[0064]
[0065] During a first pass through the processing loop 420-424 of the method 400, the clone packet 722 is generated in a respective portion of the buffer 720. The clone packet 722 comprises (i) an SG list 730 containing the pointers labeled SG1-SG3 and (ii) a data sector 732 that contains data used for masking a corresponding sub-portion of the payload portion 714. The pointer SG1 of the SG list 730 points to the network headers portion 712 of the data packet 702. The pointer SG2 of the SG list 730 points to the data sector 732. The pointer SG3 of the SG list 730 points to the payload portion 714. Hence, the clone packet 722 is a clone packet that is generated from the data packet 702 by applying to it an operation that is similar in part to the operation 104 (
[0066] During a second pass through the processing loop 420-424 of the method 400, the clone packet 724 is generated in a respective portion of the buffer 720. The clone packet 724 comprises an SG list 740 containing a single pointer labeled SG1. The pointer SG1 of the SG list 740 points to the network headers portion 712 of the data packet 702 stored in the buffer 700. Since the SG list 740 does not contain any other pointers, the clone packet 724 is a clone packet that is generated from the data packet 702 by completely slicing off the payload portion 714.
[0067] During a third pass through the processing loop 420-424 of the method 400, the clone packet 726 is generated in a respective portion of the buffer 720. The clone packet 726 comprises (i) an SG list 750 containing the pointers labeled SG1-SG3 and (ii) a data sector 752 that contains replacement data for a corresponding sub-portion of the payload portion 714. The pointer SG1 of the SG list 750 points to the network headers portion 712 of the data packet 702. The pointer SG2 of the SG list 750 points to the data sector 752. The pointer SG3 of the SG list 750 points to the payload portion 714. Hence, the clone packet 726 is a clone packet that is generated from the data packet 702 by applying to it an operation that is similar in part to the operation 106 (
[0068] During an n-th pass through the processing loop 420-424 of the method 400, the clone packet 728 is generated in a respective portion of the buffer 720. The data packet 728 comprises (i) an SG list 760 containing the pointers labeled SG1-SG4; (ii) a data sector 762 that contains data used for masking a corresponding sub-portion of the payload portion 714; and (iii) a data sector 764 that contains data used for replacing a corresponding sub-portion of the payload portion 714. The pointer SG1 of the SG list 760 points to the network headers portion 712 of the data packet 702. The pointer SG2 of the SG list 760 points to the data sector 762. The pointer SG3 of the SG list 760 points to the data sector 764. The pointer SG4 of the SG list 760 points to the payload portion 714. Hence, the clone packet 728 is a clone packet that is generated from the data packet 702 by applying to it an operation that is similar in part to a combination of the operations 104 and 106 (
[0069]
[0070] At step 802 of the method 800, the packet transmission confirmation for the corresponding data packet is received from the appropriate circuit or device. As already indicated above, the data packet in question may be the data packet transmitted at one of steps 412, 422, and 426 of the method 400.
[0071] At step 804, the reference count is decremented by one. As used herein, the term “reference count” refers to the number of data packets that are yet to be transmitted out. The reference count includes both the clone packets and the original data packet.
[0072] At step 806, the current reference count is checked. If the reference count is positive, then the processing of the method 800 is directed to step 810. If the current reference count is zero, then the processing of the method 800 is directed to step 808.
[0073] At step 808, all buffers that are referred to in the metadata list(s) corresponding to the original data packet are freed up and made available for accepting other incoming data packets.
[0074] At step 810, the processing of the method 800 is terminated.
[0075] It will be further understood that various changes in the details, materials, and arrangements of the parts that have been described and illustrated in order to explain the nature of the invention may be made by those skilled in the art without departing from the scope of the invention as expressed in the following claims.
[0076] Reference herein to “one embodiment” or “an embodiment” means that a particular feature, structure, or characteristic described in connection with the embodiment can be 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, nor are separate or alternative embodiments necessarily mutually exclusive of other embodiments. The same applies to the term “implementation.”
[0077] Unless explicitly stated otherwise, each numerical value and range should be interpreted as being approximate as if the word “about” or “approximately” preceded the value of the value or range. As used in this application, unless otherwise explicitly indicated, the term “connected” is intended to cover both direct and indirect connections between elements.
[0078] For purposes of this description, the terms “couple,” “coupling,” “coupled,” “connect,” “connecting,” or “connected” refer to any manner known in the art or later developed in which energy is allowed to be transferred between two or more elements, and the interposition of one or more additional elements is contemplated, although not required. The terms “directly coupled,” “directly connected,” etc., imply that the connected elements are either contiguous or connected via a conductor for the transferred energy.
[0079] Although the steps in the following method claims are recited in a particular sequence with corresponding labeling, unless the claim recitations otherwise imply a particular sequence for implementing some or all of those steps, those steps are not necessarily intended to be limited to being implemented in that particular sequence.