Method and device for generating random test packet length for network tester

By introducing pre-RAM and mask bit processing into the network tester, the problem of random number generator misses is solved, and a uniform distribution of random network frame length is achieved, improving the accuracy and realism of the test.

CN120880958APending Publication Date: 2025-10-31CHINA ACADEMY OF INFORMATION & COMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510767232.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-10-31

AI Technical Summary

Technical Problem

In existing technologies, the length of random network frames generated by network testers does not meet the uniform distribution requirement, resulting in uneven packet length distribution. In particular, the random number generator has a high probability of missing, which affects the accuracy of the test.

Method used

A front-end RAM is introduced, and the random number range and mask bits are configured by software. A new random number is generated in conjunction with a random number generator, and a value is randomly extracted from the front-end RAM in the event of a miss, so as to ensure the uniformity and randomness of the packet length.

Benefits of technology

This technology enables the uniform and random acquisition of packet lengths when the random number generator fails to meet requirements, improving the accuracy and randomness of network testers, avoiding the use of a single median, and closely approximating the distribution of real network traffic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120880958A_ABST
    Figure CN120880958A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for generating a random test packet length for a network tester, and the method comprises the steps: configuring a random number interval Lmin-Lmax through software; a current random number is obtained through a random number generator, the current random number and a mask bit are subjected to AND operation, a new random number r1 is generated, and the mask bit is determined according to a packet length value to be obtained; judging whether the new random number r1 is within an interval [0, Lmax-Lmin] or not; under the condition that the new random number does not fall in the interval [0, Lmax-Lmin], a value is randomly selected from the preposed RAM, the result obtained by adding the value and r1 serves as the packet length value of the current frame, the random value in the preposed RAM is obtained through offline calculation according to Lmin and Lmax through software and is updated according to a certain probability, and the uniformity and randomness of the packet length can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication network technology, and in particular to a method and apparatus for generating random test packet lengths for a network tester. Background Technology

[0002] A network tester is a common instrument for testing network devices. It generates Ethernet network traffic and injects it into the network device under test (DUT), then analyzes the network information returned by the DUT to obtain information about the DUT. When testing network devices, network frames of random length are needed to simulate real network traffic. Since the length of a network frame is limited—for example, according to international standards, the length of a standard network frame is 64-1518 bytes—then the generated random-length network frames must meet two conditions:

[0003] 1. Length is in the range of 64-1518 or other user-preset ranges.

[0004] 2. Statistically, the probability of each frame length occurring within the interval is equal. In other words, if a large number of frame length samples are collected, their average should converge to the average of the maximum and minimum frame lengths, and the probability of each allowed length value occurring should be equal. For example, if there are 1000 allowed values, then the probability of each length value occurring should be 0.1% under large-value statistical conditions.

[0005] For ease of implementation, the maximum packet length Lmax is usually subtracted from the minimum packet length Lmin, and its value is set to Ldiff. Then the interval of the random number becomes [0, Ldiff]. After obtaining the random number r that meets the conditions, adding Lmin will give the desired random packet length.

[0006] For generating random numbers, digital chips generally use linear feedback shift registers (LFSRs). The random number generation performance of LFSRs is sufficient for most applications requiring random numbers. For example, a 16-bit random number generator produces random numbers uniformly distributed between 0 and (2^16-1). If we AND this 16-bit random number with an 11-bit mask 11111111111, the random number will then fall within the range of 0 to (2^11-1), meaning the range is 0 to 2047.

[0007] The natural range of network packet length does not satisfy a power of 2. For example, a typical packet length is 64-1518 bytes, and the difference (Ldiff) is 1454. If the generated random number is between 0 and 1454, it is called a hit; if the generated random number is between 1455 and 2047, it is called a miss, and the random number cannot be used as the length of the network frame. As we have analyzed above, since the range of random numbers generated by digital circuits is always a power of 2, the probability of a miss is still considerable. For example, for a network frame in the 64-1518 byte range, the probability of a single miss in random length generation is approximately (2047-1454) / 2047 = 28.9%.

[0008] The conventional approach is to take the median of the frame length range as the network frame length if a match is missed. For example, for a network frame in the range of 64-1518, the median is (64+1518) / 2 = 791, which is the network frame length.

