CSS-WC Servers

Modules: dvbcss.protocol.server.wc

The WallClockServer class implements a standalone CSS-WC server.

The server can be started and stopped. While running it runs in its own separate thread of execution in the background.

An example server is provided in this package.

Example usage

To use it, you need to provide a clock object that represents the “wall clock”. Although it is not required, it is recommended to set the tick rate of that clock to match the required tick rate of the wall clock (1e9 ticks per second).

First, create the clock and measure its precision:

from dvbcss.clock import SysClock, measurePrecision

sysClock = SysClock(tickRate=1000000000)
wallClock = sysClock

precisionSecs = measurePrecision(wallClock)

Next create and start the wall clock server. You must provide information on the maximum range of frequency error of the hardware clock underpinning the wall clock. This will depend on oscillator accuracy in the hardware the code is running on, and whether an NTP client is running (and which therefore may slew the clock).

For example, here we assume the combined worst case of NTP client slew and hardware oscillator accuracy is approx 500 ppm:

from dvbcss.protocol.wc.server import WallClockServer

mfe = 500

wcServer = WallClockServer(wallClock, precisionSecs, mfe)
wcServer.start()

Classes

WallClockServer

class dvbcss.protocol.server.wc.WallClockServer(wallClock, precision, maxFreqError, bindaddr='0.0.0.0', bindport=6677, followup=False)[source]

A CSS-WC server.

Pass it a clock object and information on clock precision and frequency stability, and tell it which network interface to listen on.

Call start() and stop() to start and stop the server. It runs in its own separate thread in the background.

You can optionally ask this server to operate in a mode where it will send follow-up responses. Note, however, that in this implementation the transmit-timevalue reported in the follow-up response is not guaranteed to be more accurate. This option exists primarily to check whether a Wall Clock Client has implemennted handling of follow-up responses at all.

Parameters:
  • wallClock – (:class:dvbcss.clock.ClockBase) The clock to be used as the wall clock for protocol interactions
  • precisionSecs – (float) The precision (in seconds) to be reported for the clock in protocol interactions
  • maxFreqErrorPpm – (float) The clock maximum frequency error in parts-per-million
  • bindaddr – (str, ip address) The ip address of the network interface to bind to, e.g. “127.0.0.1”. Defaults to “0.0.0.0” which binds to all interfaces.
  • bindport – (int) The port number to bind to (defaults to 6677)
  • followup – (bool) Set to True if the Wall Clock Server should send follow-up responses. Defaults to False.
run()[source]

Internal method - the main runloop of the thread.

Runs in a loop calling the handle() method of the object assigned to the handler property whenever a UDP packet is received.

Does not return until the _pleaseStop attribute of the object has been set to True

start()[source]

Starts the wall clock server running. It runs in a thread in the background.

stop()[source]

Stops the wall clock server running. Does not return until the thread has terminated.