Data Transfer Objects

API Request/Response Models

MeasurementRequest

class server.app.dtos.MeasurementRequest.MeasurementRequest(**data)[source]

Bases: BaseModel

Data model for an NTP measurement request.

server

The IP address or domain name of the NTP server to be measured.

Type:

str

ipv6_measurement

True if the type of IPs that we want to measure is IPv6. False otherwise.

Type:

bool

validate_after()[source]

Checks that the server is a string. :type self: :param self: Instance of the class. :type self: Self

Returns:

the MeasurementRequest instance.

Return type:

Self

Raises:
  • TypeError – if the server is not a string.

  • TypeError – if the flag for ipv6 measurement is not a bool.

NtpMeasurementResponse

class server.app.dtos.NtpMeasurementResponse.MeasurementResponse(**data)[source]

Bases: BaseModel

measurements: List[MeasurementResult]
class server.app.dtos.NtpMeasurementResponse.MeasurementResult(**data)[source]

Bases: BaseModel

client_recv_time: PreciseTime
client_sent_time: PreciseTime
jitter: float
leap: int
nr_measurements_jitter: int
ntp_last_sync_time: PreciseTime
ntp_server_ip: Union[IPv4Address, IPv6Address, None]
ntp_server_location: ServerLocation
ntp_server_name: Optional[str]
ntp_server_ref_parent_ip: Union[IPv4Address, IPv6Address, None]
ntp_version: int
offset: float
poll: int
precision: float
reachability: str
ref_name: Optional[str]
root_delay: PreciseTime
root_dispersion: PreciseTime
rtt: float
server_recv_time: PreciseTime
server_sent_time: PreciseTime
stratum: int
vantage_point_ip: Union[IPv4Address, IPv6Address, None]

RipeMeasurementResponse

class server.app.dtos.RipeMeasurementResponse.ProbeAddr(**data)[source]

Bases: BaseModel

ipv4: Optional[IPv4Address]
ipv6: Optional[IPv6Address]
class server.app.dtos.RipeMeasurementResponse.ProbeCountPerType(**data)[source]

Bases: BaseModel

area: Optional[str]
asn: Optional[int]
country: Optional[str]
prefix: Optional[str]
random: Optional[int]
class server.app.dtos.RipeMeasurementResponse.RipeMeasurementResponse(**data)[source]

Bases: BaseModel

measurements: List[RipeResult]
class server.app.dtos.RipeMeasurementResponse.RipeMeasurementResult(**data)[source]

Bases: BaseModel

client_recv_time: PreciseTime
client_sent_time: PreciseTime
offset: float
rtt: float
server_recv_time: PreciseTime
server_sent_time: PreciseTime
class server.app.dtos.RipeMeasurementResponse.RipeResult(**data)[source]

Bases: BaseModel

ntp_server_ip: Union[IPv4Address, IPv6Address, None]
ntp_server_location: ServerLocation
ntp_server_name: Optional[str]
ntp_version: int
poll: int
precision: float
probe_addr: ProbeAddr
probe_count_per_type: ProbeCountPerType
probe_id: Union[int, str]
probe_location: ServerLocation
ref_id: str
result: List[RipeMeasurementResult]
ripe_measurement_id: int
root_delay: float
root_dispersion: float
stratum: int
time_to_result: float
vantage_point_ip: Union[IPv4Address, IPv6Address, None]

RipeMeasurementTriggerResponse

class server.app.dtos.RipeMeasurementTriggerResponse.RipeMeasurementTriggerResponse(**data)[source]

Bases: BaseModel

measurement_id: str
message: str
status: str
vantage_point_ip: str
vantage_point_location: ServerLocation

Core Data Models

RipeMeasurement

class server.app.dtos.RipeMeasurement.RipeMeasurement(measurement_id, ntp_measurement, probe_data, time_to_result, ref_id)[source]

Bases: object

Represents the complete set of information retrieved from a RipeMeasurement.

measurement_id

ID of the measurement from RIPE Atlas

Type:

int

ntp_measurement

The NTP measurement data

Type:

NtpMeasurement

probe_data

Data related to the probe

Type:

ProbeData

time_to_result

The duration (seconds) it took to receive the result after the measurement was initiated

Type:

int

ref_id

The reference ID of the server

Type:

str

NtpMeasurement

