System and method for generating random frame length, medium and electronic equipment

By introducing the front value register and historical value module in the random number generator system, the frame length is sampled and calculated, and the randomness and uniform distribution of the frame length are achieved.

CN119094400APending Publication Date: 2024-12-06NO 50 RES INST OF CHINA ELECTRONICS TECH GRP +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411050814.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

When generating the length of a random network frame, the natural interval of the random number generator does not match the limit of the length of the network frame, resulting in a high probability of missing, which violates the principle of uniform length distribution.

Method used

The random number generator, the pre-value register, the random length historical value FIFO module and the length operation logic module are used to sample and calculate the new frame length from the previous value and historical value when the hit is missed, satisfying the random characteristics.

Benefits of technology

Effectively reduce misses, avoid using the median frame length value as a solution, and ensures randomness and uniform distribution of frame length.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094400A_ABST
    Figure CN119094400A_ABST
Patent Text Reader

Abstract

The invention provides a system and a method for generating a random frame length, a medium and electronic equipment. A previous value register in the system is used for storing the last output of a multiplexer; the random length historical value FIFO module is used for storing historical output of the multiplexer; the length operation logic module is used for calculating a sampling value; and the multiplexer is used for outputting a current random value meeting the random characteristic by selecting different data paths. When a sampling value needs to be acquired, a value is taken from each of the front value register and the random length historical value FIFO module, and the sampling value is calculated through the length arithmetic logic module to serve as a current random frame length value. According to the invention, the generated random value is effectively prevented from exceeding the length interval requirement, and a median compromise mode is not needed. According to the solution, if the generated random frame length does not meet the expected or specific requirement, the current frame length is obtained from the values of the random frame length which are successfully generated before according to the sampling rule, and the random characteristic of the frame length is met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of testing instruments, and in particular to a system, method, medium and electronic equipment for generating random frame lengths. Background Art

[0002] Whether it is in the R&D stage or in mass production, network equipment needs to be tested to verify whether its performance and functions meet relevant international standards. A network tester is a common instrument for testing network equipment. It generates Ethernet network traffic and injects it into the device under test, and analyzes the Ethernet network traffic returned from the device under test to obtain information about the device under test.

[0003] When testing network equipment, it is necessary to use random-length network frames to simulate real network traffic. Since the length of network frames is limited, for example, according to international standards, the length of conventional network frames is 64-1518 bytes, then the random-length network frames that need to be generated must meet two conditions: 1. The length is in the range of 64-1518 bytes or other user-preset ranges. 2. From the statistical results, the probability of each frame length in the range is equal. In other words, if a large number of frame length sampling values ​​are collected, their average value should converge to the average value of the maximum frame length and the minimum frame length.

[0004] In digital chips, random numbers are generally generated using a linear feedback shift register (LFSR). The random number generation effect of a linear feedback shift register can meet most occasions where random numbers are required. However, there are restrictions on the random length range of network frames. For example, the length of a normal network frame is 64 bytes to 1518 bytes, the length of a jumbo frame can be up to 64K bytes, and the length of a short frame can be less than 64 bytes, such as 58 bytes, etc. In other words, the length of a network frame does not meet the natural interval boundary of the random number generator.

[0005] For example, suppose the required random packet length ranges from 64 bytes to 1518 bytes, 1518-64=1454. Then what is needed is to find a random number r between 0 and 1454. If found, add 64 to this number r to get the current packet length. A 16-bit random number generator generates random numbers that are uniformly distributed between 0 and (2^16-1). If we use the 11-bit mask 111111111111 to AND this 16-bit random number, the random number range is 0-(2^11-1), that is, the random number range is 0-2047, but the range we need is 0-1454. If the generated random number is between 0 and 1454, it is called a hit, and the generated random number can be used as the length of the network frame. If the generated random number is between 1455 and 2047, it is called a miss, and it 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 quite high. For example, for a network frame in the range of 64-1518, the probability of a single miss of its random length is approximately (2047-1454) / 2047=28.9%.

