Disclosure of Invention
In order to improve the reliability of the time stamp accuracy used in network transmission, the application provides a time stamp accuracy verification method and a time stamp accuracy verification system for network equipment.
In a first aspect of the present application, there is provided a method for verifying timestamp accuracy of a network device, the method comprising:
acquiring n groups of delay data, wherein n is more than or equal to 2, the parameter values of network channels corresponding to the n groups of delay data are different, the network channels consist of transmission lines and gateway equipment, and the parameter values refer to the lengths of the transmission lines;
Calculating according to n groups of delay data to obtain actual timestamp accuracy;
And obtaining a verification result according to the actual time stamp precision and the preset time stamp precision.
In one possible implementation manner, the method for acquiring any one of n sets of delay data includes:
adjusting the length of a transmission line to obtain a transmission delay, wherein the transmission delay is positively correlated with the length of the transmission line;
Acquiring a forwarding delay, a sending time stamp and a receiving time stamp, wherein the forwarding delay is related to the forwarding speed of the gateway equipment, the receiving time stamp is the moment when a network packet is sent out, and the receiving time stamp is the moment when the network packet is received;
Building a relation from the transmission delay, the forwarding delay, the sending timestamp and the receiving timestamp:
Transmission delay+forwarding delay= (reception timestamp-transmission timestamp) ×initial timestamp accuracy, which is the timestamp accuracy of any one of n sets of delay data.
By adopting the technical scheme, the length of the transmission line is changed to obtain multiple groups of delay data with different transmission delay increment, and because the change of the length of the transmission line and the process of calculating the difference value between the receiving time stamp and the sending time stamp do not have communication channels, namely the change of the length of the transmission line is not self-modified or determined in a system for calculating the difference value between the receiving time stamp and the sending time stamp, the two are mutually independent processes, the possibility of cheating is eliminated, and the reliability of the result of verifying the accuracy of the preset time stamp according to the multiple groups of delay data can be ensured.
In one possible implementation, when the length of the transmission line is adjusted to obtain the transmission delay, the increment of the adjusted transmission delay is larger than the preset timestamp precision.
By adopting the technical scheme, when the increment of the transmission delay is smaller than the precision of the time stamp, the increment of the transmission delay possibly falls into the non-driving time stamp of the gateway device, so that the gateway device does not have network packets capable of being forwarded on the driving time stamp, and the received network packets in the non-driving time stamp are not forwarded, namely the increment of the transmission delay is annihilated by the forwarding delay. Therefore, the increment of the transmission delay after adjustment is set to be larger than the preset time stamp precision, and the method has the advantage of avoiding annihilation of the increment of the transmission delay, thereby providing technical guarantee for improving the reliability of the time stamp precision used in network transmission.
In one possible implementation manner, the calculating the actual timestamp accuracy according to the n sets of delay data includes:
calculating to obtain the initial time stamp precision of each group of delay data through the relational expression;
Calculating the average value of the initial timestamp precision of n groups of delay data;
And determining the mean value as the actual timestamp precision.
In one possible implementation manner, the calculating the actual timestamp accuracy according to the n sets of delay data includes:
calculating to obtain the initial time stamp precision of each group of delay data through the relational expression;
the mode of the initial timestamp accuracy of the n sets of delay data is determined to be the actual timestamp accuracy.
By adopting the technical scheme, the application provides two modes for calculating the accuracy of the actual time stamp, and the two calculation modes comprehensively consider the initial time stamps of a plurality of groups of delay data, so that the accuracy of the actual time stamp obtained by calculation can be ensured no matter which calculation mode is selected, and a plurality of selectable calculation modes can also adapt the verification method of the application to a plurality of application scenes, thereby improving the practicability of the application.
In one possible implementation manner, the obtaining the verification result according to the actual timestamp precision and the preset timestamp precision includes:
Calculating a difference value between the actual timestamp precision and the preset timestamp precision;
When the absolute value of the difference value is less than or equal to a difference value threshold value, obtaining a verification result as verification passing;
And when the absolute value of the difference value is greater than the difference value threshold value, obtaining a verification result that the verification is not passed.
By adopting the technical scheme, after the actual timestamp precision is obtained, the difference between the actual timestamp precision and the preset timestamp precision is required to be judged, and when the difference between the actual timestamp precision and the preset timestamp precision is not larger than the difference threshold value, the preset timestamp precision is considered to pass verification, namely, the smaller the difference between the actual timestamp precision and the preset timestamp precision is, the higher the reliability of the verification result is.
In a second aspect of the present application, there is provided a time stamp accuracy verification system for a network device, the system being applied to a network architecture, the network architecture including a transmitting device for transmitting a network packet and embedding a transmission time stamp in the network packet, a gateway device for receiving and forwarding the network packet, and a receiving device for receiving the network packet, the gateway device being connected to the transmitting device and the receiving device respectively through transmission lines, the system including a network tester for executing the time stamp accuracy verification method for any one of the above network devices.
By adopting the technical scheme, on one hand, the application designs the verification method based on the existing network architecture without system cost. On the other hand, the process of changing the length of the transmission line and calculating the difference between the receiving timestamp and the sending timestamp has no communication channel, namely, the change of the length of the transmission line is not self-modified or determined in the network tester and is mutually independent, so that the possibility of cheating is eliminated, and the reliability of the result of verifying the accuracy of the preset timestamp according to multiple groups of delay data can be ensured.
In one possible implementation, the receiving device and the network tester are the same network device.
By adopting the technical scheme, the receiving equipment and the network tester are the same network equipment, so that the verification cost is reduced, the verification process is directly carried out in the network tester, the data exchange times are reduced, and the verification error is reduced.
In one possible implementation, the transmission line is an optical fiber.
By adopting the technical scheme, the optical fiber is adopted as the transmission line, on one hand, the optical fiber can adapt to a high-speed network, the transmission efficiency of the network packet between the sending equipment and the receiving equipment is improved, and the transmission delay of the network packet in the optical fiber is more stable compared with that of a common copper cable, so that the length of the optical fiber can be dynamically set according to the transmission delay requirement.
In one possible implementation, the network tester includes:
The data acquisition module is used for acquiring n groups of delay data, wherein n is more than or equal to 2, the parameter values of network channels corresponding to the n groups of delay data are different, the network channels consist of transmission lines and gateway equipment, and the parameter values refer to the lengths of the transmission lines;
The data calculation module is used for calculating and obtaining the actual timestamp precision according to n groups of delay data;
and the data determining module is used for obtaining a verification result according to the actual time stamp precision and the preset time stamp precision.
In summary, the application has the following beneficial technical effects:
Firstly, the increment of the transmission delay after adjustment is set to be larger than the preset time stamp precision, and the increment of the transmission delay is prevented from falling on the non-driving time stamp of the gateway equipment, so that the accuracy of the obtained actual time stamp precision is improved. Secondly, the process of changing the length of the transmission line and calculating the difference between the receiving timestamp and the sending timestamp has no communication channel, namely, the change of the length of the transmission line is not self-modified or determined in the network tester and is mutually independent, so that the possibility of cheating is eliminated, and the reliability of the verification result can be ensured. Therefore, the application has the effect of doubly guaranteeing the reliability of the verification result, and can improve the reliability of the time stamp precision used in network transmission.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Fig. 1 shows a schematic diagram of an exemplary operating environment in which an embodiment of the application can be implemented, comprising a transmitting device 1, a receiving device 3 and a gateway device 22, the transmitting device 1 being in information interaction with the receiving device 3 via the gateway device 22.
The transmitting device 1 is driven by a counter of a high frequency clock, for example, one frequency is selected from MHz-GHz or GHz-THz as a driving frequency of the counter. The high frequency clock generates a time stamp on which the transmitting device 1 is triggered, and simultaneously issues a network packet, which may be data requested by the receiving party or data randomly transmitted by the transmitting device 1 to the receiving device 3. In addition, the transmitting apparatus 1 embeds the binary value of the time stamp into the network packet at the time stamp, and then transmits the network packet. In this example, the corresponding timestamp when the network packet was sent out is referred to as a transmission timestamp.
The gateway device 22 is disposed between the transmitting device 1 and the receiving device 3, and the gateway device 22, such as a switch, a router, etc., is connected to the transmitting device 1 and the receiving device 3 through the transmission line 21, where the transmission line 21 is a cable capable of transmitting network packets, such as an optical fiber, a copper cable, etc., and the optical fiber is adapted to a high-speed network, and the transmission delay of the optical fiber is more stable than that of the copper cable, and is less interfered by external environmental factors, so that the optical fiber will be described below as the transmission line 21. Since the network packet output from the transmitting device 1 reaches the gateway device 22 through the optical fiber, and is forwarded by the gateway device 22 to the receiving device 3 through the optical fiber, a transmission channel formed by the gateway device 22 and the optical fiber is also referred to as a network channel 2.
The reception device 3 is also driven by a counter of a high-frequency clock, and the driving frequency is selected to be the same as that of the counter of the transmission device 1, so that the transmission device 1 and the reception device 3 perform synchronous signal processing. Specifically, the high-frequency clock generates a time stamp on which the receiving apparatus 3 is triggered while receiving a network packet, which is data output by the transmitting apparatus 1, and the time stamp corresponding to when the network packet is received is referred to as a reception time stamp in this example. At the receiving device 3 side, the receiving device 3 takes out the transmission timestamp in the network packet, calculates the difference between the reception timestamp and the transmission timestamp, and multiplies the difference by the timestamp precision to obtain the delay of the network packet, that is, the delay of the network packet= (reception timestamp-transmission timestamp) = timestamp precision, where the timestamp precision is related to the driving frequency of the counter of the receiving device 3, and since the driving frequency of the counter of the receiving device 3 is equal to the driving frequency of the counter of the transmitting device 1, the timestamp precision is also considered to be related to the driving frequency of the transmitting device 1, specifically, the product of the driving frequency and the period is equal to 1 second, and the period refers to the triggering period of the counter, that is, the period of the time stamp generated by the transmitting device 1 or the receiving device 3.
Since the receiving device 3 has a function of calculating the delay of the network packet, the receiving device 3 may be the network tester 4, and the relationship between the network tester 4 and the transmitting device 1 and the receiving device 3 is indicated by a broken line. Of course, a network tester 4 may be separately set up, and the network tester 4 is connected to the receiving device 3 so as to be capable of reading the receiving time stamp and the sending time stamp, and calculating the delay of the network packet according to the receiving time stamp and the sending time stamp.
It should be noted that, in the case where the receiving device 3 is the network tester 4, the sending device 1 and the receiving device 3 may also be the same network tester 4, that is, one network tester 4 takes two roles, for example, one port of the network tester 4 outputs a network packet, and the network packet enters the network tester 4 from the other port after passing through the network channel 2 formed by the optical fiber and the gateway device 22.
The network tester 4 is a network device having an FPGA chip, wherein the FPGA chip calculates the difference between the receiving time stamp and the sending time stamp, stores the difference in a register, reads the difference by a software system in the network tester 4, and calculates the product of the difference and the time stamp precision to obtain the delay of the network packet. In addition, the software system of the network tester 4 also has a function of verifying the accuracy of the time stamp.
It should also be noted that the operating environment illustrated in fig. 1 is merely illustrative and is in no way intended to limit the application or uses of embodiments of the present application. For example, the operating environment may include a plurality of transmitting devices 1, a plurality of receiving devices 3, and a plurality of gateway devices 22.
Fig. 2 shows a flowchart of a method for verifying the accuracy of a timestamp of a network device according to an embodiment of the application, which is applied to the network tester 4. Specifically, the main flow of the timestamp accuracy verification method of the network device is described as follows.
Step S1, n groups of delay data are acquired, n is more than or equal to 2, parameter values of a network channel 2 corresponding to the n groups of delay data are different, the network channel 2 consists of optical fibers and gateway equipment 22, and the parameter values refer to lengths of the optical fibers.
As the network packets pass through the network channel 2, the delay in transmission may be different even though the network packets are going from the same transmitting device 1 to the same receiving device 3, due to the length of the optical fiber and the forwarding speed of the gateway device 22.
In order to verify the accuracy of the timestamp accuracy, n groups of delay data need to be acquired first, specifically, each time the length of the optical fiber is adjusted, a group of corresponding delay data is acquired. In order to ensure the accuracy of verification, the application reduces the number of variables involved in the verification process, namely the gateway equipment 22 used in the verification process is the same, namely the forwarding speeds corresponding to the gateway equipment 22 in n groups of delay data are the same, so that the time stamp accuracy can be verified by only changing the length of the optical fiber and changing the delay increment of the network packet caused by the length of the optical fiber.
Specifically, each set of delay data includes a transmission delay, a forwarding delay, a transmission timestamp, a reception timestamp, and a relationship between the four. The propagation delay is positively correlated with the length of the fiber, and typically, each 0.2 meter increase in length of the fiber increases the corresponding propagation delay by 1ns. The forwarding delay is a delay when the gateway apparatus 22 forwards the network packet, and is typically in the order of milliseconds, and is an attribute defined by the gateway apparatus 22 before leaving the factory. The transmission time stamp is the time when the transmission device 1 transmits the network packet, and the reception time stamp is the time when the reception device 3 receives the network packet. Specifically, the relation among the transmission delay, the forwarding delay, the sending timestamp and the receiving timestamp is that the transmission delay and the forwarding delay= (receiving timestamp-sending timestamp) ×initial timestamp precision, wherein the initial timestamp precision refers to the timestamp precision of any one of n groups of delay data.
In the above-mentioned relation, the transmission delay may be calculated by the length of the optical fiber, the forwarding delay may be obtained by reading the attribute of the gateway device 22, then calculating the difference between the receiving timestamp and the sending timestamp by the receiving device 3, and finally constructing the above-mentioned relation by the network tester 4 under the condition that the initial timestamp is unchanged, thereby obtaining one set of delay data. In the whole test process, similar to a double-blind test in medicine, the increase of the length of the optical fiber and the calculation of the difference value between the receiving time stamp and the sending time stamp are not the same group of people, and no communication channel exists (the length of the optical fiber is input into the network tester 4 by a tester and is not self-modifiable or determinable at the end of the network tester 4), so that the possibility of cheating is eliminated, and the reliability of a verification result is ensured.
In this example, the length of the optical fiber is sequentially increased or decreased, so that the transmission delay is also changed, and the difference between the receiving timestamp and the sending timestamp is changed, so that multiple sets of delay data are obtained, and the accuracy of the timestamp is verified through the multiple sets of delay data. When the length of the optical fiber is changed, the optical fiber between the transmitting device 1 and the gateway device 22 may be changed, the optical fiber between the gateway device 22 and the receiving device 3 may be changed, or the lengths of both optical fibers may be changed, and the specific changing manner is not limited herein. It should be further noted that, whether the length of the optical fiber is sequentially increased or the length of the optical fiber is sequentially decreased, the transmission delay caused by the change of the optical fiber length should be greater than the timestamp precision, because the receiving device 3 and the gateway device 22 may have clocks asynchronous, and the receiving device 3 and the gateway device 22 are driven by clocks with different driving frequencies, and the gateway device 22 is of a storage forwarding type, that is, the gateway device 22 receives all bytes of one network packet and forwards the network packet, and when the increment of the transmission delay is less than the timestamp precision, the increment of the transmission delay may fall on a non-driving timestamp of the gateway device 22, so that the gateway device 22 has no network packet to forward on the driving timestamp, and the network packet received in the non-driving timestamp is not forwarded, that is, the increment of the transmission delay is annihilated by the forwarding delay.
To illustrate the above annihilation, for example, as shown in fig. 3, if the driving frequency of the gateway device 22 is 300MHz, the maximum possible forwarding delay due to the asynchronous clock of the gateway device 22 reaches 3.3ns, and at this time, the clock period of the gateway device 22 is considered to be 3.3ns, i.e., a driving timestamp is reached after every 3.3ns, and the clock period is within 3.3ns as a non-driving timestamp. Again assuming that the driving frequency of the receiving device 3 is 400MHz, the time interval for each bit is 2.5ns, i.e. the time stamp accuracy is 2.5ns. If, in the first test, 0.5 meters of fiber were added such that the increment of transmission delay was 2.5ns, the gateway device 22 received the first network packet at a time of 0.2ns,0.2ns slightly later than the first clock edge 0 (drive timestamp) of the gateway device 22, then the first network packet would be in a state to be forwarded until the time reached the second clock edge 3.3ns, and the network packet would not be forwarded. Similarly, since the transmission delay of the network packet is 2.5ns, the time when the second network packet arrives at the receiving device 3 is 2.7ns, but 2.7ns is still later than the first clock edge 0 and earlier than the second clock edge 3.3ns, so the second network packet is still forwarded after the clock edge 3.3ns, so on the driving timestamp of 3.3ns, the first network packet and the second network packet are forwarded at the same time, and it is difficult for the receiving device 3 to know the transmission delay of the two packets before and after each other, that is, the transmission delay is annihilated.
For this reason, it is necessary to amplify the time stamp accuracy of the receiving apparatus 3 by changing the length of the optical fiber, for example, the initial time stamp accuracy of different sets of delay data is amplified by 10 times, 20 times, 100 times, etc., respectively, and may even be an arbitrarily large prime number times, the delay of the corresponding network packet will be increased by 25ns,50ns,250ns, etc., and the larger the increment of the transmission delay, the larger the amplification of the corresponding initial time stamp accuracy, the smaller the influence due to the above-mentioned clock-crossing domain will be.
And S2, calculating according to n groups of delay data to obtain the actual timestamp accuracy.
In the above-described relation, transmission delay+transfer delay= (reception timestamp-transmission timestamp) = initial timestamp accuracy, since the transmission delay is calculated by the length of the optical fiber, the transfer delay is also calculated by reading the attribute of the gateway device 22, and the difference between the reception timestamp and the transmission timestamp is calculated by the receiving device 3, the differences between the transmission delay, the transfer delay, the reception timestamp and the transmission timestamp are all known numbers, and only the initial timestamp accuracy is unknown, and the initial timestamp accuracy of each set of delay data is obtained by using the above-described relation.
In a specific example, the actual time stamp accuracy is calculated by obtaining an initial time stamp accuracy of each set of delay data in the n sets of delay data, and then calculating an average value of the n initial time stamp accuracy, and taking the average value as the actual time stamp accuracy of the receiving device 3.
Before calculating the actual timestamp accuracy, the maximum value and the minimum value of the initial timestamp accuracy in n groups of delay data are removed, or the initial timestamp accuracy beyond a threshold range is removed, so that the accuracy of the calculated actual timestamp accuracy is ensured.
In another specific example, the actual time stamp accuracy is calculated by obtaining an initial time stamp accuracy of each of the n sets of delay data and taking a mode of the n initial time stamp accuracy as the actual time stamp accuracy.
In addition, in the actual test, the method of calculating the accuracy of the actual timestamp is specifically adopted, and the present application is not limited herein.
And step S3, obtaining a verification result according to the actual time stamp precision and the preset time stamp precision.
First, a difference between an actual time stamp accuracy and a preset time stamp accuracy, which is a time stamp accuracy to be verified, is calculated. Then, the magnitude relation between the absolute value of the difference value and the difference value threshold value is judged, and when:
When the absolute value of the difference value is less than or equal to the difference value threshold value, obtaining a verification result as verification passing;
and when the absolute value of the difference value is greater than the difference value threshold value, obtaining a verification result that the verification is not passed.
The difference threshold is a value set in advance, and when the absolute value of the difference is smaller than or equal to the difference threshold, the actual timestamp precision is considered to be equal to the preset timestamp precision, which indicates that the preset timestamp precision passes verification.
Therefore, the application designs a verification mode based on the existing network architecture, realizes the aim of verifying the time stamp accuracy of the receiving equipment 3 by only changing the length of the optical fiber, precisely controls the increment of the transmission delay by the length of the optical fiber, avoids errors caused by clock domain crossing, and has no communication channel in the process of calculating the difference value between the receiving time stamp and the transmitting time stamp due to the increment of the length of the optical fiber, so the application has the effect of doubly guaranteeing the reliability of the verification result.
In summary, the implementation principle of the method for verifying the timestamp accuracy of the network device according to the embodiment of the application is that, firstly, the length of the transmission line 21 is changed, and the transmission delay is changed due to the change of the length of the transmission line 21, so that the difference value between the corresponding receiving timestamp and the corresponding transmitting timestamp is changed, and then, a relational expression is constructed according to the corresponding transmission delay, the forwarding delay, the difference value between the receiving timestamp and the transmitting timestamp and the initial timestamp accuracy during each adjustment, so as to obtain multiple groups of delay data. In each set of relation, the differences of the transmission delay, the forwarding delay, the receiving time stamp and the sending time stamp are all known numbers, so that the initial time stamp precision corresponding to each set of delay data can be obtained by calculating the relation. And finally, comprehensively calculating the actual timestamp precision by utilizing the calculated multiple initial timestamp precision, ensuring the accuracy of the obtained actual timestamp precision, further judging the size relation between the actual timestamp precision and the preset timestamp precision to obtain a final verification result, and when the difference between the actual timestamp precision and the preset timestamp precision is not greater than a threshold value difference value, indicating that the verification of the preset timestamp precision is passed, thereby improving the reliability of the timestamp precision used in network transmission.
Fig. 4 shows a block diagram of a time stamp accuracy verification system of a network device according to an embodiment of the application, the system comprising a data acquisition module 41, a data calculation module 42 and a data determination module 43.
The data acquisition module 41 is configured to acquire n sets of delay data, where n is greater than or equal to 2, and parameter values of the network channels 2 corresponding to the n sets of delay data are different, where the network channels 2 are composed of the transmission line 21 and the gateway device 22, and the parameter values refer to lengths of the transmission line 21.
The data calculation module 42 is configured to calculate the actual timestamp accuracy according to the n sets of delay data.
The data determining module 43 is configured to obtain a verification result according to the actual timestamp precision and the preset timestamp precision.
The modules involved in the embodiments of the present application may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, a processor may be described as comprising a data acquisition module 41, a data calculation module 42 and a data determination module 43. The names of these modules do not constitute a limitation of the module itself in some cases, and the data acquisition module 41 may also be described as "a module for acquiring n sets of delay data", for example.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the described modules may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again.
In order to better execute the program of the method, the application also provides a timestamp accuracy verification device of the network equipment, which comprises a memory and a processor.
Wherein the memory may be used to store instructions, programs, code, sets of codes, or sets of instructions. The memory may include a storage program area that may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing a time stamp accuracy verification method of the network device, and the like, and a storage data area that may store data and the like involved in the time stamp accuracy verification method of the network device.
The processor may include one or more processing cores. The processor performs the various functions of the application and processes the data by executing or executing instructions, programs, code sets, or instruction sets stored in memory, calling data stored in memory. The processor may be at least one of an application specific integrated circuit, a digital signal processor, a digital signal processing device, a programmable logic device, a field programmable gate array, a central processing unit, a controller, a microcontroller, and a microprocessor. It will be appreciated that the electronics for implementing the above-described processor functions may be other for different devices, and embodiments of the present application are not particularly limited.
The application also provides a computer readable storage medium, such as a U disk, a mobile hard disk, a Read Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk or an optical disk, etc., which can store program codes. The computer readable storage medium stores a computer program that can be loaded by a processor and that performs the above method for verifying the accuracy of a timestamp of a network device.
The above description is only illustrative of the preferred embodiments of the present application and of the principles of the technology employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in the present application is not limited to the specific combinations of technical features described above, but also covers other technical features which may be formed by any combination of the technical features described above or their equivalents without departing from the spirit of the disclosure. Such as the above-mentioned features and the technical features disclosed in the present application (but not limited to) having similar functions are replaced with each other.