Skip to content

Commit 7331e9d

Browse files
committed
PTP
1 parent 9056122 commit 7331e9d

File tree

4 files changed

+254
-23
lines changed

4 files changed

+254
-23
lines changed

linux-servers/applications.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,13 @@ See [NTP](/services/ntp/) for more info about NTP.
163163
164164
### Usage
165165
166-
- Check tracking: `chronyc tracking`
167-
- Check sources: `chronyc sources`
166+
- Note: Commands may need to be run as root.
167+
- Sources:
168+
- Show tracking: `chronyc tracking`
169+
- Show sources: `chronyc sources`
170+
- Show sources (detailed): `chronyc ntpdata`
171+
- Show server stats: `chronyc serverstats`
172+
- Show clients: `chronyc clients`
168173
169174
## DDNS
170175
@@ -883,6 +888,21 @@ See [Team Fortress 2 (TF2)](/game-servers/tf2/).
883888
- Run test: `smartctl -t <short|long|conveyance|select> [-C] <dev>`
884889
- `-C`: Foreground mode.
885890
891+
## NetSNMP
892+
893+
[Debian: SNMP](https://wiki.debian.org/SNMP)
894+
895+
### Server
896+
897+
#### Installation
898+
899+
1. Install: `apt install snmpd`
900+
1. **TODO**: Do we need human-readable names on the _server_? See the guide.
901+
1. Update the config:
902+
- Path: `/etc/snmp/snmpd.conf`
903+
- Example: [snmpd.conf](https://github.com/HON95/configs/blob/master/netsnmp/snmpd.conf)
904+
1. Enable and start: `systemctl enable --now snmpd`
905+
886906
## SSHD
887907
888908
### Security Recommendations

networking/ipv4.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ breadcrumbs:
3838
| `224.2.0.0/16` | Session Description Protocol/Session Announcement Protocol (SDP/SAP) |
3939
| `224.3.0.0/15` | AD-HOC II, see block I |
4040
| `224.5.0.0-224.255.255.255` | Reserved |
41-
| `232.0.0.0/8` | SSM range, locally assigned |
41+
| `232.0.0.0/8` | Source-specific multicsat (SSM), locally assigned |
4242
| `233.0.0.0-233.251.255.255` | GLOP, /24 blocks for 16-bit ASNs, experimental |
4343
| `233.252.0.0/14` | AD-HOC III, see block I |
4444
| `234.0.0.0-238.255.255.255` | Reserved |

networking/ipv6.md

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ See the [IANA IPv6 Special-Purpose Address Registry](https://www.iana.org/assign
5656
| `ff05::1:3` | Site | All-DHCP-servers |
5757
| `ff02::6b` | Link | PTPv2 messages |
5858
| `ff02:0:0:0:0:1:ff00::/104` | Link | Solicited-node |
59+
| `ff0x::/96` | Any | Source-specific multicast (SSM) |
5960

6061
### Subnet Addresses
6162

services/ptp.md

+230-20
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,26 @@ breadcrumbs:
1919
- Uses the same epoch as UNIX, i.e. 1970-01-01 00:00:00.
2020
- Supports a one-step and a two-step method, but the two-step method is more widely supported. The "second step" is the follow-up message after the sync message, containing the time when the sync message *actually* entered the wire. In the one-step method, the time is embedded into the sync message itself.
2121
- The synchronization uses a simple, rooted tree. Any redundant paths are blocked, such that each clock receives time from a single slave port. It's basically STP.
22+
- UTC offset:
23+
- PTP uses International Atomic Time (TAI), while NTP and most applications use Coordinated Univseral Time (UTC).
24+
- UTC is offset from TAI with an integer number to remain in synchronization with mean solar time.
25+
- `TAI = UTC + offset`
26+
- As of 01 Jan 2017, the UTC offset is +37 seconds.
2227
- PTP domains:
2328
- Domains allow multiple clock distribution systems to share the same communications medium.
2429
- Domain 0 is the default. Many devices only support the default domain.
2530
- Packet delay variation (PDV):
2631
- Variation is often due to varying queue depths.
2732
- Computed constantly, averaged out over time.
2833
- Transport:
34+
- Ethernet (PTPoE) or IP/UDP.
2935
- Multicast or unicast, but most often multicast.
3036
- Typically uses multicast with group 224.0.1.129 (default domain 0). These messages may be forwarded, according to the specific profile.
3137
- Profiles using peer delay messages use group 224.0.0.107 for specifically those messages. These messages are not forwarded.
3238
- Time-critical event messages (sync) use UDP port 319, while general messages (announce, management etc.) use port 320. Delay messages are split across both ports according to the profile details.
39+
- Management messages:
40+
- Used by an external client to monitor PTP clocks.
41+
- The frames are forwarded inband in the PTP hierarchy, both upward and downward from the clock connected to the management client.
3342
- Intervals/rates of messages:
3443
- Announce: 1s (power profile), 2s (default profile)
3544
- Sync: 1s (power and default profiles)
@@ -65,10 +74,10 @@ breadcrumbs:
6574
- Grandmaster clocks (GMCs):
6675
- Only one GMC per PTP domain, but backups are recommended.
6776
- Has a connection to an external time source, e.g. GNSS.
68-
- Best Master Clock (BMC) algorithm:
77+
- Best Master Clock algorithm (BMCA):
6978
- Uses Announce messages.
7079
- Selects a clock according to (from highest priority):
71-
- Priority 1: User-configurable from 0 to 255, lower value takes precedence.
80+
- Priority 1: User-configurable from 0 to 255, lower value takes precedence. 255 for client-only devices.
7281
- Class: Related to the source of time, e.g. if using GNSS or (only) an internal oscillator.
7382
- Accuracy: Accuracy of a clock.
7483
- Variance: Stability of a clock.
@@ -79,6 +88,7 @@ breadcrumbs:
7988
- Class 7: Like class 6, but lost synchronization.
8089
- Class 13/14: Like 6/7, but timescale distribution is ARB.
8190
- Class 248: Default. Free-running on internal oscillator.
91+
- Class 255: Client-only devices.
8292
- Assumes that each clock elects the same GMC each second, assuming they all see the same Announce messages.
8393
- While the class can typically correctly pick the BMC, it's a good idea to use priority 1 (or priority 2) in addition, to prevent BMC flapping.
8494
- Oscillators:
@@ -87,7 +97,7 @@ breadcrumbs:
8797
- Good quality oscillators are critical for free-running clocks.
8898
- Primary and backup GMC:
8999
- A single backup is typically enough.
90-
- Use priority 1 to choose the primary GMC.
100+
- Use a priority 1 of 1 on both GMC candidates. Use a priority 2 of 1 and 2 for the primary and backup, to choose which of the clocks to prefer when both are healthy.
91101
- Connect the backup GMC to an Ethernet switch at most one bridge hop away from the primary. This yealds lower PDV changes in case of failovers.
92102

93103
### Versions and Amendments
@@ -175,7 +185,7 @@ breadcrumbs:
175185

176186
- Used for telecom and mobile backhaul.
177187

178-
#### AES67
188+
#### Media (AES67-2015)
179189

180190
- For AES67 and Dante audio.
181191
- Used by newer Dante devices, while older ones use PTPv1. Certain Dante devices support both PTP versions, such that they can consume PTPv2 and supply PTPv1 to other devices in the same bridge domain (like a BC).
@@ -185,17 +195,91 @@ breadcrumbs:
185195

186196
- For multimedia.
187197

188-
## Vendor Support
198+
## Implementations
199+
200+
### Linux PTP
201+
202+
- Supports OC and BC.
203+
- Supports multiple PTPv2 profiles, including default and 802.1AS-2011 (gPTP/AVB).
204+
- Version 4 added support for PTPv2.1 (IEEE 1588-2019). Some clocks refuse to accept v2.1, as testet myself on Cisco Catalyst 9300 and as someone discussed on the mailing list [here](https://sourceforge.net/p/linuxptp/mailman/linuxptp-users/thread/20230710162104.2a8dd088%40rugged/). This support may be reverted by changing `PTP_MINOR_VERSION` in the source code.
205+
- Supports serving NTP time to PTP and PTP time to NTP.
206+
- Resources:
207+
- [linuxptp.sourceforge.net](https://linuxptp.sourceforge.net/)
208+
- [RHEL7: Configuring PTP Using ptp4l](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ptp_using_ptp4l)
209+
210+
#### Setup: Grandmaster Mode with Chrony Source (Debian)
211+
212+
Configure LinuxPTP as a GM using the default PTPv2 profile, with Chrony as the local time source.
213+
214+
For this setup, Chrony is the one updating the system time, so `phc2sys` is not used. **TODO**
215+
216+
For testing purposes only, using NTP as the source for PTP is not recommended.
217+
218+
**TODO**: NTP to PTP: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ptp_using_ptp4l#sec-Serving_NTP_Time_with_PTP
219+
**TODO**: Sync PTP HW clock to system clock
220+
**TODO**: Use NTP server directly without Chrony?
221+
**TODO**: clockClass?
222+
223+
1. Check if your NIC supports hardware timestamping: `ethtool -T <interface>`
224+
- Software mode is fine for testing stuff.
225+
1. Install:
226+
1. `git clone --depth=1 --branch=v4.1 http://git.code.sf.net/p/linuxptp/code linuxptp`
227+
1. `cd linuxptp`
228+
1. If you need PTPv2 instead of v2.1: In `msg.h`, change `PTP_MINOR_VERSION` from 1 to 0.
229+
1. `make`
230+
1. `sudo make install`
231+
1. `cd ..`
232+
1. Create the config file (default profile):
233+
1. Copy the example config the the default profile: `sudo cp linuxptp/configs/default.cfg /etc/ptp4l.conf`
234+
1. Reduce the logging interval by setting `summary_interval 6` (2^N seconds). The default is 0 (each second).
235+
1. Set the first priority to avoid losing the GM role by setting `priority1 1`.
236+
1. If you have multiple clocks and want to assign some priority between then (after pri1 and class), set `priority2` to some appropriate value.
237+
1. Create the service config below, using the correct interface: `sudo vim /etc/systemd/system/ptp4l.service`
238+
- If you plan on running multiple PTP profiles on the same computer, you may want to structure the service a bit differently and use different configs.
239+
- `-i <interface>` for each interface to use with the provided config.
240+
- `-4` for IPv4.
241+
- `-S` for SW timestamping, if no HW support available.
242+
1. Enable and start the service: `sudo systemctl daemon-reload && sudo systemctl enable --now ptp4l.service`
243+
1. Check the system journal to make sure it started correctly: `sudo journalctl -u ptp4l.service -f`
244+
- See the usage notes for more info.
245+
1. Validate that PTP messages are sent: `sudo tcpdump -nn -i <interface> host 224.0.1.129`
246+
247+
Service config (`/etc/systemd/system/ptp4l.service`):
248+
249+
```ini
250+
[Unit]
251+
Description=LinuxPTP daemon
252+
After=network.target
253+
254+
[Service]
255+
ExecStart=ptp4l -f /etc/ptp4l.conf -i eth0 -4
256+
257+
[Install]
258+
WantedBy=multi-user.target
259+
```
260+
261+
#### Usage
262+
263+
- Note: Commands may require root.
264+
- Check the log: `journalctl -u ptp4l.service -f`
265+
- It should show "assuming the grand master role" after a few seconds, assuming it got the grandmaster role.
266+
- If `summary_interval 0`, the "master offset" value is the measured offset from the master in nanoseconds.
267+
- If `summary_interval 0`, the "sN" strings indicate the different clock servo states: "s0" is unlocked, "s1" is clock step and "s2" is locked.
268+
- Show status: `pmc -u -b 0 'GET CURRENT_DATA_SET'` and `pmc -u -b 0 'GET TIME_STATUS_NP'`
269+
- "stepsRemoved" is the number of jumps toward the GMC.
270+
- "offsetFromMaster" is the last measured offset of the clock from the master, in nanoseconds.
271+
- "meanPathDelay" is the estimated delay of the synchronization messages sent from the master, in nanoseconds.
272+
- "gmPresent" means that the local clock is synchronized to a GMC and that the local clock is _not_ the GMC.
189273

190274
### Cisco
191275

192-
#### Product Support
276+
#### Support Overview
193277

194278
- 2-step PTP and multicast support only.
195279
- Catalyst 9000:
196280
- Profiles: Default, 802.1AS, G.8275.1, AES67.
197281
- Clock modes: GMC, BC, E2E-TC, P2P-TC
198-
- With exceptions.
282+
- With many exceptions.
199283
- Nexus 9000 (first gen):
200284
- Profiles: Default.
201285
- Clock modes: GMC, BC.
@@ -209,12 +293,90 @@ breadcrumbs:
209293
- Profiles: SyncE, G.8265.1, G.8275.1, G.8275.2, GNSS external.
210294
- Clock modes: GMC, BC, OC.
211295

212-
#### Configuration and Troubleshooting (Catalyst)
296+
#### Catalyst 9000 Series
297+
298+
##### General
299+
300+
- No IPv6 or VRF support.
301+
- PTPv1 is not supported, but can be forwarded like normal traffic.
302+
- Seemingly does not support PTPv2.1 (completely ignored it during testing).
303+
- Supports the default profile and the gPTP profile.
304+
- Does not support transparent clock mode on native L3 ports and EtherChannel interfaces. Boundary clocks are supported on L3 ports.
305+
- EtherChannel interfaces run PTP as individual interfaces.
306+
- Not supported on subinterfaces (or their base interface).
307+
- Not supported on any ports of the supervisor module.
308+
- Does not support SSO. PTP will restart after a switchover.
309+
- Supported on Stackwise since 17.xxx.
310+
- Supported on StackWise Virtual since IOS XE 17.10.1.
311+
- Supports gPTP on 100Mb/s ports: C9300-24H, C9300-24UXB, C9300-48H, C9300L-48PF-4G, C9300L-48PF-4X
312+
- Cat 9200:
313+
- Not supported.
314+
- Cat 9300:
315+
- Generally supported.
316+
- C9300-48UXM: Supported on 1-16 downlinks and all uplinks.
317+
- C9300-48UN: Supported on 1-36 downlinks and all uplinks.
318+
- Cat 9400:
319+
- Supported on 9404R, 9407R and 9410R.
320+
- Not supported on SUP 9400X.
321+
- Not supported on supervisor ports.
322+
- Cat 9500:
323+
- Generally supported, except 9500X.
324+
- Cat 9600:
325+
- Generally supported, except 9600X.
326+
327+
##### Configuration
328+
329+
- Defaults:
330+
- PTPv2 default profile.
331+
- Transparent mode.
332+
- Domain 0.
333+
- Enable required license: `license boot level network-advantage` (then reboot)
334+
- Set transport mode to L3 (before setting clock type): `ptp transport ipv4 udp`
335+
- Set clock type (default profile):
336+
- BC: `ptp mode boundary delay-req`
337+
- TC: `ptp mode e2etransparent`
338+
- Set priority 1: `ptp priority1 <0-255>`
339+
- Use 1 if intended to be GMC or 255 to never become GMC.
340+
- Set PTP source interface: `ptp source Loopback0`
341+
- Set port as permanent master (guard against downstream masters) (BC, interface): `ptp role primary`
342+
- Set PTP VLAN on trunk if not native VLAN (interface): `ptp vlan <vid>`
343+
- Set priority for GMC (default 128): `ptp priority1 100` (example)
344+
- Set source interface: `ptp source <interface>`
345+
- Crossing L3 boundaries using the default profile (L3 switch):
346+
- Must use VLAN interfaces, not physical routed interfaces.
347+
- Physical interfaces must be in switchport mode for PTP messages to work.
348+
- PTP uses a TTL of 1 by default, but some devices support setting the TTL.
349+
350+
**Cat 9300 BC example:**
351+
352+
```
353+
ip access-list extended ptpv2-4
354+
10 permit udp any eq 319 host 224.0.1.129 eq 319
355+
20 permit udp any eq 320 host 224.0.1.129 eq 320
356+
357+
int Te1/1/1
358+
desc ptp-only-uplink
359+
ip address 10.0.1.0 255.255.255.0
360+
no switchport
361+
ip access-group ptpv2-4 in
362+
ip access-group ptpv2-4 out
363+
364+
int Te1/1/8
365+
desc downlink
366+
no switchport
367+
ip address 10.0.2.0 255.255.255.0
368+
ptp role primary
369+
370+
ptp transport ipv4 udp
371+
ptp mode boundary delay-req
372+
ptp priority1 255
373+
```
374+
375+
##### Troubleshooting
213376

214-
- The default profile with transparent mode is the default.
215-
- PTP can be disabled by changing to "forwarding" mode.
216377
- Show general info: `show ptp clock`
217378
- Shows role, profile, identity, domain, offset from master, mean path delay, steps removed etc.
379+
- Show PTP servo clock: `show platform software fed switch active ptp domain`
218380
- Show master info: `show ptp parent`
219381
- If the parent port number is zero, then the local switch is the GMC.
220382
- Only GMCs and BCs show up as parents, TCs are transparent.
@@ -224,21 +386,69 @@ breadcrumbs:
224386
- Show interface counters: `show ptp port counters {errors|messages}`
225387
- Debugging:
226388
- Show errors: `debug ptp error`
227-
- Set priority for GMC (default 128) (example):
228-
- `ptp priority1 110`
229-
- Crossing L3 boundaries using the default profile (L3 switch):
230-
- Must use VLAN interfaces, not physical routed interfaces.
231-
- Physical interfaces must be in switchport mode for PTP messages to work.
232-
- PTP uses a TTL of 1 by default, but some devices support setting the TTL.
233389
- Common issues:
234390
- Configure tagging for native VLAN on trunks (`vlan dot1x tag native`) to add CoS and avoid congestion drops (PTP uses priority 7).
235391
- For ring topologies, configure the gateway bridges as BCs and the rest as TCs.
236392
- Use STP portfast for non-bridge links.
237393
- Use matching master and slave profiles. Look for suspicious zero values in the info.
238394
- Set the TTL to >1 if it will be routed.
239-
240-
## Implementations
241-
242-
- [Linux PTP](/linux-servers/applications/#linux-ptp)
395+
- Resources:
396+
- [Cisco: Troubleshoot Precision Time Protocol (PTP) on Catalyst 9000 Switches](https://www.cisco.com/c/en/us/support/docs/switches/catalyst-9300-series-switches/221062-troubleshoot-precision-time-protocol-pt.html)
397+
398+
#### ACI
399+
400+
##### General
401+
402+
- Switch support:
403+
- Requires second generation or later ACI switches.
404+
- Only BC mode with 2-step is supported.
405+
- Only multicast UDP transport mode is supported.
406+
- Does not support management messages.
407+
- Fabric latency measurements:
408+
- One of the main use cases for PTP within ACI.
409+
- May be used together with atomic counters for a fuller image of what is happening in the network.
410+
- Used for measuring ongoing TEP-to-TEP latency and on-demand tenant latency (see the docs for details and examples).
411+
- Supports *average mode* and *histogram mode*.
412+
- Topology:
413+
- To align with the PTP hierarchy of clocks and reduce the number of switches in the clock path, as well as reduce the difference in clock paths to leaf switches, the upstream clock should be connected to all spines.
414+
- For multi-pod architectures, the inter-pod network (IPN) may be a fitting place to connect the upstream clock to, such that the IPN redistributed the time from the same GMC to the spines in all the pods.
415+
- By default, all ACI switches use a priority 1 of 255, while a single spine in each pod that uses priority 254.
416+
- Resources:
417+
- [Cisco: Cisco ACI Latency and Precision Time Protocol](https://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/kb/b_Cisco_ACI_Latency_and_Precision_Time_Protocol.html)
418+
- [Cisco: Cisco APIC System Management Configuration Guide, Release 6.0(x)](https://www.cisco.com/c/en/us/td/docs/dcn/aci/apic/6x/system-management-configuration/cisco-apic-system-management-configuration-guide-60x/precision-time-protocol-60x.html)
419+
420+
##### Configuration
421+
422+
- Activate PTP globally (GUI):
423+
1. Note: This will configure each switch as a BC, where one spine in each pod will get priority 254 and become GMC for the pod. PTP will only be enabled on internal fabric ports.
424+
1. Go to "System > System Settings > PTP and Latency Measurements > Policy".
425+
1. Configure it as follows (example):
426+
- Global priority 1: 255
427+
- Global priority 2: 255
428+
- Global domain 0
429+
- Profile: Default
430+
- Announce interval: 1 (2s)
431+
- Sync interval: 0 (1s)
432+
- Delay request interval: 1 (2s)
433+
- Announce timeout: 3s
434+
1. Go to the "Latency" tab and set "System Resolution" to 11.
435+
- Configure a latency measurement (when needed) (GUI):
436+
1. Go to "Tenants > the tenant > Policies > Troubleshooting > Atomic Counter and Latency".
437+
1. Click the configuration button and select the appropriate measurement type (e.g. EPG to EPG).
438+
1. Select the IP version(s) to measure.
439+
1. Select "Latency Statistics" and optionally "Atomic Counter".
440+
1. Choose the measurement mode (average or histogram).
441+
1. Fill in the traffic selectors (e.g. source and destination EPG).
442+
1. Optionally add some traffic filters.
443+
1. Submit.
444+
1. To view the results, go to the operational tab and check the atomic counter and latency subtabs.
445+
446+
##### Troubleshooting
447+
448+
- Show PTP info (switch CLI):
449+
- Show local clock: `show ptp clock`
450+
- Show parent clock: `show ptp parent`
451+
- Show interface states: `show ptp brief`
452+
- Show PTP packet counters for some interface: `show ptp counters interface <ethx/x>`
243453

244454
{% include footer.md %}

0 commit comments

Comments
 (0)