[0006] The conventional way to handle misses is to take the median of the frame length interval as the network frame length if misses occur. For example, for network frames in the range of 64-1518, the median is (64+1518) / 2=791, which is the network frame length. The obvious disadvantage of this approach is that due to the high probability of misses, there will be a relatively large number of network packets with an average packet length of 791 bytes, which does not meet the principle of random packet length.

[0007] According to the above analysis, since the probability of a miss is still quite high, if a miss occurs, the median of the interval is used as the network frame length. Finally, it is found that the proportion of the median length in the random length network frame is relatively large, which violates the principle of uniform distribution of all lengths. Therefore, a new mechanism for generating random frame lengths and a new system and method for solving the miss problem are needed. Summary of the invention

[0008] In view of the defects in the prior art, the purpose of the present invention is to provide a new mechanism for handling random length generation misses. Specifically, if a miss is found, the current frame length is obtained according to the sampling rules from the random length generated previously to meet the random characteristics of the frame length.

[0009] The present invention provides a system for generating random frame length, comprising: a random number generator, a previous value register, a random length history value FIFO module, a length operation logic module and a multiplexer;

[0010] The previous value register is electrically connected to the multiplexer and is used to store the previous output of the multiplexer;

[0011] The random length history value FIFO module is electrically connected to the multiplexer and is used to store the history output of the multiplexer;

[0012] The length operation logic module is connected to the previous value register, the random length history value FIFO module and the multiplexer at the same time, and is used to calculate the sampling value according to the output of the previous value register and the random length history value FIFO module;

[0013] The multiplexer connects the length operation logic module and the random number generator, and is used for outputting a current random value satisfying the random characteristics by selecting different data paths.

[0014] Preferably, the random number generator adopts a linear feedback shift register.

[0015] The present invention also provides a method for generating a random frame length, which uses the above-mentioned system for generating a random frame length, and comprises the following steps:

[0016] Step S1, configuring the random number interval and mask of the random number generator, the random number interval is [Lmin-Lmax], where Lmax and Lmin are the upper and lower limits of the random frame length value respectively;

[0017] Step S2, obtain the current random number r of the random number generator, calculate the current random number r and the mask to generate a new random number r1, and then determine whether the new random number r1 is within the random interval [0, Lmax-Lmin]. If r1 is within the random interval, the multiplexer outputs (r1+Lmin) and enters step S4; if r1 is not within the random interval, then enter step S3.

[0018] Step S3, taking a value from the previous value register and the random length history value FIFO module respectively, performing mathematical operations through the length operation logic module to obtain a sampled value, and the multiplexer outputs the sampled value;

[0019] Step S4, feeding back the output of the multiplexer to the previous value register and the random length history value FIFO module.

[0020] Preferably, in step S1, the random number interval is [64, 1518], Lmin is 64, and Lmax is 1518.

[0021] Preferably, in step S1, the random number generator adopts a linear feedback shift register.

[0022] Preferably, in step S2, a bitwise AND operation is performed on the current random number r and the mask to generate a new random number r1.

[0023] Preferably, in step S2, the random interval is [0, 1454].

[0024] Preferably, in step S3, the values ​​taken out from the previous value register and the random length history value FIFO module are averaged to obtain a sampled value.

[0025] The present invention provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the method for generating a random frame length are implemented.

[0026] The present invention provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and operable on the processor. When the computer program is executed by the processor, the steps of the method for generating a random frame length are implemented.

[0027] Compared with the prior art, the present invention has the following beneficial effects:

[0028] The system of the present invention includes a random number generator, a previous value register, a random length history value FIFO module, a length operation logic module and a multiplexer. The previous value register is electrically connected to the multiplexer for storing the previous output of the multiplexer; the random length history value FIFO module is electrically connected to the multiplexer for storing the historical output of the multiplexer; the length operation logic module is connected to the previous value register, the random length history value FIFO module and the multiplexer at the same time, and is used to calculate the sampling value according to the output of the previous value register and the random length history value FIFO module; the multiplexer connects the length operation logic module and the random number generator, and is used to output the current random value that meets the random characteristics by selecting different data paths. When the random number generated by the random number generator does not meet the requirements (miss), a value is taken from each of the previous value register and the random length history value FIFO module, and the sampling value is calculated by the length operation logic module, and the sampling value is used as the random frame length value of this time to meet the random characteristics.

