LATENCY_BUDGET
-
The LATENCY_BUDGET policy applies to topic, data reader, and data writer entities via the
latency_budget
member of their respective QoS policy structures. Below is the IDL related to the LatencyBudget QoS policy:
struct LatencyBudgetQosPolicy {
Duration_t duration;
};
-
The default value of
duration
is zero indicating that the delay should be minimized. This policy is considered a hint to the transport layer to indicate the urgency of samples being sent. OpenDDS uses the value to bound a delay interval for reporting unacceptable delay in transporting samples from publication to subscription. This policy is used for monitoring purposes only at this time. Use the TRANSPORT_PRIORITY policy to modify the sending of samples. The data writer policy value is used only for compatibility comparisons and if left at the default value of zero will result in all requested
duration
values from data readers being matched.
-
An additional listener extension has been added to allow reporting delays in excess of the policy
duration
setting. The
OpenDDS::DCPS::DataReaderListener
interface has an additional operation for notification that samples were received with a measured transport delay greater than the
latency_budget
policy duration. The IDL for this method is:
struct BudgetExceededStatus {
long total_count;
long total_count_change;
DDS::InstanceHandle_t last_instance_handle;
};
void on_budget_exceeded(
in DDS::DataReader reader,
in BudgetExceededStatus status);
-
To use the extended listener callback you will need to derive the listener implementation from the extended interface, as shown in the following code fragment:
class DataReaderListenerImpl
: public virtual
OpenDDS::DCPS::LocalObject<OpenDDS::DCPS::DataReaderListener>
-
Then you must provide a non-null implementation for the
on_budget_exceeded()
operation. Note that you will need to provide empty implementations for the following extended operations as well:
on_subscription_disconnected()
on_subscription_reconnected()
on_subscription_lost()
on_connection_deleted()
-
OpenDDS also makes the summary latency statistics available via an extended interface of the data reader. This extended interface is located in the
OpenDDS::DCPS
module and the IDL is defined as:
struct LatencyStatistics {
GUID_t publication;
unsigned long n;
double maximum;
double minimum;
double mean;
double variance;
};
typedef sequence<LatencyStatistics> LatencyStatisticsSeq;
local interface DataReaderEx : DDS::DataReader {
/// Obtain a sequence of statistics summaries.
void get_latency_stats( inout LatencyStatisticsSeq stats);
/// Clear any intermediate statistical values.
void reset_latency_stats();
/// Statistics gathering enable state.
attribute boolean statistics_enabled;
};
-
To gather this statistical summary data you will need to use the extended interface. You can do so simply by dynamically casting the OpenDDS data reader pointer and calling the operations directly. In the following example, we assume that
reader
is initialized correctly by calling
DDS::Subscriber::create_datareader()
:
DDS::DataReader_var reader;
// ...
// To start collecting new data.
dynamic_cast<OpenDDS::DCPS::DataReaderImpl*>(reader.in())->
reset_latency_stats();
dynamic_cast<OpenDDS::DCPS::DataReaderImpl*>(reader.in())->
statistics_enabled(true);
// ...
// To collect data.
OpenDDS::DCPS::LatencyStatisticsSeq stats;
dynamic_cast<OpenDDS::DCPS::DataReaderImpl*>(reader.in())->
get_latency_stats(stats);
for (unsigned long i = 0; i < stats.length(); ++i)
{
std::cout << "stats[" << i << "]:" << std::endl;
std::cout << " n = " << stats[i].n << std::endl;
std::cout << " max = " << stats[i].maximum << std::endl;
std::cout << " min = " << stats[i].minimum << std::endl;
std::cout << " mean = " << stats[i].mean << std::endl;
std::cout << " variance = " << stats[i].variance << std::endl;
}