Feb
02

Automatically Turn Off and On Build to Lossess Based on Internal or External Access – VMware View 5.0

I’ll start off by saying the vast majority of users will never be able to tell the difference with Build to Lossess(BTL) turned off or on. VMware recommends in its PCOIP Performance Best Practices to have it turned off by default. BTL turned off is one of three major bandwidth saving in View 5.0. The other bandwidth saving features are the client side caching and the lossess codec for text.

I can see the need for it with special uses cases like in the Medical Field or high end graphical workstations in the office, but when you go home at night you just want to check an couple of emails. So lets begin.

All the PCOIP sessions variables can be controlled by Group Policy Administrative (ADM) Template files. The View ADM template files are installed in the install_directory\VMware\VMware View\Server\extras\GroupPolicyFiles . To get this to work we need to use:

    vdm_agent.adm – used to run a viscual basic script or PowerShell script on Connect or Reconnect
    pcoip.adm – used to set the defaults for Frame Rate, BTL, Image quality and many more.


The PCOIP will take the settings you provide and apply them at the time you connect to your virtual desktop. If you want to verify the settings are being used you can check the logs on the VM at :\ProgramData\VMware\VDM\logs ( I am pretending everyone is running Windows 7). The first few lines of code in the pcoip_server*timestampOfConnection*.log. will show the settings, see below.

02/02/2012, 22:04:16.737> LVL:0 RC: 0 MGMT_ENV :cTERA_MGMT_CFG::load_server_config_from_stores[1]: Did not process over-rideable pcoip defaults from registry.

02/02/2012, 22:04:16.737> LVL:0 RC: 0 MGMT_ENV :cTERA_MGMT_CFG::Registry setting parameter pcoip.audio_bandwidth_limit = 150

02/02/2012, 22:04:16.737> LVL:0 RC: 0 MGMT_ENV :cTERA_MGMT_CFG::Registry setting parameter pcoip.image_cache_size_mb = 300

02/02/2012, 22:04:16.737> LVL:0 RC: 0 MGMT_ENV :cTERA_MGMT_CFG::Registry setting parameter pcoip.enable_build_to_lossless = 0

You can only detect where the user has connected from after the fact, you will have to make your users disconnect to make the necessary changes. So I guess it’s not that automatic but it’s the best I good come up with.

How do you tell where the user connected from?

You can find out from the following registry key –
HKEY_CURRENT_USER\Volatile Environment\ViewClient_Broker_URL
If they are connecting from outside your corporate network it should be the name of your security server which you can check for. If your using an F5 device and no security servers you will have to use
HKEY_CURRENT_USER\Volatile Environment\ViewClient_IP_Address
and create your own logic. PowerShell might be the easiest to use because it has a LIKE operator which will make a quicker job of comparing strings.

So here is the code that you use to accomplish the task of turning BTL off. I named the text file Flip-BTL.vbs

'Declare Environment Variables

Dim ViewBroker, BTL

'Set Environment Variables

Set WSHShell = CreateObject("WScript.Shell")

'Lookup values in registry and assign to variables

ViewBroker = WSHShell.RegRead("HKEY_CURRENT_USER\Volatile Environment\ViewClient_Broker_URL")

BTL = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Teradici\PCoIP
\pcoip_admin_defaults\pcoip.enable_build_to_lossless")

'Check Build to Lossess and if they are connecting to a security server

If ((ViewBroker = "External-Broker-Name") And (BTL = 1)) Then

WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Teradici\PCoIP\
pcoip_admin_defaults\pcoip.enable_build_to_lossless","0","REG_DWORD"

'Test Message Box inform the user

MsgBox "Your Connected from a Remote Location, to get better performance please disconnect and connect to get optimal user experince. A new setting must be applied"

End If

'Check to see if they connected from home and turned BTL off but are now back on the LAN
If ((ViewBroker = "Internal") And (BTL = 0)) Then

WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Teradici\PCoIP\
pcoip_admin_defaults\pcoip.enable_build_to_lossless","1","REG_DWORD"

'Test Message Box inform the user

MsgBox "Your Performance is optimized for a slow link. To have the best user experience disconnect your session and log back in. A new setting must be applied"

End If

To get the code to run when the user connects into their session we must use the vdm_agent.adm. The graphic below shows a local policy but you should use an AD one for better manamgment.


Comments

  1. Great Post. You know I have been asking about this so having it as a reference will be hugely helpful

  2. thanks for this, very helpful, wanted to find a way to run scripts based on the view client info 🙂

Speak Your Mind

*