[0029] The present invention innovatively proposes a new generation system, method, medium and electronic device for random network packet length without significantly increasing the hardware complexity. The present invention can effectively avoid the generated random value from exceeding the length interval requirement, thereby eliminating the need to adopt a compromise method such as the median. The solution is that if the generated random frame length does not meet the expected or specific requirements, the current frame length is obtained according to the sampling rules from the values ​​of the random frame lengths that have been successfully generated before, so as to meet the random characteristics of the frame length. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0031] Figure 1The figure is a hardware implementation principle diagram of a system for generating random frame lengths in an embodiment of the present invention. DETAILED DESCRIPTION

[0032] The present invention innovatively proposes a new generation system, method, medium and electronic device for network random packet length without significantly increasing the hardware complexity. It can effectively avoid the generated random value from exceeding the length interval requirement, so there is no need to adopt the compromise method of median. The solution is that if the generated random frame length does not meet the expected or specific requirements, the current frame length is obtained according to the sampling rules from the values ​​of the random frame lengths that have been successfully generated before, so as to meet the random characteristics of the frame length.

[0033] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

[0034] Embodiment 1:

[0035] Figure 1 The figure is a hardware implementation principle diagram of a system for generating random frame lengths in an embodiment of the present invention.

[0036] like Figure 1 As shown, this embodiment provides a system for generating a random frame length, including a random number generator, a previous value register, a random length history value FIFO module, a length operation logic module and a multiplexer.

[0037] The previous value register is electrically connected to the multiplexer and is used for storing the previous output of the multiplexer.

[0038] The random length history value FIFO module is electrically connected to the multiplexer and is used for storing the history output of the multiplexer.

[0039] The length operation logic module is connected to the previous value register, the random length history value FIFO module and the multiplexer at the same time, and is used to calculate the sampling value according to the output of the previous value register and the random length history value FIFO module.

[0040] The multiplexer connects the length operation logic module and the random number generator, and is used for outputting a current random value satisfying the random characteristics by selecting different data paths.

[0041] In this embodiment, the random number generator may adopt a linear feedback shift register.

[0042] If the random number generated by the random number generator meets the requirements (hit), the random number is used as the frame length value, path 1 is followed to obtain the current random value, and the current random value is fed back to the previous value register and the random length history value FIFO module from path 3.

[0043] If the random number generated by the random number generator does not meet the requirements (misses), it is necessary to obtain a sample value, take a value from the previous value register and the random length history value FIFO module, and calculate the sample value through the length operation logic module. Undoubtedly, the sample value meets the length requirement and has a random characteristic, because the value in the previous value register and the value in the random length history value FIFO module are both from the previous legal random length value. The multiplexer outputs the sample value and stores it in the previous value register and the random length history value FIFO module.

[0044] Embodiment 2:

[0045] This embodiment provides a method for generating a random frame length, using the system for generating a random frame length in the above embodiment 1, including the following steps:

[0046] Step S1, configure the random number interval and mask of the random number generator, the random number interval is [Lmin-Lmax], where Lmax and Lmin are the upper and lower limits of the random frame length value respectively.

[0047] This embodiment takes the frame length of 64-1518 as an example, configures the random number interval to be [64, 1518], Lmin to be 64, and Lmax to be 1518. In this embodiment, the random number generator uses a linear feedback shift register.

[0048] Step S2, obtain the current random number r of the random number generator, operate the current random number r with the mask to generate a new random number r1, and then determine whether the new random number r1 is in the random interval [0, Lmax-Lmin]. If r1 is in the random interval, the current frame length adopts (r1+Lmin), the multiplexer outputs (r1+Lmin), and enters step S4; if r1 is not in the random interval, enter step S3.

[0049] In this embodiment, a bitwise AND operation is performed on the current random number r and the mask to generate a new random number r1.

