Sunday, October 18, 2015

Decoding TimeStamping on Arista 7150

If you need a primer on 'How to configure PTP' on Arista click here. If you understand Arista's implementation of PTP then wait no further and read the rest of the blogtorial on how to decode them from a RAW packet capture.

Key frames DATA is 46bytes and is broken down as follows. What is in bold is important for calculating UTC time of a given packet.

8Bytes - ASIC Ticks
8Bytes - UTC in ns
8Bytes - LAST SYNC
8Bytes - KEY TS
8Bytes - EGRESS Interface DROPS
2Bytes - User defined DEVICE ID
2Bytes - Egress interface of the keyframe
1Byte - FCS TYPE

1) First get the ASIC TICK (not the full ASIC time but just the TICK) of the key frame.

In this case it is 1111111 01010101 00000101 11101010 and then convert it to decimal which is 2136278506.

2) Get the UTC in nanoseconds from the keyframe. (The 2nd 8Bytes in the keyframe data).

In this case it is 00010011 01000000 01111000 00101111 00000001 11111100 10100101 10001111 and then convert it to decimal 1387240828522243471

3) Now let’s look at the packet you want to decode and get the LOW order ASIC TICK. We’ll do packet 10. Keep in mind that we are doing APPEND mode so we are appending the ASIC tick (4 bytes) at the end of the data.

In this case it is 11111111 00010000 10101011 01110110, but the most significant bit of the low order byte is padded so you take it out and you end up with  11111111 00010000 10101011 1110110 and convert this to decimal and you end up with 2139641334.

4) Now take the TICK from the 10th packet and subtract from the keyframe TICK so .. 2139641334 – 2136278506 and you end up 3362828 ticks.

5) Arista ticks are based on the 350MHz and each tick is 2.857ns. So, multiply the delta ticks by 2.857 ... 3362828 * 2.857 = 9607599.596.
                * This is how many nanoseconds has passed since the KEYFRAME.

6) Take the UTC time in nanoseconds which we got from the KEYFRAME (2nd 8Bytes of the DATA in the keyframe) and add the delta nanos. So in this case …
                9607599.596 + 1387240828522243471 = 1387240828531851070.596

7) 1387240828531851070.596 is the UTC timestamp of the packet #10 in this capture.

8) Convert the UTC timestamp in nanoseconds (1387240828531851070.596) to UTC DATE AND TIME and you end up with 2013-12-17 00:40:28.531851070

This is packet capture after it was decoded using the pcaptd script on netlab. PCAP cannot do nanoseconds that’s why you see a bunch of 000 for the nanosecond field.

As you can see both times match  …….

Just in case you need to this by hand …

No comments:

Post a Comment