主要内容

Simulate FTP Model 1 Traffic in 5G Network

R2026b

File transfer protocol (FTP) Model 1 generates traffic according to a Poisson arrival process. In this model, each user equipment(UE) node handles only one file transfer session at a time, although file transfer sessions for different UE nodes can overlap in time. Each session transfers a file of fixed size. This example shows how to simulate FTP Model 1 in a 5G network using the networkTrafficFTPModel1 object. The example also verifies that the generated traffic exhibits the expected Poisson arrival characteristics.

Configure and Simulate Network Scenario

Set the random number generator seed.

rng(42,"twister")

Create the wireless network simulator.

wns = wirelessNetworkSimulator.init;

Specify the number of UE nodes in the cell.

numUsersInCell = 10;

Specify the simulation duration (in seconds).

simulationTime = 10;  

Specify the number of frames.

numFrames = simulationTime*100;

Create a gNB node.

gNB = nrGNB(ChannelBandwidth=50e6);

Randomly place the UE nodes in a 1000 m by 1000 m deployment area.

uePositions = [randi([0 1000],numUsersInCell,2) ...
    zeros(numUsersInCell,1)];

Create the UE nodes.

UEs = nrUE(Position=uePositions);

Connect the UE nodes to the gNB node.

connectUE(gNB,UEs)

Configure an FTP Model 1 traffic source for each UE node. The UserArrivalRate property of the networkTrafficFTPModel1 object specifies the average number of user arrivals per second (file transfer rate) across the entire network. FTP Model 1 generates file arrivals according to a Poisson process and distributes the file arrivals across the UE nodes.

Configure a file size of 3000 bytes. The application divides the file into three packets:

  • Two maximum-size packets of 1500 bytes each, including a 40-byte TCP/IP header and a 1460-byte payload

  • One packet containing the remaining 80-byte payload and a 40-byte TCP/IP header

arrivalRate = 2.5;       % network-wide user arrival rate (files/sec)
fileSize = 3e3/1e6;      % MB
% Create an FTP Model 1 traffic source for each UE node
ftpMod1 = networkTrafficFTPModel1(numUsersInCell,simulationTime, ...
    UserArrivalRate=arrivalRate,FileSize=fileSize);
% Add a traffic source for each UE node and configure the UE node
% as the destination of the generated application traffic
for i = 1:numUsersInCell
    addTrafficSource(gNB,ftpMod1(i),DestinationNode=UEs(i))
end

Add the gNB and UE nodes to the wireless network simulator.

addNodes(wns,gNB)
addNodes(wns,UEs)

Create a scheduling logger and record downlink scheduling information throughout the simulation.

% simLogger = helperNRSchedulingLogger(numFrames,gNB, ...
% UEs,LinkDirection="DL");

Run the simulation.

run(wns,simulationTime)

Obtain statistics from the gNB and UE nodes.

gNBStats = statistics(gNB,"all");
ueStats = statistics(UEs);

Retrieve Scheduling Logs

Retrieve the downlink scheduling logs.

% dlLogs = simLogger.getSchedulingLogs();
% logData = dlLogs(2:end,:);
% bufferCol = simLogger.ColumnIndexMap("Buffer Status of UEs (bytes)");
% timestampCol = simLogger.ColumnIndexMap("Timestamp (ms)");
% numSlots = size(logData,1);

Record the transmit-buffer occupancy of each UE node at every scheduling instant.

% bufferHistory = zeros(numSlots,numUsersInCell);
% timestamps = zeros(numSlots,1);
% for s = 1:numSlots
%     bufStatus = logData{s,bufferCol};
%     if ~isempty(bufStatus)
%         bufferHistory(s,:) = bufStatus';
%     end
%     timestamps(s) = logData{s, timestampCol};
% end

Record the arrival time of each detected file and count the total number of file arrivals observed during the simulation.

% totalArrivals = 0;
% arrivalTimesMs = cell(numUsersInCell,1);
% 
% fprintf("Configured UserArrivalRate (network-wide): %.1f files/sec\n", ...
%     arrivalRate);
% fprintf("Expected per-UE rate: %.2f files/sec\n", ...
%     arrivalRate/numUsersInCell);
% fprintf("\nPer-UE file arrivals:\n");
% for ue = 1:numUsersInCell
%     prevBuffer = 0;
%     arrivals = [];
%     for s = 1:numSlots
% 
%         currBuffer = bufferHistory(s,ue);
%         if currBuffer > 0 && prevBuffer == 0
%             arrivals = [arrivals;timestamps(s)];
%         end
%         prevBuffer = currBuffer;
%      end
% 
%     totalArrivals = totalArrivals + numel(arrivals);
%     arrivalTimesMs{ue} = arrivals;
%     fprintf('  UE %2d: %d arrivals at t = [%s] ms\n', ...
%         ue, numel(arrivals),strjoin(string(arrivals'), ', '));
% end

Calculate Observed Network-Wide User Arrival Rate

Calculate the observed network-wide user arrival rate from the detected file arrivals and compare it with the configured UserArrivalRate. FTP Model 1 generates arrivals randomly. As a result, the measured arrival rate can differ slightly from the configured value in a finite-duration simulation.

% measuredUserArrivalRate = totalArrivals / simulationTime;
% fprintf('Measured network-wide rate: %.2f files/sec\n', ...
%    measuredUserArrivalRate);

See Also

Objects

Functions