[0009] The obvious drawback of this approach is that, due to the higher probability of a miss, there will be a relatively large number of network packets with a length of 791 bytes, which does not conform to the principle of averaging out random packet length distribution. Summary of the Invention

[0010] This invention provides a method for generating random test packet lengths for a network tester, which solves the defect of uneven packet length distribution in the prior art for testing network devices. By introducing a front-end RAM, the method can obtain packet lengths evenly and randomly when the random numbers generated by the random number generator do not meet the requirements.

[0011] This invention provides a method for generating random test packet lengths for a network tester, the method comprising:

[0012] The random number range Lmin to Lmax is configured through software, where Lmin and Lmax are the upper and lower limits of the packet length value, respectively.

[0013] A new random number r1 is generated by obtaining a current random number through a random number generator and performing an AND operation between the current random number and the mask bits. The number of mask bits is determined according to the packet length value to be obtained.

[0014] Determine whether the new random number r1 falls within the interval [0, Lmax-Lmin];

[0015] If the new random number falls within the interval [0, Lmax-Lmin], the length of the current frame is r1+Lmin; if the new random number does not fall within the interval [0, Lmax-Lmin], a value is randomly selected from the front-end RAM, and the result of adding this value to r1 is used as the current frame packet length. The random value in the front-end RAM is obtained by software through offline calculation based on Lmin and Lmax, and is updated according to a certain probability.

[0016] Optionally, the number of bits in the mask can be configured via software.

[0017] Optionally, the method further includes: initializing RAM by software according to the required random number range, wherein the initialized values ​​are not repeated and the arithmetic mean converges to the median of Lmin and Lmax.

[0018] Optionally, the method further includes: initializing RAM based on a predetermined low-order bit value generated by a random number generator.

[0019] Optionally, initializing RAM based on a predetermined low-order bit value generated by a random number generator includes: initializing RAM using the predetermined low-order bit value with a certain probability.

[0020] Optionally, if the new random number falls within the interval [0, Lmax-Lmin], then the length of the current frame is r1+Lmin, and r1+Lmin is sent as a random number to the update logic unit, which then randomly updates the RAM.

[0021] This invention provides a device for generating random test packet lengths for a network tester, the device comprising:

[0022] The input module is used to configure the random number range Lmin to Lmax through the interface, where Lmin and Lmax are the upper and lower limits of the packet length value, respectively.

[0023] A random number generator is used to generate the current random number.

[0024] The AND logic operator performs an AND operation on the current random number and the mask bits to generate a new random number r1. The number of mask bits is determined according to the packet length value to be obtained.

[0025] The processor is used to determine whether the new random number r1 falls within the interval [0, Lmax-Lmin]. If the new random number falls within the interval [0, Lmax-Lmin], the length of the current frame is r1+Lmin. If the new random number does not fall within the interval [0, Lmax-Lmin], a value is randomly selected from the front-end RAM, and the result of adding this value to r1 is used as the current frame packet length.

[0026] The random values ​​in the front-end RAM are obtained offline by the processor module based on Lmin and Lmax, and are updated according to a certain probability.

[0027] Optionally, the RAM is initialized with a predetermined low-order value generated by a random number generator.

[0028] Optionally, the RAM is initialized using the predetermined low-bit value with a certain probability.

[0029] Optionally, the device further includes an update logic unit. If the new random number falls within the interval [0, Lmax-Lmin], the processor uses the length of the current frame as r1+Lmin and sends r1+Lmin as a random number to the update logic unit, which then randomly updates the RAM.

[0030] The present invention provides a method and apparatus for generating random test packet lengths for network testers. In order to generate random packet lengths, in addition to a random number generator, a buffer pool with controllable random packet lengths is added, so that even if the random number generated by the random number generator fails, a random packet length can still be obtained. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0032] Figure 1 This is a flowchart illustrating the method for generating random test packet lengths for a network tester provided by the present invention.

[0033] Figure 2 This is a schematic diagram of the path for generating random numbers provided by the present invention.

