Method and apparatus for improving ptp time acquisition efficiency
By obtaining the first timestamp of the PTP message on the write side of MacTxBuff and compensating for it, the problem of complex logic design in the 1-step mode of PTP messages is solved, and the execution efficiency and time synchronization accuracy are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SUZHOU CENTEC COMM CO LTD
- Filing Date
- 2021-12-24
- Publication Date
- 2026-04-10
AI Technical Summary
The logic design of PTP messages in 1-step mode is complex and the execution efficiency is not high.
The first timestamp of the PTP packet is obtained on the write side of MacTxBuff, and the compensation value is calculated to perform 1-step editing and CRC calculation, simplifying the processing of one packet within one clock cycle.
It reduces design complexity, improves design reliability and execution efficiency, reduces time accuracy jitter, and achieves high-precision time synchronization.
Smart Images

Figure CN116346271B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to network communication technology, in particular to a method and device for improving PTP time acquisition efficiency. BACKGROUND
[0002] Ethernet has been widely applied and rapidly developed for a long time. From 10M / 100M / 1000Mbps to 10Gbps, 40Gbps, 100Gbps, and even 25Gbps / 50Gbps / 200Gbps / 400Gbps. While the network rate is rapidly developing, the 5G network is also in the golden period of development. Low latency is a very important application of 5G network, such as vehicle networking, unmanned driving, intelligent manufacturing, and unmanned delivery business, which need to have ultra-low latency and high reliability.
[0003] To ensure the low latency of 5G network, it is required that the network devices need to be clock synchronized. Precision Time Protocol (PTP) is a time synchronization protocol, which is used for high-precision time synchronization between devices. In the PTP protocol, there are 1-step and 2-step methods. The 1-step method needs to put the message sending time of the device into the Sync message for sending. This requires that when the Sync message arrives at the MAC sending end, the timestamp of the message sending is obtained and the timestamp is replaced in the corresponding position of the message. The accuracy of the timestamp acquisition will determine the time precision of PTP 1-step.
[0004] As shown in Figure 1 , the data interface between the module MacTx and the upper system has a bit width of 128 bytes. For a message whose length is less than or equal to 128 bytes, one clock cycle can complete the sending. When the message length is greater than 128 bytes, it needs to be sent in multiple clock cycles, 128 bytes of data are sent in each clock cycle, and the last clock cycle may have a situation that the number of sent bytes is less than 128. Even in this case, the remaining number of bytes of the clock cycle is wasted, and the next message will not be filled into these remaining bytes. As can be seen, the data interface between the module MacTx and the upper system will send only one data message in one clock cycle.
[0005] And as Figure 2As shown, the 128-byte output interface of MiiTx can send multiple data packets in one clock cycle. The 1-step editing of PTP packet is to edit the start time of sending the PTP packet on the MiiTx output interface (i.e. the sending time of the preamble of the packet) to the specified position of the packet. It can be seen that the MiiTx module acquires the sending time stamp of the PTP packet and performs 1-step editing to obtain relatively high time accuracy, but there is a relatively complex problem. According to Figure 2 It can be seen that multiple data packets can be sent on the MiiTx output interface in one clock cycle, and if these data packets are all PTP packets and also need to be edited by 1-step, it means that multiple packets need to be edited by 1-step in one clock cycle. After the 1-step editing of the packet, the CRC of the packet needs to be recalculated. Therefore, the CRC of multiple packets needs to be calculated in one clock cycle, which undoubtedly makes the logic design extremely complex and affects the execution efficiency. SUMMARY
[0006] The technical problem to be solved by the embodiments of the present application is how to solve the problem of complex logic design and low execution efficiency of PTP packet in 1-step mode in the prior art.
[0007] In order to solve the above technical problems, the embodiments of the present application provide a method for improving PTP time acquisition efficiency, applied to PTP 1-step mode, comprising: acquiring a first time stamp when a PTP packet is written into MacTxBuff on the write side of MacTxBuff; calculating a compensation value of a second time stamp of the sending time stamp in 1-step according to the depth of the packet stored in MacTxBuff; compensating the first time stamp according to the compensation value and editing it to the specified position of the second time stamp in the PTP packet to complete the compensation of the sending time stamp in 1-step.
[0008] In the above method for improving PTP time acquisition efficiency, the calculation of the compensation value of the second time stamp of the sending time stamp in 1-step according to the depth of the packet stored in MacTxBuff comprises: calculating the number of valid bytes contained in MacTxBuff according to the depth of the information FIFO in the information FIFO queue, the number of EOPs and the number of valid bytes per EOP cycle; calculating the total number of occupied bytes of the preamble and the packet gap according to the number of EOPs; and calculating the compensation value of the second time stamp by dividing the sum of the number of valid bytes contained in MacTxBuff and the total number of occupied bytes of the preamble and the packet gap by the port rate.
[0009] In the method for improving PTP time acquisition efficiency, the calculating the compensation value of the second time stamp of the sending time stamp in the 1-step according to the depth of the message stored in the MacTxBuff comprises: presetting a first list; the first list pre-stores the sending time of the non-EOP byte number in the MacTxBuff under different port rates; presetting a second list; the second list pre-stores the sending time of the EOP valid byte number under different port rates; presetting a third list; the third list pre-stores the sending time of the corresponding preamble and packet gap under different port rates when the number of EOPs is different; according to the number of the current EOP in the information FIFO queue, searching the sending time corresponding to the current port rate in the first list, the second list and the third list and accumulating, so as to calculate the compensation value of the second time stamp of the sending time stamp in the 1-step.
[0010] In the method for improving PTP time acquisition efficiency, the EOP valid byte number is range-divided, and the corresponding compensation granularity is pre-configured for each range; the sending time of the compensation granularity under different port rates is calculated; and the second list stores each range of the EOP valid byte number and the corresponding sending time.
[0011] In the method for improving PTP time acquisition efficiency, the compensation granularity is the median value of the corresponding range.
[0012] In order to solve the above technical problems, the embodiment of the application further provides a device for improving PTP time acquisition efficiency, which is applied to PTP 1-step mode and comprises: an acquisition unit, configured to acquire the first time stamp when a PTP message is written into the MacTxBuff at the writing side of the MacTxBuff; a calculation unit, configured to calculate the compensation value of the second time stamp of the sending time stamp in the 1-step according to the depth of the message stored in the MacTxBuff; and a processing unit, configured to compensate the first time stamp according to the compensation value and edit the second time stamp to the specified position in the PTP message, so as to complete the compensation of the sending time stamp in the 1-step.
[0013] In the device for improving PTP time acquisition efficiency, the calculation unit is configured to: calculate the valid byte number contained in the MacTxBuff according to the depth of the information FIFO, the number of EOPs and the valid byte number of each EOP period in the information FIFO queue; calculate the total occupied byte number of the preamble and the packet gap according to the number of EOPs; and calculate the compensation value of the second time stamp by dividing the sum of the valid byte number contained in the MacTxBuff and the total occupied byte number of the preamble and the packet gap by the port rate.
[0014] The device for improving PTP time acquisition efficiency comprises a calculation unit, which is configured by CPU to pre-store a first list of transmission time of non-EOP byte number in MacTxBuff at different port rates, a second list of transmission time of EOP period effective byte number at different port rates, a third list of transmission time of preamble and packet gap corresponding to different EOP numbers at different port rates, and find transmission time corresponding to current port rate in the first list, the second list and the third list according to the number of current EOP in the information FIFO queue and accumulate to calculate the compensation value of the second time stamp of the transmission time stamp in 1-step.
[0015] The device for improving PTP time acquisition efficiency comprises a calculation unit, which is configured by CPU to pre-store a first list of transmission time of non-EOP byte number in MacTxBuff at different port rates, a second list of transmission time of EOP period effective byte number at different port rates, a third list of transmission time of preamble and packet gap corresponding to different EOP numbers at different port rates, and find transmission time corresponding to current port rate in the first list, the second list and the third list according to the number of current EOP in the information FIFO queue and accumulate to calculate the compensation value of the second time stamp of the transmission time stamp in 1-step.
[0016] The device for improving PTP time acquisition efficiency comprises a calculation unit, which is configured by CPU to pre-store a first list of transmission time of non-EOP byte number in MacTxBuff at different port rates, a second list of transmission time of EOP period effective byte number at different port rates, a third list of transmission time of preamble and packet gap corresponding to different EOP numbers at different port rates, and find transmission time corresponding to current port rate in the first list, the second list and the third list according to the number of current EOP in the information FIFO queue and accumulate to calculate the compensation value of the second time stamp of the transmission time stamp in 1-step.
[0017] The device for improving PTP time acquisition efficiency comprises a calculation unit, which is configured by CPU to pre-store a first list of transmission time of non-EOP byte number in MacTxBuff at different port rates, a second list of transmission time of EOP period effective byte number at different port rates, a third list of transmission time of preamble and packet gap corresponding to different EOP numbers at different port rates, and find transmission time corresponding to current port rate in the first list, the second list and the third list according to the number of current EOP in the information FIFO queue and accumulate to calculate the compensation value of the second time stamp of the transmission time stamp in 1-step. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 is a schematic diagram of the architecture of the PTP 1-step transmission direction of the Ethernet interface;
[0019] Figure 2 is a schematic diagram of the structure of the data frame in the MiiTx output direction. DETAILED DESCRIPTION
[0020] In the prior art, Figure 2As shown, the 128-byte output interface of MiiTx can send multiple data packets in one clock cycle. The 1-step editing of the PTP packet is to edit the start time of sending the PTP packet on the MiiTx output interface (i.e. the sending time of the preamble of the packet) to the specified position of the packet. It can be seen that the MiiTx module acquires the sending time stamp of the PTP packet and performs 1-step editing to obtain relatively high time accuracy, but there is a relatively complex problem at the same time. According to the Figure 2 It can be seen that multiple data packets can be sent on the MiiTx output interface in one clock cycle, and if these data packets are all PTP packets and also need to be edited by 1-step, it means that multiple packets need to be edited by 1-step in one clock cycle. After editing the packet by 1-step, the CRC of the packet also needs to be recalculated. Therefore, the CRC of multiple packets also needs to be calculated in one clock cycle, which undoubtedly makes the logic design extremely complex and affects the execution efficiency.
[0021] In view of the problems in the prior art, the embodiment of the present application acquires the time stamp in the write side of MacTxBuff (i.e. in MacTx) and edits the PTP packet by 1-step and calculates the CRC. Since 1-step editing and CRC calculation are performed at this place, only one packet needs to be edited by 1-step and calculated by CRC in one clock cycle, which greatly reduces the design complexity and improves the design reliability. As for the error between the PTP sending time stamp and the time stamp when the PTP packet is written into MacTxBuff, the compensation value of the PTP sending time stamp can be calculated according to the depth of the existing packet in MacTxBuff, so as to complete the editing of the sending time stamp in 1-step.
[0022] In order to make the above-mentioned purposes, characteristics and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0023] Embodiment 1
[0024] The method for improving the PTP time acquisition efficiency of the embodiment of the present application can be applied in the PTP 1-step mode, and specifically comprises:
[0025] Step S101, acquiring the first time stamp when the PTP packet is written into MacTxBuff in the write side of MacTxBuff;
[0026] Compared with the prior art of acquiring the sending time stamp of the PTP packet in the MiiTx module and then performing 1-step editing, in order to reduce the complexity of design and improve the reliability of design, the embodiment of the application adopts the mode of acquiring the first time stamp when the PTP packet is written into the MacTxBuff at the write side of the MacTxBuff, and performing 1-step editing and CRC calculation on the PTP packet.
[0027] However, the first time stamp acquired at this time is the time stamp when the PTP packet is written into the MacTxBuff, and is not the time stamp of the PTP packet on the MiiTx output interface. The two may not be the same, and the difference between the two is the time required for the packet already contained in the MacTxBuff to be sent out when the PTP packet is written into the MacTxBuff.
[0028] In step S102, the number of valid bytes contained in the MacTxBuff is calculated according to the depth of the information FIFO, the number of EOPs and the number of valid bytes in each EOP period.
[0029] When the packet is written into the MacTxBuff at each clock period, the related information of the packet is recorded at the same time, and the information is stored into the information FIFO. The information includes the start of packet (SOP), the end of packet (EOP) and the number of valid bytes. In a clock period that is not an EOP, the number of valid bytes is 128 bytes, which is equal to the bit width of the output interface of the MacTxBuff, and only in the current clock period of the EOP, the number of valid bytes is indefinite. For example, a data packet with a length of 257 bytes is written into the MacTxBuff for 3 clock periods, 128 bytes of SOP data are written into the MacTxBuff in the first clock period, 128 bytes of intermediate data are written into the MacTxBuff in the second clock period, and 1 byte of EOP data is written into the MacTxBuff in the third clock period. In this way, when the PTP packet is written into the MacTxBuff, the number of valid bytes already contained in the MacTxBuff when the PTP packet is written into the MacTxBuff can be calculated through the depth of the information FIFO, the number of EOPs and the number of valid bytes in each EOP clock period.
[0030] In step S103, the total number of occupied bytes of the preamble and the packet gap is calculated according to the number of EOPs.
[0031] It should be noted that 8 bytes of preamble and 12 bytes of packet gap are additionally added when each packet is sent out at the MiiTx interface. Therefore, the total number of occupied bytes of the preamble and the packet gap is 20 bytes multiplied by the number of EOPs.
[0032] Step S104, the number of valid bytes contained in the MacTxBuff is divided by the port rate to calculate the compensation value of the second timestamp.
[0033] Through the above steps S102 and S103, the final number of bytes to be compensated in this embodiment is the number of valid bytes contained in the MacTxBuff, plus 20 times the number of EOPs (the total number of bytes of the preamble and the packet gap). These byte numbers can be calculated at a certain fixed port rate.
[0034] Taking the port rate of 100Gbps as an example, assuming that the information FIFO depth is 10 when the PTP packet is written into the MacTxBuff, and the number of EOPs is 3, and the number of valid bytes corresponding to each EOP is 10 bytes, 37 bytes and 100 bytes respectively, then when the PTP packet is written into the MacTxBuff, the number of valid bytes contained in the MacTxBuff is: 128*(10-3)+10+37+100=1043 (bytes). The total number of bytes to be compensated is also added to the 3 preambles and packet gaps, i.e. the total number of bytes to be compensated is 1043+60=1103 bytes.
[0035] And 1103 bytes at the port rate of 100Gbps (100bit / ns) takes 1103*8bit÷(100bit / ns)=88.24ns to send. As long as the 88.24ns is compensated to the obtained first timestamp when performing 1-step editing, and edited to the specified position of the PTP packet, the timestamp compensation can be completed, thereby eliminating the time precision jitter caused by the fixed depth of the MacTxBuff, and achieving high time precision.
[0036] Embodiment Two
[0037] Step S201, obtaining the first timestamp when the PTP packet is written into the MacTxBuff at the write side of the MacTxBuff;
[0038] The step S201 of this embodiment can refer to the step S101 of the embodiment one, and the number will not be repeated.
[0039] Step S202, preconfiguring three lists; the first list pre-stores the transmission time of the non-EOP byte number in the MacTxBuff at different port rates; the second list pre-stores the transmission time of the valid byte number of the EOP period at different port rates; and the third list pre-stores the transmission time of the preamble and the packet gap at different port rates when the number of EOPs is different;
[0040] In the method of calculating compensation time in the first embodiment, both multiplication and division are involved. But from the PTP message 1-step editing to writing into MacTxBuff, there is only 2 clock cycles at most, which requires the above-mentioned compensation time to be completed within 2 clock cycles. The multiplication and division above-mentioned to be completed within 2 clock cycles have a very big risk to the timing of logic design, and also occupy more logic resources. Moreover, different port rates, the coefficients of multiplication and division are also different, need to have multiple sets of multiplication and division logic to proceed, and then select one result through the port rate, the design logic is very complex.
[0041] In the embodiment, the compensation time is configured by CPU to achieve unified support for different port rates. Specifically, three lists are configured in advance, and each list is configured with the compensation time of MacTxBuff depth, the compensation time of EOP byte number, and the compensation time of preamble and interframe space, respectively, which are recorded as the first list, the second list, and the third list. The conditions of the three lists will be described below:
[0042] (1) The first list
[0043] The depth of the first list is the same as the depth of MacTxBuff. Each entry indicates the time required for sending at different port rates when the MacTxBuff depth minus the number of EOPs is equal to the value. Still taking the example in step S104 of the first embodiment as an example, the depth of the information FIFO is 10, and the number of EOPs is 3, so the MacTxBuff depth minus the number of EOPs is equal to 7. At this time, the CPU needs to send 128*7=896 bytes to the entry 7 of the first list.
[0044] Further, the CPU will configure different values according to different port rates and write them into the first list. For example, if the port rate is 100Gbps, 896*8bit÷100bit / ns=71.68ns≈72ns needs to be configured into entry 7; if the port rate is 25Gbps, 896*8bit÷25bit / ns=286.72ns≈287ns needs to be configured into entry 7. Other port rates use the same configuration method, which is not described here.
[0045] In this way, if it is found through the information FIFO queue that the depth of the information FIFO is 10 at this time, and the number of EOPs is 3, then the MacTxBuff depth minus the number of EOPs is equal to 7, and the sending time of non-EOP bytes in MacTxBuff, such as SOP and intermediate data, can be obtained through index entry 7 corresponding to the port rate.
[0046] (2) Second List
[0047] The depth of the second list needs to be set as 16 times the depth of MacTxBuff, because the second list is configured to compensate the time of EOP byte number, so the EOP byte number is used to index the second list to get the compensation time of EOP byte number.
[0048] The maximum EOP byte number is 128 times the depth of MacTxBuff, that is, there are 128 bytes of EOP data in each entry of MacTxBuff. If the depth of the second list is set according to 128 times the depth of MacTxBuff, the depth of the second list will be very large. Therefore, the embodiment adopts the method of expanding granularity to reduce the depth of the second list, that is, the EOP valid byte number is equally divided, and the corresponding compensation granularity is pre-configured for each equally divided range, then the transmission time of the compensation granularity under different port rates is calculated, and the equally divided range of the EOP valid byte number and the corresponding transmission time are stored in the second list. The compensation granularity can be configured as the median value of the corresponding equally divided range, and if the number of elements in the equally divided range is even, the compensation granularity is the larger one of the two middle elements.
[0049] For example, the EOP byte number is equally divided by 8 bytes (including 0 bytes), so entry 0 is configured with a compensation time of 4 bytes, entry 1 is configured with a compensation time of 12 bytes, entry 2 is configured with a compensation time of 20 bytes, and the subsequent entries are configured in the same way. In this way, when the byte number of an EOP is 0-7, the value of entry 0 is read as its compensation time; when the EOP byte number is 8-15, the value of entry 1 is read as its compensation time, and the subsequent EOP byte numbers are sequentially divided. It can be seen that although the second list is not indexed one by one according to the byte number of the EOP, there will be at most a 4-byte time error, which is negligible compared to reducing the depth of the second list by 8 times, and will not have a great impact.
[0050] (3) Third List
[0051] The depth of the third list is consistent with the depth of the MacTxBuff, and each entry indicates the additional preamble and interframe space and the time required for transmission at different port rates. Still taking the above example as an illustration, the number of EOPs is 3, and the time required for the CPU to transmit 20*3=60 bytes is configured into entry 3 of the third list. Meanwhile, the CPU configures different values into entry 3 according to different port rates. For example, if the port rate is 100 Gbps, 60*8bit÷100bit / ns=4.8ns≈5ns is configured into entry 3; if the port rate is 25 Gbps, 60*8bit÷25bit / ns=19.2ns≈19ns is configured into entry 3, and other port rates are configured in the same way.
[0052] In summary, the embodiment uses the CPU to configure the time compensation, thereby achieving unified support for different port rates, simplifying the complex multiplication and division operations, and greatly improving the flexibility of time compensation.
[0053] Embodiment Three
[0054] To solve the problems in the prior art, the embodiment also discloses a device for improving PTP time acquisition efficiency, which is applied to PTP 1-step mode and comprises:
[0055] The acquisition unit is configured to acquire a first timestamp when a PTP message is written into the MacTxBuff at the write side of the MacTxBuff; the calculation unit is configured to calculate a compensation value of a second timestamp of a sending timestamp in 1-step according to the depth of the message in the MacTxBuff; and the processing unit is configured to compensate the first timestamp according to the compensation value and edit the second timestamp into a specified position of the PTP message, thereby completing the compensation of the sending timestamp in 1-step.
[0056] In specific implementation, the calculation unit calculates the number of valid bytes contained in the MacTxBuff according to the depth of the information FIFO, the number of EOPs, and the number of valid bytes per EOP period; calculates the total number of occupied bytes of the preamble and the interframe space according to the number of EOPs; and calculates the compensation value of the second timestamp by dividing the sum of the number of valid bytes contained in the MacTxBuff and the total number of occupied bytes of the preamble and the interframe space by the port rate.
[0057] Those skilled in the art can understand that the device for improving PTP time acquisition efficiency in the embodiment and the method for improving PTP time acquisition efficiency in Embodiment One are based on the same inventive concept, and therefore the content related to the relevant embodiments can be referred to the corresponding content in the foregoing description, which will not be described herein again.
[0058] Embodiment Four
[0059] To solve the problems in the prior art, the embodiment further discloses a device for improving PTP time acquisition efficiency, which is applied to PTP 1-step mode and comprises the following steps of:
[0060] a obtaining unit, configured to obtain a first timestamp when a PTP message is written into MacTxBuff on a write side of the MacTxBuff; a calculating unit, configured to calculate a compensation value of a second timestamp of a sending timestamp in 1-step according to a depth of the message stored in the MacTxBuff; and a processing unit, configured to compensate the first timestamp according to the compensation value and edit the second timestamp into a specified position of the PTP message, so as to complete compensation of the sending timestamp in 1-step.
[0061] In a specific implementation, the calculating unit is configured to preconfigure, by a CPU, a first list, the first list pre-storing sending time of a non-EOP byte number in the MacTxBuff under different port rates, a second list, the second list pre-storing sending time of an effective byte number of an EOP cycle under different port rates, a third list, the third list pre-storing sending time of a preamble and a packet gap corresponding to different numbers of EOPs under different port rates, and
[0062] According to the number of the current EOPs in the information FIFO queue, the first list, the second list and the third list are searched for sending time corresponding to the current port rate and accumulated, so as to calculate the compensation value of the second timestamp of the sending timestamp in 1-step.
[0063] In a specific implementation, the calculating unit is configured to preconfigure, by a CPU, range equal division on the EOP effective byte number and preconfigure corresponding compensation granularity for each equal division range, calculate sending time of the compensation granularity under different port rates, and store each equal division range of the EOP effective byte number and corresponding sending time in the second list.
[0064] In a specific implementation, the compensation granularity is a median value corresponding to the equal division range.
[0065] Those skilled in the art can understand that the device for improving PTP time acquisition efficiency in the embodiment and the method for improving PTP time acquisition efficiency in Embodiment Two are based on the same inventive concept, and therefore the content related to the related embodiments can be referred to the foregoing corresponding content, which will not be described here again.
[0066] Those skilled in the art can understand that all or part of the steps of various methods in the above embodiments can be completed by instructing the related hardware through a program, and the program can be stored in a computer readable storage medium, which can include ROM, RAM, magnetic disk or optical disk, etc.
[0067] Although the present application is disclosed by the above, the present application is not limited to this. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present application, and the protection scope of the present application should be limited by the scope defined by the claims.
Claims
1. A method for improving PTP time acquisition efficiency, characterized in that, Applied to PTP 1-step mode, comprising: The first timestamp when the PTP message is written into the MacTxBuff on the write side of the MacTxBuff; According to the depth of the message stored in the MacTxBuff, the compensation value of the second timestamp of the sending timestamp in 1-step is calculated, specifically comprising: a first list is preset; the first list pre-stores the sending time of the non-EOP byte number in the MacTxBuff under different port rates; a second list is preset; the second list pre-stores the sending time of the EOP valid byte number under different port rates; a third list is preset; the third list pre-stores the sending time of the corresponding preamble and inter-packet gap under different port rates when the number of EOPs is different; according to the number of current EOPs in the information FIFO queue, the sending time corresponding to the current port rate in the first list, the second list and the third list is searched and accumulated, so as to calculate the compensation value of the second timestamp of the sending timestamp in 1-step, and the EOP is an end-of-packet (EOP) flag; The first timestamp is compensated according to the compensation value, and edited to the specified position of the second timestamp in the PTP message, completing the compensation of the sending timestamp in 1-step.
2. The method for improving PTP time acquisition efficiency of claim 1, wherein, According to the depth of the message stored in the MacTxBuff, the compensation value of the second timestamp of the sending timestamp in 1-step includes: According to the depth of the information FIFO, the number of EOPs and the number of valid bytes per EOP period in the information FIFO queue, the number of valid bytes contained in the MacTxBuff is calculated; According to the number of EOPs, the total number of occupied bytes of the preamble and the inter-packet gap is calculated; The sum of the number of valid bytes contained in the MacTxBuff and the total number of occupied bytes of the preamble and the inter-packet gap is divided by the port rate to calculate the compensation value of the second timestamp.
3. The method for improving PTP time acquisition efficiency according to claim 1, wherein: The EOP valid byte number is equally divided in range, and a corresponding compensation granularity is pre-configured for each equally divided range; The sending time of the compensation granularity under different port rates is calculated; The second list stores each equally divided range of the EOP valid byte number and the corresponding sending time.
4. The method for improving PTP time acquisition efficiency of claim 3, wherein, The compensation granularity is the median value of the corresponding equally divided range.
5. An apparatus for improving PTP time acquisition efficiency, comprising: Applied to PTP 1-step mode, comprising: An acquisition unit is configured to acquire a first timestamp when a PTP message is written into a MacTxBuff on a write side of the MacTxBuff; A calculation unit is configured to calculate a compensation value of a second timestamp of a sending timestamp in 1-step according to a depth of a message stored in the MacTxBuff; the calculation unit is configured to pre-configure a CPU with: A first list pre-storing sending time of non-EOP byte number in the MacTxBuff under different port rates; A second list pre-storing sending time of EOP valid byte number under different port rates; and A third list pre-storing sending time of corresponding preamble and inter-packet gap under different port rates when the number of EOPs is different. a third list; the third list pre-stores sending time of corresponding preamble and packet gap under different port rates when different number of EOPs; and, according to the number of current EOPs in the information FIFO queue, searching the first list, the second list and the third list for sending time corresponding to the current port rate and accumulating to calculate the compensation value of the second time stamp of the sending time stamp in 1-step, the EOP being a packet end flag; a processing unit for compensating the first time stamp according to the compensation value and editing to a specified position of the second time stamp in the PTP packet to complete compensation of the sending time stamp in 1-step.
6. The apparatus for improving PTP time acquisition efficiency of claim 5, wherein, the calculation unit is used for: calculating the number of effective bytes contained in MacTxBuff according to the depth of information FIFO, the number of EOPs and the number of effective bytes of each EOP period in the information FIFO queue; calculating the total number of occupied bytes of preamble and packet gap according to the number of EOPs; dividing the sum of the number of effective bytes contained in the MacTxBuff and the total number of occupied bytes of preamble and packet gap by the port rate to calculate the compensation value of the second time stamp.
7. The apparatus for improving PTP time acquisition efficiency of claim 5, wherein, the calculation unit is used for pre-configuring by CPU: range equidividing the number of EOP effective bytes and pre-configuring corresponding compensation granularity for each equidivided range; calculating sending time of the compensation granularity under different port rates; storing each equidivided range of the number of EOP effective bytes and corresponding sending time in the second list.
8. The apparatus for improving PTP time acquisition efficiency of claim 7, wherein, the compensation granularity is the median value of the corresponding equidivided range.
Citation Information
Patent Citations
Universal full-hardware one-step 1588 clock synchronization device and method
CN108650051A
A method for improving the precision of IEEE 1588 timestamp
CN109039514A