# 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: - Django Web framework -- https://www.djangoproject.com/ ### Usage ### In order to use the DeviceAtlas Connectivity Analyser in your application, follow these steps: 1. Install the DeviceAtlas Connectivity Analyser module: ** Source archive file ** ```sh $ pip install ExtraTools/deviceatlas-connectivity-analyser-1.2.zip ``` ** Built archive file ** ```sh $ pip install ExtraTools/deviceatlas_connectivity_analyser-1.2-py2.py3-none-any.whl ``` 2. Enable the session framework. See https://docs.djangoproject.com/en/dev/topics/http/sessions/ 3. Create a view. See https://docs.djangoproject.com/en/dev/topics/http/views/ 4. Import the DeviceAtlas Connectivity Analyser within the view. ```python from connectivity_analyser import ConnectivityAnalyser ``` 5. Put the lines show below in the view. The ConnectivityAnalyser constructor requires a request and response object. Provide instances of django.http.HttpRequest and django.http.HttpResponse when creating the ConnectivityAnalyser object. ```python from connectivity_analyser import ConnectivityAnalyser from django.http import HttpResponse def index(request): # Create a response object response = HttpResponse() # The request and response objects must be passed to the ConnectivityAnalyser connectivity_analyser = ConnectivityAnalyser(request, response) # Get the result if connectivity_analyser.getDuration(): duration = connectivity_analyser.getDuration() quality = connectivity_analyser.getQuality() # Use the quality value and decide which content suites the user return response ``` Note: The ConnectivityAnalyser module is made to work with Django but it 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 ### Please see the Examples directory for examples that encompass the following scenarios: 1. **Quality of user's connection**: Located at Examples/connectivity_analyser/web_app - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ Copyright (c) Afilias Technologies Limited 2021. 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.Installation.html">Enterprise API Installation</a></li><li><a href="README.DeviceApi.html">Device Identification API</a></li><li><a href="README.DeviceApi-Config.html">Device Identification API Config</a></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li><a href="README.Upgrade.html">API Upgrade</a></li><li class="divider"></li><li><a href="./ApiDocs/index.html">DeviceAtlas API Docs</a></li><li class="divider"></li><li><a href="README.ClientSide.html">Client-side Component</a></li><li class="divider"></li><li class="disabled"><a href="README.ConnectivityAnalyser.html">Connectivity Analyser</a></li></ul></div>