[0050] In this embodiment, the required random frame length range is [64, 1518], 1518-64=1454. If the generated new random number r1 is within [0, 1454], it is called a hit, and the new random number r1 can be used as the length of the network frame. The new random number r1 plus 64 is obtained to obtain the current frame length. The multiplexer selects path 1, outputs the current frame length, and enters step S4; if the generated new random number r1 is not within [0, 1454], it is called a miss, and the current random number r1 cannot be used as the length of the network frame. The multiplexer selects path 2 and enters step S3.

[0051] Step S3, taking a value from the previous value register and the random length history value FIFO module, performing mathematical operations to obtain a sampled value, and the multiplexer outputs the sampled value, which is used as the random frame length value this time.

[0052] In this embodiment, the values ​​taken out from the previous value register and the random length history value FIFO module are averaged to obtain the sampling value.

[0053] Step S4, feeding back the output of the multiplexer to the previous value register and the random length history value FIFO module for use in generating the next sampling value.

[0054] Embodiment 3:

[0055] The present invention also provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the method for generating a random frame length in the above-mentioned embodiment 2 are implemented.

[0056] Embodiment 4:

[0057] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the method for generating a random frame length in the above-mentioned embodiment 2 are implemented.

[0058] Those skilled in the art know that, in addition to realizing the system and its various devices, modules, and units provided by the present invention in a purely computer-readable program code, it is entirely possible to realize the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered as a hardware component, and the devices, modules, and units included therein for realizing various functions can also be regarded as structures within the hardware component; the devices, modules, and units for realizing various functions can also be regarded as both software modules for realizing the method and structures within the hardware component.

[0059] In the description of the present application, it should be understood that the terms "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.

[0060] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.

Claims

1. A system for generating random frame lengths, characterized in that: include: Random number generator, previous value register, random length history value FIFO module, length operation logic module and multiplexer; The previous value register is electrically connected to the multiplexer and is used to store the previous output of the multiplexer; The random length history value FIFO module is electrically connected to the multiplexer and is used to store the history output of the multiplexer; The length operation logic module is connected to the previous value register, the random length history value FIFO module and the multiplexer at the same time, and is used to calculate the sampling value according to the output of the previous value register and the random length history value FIFO module; The multiplexer is connected to the length operation logic module and the random number generator, and is used to output a current random value that meets the random characteristics by selecting different data paths.

2. The system for generating random frame length according to claim 1, characterized in that: The random number generator adopts a linear feedback shift register.

3. A method for generating a random frame length, using the system for generating a random frame length according to claim 1, characterized in that: The steps include: Step S1, configuring a random number interval and mask of a random number generator, wherein the random number interval is [Lmin-Lmax], where Lmax and Lmin are the upper and lower limits of the random frame length value, respectively; Step S2, obtain the current random number r of the random number generator, calculate the current random number r and the mask to generate a new random number r1, and then determine whether the new random number r1 is within the random interval [0, Lmax-Lmin]. If r1 is within the random interval, the multiplexer outputs (r1+Lmin) and enters step S4; if r1 is not within the random interval, enter step S3. Step S3, taking a value from each of the previous value register and the random length history value FIFO module, performing mathematical operations through the length operation logic module to obtain a sampled value, and the multiplexer outputs the sampled value; Step S4, feeding back the output of the multiplexer to the previous value register and the random length history value FIFO module.

4. The method for generating a random frame length according to claim 4, characterized in that: In step S1, the random number interval is [64, 1518], Lmin is 64, and Lmax is 1518.

5. The method for generating a random frame length according to claim 4, characterized in that: In the step S1, the random number generator adopts a linear feedback shift register.

6. The method for generating a random frame length according to claim 4, characterized in that: In step S2, a bitwise AND operation is performed on the current random number r and the mask to generate a new random number r1.

7. The method for generating a random frame length according to claim 5, characterized in that: In step S2, the random interval is [0, 1454].

8. The method for generating a random frame length according to claim 4, characterized in that: In the step S3, the values ​​taken out from the previous value register and the random length history value FIFO module are averaged to obtain a sampling value.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for generating a random frame length according to any one of claims 3 to 8 are implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the computer program is executed by a processor, the steps of the method for generating a random frame length according to any one of claims 3 to 8 are implemented.