[0034] Figure 3 This is a schematic diagram of the device for generating random test packet lengths for a network tester provided by the present invention. Detailed Implementation

[0035] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0036] All network switches must be subjected to random packet length traffic during testing. This is because packet lengths are variable in real networks, and switches must be able to withstand line-speed forwarding of network packets of various lengths.

[0037] This invention provides a method for generating random test packet lengths for a network tester, which solves the defect of uneven packet length distribution in the prior art for testing network devices. By introducing a front-end RAM, the method can obtain packet lengths evenly and randomly when the random numbers generated by the random number generator do not meet the requirements.

[0038] This invention provides a method for generating random test packet lengths for a network tester, such as... Figure 1 As shown, the method includes:

[0039] S11. Configure the random number range Lmin~Lmax and the mask bit through software, where Lmin and Lmax are the upper and lower limits of the packet length value, respectively.

[0040] S12. Obtain the current random number through a random number generator, and AND the current random number with the mask bits to generate a new random number r1. The number of mask bits is determined according to the packet length value to be obtained.

[0041] S13. Determine whether the new random number r1 falls within the interval [0, Lmax-Lmin];

[0042] S14. If the new random number falls within the interval [0, Lmax-Lmin], then the length of the current frame is r1+Lmin;

[0043] S15. If the new random number does not fall within the interval [0, Lmax-Lmin], a value is randomly selected from the front RAM, and the result of adding this value to r1 is used as the current frame packet length value. The random value in the front RAM is obtained by software offline calculation based on Lmin and Lmax, and is updated according to a certain probability.

[0044] This invention innovatively proposes a novel hardware-software combined mechanism for generating random length network packets for testing network devices, which can better handle the randomness in the event of a packet miss. Under this mechanism, when a packet miss occurs, there is no need to refer to the median value, making it closer to true randomness.

[0045] A hit means that the packet length generated by the random number generator meets the requirements. For example, if the random packet length is set to a range of 64 bytes to 1000 bytes, then Lmin = 64, Lmax = 1000, and Lmax - Lmin = 1000 - 64 = 936. If the packet length L generated by the random number generator is between 0 and 936, then it's a hit, and the final packet length is L + 64. If the data generated by the random number generator is outside the range of 0 to 936, then it's a miss.

[0046] As a specific implementation, taking a required packet length of 64-1518 bytes as an example, Lmin = 64, Lmax = 1518, Ldiff = 1518-64 = 1454, and the required random number range is 0-1454. If the random number generator generates a random value that meets the requirements (hit), then the random number is used as the frame length value. After obtaining a random number r that meets the conditions, adding 64 gives the required random packet length. The random number range 0-1454 does not satisfy the power of 2. If the generated random number is between 0-1454, it is called a hit; if the generated random number is between 1455-2047, it is called a miss, and the random number cannot be used as the length of the network frame. Since the range of random numbers generated by digital circuits is always a power of 2, the probability of a miss is still considerable. The probability of a single miss in the random length is approximately (2047-1454) / 2047 = 28.9%. The depth of RAM can be determined according to actual needs. For example, a depth of 256 can be selected, providing 256 alternative random values ​​in case of a cache miss, instead of simply selecting the median value of 727. These random values ​​are calculated offline by software, ensuring both uniformity and randomness. The alternative random values ​​can be pre-initialized in the RAM according to the required random number range. During initialization, these values ​​must be unique, and their arithmetic mean must converge to the median of the maximum and minimum values ​​in the random range. This ensures that the random numbers buffered in the RAM not only meet the required numerical requirements but also have a uniform random distribution. In a specific implementation, if a depth of 256 is selected for the RAM, then an 8-bit address is sufficient, and the lower 8 bits of the random number generator can be used as the RAM read address. Therefore, as one implementation, the RAM can be initialized based on the predetermined lower bits of the values ​​generated by the random number generator. As a second implementation, initializing the RAM based on the predetermined lower bits of the values ​​generated by the random number generator includes: initializing the RAM using the predetermined lower bits with a certain probability. As a third implementation method, the software initializes the RAM according to the required random number range, with no repetition between the initialized values, and the arithmetic mean converges to the median of Lmin and Lmax.

