The multiplayer session directory (MPSD) enables service-based Quality of Service (QoS) testing that allows your title to retrieve connection quality even if the title is not running. Your title can also explicitly perform in-title QoS testing on secure socket links and retrieve quality metrics this way. The core API for QoS testing this way is QualityOfService::MeasureQualityOfServiceAsync. With this API our title can specify and measure the metrics available through the QualityOfServiceMetric enumeration, including bandwidth and latency, as well as setting private QoS payloads. QoS metrics are measured against a set of Secure Device Addresses you specify in your code.
The following code snippet demonstrates the use of MeasureQualityOfServiceAsync.
// Create a list of metrics to measure.
Platform::Collections::Vector<Windows::Xbox::Networking::QualityOfServiceMetric
^ metrics = ref new Platform::Collections::Vector<Windows::Xbox::Networking::QualityOfServiceMetric();
metrics->Append(Windows::Xbox::Networking::QualityOfServiceMetric::LatencyAverage);
metrics->Append(Windows::Xbox::Networking::QualityOfServiceMetric::BandwidthUp);
metrics->Append(Windows::Xbox::Networking::QualityOfServiceMetric::BandwidthDown);
Platform::Collections::Vector<SecureDeviceAddress^>
^ addresses = ref new Platform::Collections::Vector<SecureDeviceAddress^();
addresses->Append(m_peerSecDeviceAddress);
IAsyncOperation<MeasureQualityOfServiceResult^
^ qosMeasurementOp = QualityOfService::MeasureQualityOfServiceAsync(
addresses,
metrics,
QOS_TIMEOUT,
QOS_PROBECOUNT);
MeasureQualityOfServiceResult^ result = nullptr;
create_task(qosMeasurementOp).then([this, &result](task<MeasureQualityOfServiceResult^ t)
{
try
{
result = t.get();
// use result, throws if failed
}
catch (Platform::Exception^ e)
{
// failure
}
}).wait();
The following are best practices when measuring QoS on secure sockets.