How to calculate latency (or delay) from statistics? - latency

I would to calculate latency time of a running audio/video call.
According to these parameters of RTCStatsReport object, how can I retrieve the delay time?
latency = packetsize / delay + bandwidth

I think what you want is the RTT (round-trip time), which is available as "googRtt" in Chrome. You can see it if you go to chrome://webrtc-internals or you can get it programmatically via the stats interface: https://webrtc.github.io/samples/src/content/peerconnection/constraints/ (click the capture and connect button and then scroll down to the statistics).
Note that two of the reports should have googRtt in them: one is for audio and the other for video.

Related

Is it possible to accelerate time in grafana?

Actually what I want to do,
I created dashboards to monitor the alert status in grafana.
I created fake data in my system to simulate my alert situations on these boards. The time of this data covers the range now - now + 12h. In fact, it takes a long time to analyze the alert status in real data. For this reason, I cannot be very flexible on my alert rules. I have to wait until the end of this period to see alert status in the system. (I have many states like this actually.) Grafana creates pending, alerting, and ok states according to the records in my database. Is there a method to quickly verify my tests without waiting for this time?
The main problem is that it is fairly expensive to do in a data source agnostic way. The way worked in Bosun is you would select a time range, and then an interval or a number of queries to run.
Setting both From and To enables testing multiple iterations of the selected alert over time. The number of iterations depends on the setting to the two linked fields Intervals and Step Duration at 3 Changing one changes the other. Intervals will be the number of runs to do even spaced out over the duration of From to To and Step Duration is how much time in minutes should be between intervals. Doing a test over time will populate the Timeline tab 5 which draws a clickable graphic of severity states for each item in the set:
It would then run all those queries with a pool limiting simultaneous queries. For an interval of say 5 minutes, it would run adjacent 5 minute queries.
So this would speed up the alert authoring and testing workflow significantly. But it would best be implemented as a job system. This is because with more expensive queries, or range/interval combination that is a fair amount of runs, it may take a minute or so - so having to wait on an open network connection is less ideal.
So I found I generally used in two modes:
To tweak a specific alert that had fired at some time
To get a general overview of how much the alert rule would trigger for the historical data
For the general over, a larger time range is generally wanted, which means more queries if the interval is kept the same. And with a feature like FOR (Pending), you would have to use the same interval it would actually run at.
So possible, has some limitations, and some care needs to be taken to do it right. But extremely useful in my experience.

Is it recommended to set the FTDI delay (latency_timer) to 1ms?

I've struggled over an article from FTDI about the Latency Timer. Setting a Custom Default Latency Timer Value
... although 1ms is not recommended as this is the same as the USB frame length.
I've setup in several project the latency to 1ms (I want low round robin delays). So is this not recommended? Would be 2ms the "correct" alternative?
I don't know, how old the web page "Setting a Custom Default Latency Timer Value" is. Application note AN232B-04 does not have a special note for 1 ms latency timer.
Note: Latency timer matters only for small amounts of data (see page 6 of the application note) including last fragment of large data.
From my experience: FT2232C/L/D work fine with 1 ms latency, but in case of MPSSE mode SEND IMMEDIATE command gives even faster data transmission.
For UART mode an EVENT CHARACTER (one can set the character to '\n' in text mode or packet delimiter in packet mode) also triggers transmission with no regards on latency timer.
As you can read in the linked documentation 2ms should be correct.
The valid range for the latency timer is 1ms - 255ms

Show current internet speed in iOS [duplicate]

