Message timestamp acquisition method, apparatus, and device, and storage medium
By determining the offset and time difference between the preset flag bits of the packet on the physical media connection side in Ethernet, the problem of insufficient time stamp accuracy of the packet is solved, and the timestamp stability and accuracy are improved when the Ethernet rate changes are improved.
Patent Information
- Application Number
- PCT/CN2024/143224
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-27
- Filing Date
- 2024-12-27
- Publication Date
- 2025-07-03
AI Technical Summary
In the prior art, the accuracy of message timestamps is poor, especially when the Ethernet rate changes, it is easy to introduce jitter.
By determining the target offset of the preset flag bit of the message on the physical medium connection side in the target data transmitted by the target clock signal, determining the target timestamp of the preset flag bit based on the target clock signal and the offset, and calculating the time difference between the preset flag bit and the frame start symbol flag bit, the actual time stamp of the frame start symbol flag bit is obtained.
Improve the accuracy of packet timestamps, avoid timestamp jitter caused by changes in Ethernet speed, and ensure the real-time and accuracy of timestamps acquired on the physical media connection side.
Smart Images

Figure CN2024143224_03072025_PF_FP_ABST
Abstract
Description
Method, device, equipment and storage medium for obtaining message timestamp
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority and benefits of patent application No. 202311833964.X filed with the State Intellectual Property Office of China on December 27, 2023, the entire contents of which are incorporated herein by reference for all purposes. Technical Field
[0003] The present application belongs to the field of semiconductor technology and relates to a method, apparatus, device and storage medium for obtaining a message timestamp. Background Art
[0004] In order to synchronize the slave device's clock with the master device's reference clock in an Ethernet network, it is necessary to determine the time delay between the slave device's clock and the master's reference clock. The PTP (Precision Time Protocol) protocol defines a method for measuring time delay. Assuming the link between the master and the slave is symmetrical to the link between the slave and the master, the time delay can be calculated by subtracting t2 from t1 and then subtracting the MPD (Mean Path Delay). The MPD is the average of the difference between t1 and t2 and the difference between t4 and t3, where t1 is the time the message is sent from the master, t2 is the time the message is received by the slave, t3 is the time the delay request message is sent from the slave, and t4 is the time the delay request message is received by the master.
[0005] Therefore, in order to correct the slave device clock and synchronize it with the master device's reference clock, it is necessary to determine the timestamps t1, t2, t3, and t4 of the message. Ethernet is generally divided into the MAC (Medium Access Control) layer, the PCS (Physical Coding Sublayer) layer, and the PMA (Physical Medium Attachment) sublayer. In theory, the closer the timestamp is to the line-side timestamp, the more accurate it is and the closer it is to the actual value. Therefore, in related technologies, the timestamp is usually stamped on the mii (Media Independent Interface) interface, and the mii interface is the MAC interface and the PCS interface. However, because the PCS processing methods of each rate are different, the processing they undergo is also different, and the asynchronous FIFO (First in, First out) introduced when switching the rate will also cause timestamp jitter. Summary of the Invention
[0006] The present application provides a method, apparatus, device and storage medium for obtaining a message timestamp, so as to solve the problem of poor accuracy of message timestamps obtained in the prior art.
[0007] In order to solve the above technical problems, in a first aspect, the present application provides a method for obtaining a message timestamp, the method comprising:
[0008] Determining a target offset of a preset flag bit of a message on a physical medium connection side in target data transmitted by a target clock signal, wherein the target data includes data in the message, and the target offset is a difference between the number of bits of the preset flag bit and the first bit of the target data;
[0009] Determining a target timestamp corresponding to the preset flag bit according to the target clock signal and the target offset;
[0010] Determining a time difference between the preset flag and a start-of-frame flag of the message;
[0011] The actual timestamp of the frame start mark is obtained according to the target timestamp and the time difference.
[0012] Optionally, when sending a message, the preset flag is a start of frame flag.
[0013] Optionally, determining a target offset of a preset flag bit of a message on the physical medium connection side in the target data transmitted by the target clock signal includes:
[0014] When receiving a message, for a message without alignment characters, the target offset of the preset flag bit of the message on the physical medium connection side is determined in the target data transmitted by the target clock signal, wherein the preset flag bit is a fixed flag bit set periodically.
[0015] Optionally, determining a target offset of a preset flag bit of a message on the physical medium connection side in the target data transmitted by the target clock signal includes:
[0016] When receiving a message, for a message containing an alignment character, the target offset of a preset flag bit of the message on the physical medium connection side is determined in the target data transmitted by the target clock signal, wherein the preset flag bit is a position N bits away from the flag bit of the alignment character.
[0017] Optionally, after obtaining the actual timestamp of the start of frame marker, the method further includes:
[0018] Calculate a first time difference between a first timestamp of a target message sent by the master device and a second timestamp of the target message received by the slave device, wherein the first timestamp and the second timestamp are both actual timestamps of a start of frame flag;
[0019] Determining a second time difference between the first time difference and a preset average path delay;
[0020] Determining the second time difference as the actual clock delay between the master device and the slave device;
[0021] The clock of the master device is used as a reference clock, and the clock of the slave device is corrected according to the actual clock delay.
[0022] Optionally, determining a target timestamp corresponding to the preset flag bit according to the target clock signal and the target offset includes:
[0023] Determine a third timestamp of the target clock signal corresponding to the first bit of the target data;
[0024] A target timestamp corresponding to the preset flag bit is determined according to the target offset and the third timestamp.
[0025] Optionally, determining a time difference between the preset flag and a start of frame flag of the message includes:
[0026] Determine first data where a frame start character flag of the message is located and a first clock signal for transmitting the first data;
[0027] determining a first number of clock signals that differs between the target clock signal and the first clock signal;
[0028] When the message is transmitted from the preset flag to the frame start delimiter flag, determining a first offset of the message transmitted in the target data and a second offset of the message transmitted in the first data;
[0029] The time sum of a first time corresponding to the first offset, a second time corresponding to the second offset, and a third time corresponding to the first number of clock signals is determined as the time difference between the preset flag and the frame start mark flag.
[0030] In a second aspect, the present application provides a device for obtaining a message timestamp, the device comprising:
[0031] A first determining module is configured to determine a target offset of a preset flag bit of a message on a physical medium connection side in target data transmitted by a target clock signal, wherein the target data includes data in the message, and the target offset is a difference between the number of bits of the preset flag bit and the first bit of the target data;
[0032] A second determining module is configured to determine a target timestamp corresponding to the preset flag bit according to the target clock signal and the target offset;
[0033] A third determining module is used to determine the time difference between the preset flag bit and the frame start mark bit of the message;
[0034] The acquisition module is used to acquire the actual timestamp of the frame start mark according to the target timestamp and the time difference.
[0035] In a third aspect, the present application provides a device for obtaining a message timestamp, including a memory and a processor, wherein:
[0036] The memory is used to store computer programs;
[0037] The processor is used to read the program in the memory and execute the steps of a method for obtaining a message timestamp provided in the first aspect above.
[0038] In a fourth aspect, the present application provides a computer-readable storage medium having a readable computer program stored thereon, which, when executed by a processor, implements the steps of a method for obtaining a message timestamp as provided in the first aspect above.
[0039] The present invention provides a method for obtaining a message timestamp, which has the following beneficial effects:
[0040] The present application obtains a timestamp for the preset flag bit on the PMA side by determining the offset of the preset flag bit in the target data on the PMA side in real time. It is understood that this offset will also change in real time when the Ethernet rate changes, thereby ensuring that the timestamp for the preset flag bit ultimately obtained on the PMA side is a real-time timestamp. This avoids the issue of timestamp jitter caused by Ethernet rate changes after timestamp generation in the prior art, thereby effectively improving the accuracy of the obtained timestamp for the preset flag bit. Since the PMA side is the line side, it is understood that obtaining the timestamp for the preset flag bit on the PMA side can further improve the accuracy of the obtained timestamp for the preset flag bit. This also effectively improves the accuracy of the obtained timestamp for the SFD (Start Frame Delimiter) flag by determining the time distance between the preset flag bit and the SFD flag bit and obtaining the timestamp for the SFD flag bit based on the timestamp and the time distance. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only part of the embodiments of the present application, rather than all the embodiments. For ordinary technicians in this field, without paying any creative work, other drawings obtained based on these drawings are all within the scope of protection of this application.
[0042] FIG1 is a flow chart of a method for obtaining a message timestamp according to an embodiment of the present application;
[0043] FIG2 is a flowchart of another method for obtaining a message timestamp provided in an embodiment of the present application;
[0044] FIG3 is a schematic structural diagram of a device for obtaining a message timestamp according to an embodiment of the present application;
[0045] FIG4 is a schematic structural diagram of a device for obtaining a message timestamp according to an embodiment of the present application;
[0046] FIG5 is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of this application more clearly understood, this application is further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0048] In order to make the description of the contents of this disclosure more detailed and complete, the following is an illustrative description of the implementation methods and specific examples of this application; however, this is not the only form of implementing or using the specific embodiments of this application. The implementation methods cover the features of multiple specific embodiments and the method steps and their sequence for constructing and operating these specific embodiments. However, other specific embodiments can also be used to achieve the same or equal functions and step sequences. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0049] It should be noted that the terms "first," "second," and the like in the specification and claims of this application and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, such that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0050] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" refers to two or more than two, and other quantifiers should be understood similarly. The preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments of the present application and the features in the embodiments may be combined with each other unless there is a conflict.
[0051] FIG1 is a flowchart of a method for obtaining a message timestamp provided in an embodiment of the present application, which includes the following steps.
[0052] Step S101 : determining a target offset of a preset flag of a message on the PMA side in target data transmitted by a target clock signal.
[0053] The target data includes the data in the message, and the target offset is the difference between the number of bits of the preset flag bit and the first bit of the target data.
[0054] Specifically, the process of transmitting a message may be a process of sending a message or a process of receiving a message. It is understandable that the target data is the data transmitted by the clock signal when the message is transmitted to the PMA side.
[0055] It should be noted that the target clock signal can be one of multiple clock signals when transmitting a message, and the clock signal can be generated by a clock generator; it should be further noted that the target data transmitted by the target clock signal can be transmitted through the data bus, and the number of bits of the target data transmitted by the data bus under the target clock signal can be determined according to the specific needs of the application. For example, the number of bits of the target data can be 128 bits, or 256 bits, etc.
[0056] It should be noted that the preset flag bit in this step can be any bit in the target data, and can be set according to the specific needs of the application. For example, the preset flag bit can be the first bit in the target data, the last bit in the target data, or the middle bit in the target data.
[0057] As a specific example, for example, if the preset flag bit is the 56th bit in the target data, it can be understood that the difference between the number of bits of the preset flag bit and the first bit of the target data is 55, and the target offset is 55.
[0058] Step S102: Determine a target timestamp corresponding to the preset flag according to the target clock signal and the target offset.
[0059] It is understood that the method for determining the target timestamp corresponding to the preset flag bit in this step based on the target clock signal and the target offset can be any feasible method. For example, the initial time at which the target clock signal starts can be determined, and the unit time corresponding to the unit target offset can be determined. In this case, the target timestamp corresponding to the preset flag bit is the sum of the initial time and the target offset multiplied by the unit time. The unit time corresponding to the unit target offset can be specifically set based on experience in the application.
[0060] Step S103: determining a time difference between the preset flag bit and the SFD flag bit of the message.
[0061] Specifically, the time difference between the preset flag and the SFD flag of the message can be determined in any manner. For example, the waveform of the data during message transmission can be output by an oscilloscope, and the phase difference between the preset flag and the SFD flag can be determined from the waveform. The phase difference can be converted into a time difference to obtain the time difference between the preset flag and the SFD flag.
[0062] Step S104: Acquire the actual timestamp of the SFD flag according to the target timestamp and the time difference.
[0063] It can be understood that the actual timestamp of the SFD flag is the sum of the target timestamp and the time difference.
[0064] In this way, by determining the offset of the preset flag bit in the target data on the PMA side in real time, the timestamp of the preset flag bit on the PMA side can be obtained. It can be understood that when the Ethernet rate changes, the offset will also change in real time, thereby ensuring that the timestamp of the preset flag bit ultimately obtained on the PMA side is a real-time timestamp. This avoids the problem of timestamp jitter caused by Ethernet rate changes after timestamp issuance in the prior art, thereby effectively improving the accuracy of the obtained timestamp of the preset flag bit. The PMA side is also the line side, so when the timestamp of the preset flag bit is obtained on the PMA side, the accuracy of the obtained timestamp of the preset flag bit can be further improved. In this way, when the time distance between the preset flag bit and the SFD flag bit is determined, and the timestamp of the SFD flag bit is obtained based on the timestamp of the preset flag bit and the time distance, the accuracy of the obtained timestamp of the SFD flag bit can also be effectively improved.
[0065] In an optional implementation, when sending a message, the preset flag bit is the SFD flag bit.
[0066] It should be noted that when sending a message, the SFD flag of the message can be found on the PMA side. Therefore, in order to save the process and quickly obtain the actual timestamp corresponding to the SFD flag, the preset flag can be set to the SFD flag.
[0067] It can be understood that when the preset flag is the SFD flag, the time difference between the preset flag and the SFD flag is 0, that is, the target timestamp of the preset flag is the actual timestamp of the SFD flag.
[0068] In an optional implementation, determining a target offset of a preset flag bit of a message on the PMA side in target data transmitted by the target clock signal includes:
[0069] When receiving a message, for a message without alignment characters, a target offset of a preset flag of the message on the PMA side is determined in target data transmitted by a target clock signal.
[0070] The preset flag bit is a fixed flag bit that is set periodically.
[0071] It can be understood that the so-called periodicity of the preset flag bit is set with respect to the clock signal during message transmission.
[0072] It should be noted that, for example, a message without an AM (alignment) character may be a message transmitted under 10G bit Ethernet, and a message with an AM character may be a message transmitted under 40G bit, 50G bit, and 100G bit Ethernet.
[0073] Specifically, when the preset flag is set periodically, the set period can be the time corresponding to any number of clock signals. For example, the period can be the time corresponding to one clock signal, that is, a preset flag is set for each clock signal. For example, the period can be the time corresponding to 100 clock signals, etc.
[0074] It should be noted that the target clock signal in this implementation is the clock signal corresponding to the target data at the preset flag bit closest to the PMA side when transmitting the message.
[0075] It can be understood that the preset flag bit is a fixed flag bit, which means that the preset flag bit is a fixed bit in the data sent under a clock signal. The number of bits of the fixed bit in the data can be set according to specific needs and is not specifically limited here.
[0076] It should be noted that when receiving a message, a series of pre-processing is required when looking for the SFD flag, which may result in the SFD flag being missed on the PMA side. For this purpose, a flag can be preset. Since the preset flag is a fixed flag that is set periodically, the preset flag can be found on the PMA side, and then a more accurate timestamp of the preset flag can be determined on the PMA side. In this way, after finding the SFD flag and determining the time distance between the SFD flag and the preset flag, a more accurate timestamp of the SFD flag can be obtained based on the more accurate timestamp of the preset flag.
[0077] In an optional implementation, determining a target offset of a preset flag bit of a message on the PMA side in target data transmitted by the target clock signal includes:
[0078] When receiving a message, for a message containing an AM character, a target offset of a preset flag of the message on the PMA side is determined in target data transmitted by a target clock signal.
[0079] The preset flag bit is a position N bits away from the flag bit of the AM character.
[0080] It should be noted that N in this implementation is a positive integer, and the specific value of N in this implementation can be set according to the specific needs of the application. For example, N can be 1 or N can be 2. When N is 1, the preset flag bit can be the last bit of the AM character.
[0081] It should be noted that the AM character is set in the message for alignment, and this character is usually set at the PCS layer. When the message is transmitted to the MAC layer, this character may be discarded. Therefore, in this implementation method, the preset flag is set at a position N bits away from the AM character. On the one hand, it can ensure that the preset flag will not be discarded. On the other hand, the preset flag can be set with the help of the AM character of the message itself. Compared with the need to periodically set the preset flag for messages without AM characters, it effectively saves resources for setting the preset flag.
[0082] In an optional implementation, after obtaining the actual timestamp of the SFD flag, the method further includes:
[0083] Calculate a first time difference between a first timestamp of a target message sent by the master device and a second timestamp of the target message received by the slave device, wherein the first timestamp and the second timestamp are both actual timestamps of the SFD flag bit;
[0084] Determining a second time difference between the first time difference and a preset average path delay;
[0085] Determining the second time difference as the actual clock delay between the master device and the slave device;
[0086] The clock of the master device is used as a reference clock, and the clock of the slave device is corrected according to the actual clock delay.
[0087] It should be noted that the first time difference is a value obtained by subtracting the first timestamp from the second timestamp; the second time difference is a value obtained by subtracting the average path delay from the first time difference.
[0088] It should be noted that the method for obtaining the first timestamp corresponding to the target message sent by the master device and the method for obtaining the second timestamp of the target message received by the slave device can refer to the method for obtaining the actual timestamp of the SFD flag bit of the message in the above time method.
[0089] It should be noted that the average path delay in this implementation can be calculated as follows: MPD is the average of the difference between t1 and t2 and the difference between t4 and t3, where t1 is the time when the message is sent from the master device, t2 is the time when the message is received by the slave device, t3 is the time when the delay request message is sent from the slave device, and t4 is the time when the delay request message is received by the master device. It is understood that the above timestamps t1-t4 can all correspond to the timestamps of the SFD flag. It is understood that the message used to calculate the average path delay can be consistent with the target message in this implementation, or it can be inconsistent with the target message in this implementation. The specific setting can be based on the specific needs of the application and is not specifically limited here.
[0090] It should be noted that the corresponding timestamp in the above implementation is obtained based on the clock signal set in this implementation. In specific applications, if it is necessary to make the clocks of the master device and the slave device based on the global clock, the correspondence between the clock signal and the global clock (such as Beijing time) can be determined. Then, when determining the timestamp under the clock signal, the timestamp can be converted into a standard timestamp under the global clock based on the correspondence between the clock signal and the global clock.
[0091] In an optional implementation, determining the target timestamp corresponding to the preset flag bit according to the target clock signal and the target offset includes:
[0092] Determine a third timestamp of the target clock signal corresponding to the first bit of the target data;
[0093] A target timestamp corresponding to the preset flag bit is determined according to the target offset and the third timestamp.
[0094] It can be understood that the third timestamp of the target clock signal corresponding to the first bit of the target data is the start time of the target clock signal.
[0095] It can be understood that the ratio of the time corresponding to the target clock signal to the number of target data bits under the target clock signal is the unit time for the data bus to transmit one bit of data, and then the time distance corresponding to the target offset can be obtained by multiplying the target offset by the unit time, and then the time distance is added to the third timestamp to obtain the target timestamp corresponding to the preset flag bit.
[0096] In an optional implementation, as shown in FIG2 , which is a flowchart of another method for obtaining a message timestamp according to an embodiment of the present application, step S103 includes:
[0097] Step S1031, determining first data where the SFD flag of the message is located and a first clock signal for transmitting the first data;
[0098] Step S1032, determining a first number of clock signals that differ between the target clock signal and the first clock signal;
[0099] Step S1033, when the message is transmitted from the preset flag bit to the SFD flag bit, determining a first offset of the message transmitted in the target data and a second offset of the message transmitted in the first data;
[0100] Step S1034: Determine the time difference between the preset flag and the SFD flag as the sum of the first time corresponding to the first offset, the second time corresponding to the second offset, and the third time corresponding to the first number of clock signals.
[0101] It should be noted that, during the actual transmission of the message, the SFD flag may be before or after the preset flag in the time sequence. When the SFD flag is before the preset flag, the first offset is the difference between the number of bits of the preset flag in the target data and the first bit of the target data, and the second offset is the difference between the number of bits of the SFD flag in the first data and the last bit of the first data; when the SFD flag is after the preset flag, the first offset is the difference between the number of bits of the preset flag in the target data and the last bit of the target data, and the second offset is the difference between the number of bits of the SFD flag in the first data and the first bit of the first data.
[0102] It should be noted that the method for determining the first number of clock signals that differ between the target clock signal and the first clock signal can be any method. For example, the clock signal difference between the target clock signal and the first clock signal can be counted by a counter to obtain the first number of clock signals corresponding to the difference. For another example, if the preset flag is set periodically, the number of clock signals corresponding to one cycle can be first calculated, and then the time of the corresponding clock signal within one cycle can be determined. The number of preset flags passed from the preset flag to the SFD flag can be further determined. This number multiplied by the above time is the time corresponding to the first number of clock signals. Furthermore, the unit time corresponding to each clock signal can be pre-set. Therefore, the third time corresponding to the first number of clock signals is the product of the unit time corresponding to the clock signal and the first number.
[0103] It should be noted that the method for obtaining the first time corresponding to the first offset and the second time corresponding to the second offset can refer to the description of determining the time corresponding to the target offset in the above implementation method, and will not be repeated here.
[0104] Based on the above-mentioned method for obtaining message timestamps, an embodiment of the present application provides a device for obtaining message timestamps, as shown in FIG3 , which includes:
[0105] A first determining module 310 is configured to determine a target offset of a preset flag bit of a message on the PMA side in target data transmitted by a target clock signal, wherein the target data includes data in the message, and the target offset is a difference between the number of bits of the preset flag bit and the first bit of the target data;
[0106] A second determining module 320 is configured to determine a target timestamp corresponding to the preset flag bit according to the target clock signal and the target offset;
[0107] A third determining module 330 is configured to determine a time difference between the preset flag bit and the SFD flag bit of the message;
[0108] The acquisition module 340 is configured to acquire the actual timestamp of the SFD flag according to the target timestamp and the time difference.
[0109] For other details about how the modules in the above-mentioned device for obtaining message timestamps implement the above-mentioned technical solution, please refer to the description of the method for obtaining message timestamps provided in the above-mentioned embodiment of the invention, which will not be repeated here.
[0110] Based on the above-mentioned method for obtaining message timestamps, as shown in FIG4 , an embodiment of the present application further provides a schematic structural diagram of a device for obtaining message timestamps. The device includes a processor 41 and a memory 42 coupled to the processor 41. The memory 42 stores a computer program. When the computer program is executed by the processor 41, the processor 41 performs the steps of the method for obtaining message timestamps in the above-mentioned embodiment.
[0111] For other details about how the processor 41 in the above-mentioned message timestamp acquisition device implements the above-mentioned technical solution, please refer to the description of the message timestamp acquisition method provided in the above-mentioned invention embodiment, which will not be repeated here.
[0112] Among them, the processor 41 can also be called a central processing unit (CPU), and the processor 41 may be an integrated circuit chip with signal processing capabilities; the processor 41 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, among which the general-purpose processor can be a microprocessor or the processor 41 can also be any conventional processor, etc.
[0113] As shown in FIG5 , an embodiment of the present application further provides a schematic diagram of the structure of a computer-readable storage medium, on which a readable computer program 51 is stored; wherein the computer program 51 can be stored in the above-mentioned storage medium in the form of a software product, including a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk, a read-only memory (ROM), a random access memory (RAM), and other media that can store program code, or a terminal device such as a computer, server, mobile phone, or tablet.
[0114] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0115] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules may be selected to achieve the purpose of the present embodiment according to actual needs.
[0116] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing module, or each module may exist physically separately, or two or more modules may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may be stored in a computer-readable storage medium.
[0117] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0118] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a server or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium, or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0119] The above is a detailed introduction to the technical solution provided by the present application. Specific examples are used in the present application to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
[0120] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, optical storage, etc.) that contain computer-usable program code.
[0121] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each flow and / or box in the flow chart and / or block diagram, as well as the combination of the flow chart and / or box in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more flow charts and / or one or more boxes in the block diagram.
[0122] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0123] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0124] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A method for obtaining a message timestamp, characterized in that, Including: In the target data transmitted by the target clock signal, determine the target offset of the preset flag bit of the message on the physical medium connection side, where the target data includes the data in the message, and the target offset is the bit difference between the preset flag bit and the first bit of the target data; According to the target clock signal and the target offset, determine the target timestamp corresponding to the preset flag bit; Determine the time gap between the preset flag bit and the frame start flag bit of the message; According to the target timestamp and the time gap, obtain the actual timestamp of the frame start flag bit.
2. The method for obtaining the message timestamp according to claim 1, wherein When sending a message, the preset flag bit is the frame start flag bit.
3. The method for obtaining the message timestamp according to claim 1, wherein The step of determining the target offset of the preset flag bit of the message on the physical medium connection side in the target data transmitted by the target clock signal includes: When receiving a message, for a message without alignment characters, determine the target offset of the preset flag bit of the message on the physical medium connection side in the target data transmitted by the target clock signal, where the preset flag bit is a fixed flag bit set periodically.
4. The method for obtaining the message timestamp according to claim 1, wherein The step of determining the target offset of the preset flag bit of the message on the physical medium connection side in the target data transmitted by the target clock signal includes: When receiving a message, for a message with alignment characters, determine the target offset of the preset flag bit of the message on the physical medium connection side in the target data transmitted by the target clock signal, where the preset flag bit is a position N bits away from the flag bit of the alignment character.
5. The method for obtaining the message timestamp according to claim 1, wherein After obtaining the actual timestamp of the frame start flag bit, it further includes: Calculate the first time difference between the first timestamp of the target message sent by the master device and the second timestamp of the target message received by the slave device, where both the first timestamp and the second timestamp are the actual timestamps of the frame start flag bit; Determine the second time difference between the first time difference and the preset average path delay; Determine the second time difference as the actual clock delay between the master device and the slave device; Taking the clock of the master device as the reference clock, correct the clock of the slave device according to the actual clock delay.
6. The method for obtaining the message timestamp according to claim 1, wherein The step of determining the target timestamp corresponding to the preset flag bit according to the target clock signal and the target offset includes: Determine the third timestamp of the target clock signal corresponding to the first bit of the target data; According to the target offset and the third timestamp, determine the target timestamp corresponding to the preset flag bit.
7. The method for obtaining the message timestamp according to claim 1, characterized in that The step of determining the time gap between the preset flag bit and the frame start flag bit of the message includes: Determine the first data where the frame start flag bit of the message is located and the first clock signal for transmitting the first data; Determine the first number of clock signals between the target clock signal and the first clock signal; When the message is transmitted from the preset flag bit to the frame start flag bit, determine the first offset of the message transmitted in the target data and the second offset of the message transmitted in the first data; Determine the time sum of the first time corresponding to the first offset, the second time corresponding to the second offset, and the third time corresponding to the first quantity of clock signals as the time difference between the preset flag bit and the frame start flag bit.
8. An apparatus for obtaining a message timestamp, characterized in that, Comprising: A first determination module, configured to determine a target offset of a preset flag bit of a message on the physical medium connection side in target data transmitted by a target clock signal, where the target data includes data in the message, and the target offset is the bit difference between the preset flag bit and the first bit of the target data; A second determination module, configured to determine a target timestamp corresponding to the preset flag bit according to the target clock signal and the target offset; A third determination module, configured to determine the time difference between the preset flag bit and the frame start flag bit of the message; An acquisition module, configured to acquire an actual timestamp of the frame start flag bit according to the target timestamp and the time difference.
9. A device for obtaining a message timestamp, characterized in that, Comprising a memory and a processor, wherein: The memory is used for storing a computer program; The processor is configured to read the computer program in the memory and execute the steps of any of the message timestamp acquisition methods as claimed in claims 1-7.
10. A computer-readable storage medium, characterized in that, Stored thereon is a readable computer program, which when executed by a processor implements the steps of any of the message timestamp acquisition methods as claimed in claims 1-7.
Citation Information
Patent Citations
Method for determining timestamp, communication device, and communication system
CN109687927A
Ethernet time synchronization method and device
CN112910588A
Message timestamp acquisition method and device, equipment and storage medium
CN117879747A
Nanosecond accuracy under precision time protocol for ethernet by using high accuracy timestamp assist device
US20180191802A1
Synchronization method and device
WO2021077289A1
Cited By
Low-voltage transformer area electric energy meter timing method and system based on voltage transition event
CN121325086A