Tag Archives: ethernet

Introduction to Precision Time Protocol (IEEE 1588)

This entry is part 1 of 2 in the series Precision Time Protocol

This is the first part of a multi-part series that will cover the basic concepts, terminology, behaviours, and applications of PTP.

PTP Goals

PTP was originally defined in the IEEE 1588-2002 standard, officially entitled “Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems” and published in 2002. In 2008, IEEE 1588-2008 was released as a revised standard; also known as PTP Version 2 [PTPv2], it improves accuracy, precision and robustness but is not backward compatible with the original 2002 version.

IEEE 1588 was designed to fill a niche that neither NTP nor GPS could fulfill by solving two problems:

  1. Local systems needing clock accuracy in the sub-microsecond range
  2. Systems needing synchronisation in areas that cannot afford the cost of a GPS receiver at each node, or that cannot receive GPS signals (consider an underground or windowless datacenter)

The origins of IEEE 1588 development come from test and measurement (instrumentation and data acquisition), industrial automation or power generation, and received strong support from the automation industry leading to the adoption of the IEEE 1588-2002 standard by the Industrial Electro-technical Commission [IEC] as IEEE/IEC 61588-2004.

Specific application domains and targets had driven first release of IEEE 1588 work. Applications (e.g. data acquisition, military instrumentation, industrial robots and high-speed printers) and their targets, had sufficient shared objective to define common criteria:

  • Achievable sub-microsecond accuracy (if required).
  • Operation over control localised areas, such as local area network [LAN], with no intent to cover Internet or wide area networks, but supporting a PTP system.
  • Administration-free operation allowing “plug-and-play” deployment of IEEE 1588 clocks
  • Designed for minimal resource requirement in devices supporting PTP (clock filtering or averaging might not be necessary).

Currently one of the main industries using PTP is the High-Frequency Trading [HFT], and financial sector, to ensure highly accurate timing and synchronisation for their market feeds and trading servers.

When reading the spec

Just to note, that as an IEEE spec, 1588 can be far more difficult to read than IETF/RFC documents. A key thing to note in this particular spec is that IEEE 1588 also specifies “the node, system, and communications properties necessary to support PTP” and proposes models of devices, called “clocks” that support the protocol and aim to help and enhance the transfer of packet-based timing references. In IEEE 1588 terms, a PTP system is a set of IEEE 1588 clocks with specialised functions to support the protocol, PTP.

For instance, specifications of an IEEE 1588 clock include some material, such as a port, that is not part of the protocol itself. However, the messages sent and received by each port of an IEEE 1588 clock and the resulting behaviour of that clock is part of the protocol. Nonetheless, the standard does not define any performance objective for transport network device or clock.

To simplify – a PTP clock is a device that runs the PTP protocol, and has one or more network interfaces

Network Configuration with Raspberry Pi – WiFi and Ethernet

I was configuring my Raspberry Pi (B+) on Raspbian via the ethernet port, but also wanted to get the WiFi adapter up and running. I had some issues getting both running at the same time though – don’t know why as the device is running headless, but as soon as I disconnected the ethernet cable the WiFi was working as you would expect.

The workaround for this is a little messy, but I thought I’d share it here. First of all, use either the GUI or the config file to configure the WiFi (GUI is easier). The key point here, as I want to use a static IP when on my home network and DHCP the rest of the time, is to set the ‘id_str’ parameter to something meaningful e.g. home_network. The id_str allows us to match a WiFi access point to an interface configuration.

WiFi Config File

This is stored in /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="network-SSID"
psk="my_network_key"
proto=RSN
key_mgmt=WPA-PSK
pairwise=TKIP
auth_alg=OPEN
id_str="<strong>home_static</strong>"
}

Interfaces File

This is /etc/network/interfaces
Note how the iface name is the same as the id_str for the home network/static IP configuration

auto lo

iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface <strong>home_static</strong> inet static
address 192.168.1.20
netmask 255.255.255.0
gateway 192.168.1.1

iface default inet dhcp

The Weirdness

For some reason if we hotplug the Ethernet port we disable wlan0 (and it makes a right mess of things as the sshd and other services aren’t bound to the correct interface any more).

So we edit /etc/default/ifplugd

INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

And to give the WiFi dongle a kick at startup we add the following to /etc/rc.local.

# Disable the ifplugd eth0
sudo ifplugd eth0 --kill
sudo ifup wlan0