class server.app.dtos.NtpMeasurement.NtpMeasurement(vantage_point_ip, server_info, timestamps, main_details, extra_details)[source]

Bases: object

Represents the complete set of measurements for a given NTP server.

vantage_point_ip

IP address of the vantage point where measurement is being triggered

Type:

IPv4Address | IPv6Address | None

server_info

Metadata about the NTP server

Type:

NtpServerInfo

timestamps

NTP timestamps from the exchange

Type:

NtpTimestamps

main_details

Key metrics

Type:

NtpMainDetails

extra_details

Additional fields

Type:

NtpExtraDetails

NtpServerInfo

class server.app.dtos.NtpServerInfo.NtpServerInfo(ntp_version, ntp_server_ip, ntp_server_location, ntp_server_name, ntp_server_ref_parent_ip, ref_name)[source]

Bases: object

Represents the relevant metadata of an NTP server.

ntp_version

The version of NTP the user chose to use (backwards compatible)

Type:

int

ntp_server_ip

The IP of the server, either in IPv4 or IPv6 format

Type:

IPv4Address | IPv6Address | None

ntp_server_name

The name of the server

Type:

str | None

ntp_server_ref_parent_ip

The IP of the parent server (it is None if it is a root server)

Type:

IPv4Address | IPv6Address | None

ref_name

The name of the parent (reference) server or None if we can only get the IP

Type:

str | None

NtpTimestamps

class server.app.dtos.NtpTimestamps.NtpTimestamps(client_sent_time, server_recv_time, server_sent_time, client_recv_time)[source]

Bases: object

The four key timestamps used in NTP (Network Time Protocol) exchange between a client and a server

client_sent_time

Time when the request was sent by the client (t1)

Type:

PreciseTime

server_recv_time

Time when the request was received by the server (t2)

Type:

PreciseTime

server_sent_time

Time when the response was sent by the server (t3)

Type:

PreciseTime

client_recv_time

Time when the response was received by the client (t4)

Type:

PreciseTime

NtpMainDetails

class server.app.dtos.NtpMainDetails.NtpMainDetails(offset, rtt, stratum, precision, reachability)[source]

Bases: object

Represents the main measurements reported by an NTP server.

offset

Clock offset between the client and server, in seconds

Type:

float

rtt

Round-trip delay for NTP packet exchange, in seconds

Type:

float

stratum

Stratum level of the serve

Type:

int

precision

Precision of the system clock of the server

Type:

float

reachability

Reachability register

Type:

str

NtpExtraDetails

class server.app.dtos.NtpExtraDetails.NtpExtraDetails(root_delay, poll, root_dispersion, ntp_last_sync_time, leap)[source]

Bases: object

Represents additional measurements for a given NTP server.

root_delay

Total round-trip delay to the primary reference source

Type:

PreciseTime

poll

The poll interval (seconds) used by the probe during the measurement

Type:

int

root_dispersion

An estimate (seconds) of the maximum error due to clock frequency stability

Type:

PreciseTime

ntp_last_sync_time

Last time the server was synchronized

Type:

PreciseTime

leap

2-bit leap indicator; A value of 3 (11 in binary) represents an unsynchronized clock

Type:

int

PreciseTime

class server.app.dtos.PreciseTime.PreciseTime(seconds, fraction)[source]

Bases: object

Represents a single NTP timestamp.

seconds

The integer part of the timestamp (the first 32 bits).

Type:

int

fraction

The fractional part of the timestamp (the last 32 bits).

Type:

int

ProbeData

class server.app.dtos.ProbeData.ProbeData(probe_id, probe_addr, probe_location)[source]

Bases: object

Contains identifying and location information about a RIPE Atlas probe.

probe_id

The unique identifier of the probe

Type:

str

probe_addr

The IPv4 and IPv6 addresses of the probe

Type:

Tuple[IPv4Address | None, IPv6Address | None]

probe_location

Geographic location of the probe

Type:

ProbeLocation | None

class server.app.dtos.ProbeData.ServerLocation(country_code, coordinates)[source]

Bases: object

Represents the geographical location of a RIPE Atlas probe.

country_code

Two-letter ISO 3166-1 alpha-2 country code (e.g., ‘US’, ‘DE’) indicating the country where the probe is located

Type:

str

coordinates

The latitude and longitude of the probe’s physical location

Type:

Tuple[float, float]