9097c114 by David LaPalomento

Plot segments when they finish arriving, not when they start

Remove playlist bitrate lines between simulation runs. Make sure the plot displays scenarios where the link capacity exceeds the maximum bitrate playlist properly.
1 parent 826f480b
...@@ -191,10 +191,6 @@ ...@@ -191,10 +191,6 @@
191 // segment response headers arrive after the propogation delay 191 // segment response headers arrive after the propogation delay
192 setTimeout(function() { 192 setTimeout(function() {
193 var arrival = Math.ceil(+new Date() * 0.001); 193 var arrival = Math.ceil(+new Date() * 0.001);
194 results.playlists.push({
195 time: arrival,
196 bitrate: +request.url.match(/(\d+)-\d+$/)[1]
197 });
198 request.setResponseHeaders({ 194 request.setResponseHeaders({
199 'Content-Type': 'video/mp2t' 195 'Content-Type': 'video/mp2t'
200 }); 196 });
...@@ -204,6 +200,7 @@ ...@@ -204,6 +200,7 @@
204 if (remaining - value.bandwidth <= 0) { 200 if (remaining - value.bandwidth <= 0) {
205 // send the response body once all bytes have been delivered 201 // send the response body once all bytes have been delivered
206 setTimeout(function() { 202 setTimeout(function() {
203 var time = Math.ceil(+new Date() * 0.001);
207 if (request.aborted) { 204 if (request.aborted) {
208 return; 205 return;
209 } 206 }
...@@ -211,11 +208,15 @@ ...@@ -211,11 +208,15 @@
211 request.response = new Uint8Array(segmentSize * 0.125); 208 request.response = new Uint8Array(segmentSize * 0.125);
212 request.setResponseBody(''); 209 request.setResponseBody('');
213 210
214 buffered += segmentDuration; 211 results.playlists.push({
212 time: time,
213 bitrate: +request.url.match(/(\d+)-\d+$/)[1]
214 });
215 // update the buffered value 215 // update the buffered value
216 buffered += segmentDuration;
216 results.buffered[results.buffered.length - 1].buffered = buffered; 217 results.buffered[results.buffered.length - 1].buffered = buffered;
217 results.effectiveBandwidth.push({ 218 results.effectiveBandwidth.push({
218 time: Math.ceil(+new Date() * 0.001), 219 time: time,
219 bandwidth: player.hls.bandwidth 220 bandwidth: player.hls.bandwidth
220 }); 221 });
221 }, ((remaining / value.bandwidth) + i) * 1000); 222 }, ((remaining / value.bandwidth) + i) * 1000);
...@@ -309,7 +310,9 @@ ...@@ -309,7 +310,9 @@
309 })); 310 }));
310 y.domain([0, Math.max(d3.max(data.bandwidth, function(data) { 311 y.domain([0, Math.max(d3.max(data.bandwidth, function(data) {
311 return data.bandwidth; 312 return data.bandwidth;
312 }), d3.max(data.options.playlists))]); 313 }), d3.max(data.options.playlists), d3.max(data.playlists, function(data) {
314 return data.bitrate;
315 }))]);
313 316
314 // time axis 317 // time axis
315 svg.selectAll('.axis').remove(); 318 svg.selectAll('.axis').remove();
...@@ -330,6 +333,7 @@ ...@@ -330,6 +333,7 @@
330 .text('Bitrate (kb/s)'); 333 .text('Bitrate (kb/s)');
331 334
332 // playlist bitrate lines 335 // playlist bitrate lines
336 svg.selectAll('.line.bitrate').remove();
333 svg.selectAll('.line.bitrate') 337 svg.selectAll('.line.bitrate')
334 .data(data.options.playlists) 338 .data(data.options.playlists)
335 .enter().append('path') 339 .enter().append('path')
......