Update rtpAnalyze matlab tool to handle reordered packets

With this change, the tool will find and mark reordered packets in the
plot. Furthermore, the instantaneous send bitrate will be correct even
for reordered packets.

BUG=webrtc:2692
R=tina.legrand@webrtc.org

Review URL: https://codereview.webrtc.org/1172533004.

Cr-Commit-Position: refs/heads/master@{#9443}
This commit is contained in:
Henrik Lundin 2015-06-16 09:28:09 +02:00
parent ac81163011
commit 76381d921f

View File

@ -65,9 +65,12 @@ if length(uPT) > 1
end
fprintf('\n');
fprintf('Packets: %i\n', length(SeqNo));
SortSeqNo = sort(SeqNoUW);
fprintf('Missing sequence numbers: %i\n', ...
length(find(diff(sort(SeqNoUW)) > 1)));
fprintf('Reordered packets: %i\n', length(find(diff(sort(SeqNoUW)) < 1)));
length(find(diff(SortSeqNo) > 1)));
fprintf('Duplicated packets: %i\n', length(find(diff(SortSeqNo) == 0)));
reorderIx = findReorderedPackets(SeqNoUW);
fprintf('Reordered packets: %i\n', length(reorderIx));
tsdiff = diff(TimeStampUW);
tsdiff = tsdiff(diff(SeqNoUW) == 1);
[utsdiff, ~, ixtsdiff] = unique(tsdiff);
@ -117,8 +120,20 @@ fprintf('Received average bitrate: %i kbps\n', ...
%% Plots.
delay = ArrTime - SendTimeMs;
delay = delay - min(delay);
delayOrdered = delay;
delayOrdered(reorderIx) = nan; % Set reordered packets to NaN.
delayReordered = delay(reorderIx); % Pick the reordered packets.
sendTimeMsReordered = SendTimeMs(reorderIx);
% Sort time arrays in packet send order.
[~, sortix] = sort(SeqNoUW);
SendTimeMs = SendTimeMs(sortix);
Size = Size(sortix);
delayOrdered = delayOrdered(sortix);
figure
plot(SendTimeMs / 1000, delay);
plot(SendTimeMs / 1000, delayOrdered, ...
sendTimeMsReordered / 1000, delayReordered, 'r.');
xlabel('Send time [s]');
ylabel('Relative transport delay [ms]');
title(sprintf('SSRC: %s', SSRC{1}));
@ -130,6 +145,23 @@ xlabel('Send time [s]');
ylabel('Send bitrate [kbps]');
end
%% Subfunctions.
% findReorderedPackets returns the index to all packets that are considered
% old compared with the largest seen sequence number. The input seqNo must
% be unwrapped for this to work.
function reorderIx = findReorderedPackets(seqNo)
largestSeqNo = seqNo(1);
reorderIx = [];
for i = 2:length(seqNo)
if seqNo(i) < largestSeqNo
reorderIx = [reorderIx; i]; %#ok<AGROW>
else
largestSeqNo = seqNo(i);
end
end
end
%% Auto-generated subfunction.
function [SeqNo,TimeStamp,SendTime,Size,PT,M,SSRC] = ...
importfile(filename, startRow, endRow)