I know with reachability you can check if you are connected to the internet. But is there a way to determine the speed of that connection?
I am trying to calculate upload speed as well as download speed separately.
How to determine the speed on internet programmatically?
If you use NSURLConnection to grab a large file (say, 1 MB or greater), you can use a delegate to track intermediate download progress.
Specifically: If you measure the difference in bytes downloaded and the difference in time between calls to the delegate, then you can calculate the ongoing speed in bytes per second (or other time unit).
step 1: Take downloadable file url and configure a it with a NSURLSession and its method dataTaskWithUrl.
step 2 : Integrate NSURLSessionDelegate, NSURLSessionDataDelegate method in your controller.
step 3: Take two CFAbsoluteTime variable which store starTime and assign CFAbsoluteTimeGetCurrent() and second one stopTime in didReceiveData: Delegate method.
step 4 : Count speed like this
CFAbsoluteTime elapsedTime = stopTime - startTime;
float speedOfConnection = elapsedTime != 0 ? [data length] / (stopTime - startTime) / 1024.0 / 1024.0 : -1;
There are 2 main ways to calculate download/upload speed.
Passive testing - This is done by using iOS methods which give you currently transferred bytes. You poll this frequently and calculate speed by transferred bytes divided by time. This method will give you speed which is more closer to the actual user experience. However, it will not provide you with capacity measurement - i.e what is the expected capacity of the connection. For example for fixed networks ISPs usualy sell packages based on speed - e.g. 100 Mbit package, 1 Gbit package. If you want to see if that ISP is delivering the speed, Passive approach is not the way! The speeds will be much lower as users are not using full capacity all the time.
Active testing - this method requires downloading and uploading data to the remote server to get the download/upload speed and latency. This is what previous commenters here suggested. The important way is to realize if you want to test using single thread or multiple threads. Single thread will not saturate the internet connection and will not show you maximum capacity of the connection.
There are many methodologies how to test "internet speed", there is no one "true" speed. You can check following standards to give you more idea what is the recommended way:
https://itu.int/en/ITU-T/C-I/Pages/IM/Internet-speed.aspx
https://itu.int/itu-t/recommendations/rec.aspx?rec=q.3960
https://itu.int/ITU-T/recommendations/rec.aspx?rec=14125
https://tools.ietf.org/pdf/rfc6349.pdf
You can also use our iOS SDK which should do what you need and is compliant with ITU standard:
https://github.com/speedchecker/speedchecker-sdk-ios

How to simulate ramp-up with Locust?

As I know Ramp-up function has been removed from locust.
Just wondering if the hatching process was the same as or similar to ramp-up? Or is there anyway to simulate the situation?
Not sure about what ramp up function you are talking about. There are plenty of options for controlling ramp-up in locust, including the new step-load function:
--step-load Enable Step Load mode to monitor how performance
metrics varies when user load increases. Requires
--step-clients and --step-time to be specified.
--step-clients STEP_CLIENTS
Client count to increase by step in Step Load mode.
Only used together with --step-load
--step-time STEP_TIME
Step duration in Step Load mode, e.g. (300s, 20m, 3h,
1h30m, etc.). Only used together with --step-load
Just found a workaround by Taurus to schedule the load.

Determine the speed on internet programmatically

I know with reachability you can check if you are connected to the internet. But is there a way to determine the speed of that connection?
I am trying to calculate upload speed as well as download speed separately.
How to determine the speed on internet programmatically?
If you use NSURLConnection to grab a large file (say, 1 MB or greater), you can use a delegate to track intermediate download progress.
Specifically: If you measure the difference in bytes downloaded and the difference in time between calls to the delegate, then you can calculate the ongoing speed in bytes per second (or other time unit).
step 1: Take downloadable file url and configure a it with a NSURLSession and its method dataTaskWithUrl.
step 2 : Integrate NSURLSessionDelegate, NSURLSessionDataDelegate method in your controller.
step 3: Take two CFAbsoluteTime variable which store starTime and assign CFAbsoluteTimeGetCurrent() and second one stopTime in didReceiveData: Delegate method.
step 4 : Count speed like this
CFAbsoluteTime elapsedTime = stopTime - startTime;
float speedOfConnection = elapsedTime != 0 ? [data length] / (stopTime - startTime) / 1024.0 / 1024.0 : -1;
There are 2 main ways to calculate download/upload speed.
Passive testing - This is done by using iOS methods which give you currently transferred bytes. You poll this frequently and calculate speed by transferred bytes divided by time. This method will give you speed which is more closer to the actual user experience. However, it will not provide you with capacity measurement - i.e what is the expected capacity of the connection. For example for fixed networks ISPs usualy sell packages based on speed - e.g. 100 Mbit package, 1 Gbit package. If you want to see if that ISP is delivering the speed, Passive approach is not the way! The speeds will be much lower as users are not using full capacity all the time.
Active testing - this method requires downloading and uploading data to the remote server to get the download/upload speed and latency. This is what previous commenters here suggested. The important way is to realize if you want to test using single thread or multiple threads. Single thread will not saturate the internet connection and will not show you maximum capacity of the connection.
There are many methodologies how to test "internet speed", there is no one "true" speed. You can check following standards to give you more idea what is the recommended way:
https://itu.int/en/ITU-T/C-I/Pages/IM/Internet-speed.aspx
https://itu.int/itu-t/recommendations/rec.aspx?rec=q.3960
https://itu.int/ITU-T/recommendations/rec.aspx?rec=14125
https://tools.ietf.org/pdf/rfc6349.pdf
You can also use our iOS SDK which should do what you need and is compliant with ITU standard:
https://github.com/speedchecker/speedchecker-sdk-ios