Skip to main content

9. Peer Process

The peer process is called upon arrival of a server or peer packet. It runs the on-wire protocol to determine the clock offset and round-trip delay and computes statistics used by the system and poll processes. Peer variables are instantiated in the association data structure when the structure is initialized and updated by arriving packets. There is a peer process, poll process, and association process for each server.

9.1. Peer Process Variables

The following are the main variable categories used by the peer process:

Configuration Variables

NameFormulaDescription
srcaddrsrcaddrsource address
srcportsrcportsource port
dstaddrdstaddrdestination address
dstportdestportdestination port
keyidkeyidkey identifier key ID

Packet Variables

NameFormulaDescription
leapleapleap indicator
versionversionversion number
modemodemode
stratumstratumstratum
ppollppollpeer poll exponent
rootdelaydelta_rroot delay
rootdispepsilon_rroot dispersion
refidrefidreference ID
reftimereftimereference timestamp

Timestamp Variables

NameFormulaDescription
orgT1origin timestamp
recT2receive timestamp
xmtT3transmit timestamp
ttpacket time

Statistics Variables

NameFormulaDescription
offsetthetaclock offset
delaydeltaround-trip delay
dispepsilondispersion
jitterpsijitter
filterfilterclock filter
tpt_pfilter time

9.2. Peer Process Operations

Packet Reception Flow

The receive routine defines the process flow upon the arrival of a packet. Main steps include:

  1. Access Control: Implement access control list (ACL) checks
  2. Format Validation: Check field length, alignment, version number, and extension field syntax
  3. Authentication: If authentication is implemented, the MD5-keyed hash algorithm must be supported
  4. Association Lookup: Search the association table for matching source address and port

Peer Dispatch Table

Based on the combination of association mode and packet mode, the system dispatches processing to different steps:

Association ModePacket Mode 1Packet Mode 2Packet Mode 3Packet Mode 4Packet Mode 5
No Association 0NEWPSDSCRDFXMITMANYNEWBC
Symm. Active 1PROCPROCDSCRDDSCRDDSCRD
Symm. Passive 2PROCERRDSCRDDSCRDDSCRD
Client 3DSCRDDSCRDDSCRDPROCDSCRD
Server 4DSCRDDSCRDDSCRDDSCRDDSCRD
Broadcast 5DSCRDDSCRDDSCRDDSCRDDSCRD
Bcast Client 6DSCRDDSCRDDSCRDDSCRDPROC

Processing Actions:

  • DSCRD: Discard packet (non-fatal protocol violation)
  • ERR: Discard packet and demobilize symmetric passive association (fatal protocol violation)
  • FXMIT: Fast transmit (stateless server response)
  • MANY: Manycast server response
  • NEWBC: New broadcast association
  • NEWPS: New symmetric passive association
  • PROC: Process matching association

Packet Validation

For PROC processing, the system performs strict timestamp checks to avoid invalid, duplicate, or bogus packets. Main validations include:

  1. Check that the transmit timestamp is nonzero
  2. Verify the origin timestamp matches the previously sent transmit timestamp
  3. Detect duplicate packets (transmit timestamp matches saved origin timestamp)
  4. Verify destination timestamp is later than origin timestamp

After passing these checks, the system computes offset and delay, updates the clock filter, and prepares statistics for the system process.