[0047] As a specific implementation method, random number generation in digital chips is generally achieved using a linear feedback shift register (LFSR). The random number generation performance of the LFSR is sufficient for most applications requiring random numbers.

[0048] The number of bits in a random number generator is generally not the same as the mask length, because the data length generated by random number generators mostly follows international standards, such as 23 bits or 32 bits. In many cases, the number of bits in the random numbers generated by the random number generator does not meet the test requirements. In this case, it is necessary to set the mask bit length to meet the range requirements of the packet length random numbers. As one example, if the random number generator is 32 bits and the random packet length is 0-4095, and the packet length requires 12 bits, then a 12-bit mask is set to take the lower 12 bits of the data generated by the random number generator. As another example, for a 16-bit random number generator, the random numbers it generates are uniformly distributed between 0 and (2^16-1). By ANDing the 16-bit random number with an 11-bit mask (11111111111), the range of the random number becomes 0-(2^11-1), which is 0-2047. In other words, by ANDing a mask of a predetermined bit length with a random number, the required number of bits of random numbers can be achieved.

[0049] The number of bits in the mask depends on the length of the random packet to be obtained. For example, if the random packet length is between 0 and 2047, then an 11-bit mask is just right. If the random packet length is between 0 and 4095, then a 12-bit mask is needed. If the longest packet length we need to generate is 16,000 bytes, or 16KB, then 14 bits are sufficient to accommodate these length values. The mask bit length can be designed to be 14 bits. The mask bit length can be configured via software.

[0050] As mentioned earlier, the depth of RAM can be determined according to actual needs. For example, choosing a depth of 256 provides 256 alternative random values ​​to choose from in the event of a miss. However, if the value in RAM is continuously used in the event of a miss, these 256 values ​​will repeat randomly during the testing process, which is not the optimal design. Therefore, this invention also designs a method for dynamically updating RAM content. In this case, the content in RAM is randomly updated with a certain probability. As a specific implementation, when the hardware random number generator generates a random value that meets the conditions, in addition to being used currently, this value is also written to RAM with a certain probability. This probability and algorithm can be determined in advance, and this invention does not require detailed specifications. Through this implementation, the random values ​​in RAM are continuously updated, and even if the random number generated by the random number generator misses, the random values ​​used in RAM are uniform in randomness and probability compared to the hit random numbers. Specifically, this can be achieved through an update logic unit. If the new random number falls within the interval [0, Lmax-Lmin], then the length of the current frame is r1+Lmin, and r1+Lmin is sent as a random number to the update logic unit, which then randomly updates the RAM.

[0051] like Figure 2 As shown, this diagram illustrates a specific implementation method and the application path of random numbers. Path 1 directly uses random numbers generated by a hardware random number generator as the packet length. In this path, the random numbers generated by the random number generator hit the required packet length range. Path 2 assigns random values ​​in the RAM through randomized RAM update logic. This randomized RAM update logic reads random numbers generated by the random number generator that hit the required packet length range, thus continuously assigning values ​​to the RAM. This enriches and updates the random values ​​in the RAM, storing all historical random numbers. If the random numbers generated by the random number generator do not hit the required packet length range, a historical random number from the RAM is randomly read as the packet length.

[0052] This invention provides a device for generating random test packet lengths for network testers, such as... Figure 3 As shown, the device includes:

[0053] Input module 31 is used to configure the random number range Lmin to Lmax through the interface, where Lmin and Lmax are the upper and lower limits of the packet length value, respectively.

[0054] Random number generator 32 is used to generate the current random number;

[0055] The AND logic operator 33 performs an AND operation on the current random number and the mask bits to generate a new random number r1. The number of mask bits is determined according to the packet length value to be obtained.

[0056] The processor 34 is used to determine whether the new random number r1 falls within the interval [0, Lmax-Lmin]. If the new random number falls within the interval [0, Lmax-Lmin], the length of the current frame is r1+Lmin. If the new random number does not fall within the interval [0, Lmax-Lmin], a value is randomly selected from the front-end RAM, and the result of adding this value to r1 is used as the current frame packet length.

