# DeviceAtlas Connectivity Analyser # The DeviceAtlas Connectivity Analyser is used to measure the round trip time when sending a payload of a fixed size to a client. This measures a combination of latency and bandwidth. The measured time is then used to categorize the client's current connection into low, medium or high. ### Dependencies ### This library depends on the following third party libraries: 1) django Web framework -- https://www.djangoproject.com/ ### Usage ### In order to use the DeviceAtlas Connectivity Analyser in your application, follow these steps: 1. Enable session. See https://docs.djangoproject.com/en/dev/topics/http/sessions/ 2. Create a view and Import ConnectivityAnalyser library into it. import class ConnectivityAnalyser from connectivity_analyser.py 3. Put the lines shown bellow in the view. ConnectivityAnalyser requires a request and response object. Provide instances of django.http.HttpRequest and django.http.HttpResponse when creating object. from django.http import HttpResponse sys.path.append('path/to/ConnectivityAnalyser') from connectivity_analyser import ConnectivityAnalyser ```python def index(request): # Create response object response = HttpResponse() # request and response objects must be passed to ConnectivityAnalyser connectivityAnalyser = ConnectivityAnalyser(request, response) # Get result if connectivityAnalyser.getDuration(): duration = connectivityAnalyser.getDuration() quality = connectivityAnalyser.getQuality() # use the quality value and decide which content suites the user return response ``` 4. The ConnectivityAnalyser library and the provided example are made to work with django but they can easily be modified to be used with any other python web framework. To do so adopt connectivity_analyser.py to the request and response objects of other python based web frameworks. ### Options ### - The amount of data to send to the client as part of the bandwidth measurement. Defaults to 1KB. PAYLOAD_SIZE_BYTES = 1024 - The thresholds to define the low and mid tiers. The threshold is defined in ms. Everything faster than the mid threshold is classified as high quality. LOW_THRESHOLD_MS = 900 MEDIUM_THRESHOLD_MS = 400 - Frequency of measurement for a given user. If the frequency is not set to 1 (on every request) then between the analysis the previous result is returned e.g: 3 means analyse a user's connectivity once per each three requests. DEFAULT_FREQUENCY = 1 ### Example ### The DeviceAtlas Connectivity Analyser comes with an example application which you can find inside "Examples" directory. This example uses DeviceAtlas Connectivity Analyser to find out the quality of user's connection, then based on the quality an appropriate photo is selected and shown to the user. There are three photos with different size and compression ratio, therefore different file size. This example requires Python Django 1.6+. To run the example: 1. Enter Examples/ConnectivityAnalyser/ExampleWebApp directory 2. python manage.py runserver - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _(c) 2021 DeviceAtlas Limited. All rights reserved. https://deviceatlas.com _ <!-- HTML+JS for document formatting when opened in browser --> <div class="btn-group" id="main-menu" style="float:right"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Menu<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="README.html">Main</a></li><li><a href="README.DeviceApi.html">Device Detection API</a></li><li><a href="README.Upgrade.html">Device Detection API Upgrade</a></li><li><a href="DeviceApiDocs/mobi.mtld.da.device.device_api.DeviceApi-class.html">Device API docs</a></li><li class="divider"></li><li><a href="README.ClientSide.html">Client Side Component</a></li><li class="disabled"><a href="README.ConnectivityAnalyser.html">Connectivity Analyser</a></li><li class="divider"></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li><a href="CarrierApiDocs/mobi.mtld.da.carrier.carrier_api.CarrierApi-class.html">Carrier API docs</a></li></ul></div>