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
| Name | Formula | Description |
|---|---|---|
| srcaddr | srcaddr | source address |
| srcport | srcport | source port |
| dstaddr | dstaddr | destination address |
| dstport | destport | destination port |
| keyid | keyid | key identifier key ID |
Packet Variables
| Name | Formula | Description |
|---|---|---|
| leap | leap | leap indicator |
| version | version | version number |
| mode | mode | mode |
| stratum | stratum | stratum |
| ppoll | ppoll | peer poll exponent |
| rootdelay | delta_r | root delay |
| rootdisp | epsilon_r | root dispersion |
| refid | refid | reference ID |
| reftime | reftime | reference timestamp |
Timestamp Variables
| Name | Formula | Description |
|---|---|---|
| org | T1 | origin timestamp |
| rec | T2 | receive timestamp |
| xmt | T3 | transmit timestamp |
| t | t | packet time |
Statistics Variables
| Name | Formula | Description |
|---|---|---|
| offset | theta | clock offset |
| delay | delta | round-trip delay |
| disp | epsilon | dispersion |
| jitter | psi | jitter |
| filter | filter | clock filter |
| tp | t_p | filter 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:
- Access Control: Implement access control list (ACL) checks
- Format Validation: Check field length, alignment, version number, and extension field syntax
- Authentication: If authentication is implemented, the MD5-keyed hash algorithm must be supported
- 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 Mode | Packet Mode 1 | Packet Mode 2 | Packet Mode 3 | Packet Mode 4 | Packet Mode 5 |
|---|---|---|---|---|---|
| No Association 0 | NEWPS | DSCRD | FXMIT | MANY | NEWBC |
| Symm. Active 1 | PROC | PROC | DSCRD | DSCRD | DSCRD |
| Symm. Passive 2 | PROC | ERR | DSCRD | DSCRD | DSCRD |
| Client 3 | DSCRD | DSCRD | DSCRD | PROC | DSCRD |
| Server 4 | DSCRD | DSCRD | DSCRD | DSCRD | DSCRD |
| Broadcast 5 | DSCRD | DSCRD | DSCRD | DSCRD | DSCRD |
| Bcast Client 6 | DSCRD | DSCRD | DSCRD | DSCRD | PROC |
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:
- Check that the transmit timestamp is nonzero
- Verify the origin timestamp matches the previously sent transmit timestamp
- Detect duplicate packets (transmit timestamp matches saved origin timestamp)
- 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.