[0057] The front-end RAM 35 contains random values ​​that are calculated offline by the processor module based on Lmin and Lmax, and are updated according to a certain probability.

[0058] Optionally, the RAM is initialized with a predetermined low-order value generated by a random number generator.

[0059] Optionally, the RAM is initialized using the predetermined low-bit value with a certain probability.

[0060] Optionally, the device further includes an update logic unit. If the new random number falls within the interval [0, Lmax-Lmin], the processor uses the length of the current frame as r1+Lmin and sends r1+Lmin as a random number to the update logic unit, which then randomly updates the RAM.

[0061] The present invention provides a method and apparatus for generating random test packet lengths for network testers. In order to generate random packet lengths, in addition to a random number generator, a buffer pool with controllable random packet lengths is added, so that even if the random number generated by the random number generator fails, a random packet length can still be obtained.

[0062] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0063] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0064] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for generating random test packet lengths for a network tester, characterized in that, The method includes: The random number range Lmin to Lmax is configured through software, where Lmin and Lmax are the upper and lower limits of the packet length value, respectively. A new random number r1 is generated by obtaining a current random number through a random number generator and performing an AND operation between the current random number and the mask bits. The number of mask bits is determined according to the packet length value to be obtained. Determine whether the new random number r1 falls within the interval [0, Lmax-Lmin]; If the new random number falls within the interval [0, Lmax-Lmin], the length of the current frame is r1+Lmin; if the new random number does not fall within the interval [0, Lmax-Lmin], a value is randomly selected from the front-end RAM, and the result of adding this value to r1 is used as the current frame packet length. The random value in the front-end RAM is obtained by software through offline calculation based on Lmin and Lmax, and is updated according to a certain probability.

2. The method for generating random test packet lengths for a network tester according to claim 1, wherein the mask bit length is configured by software.

3. The method for generating random test packet lengths for a network tester according to claim 1, characterized in that, The method also includes: initializing RAM by software according to the required random number range, with no repetition between the initial values, and the arithmetic mean converging to the median of Lmin and Lmax.

4. The method for generating random test packet lengths for a network tester according to claim 1, characterized in that, The method also includes initializing RAM based on a predetermined low-order value generated by a random number generator.

5. The method for generating random test packet lengths for a network tester according to claim 4, characterized in that, Initializing RAM based on a predetermined low-order bit value generated by a random number generator includes: initializing RAM using the predetermined low-order bit value with a certain probability.

6. The method for generating random test packet lengths for a network tester according to claim 1, characterized in that, If the new random number falls within the interval [0, Lmax-Lmin], then the length of the current frame is r1+Lmin, and r1+Lmin is sent as a random number to the update logic unit, which then randomly updates the RAM.

7. A device for generating random test packet lengths for a network tester, characterized in that, The device includes: The input module is used to configure the random number range Lmin to Lmax through the interface, where Lmin and Lmax are the upper and lower limits of the packet length value, respectively. A random number generator is used to generate the current random number. The AND logic operator performs an AND operation on the current random number and the mask bits to generate a new random number r1. The number of mask bits is determined according to the packet length value to be obtained. The processor is used to determine whether the new random number r1 falls within the interval [0, Lmax-Lmin]. If the new random number falls within the interval [0, Lmax-Lmin], the length of the current frame is r1+Lmin. If the new random number does not fall within the interval [0, Lmax-Lmin], a value is randomly selected from the front-end RAM, and the result of adding this value to r1 is used as the current frame packet length. The random values ​​in the front-end RAM are obtained offline by the processor module based on Lmin and Lmax, and are updated according to a certain probability.

8. The device for generating random test packet lengths for a network tester according to claim 7, characterized in that, The RAM is initialized with a predetermined low-order value based on the value generated by the random number generator.

9. The random test packet length generation device for a network tester according to claim 8, characterized in that, The RAM is initialized with a certain probability using the predetermined low-order bit value.

10. The device for generating random test packet lengths for a network tester according to claim 7, characterized in that, The device also includes an update logic unit. If the new random number falls within the interval [0, Lmax-Lmin], the processor takes the length of the current frame as r1+Lmin and sends r1+Lmin as a random number to the update logic unit, which then randomly updates the RAM.