Now that FrameHawk is released (can we get a whoop whoop!?!) we can all get our hands dirty on testing this amazing piece of technology. FrameHawk helps you serve users (or subscribers as we’d like to name them) from locations where the connection is not as reliable as we’d like. When we’re facing lossy connections, commonly referred to as packet loss, this extension of HDX ensures users receive a great experience in a responsive session.

To ensure the product works as expected, or to demonstrate the capabilities, you need to test, test and test some more. Since most network are highly reliable (with 0% packet loss) testing is challenging, so we need a WAN emulator that can introduce certain WAN characteristics. In the past I used WANem from Tata Consulting, which is available for free here: http://wanem.sourceforge.net/

In this blog I’ll walk you through the installation of WANem in a XenServer environment and the configuration of the machine hosting the VDA.

This guide is based on the Citrix Demo Center environment (Citrix Workspace Suite – MR1.1).

Virtual Network Topology

Let’s start by explaining what we’re trying to accomplish before we’re diving into the fun stuff.

The goal we have is to simulate the connection between the client (running the Citrix Receiver) and the endpoint (running the VDA). This is the only path where we’d like to change the characteristics of (eg. introduce latency, packet loss), not the rest of the network. So we don’t want to change the path to the XenDesktop Delivery Controller or the Internet as that would influence the user experience in an unrealistic way (there’s usually no packet loss on the LAN).

The ICA traffic is processed by the WAN emulator, the other (eg. Internet) traffic isn’t.

In the example topology a client running the Citrix Receiver is connecting to a Windows desktop running the XenDesktop VDA with FrameHawk. All traffic if flowing through from the Citrix Receiver through the Citrix NetScaler *)   to the VDA. The return traffic from the VDA is passing through the WAN emulator (WANem) where latency / packet loss is introduced. Or, when the client is on the same network the NetScaler is not used.

*) Requires UDP support for NetScaler Gateway (not available at the moment of writing this article)

Create WANem Virtual Machine

In this step we’re creating a new virtual machine for the WANem system in XenServer.

1. Create a New VM
2. Select the Other install media template. Click Next
3. Name the VM WANem. Click Next
4. Select the WANemv2.3.iso from the ISO library. Click Next
5. Select the server where the VM will be placed. Click Next
6. Keep the default settings 256MB is sufficient. Click Next
7. Add a Virtual Disk (Name: WANem, Size: 20GB). Click Add
8. Verify there’s a virtual disk attached. Click Next
9. Remove all other networks so only the internal network remains. Click Next
10. Ensure the Start the new VM automatically is checked. Click Create Now

Install WANem

In this step we’ll install and configure WANem in the XenServer VM.
WANem can be used directly from the ISO but the configuration is lost after every reboot. In this step we’ll move the installation to the virtual disk to ensure we’ll have a persistent setup.

1. Press Enter to boot
2. Anser the questions asked

Do you want to configure all interface via DHCP: y
UNIX password: *****(doesn’t matter, is never used)
Type the following commands:

   exit2shell
   knx2hd

3. Press OK
4. Press OK
5. Select 1. Partition and press OK
6. Select hda QEMU HARDDISK (21.4748 GB). Press Next
TIP: use SPACE
7. Select 2. Template 1. Press OK
8. Press Yes
9. Press Yes
10. When the installation still complains there’s no disk found (after partitioning the disk) then QUIT the installation and start it again by issuing the command: knx2hd
11. Select 1. Configure Installation. Press OK
12. Select debian. Press Next
13. Select /dev/hda2. Press Next
14. Select ext3. Press Next

The accounts created below won’t be used
15. Type a name (eg Citrix). Press Next  
16. Type a user name (eg. Citrix). Press Next 
17. Type a user-password (eg. Passw0rd). Press Next
18. Retype the password. Press Next
19. Type an administrator password (eg. Passw0rd). Press Next
20. Retype the administrator password. Press Next
21. Type the FQDN of the hostname (eg. WANem.citrix.lab). Press Next
22. Select mbr Press Next
23 .Select 2. Start installation Press OK
24. Press Next
25. Wait until the installation is completed
26. Press No
27. Press OK
28. Type the command rebootWait until the system asks to remove the CD. Remove the CD. Press Enter
29. Wait until  the machine is booted. Login with root / password (the password you chose in step 19)
30. Type the command: update-rc.d apache2 defaults
31. Type the command: visudo
32. Add the following line in the sudoers file: www-data   ALL=(ALL) NOPASSWD: ALL
TIP: Move to the line where you want to add the text, press <i>, add the text and press <esc>Save the file by pressing <:> and issuing the command: wq!
34. Type the command ifconfig and write down the inet addr. of the system.eg. 172.30.200.155

    

Configure static IP

In this section we’re ensuring that the WAN emulator always receives the same IP address. This can be achieved in two ways:

a) By configuring a static IP
b) By converting the DHCP lease to a reservation (not really a static IP).

a) Static IP

1. Logon to the WANem console with the root account. Type the command: vi /etc/network/interfaces
2. Replace the line…

iface eth0 inet dhcp

…with the following…
iface eth0 inet <strong>static</strong>
 address x.x.x.x
 netmask x.x.x.x
 gateway x.x.x.x

save the file by pressing <esc>  followed by <:> and issuing the command: wq!
3. Reboot the system to apply the IP change by issuing the command: reboot

b) DHCP reservation

1. Connect to the machine that provides DHCP and start the DHCP console
2. Select the Client IP address you wrote down earlier in the Address Leases section
3. Right-click the address and select Add to Reservation

5. Wait until the lease is converted to a reservation

Configure route on Windows machine

In this section we’ll configure the route from the Windows machine (hosting the FrameHawk enabled VDA) back to the host name so it’s passing the WAN emulator.
By adding a static route to the NetScaler IP (NSIP) and/or the IP of the host machine we’re ensuring that only ICA traffic is affected by the WAN emulator (and not the other traffic, eg. Internet traffic).

1. Connect to the Windows machine that has the FrameHawk VDA installed
2. Open a command prompt as Administrator
3. Issue the command: route add <IP1> <IP2> mask 255.255.255.255 –p
where <IP1>
a)     the IP address of the SNIP of the NetScaler Gateway (when connecting via NSGW)and/or
b)     the IP address of the host computer  (when connecting direct / via VPN)
and <IP2> is the IP address of the WANem system you configured (eg. 172.30.200.155)

Configure WANem

In this section we’ll configure the WAN emulator to add latency and introduce packet loss. WANem is managed from a webbased management console.

1. Open a browser from a machine that’s inside the local networkConnect tohttp://<WANem-IP>/WANem/

TIP: the name is cAse seNSiTiVe 
2. Click on Advanced Mode
3. Click on StartThere’s only one NIC (eth0)
4. Change the Delay (latency in ms) and Loss(packet loss in %) to a desired configurationClick on Apply settings
5. After testing click on Reset Settings to revert to a normal situation

 

PS: When desired you can configure the WAN emulator via PowerShell – http://www.ingmarverheij.com/configure-wanem-via-powershell/.

Closing

By now you know how to install and configure WANem, a virtual appliance that emulates the characteristics of a WAN including packet loss. This guide showed you how to install the WANem in a XenServer VM so the configuration is persistent (instead of booting from an ISO and loosing changes after a reboot) and how the traffic from the VDA to the Citrix Receiver is routed through the WAN emulator.

For the record, I’m not an expert in WAN emulators nor suggesting this is the only or best way to install WANem.

Happy WAN emulating!

@IngmarVerheij