Sunday, February 26, 2023

Setting User Expectations - Part 2

 In Part 1 of this series, we discussed how to create a QoS indicator to inform the user of their expected experience before they even logon by making a few simple changes to the NetScaler. In part 2 of the series, we will add a graphical representation of the results. The strength of the connection will be represented by the number of bars in the graphic - the more bars, the stronger the connection.

The first step will be to upload the bar images which may be found here:

into the following directory:


Next, we need to add some css to the file: /var/netscaler/logon/themes/QoS/css/theme.css.

Insert the following:

#QoSbars {
.FourBars, .ThreeBars, .TwoBars, .OneBar, .NoBars {
   background-repeat: no-repeat;
.FourBars {
   background-image: url("../custom_media/FourBars.png");
.ThreeBars {
   background-image: url("../custom_media/ThreeBars.png");
.TwoBars {
   background-image: url("../custom_media/TwoBars.png");
.OneBar {
   background-image: url("../custom_media/OneBar.png");
.NoBars {
   background-image: url("../custom_media/NoBars.png");

The above changes need to be made to the primary NetScaler node and will be replicated to the secondary node.

The final changes need to be made to the file: /var/logon/LogonPoint/tmindex.html.

After making a backup, open the file and look for the following code (that we added in Part 1):

<div id="QoSinfo">
   <div id="QoStext">&nbsp;</div>

Add the following line after the QoSinfo <div>:

<div id="QoSbars" class="ThreeBars">&nbsp;</div>

Then, scroll to the bottom of the file to find where you added the JavaScript code, and replace the entire <script> section that you added with the below. You can customize your ranges by simply changing the values in the aLatencyRanges array below. The default below says that anything 50 ms. or below is considered Excellent, 51-100 ms. is Very Good, 101-130 ms is Good, 131-200 is Fair, and 200+ ms. is Poor.

    // QoS latency ranges - max value for range, class name for graphic, legend
    var aLatencyRanges = 
         [100,"ThreeBars","Very Good"],
    var testImgUrl = "https://" + location.hostname + "/vpn/images/Tick32.gif";
    //alert ("Using image: " + testImgUrl);
    //This method calculates the time it takes for the image to load 
    function checkLatency(url, callback) {
        var t=[], n=2, tcp, rtt;
        var ld = function() {
           t.push(+new Date);
           if(t.length > n) {
           else {
             var img = new Image;
             img.onload = ld;
             img.src=url+"?" + Math.random() + '=' + new Date;
    function displayQoS(latency) {
        var QoSbars = document.getElementById("QoSbars");
        var QoStext = document.getElementById("QoStext");
        for (i=0; i<aLatencyRanges.length;i++) {
            if(latency<=aLatencyRanges[i][0]) {
                var QoSclass = aLatencyRanges[i][1];
                var QoSrange = aLatencyRanges[i][2] + ' (' + latency + ' ms.)';
                QoSbars.className = QoSclass;
                QoStext.innerHTML = 'Connection Strength:<br>'+QoSrange; 
    function runQoS() {
       checkLatency(testImgUrl, displayQoS);

    // end of QoS modifications

Now when you browse to your logon page, in addition to having the connection strength is milliseconds, you will also have the strength displayed graphically.

No comments:

Post a Comment