Contenuto principale

Evaluate Host Capture Performance

Since R2023b

This example shows how to check your host performance capability for capturing data using the baseband receiver.

Introduction

When you capture data using a baseband application object, the capture function has two operating modes. You can capture data using the onboard radio memory buffer, which guarantees contiguous samples. Alternatively, you can bypass the buffer and capture data directly to the host computer. You can specify the desired data buffering behavior using the UseRadioBuffer name-value argument. In these scenarios, only direct-to-host capture is supported:

  • The capture length is greater than the onboard radio memory buffer size.

  • Your are using a USRP X310 radio with a TwinRX daughterboard and are capturing data on more than two antennas. This requirement is a hardware limitation.

When you capture data directly to the host, the performance that you can achieve depends on the capability of your host computer. Many factors can have an impact on your ability to transfer data over your Ethernet connection to your host computer at high rates without dropping samples. You can use this example to evaluate the capability of your physical set up to capture data directly to the host.

Set Up Radio

Call the radioConfigurations function. The function returns all available radio setup configurations that you saved using the Radio Setup wizard.

savedRadioConfigurations = radioConfigurations;

To update the dropdown menu with your saved radio setup configuration names, click Update. Then select the radio to use with this example.

savedRadioConfigurationNames = [string({savedRadioConfigurations.Name})];
radioConfig = savedRadioConfigurationNames(1) ;

Use the radioConfigurations function with the configuration name to create a radio object.

radio = radioConfigurations(radioConfig);

Configure Baseband Receiver

Create a baseband receiver application object with the radio object. Because the object requires exclusive access to radio hardware resources, before running this example for the first time, clear any other object associated with the specified radio. In subsequent runs, to speed up the execution time of the example, reuse your new workspace object.

if ~exist("bbrx","var")
    bbrx = basebandReceiver(radio);
end

Configure Behavior upon Dropped Samples

Set the DroppedSamplesAction property to 'none'. The default setting is 'error', which stops the capture with an error message when samples are dropped.

bbrx.DroppedSamplesAction = 'none';

Evaluate Performance at Multiple Sample Rates

Set the capture length equivalent to 2 GB.

captureLength = 2*2^28;

Select a set of sample rates based on the network connection you have configured using the Radio Setup wizard. If you have a 10 Gigabit NIC, set the highest sample rate to be the highest supported rate of your radio. If you have a 1 Gigabit NIC, set the highest sample rate to be 25 MHz. The test iterates from the selected highest rate and go down based on the intervalRate until a capture completes without dropping samples. Large captures at lower sample rates can take some time. For example, a single 2 GB capture at a sample rate of 10MHz will take over 54 seconds.

highSpeedTest = true;
% Define the lowest sample rate once
lowRate = 1e6;

if ~highSpeedTest
    highRate = 25000000;
    intervalRate = 5e6;
    sampleRates = (highRate:-intervalRate:lowRate)';
else
    % Get maximum sample rate supported by the radio
    highRate = hMaxSampleRate(radioConfig);
    intervalRate = 10e6;
    % Construct sample rates: max, half-max, then intervals down to lowRate
    sampleRates = [highRate; highRate/2; (highRate/2-intervalRate:-intervalRate:lowRate)'];
    % Remove duplicates if highRate/2 falls on an interval
    sampleRates = unique(sampleRates, 'stable');
end

To retry captures automatically if samples are dropped, set retryUnsuccessfulCaptures to true.

retryUnsuccessfulCaptures = true;

Iterate through the sample rates, starting with the highest sample rate, until you successfully capture data without dropping samples. Set the UseRadioBuffer name-value argument to false to capture directly to host.

% Preallocate
numRates = numel(sampleRates);
successfulCapture = false(numRates,1);

for idx = 1:numRates
    bbrx.SampleRate = sampleRates(idx);
    rateStr = num2str(bbrx.SampleRate/1e6, '%.2f'); % Format once

    disp(['Capturing at ' rateStr ' MHz']);

    % Attempt capture
    [~, ~, droppedSamples] = capture(bbrx, captureLength, UseRadioBuffer=false);

    % Retry if needed
    if retryUnsuccessfulCaptures && droppedSamples
        disp(['Retrying capture at ' rateStr ' MHz due to dropped samples']);
        [~, ~, droppedSamples] = capture(bbrx, captureLength, UseRadioBuffer=false);
    end

    successfulCapture(idx) = ~droppedSamples;

    % Exit loop after a successful capture
    if ~droppedSamples
        % Trim arrays to attempted rates only
        sampleRates = sampleRates(1:idx);
        successfulCapture = successfulCapture(1:idx);
        break;
    end
end
Capturing at 153.60 MHz
Retrying capture at 153.60 MHz due to dropped samples
Capturing at 76.80 MHz

Tabulate Capture Results

sampleRatesMHz = sampleRates/1e6;
captureResultsTable = table(sampleRatesMHz,successfulCapture);
disp(captureResultsTable)
    sampleRatesMHz    successfulCapture
    ______________    _________________

        153.6               false      
         76.8               true       

The results show you the highest sample rate at which contiguous IQ data has been captured with your hardware setup. This number can vary between runs. For more information about how to optimize the transfer speed between the host computer and the radio, see Resolve Issues with Data Transfer.

See Also

Functions

Objects

Topics