21#include <sys/socket.h>
24#include "network_time_protocol.h"
89 void startListening(
const std::string &bindAddress,
const std::string &NTPServerAddress);
Class that represents the netowrk-time-protocol server that synchronizes clients.
Definition: ntp_server.h:41
NTPServer()
Constructs a NTPServer object.
Definition: ntp_server.cc:194
void startListening(const std::string &bindAddress, const std::string &NTPServerAddress)
Starts listening to NTP clients to begin synchronization.
Definition: ntp_server.cc:183
static constexpr int NTP_PORT
Definition: ntp_server.h:43
std::string m_NTPServerAddress
Definition: ntp_server.h:48
static constexpr unsigned int NTP_SYNC_PERIOD_S
Definition: ntp_server.h:44
bool queryNTPServer(NTPPacket &response)
Queries the remote NTP server and fills the response packet.
Definition: ntp_server.cc:20
void NTPServerProcedure()
Thread procedure for handling NTP synchronization.
Definition: ntp_server.cc:121
std::atomic< bool > m_isListening
Definition: ntp_server.h:50
int m_NTPSocket
Definition: ntp_server.h:46
std::string m_bindAddress
Definition: ntp_server.h:47
pthread_t m_NTPServerThreadId
Definition: ntp_server.h:49
NTPPacket processNTPRequest(const NTPPacket &request)
Processes an incoming NTP request and returns the response packet.
Definition: ntp_server.cc:81
Structure representing an NTP packet.
Definition: network_time_protocol.h:68