Fear and Loathing in Windows 7: Testing Branch Cache using Linux

Analysis
Apr 9, 20094 mins

Unless you have been in a closet for the past couple of months, one of the new features in Windows 7 is called Branch Cache.  For some time now, I’ve been meaning to test this feature, and over the past couple of weeks I managed to squeeze in time to take a closer look.

First off, for those not familiar with what Branch Cache does here is how Microsoft defines it:

“Windows Branch Cache is intended to reduce bandwidth consumption on branch-office wide area network (WAN) links. Branch Cache clients retrieve content from distributed caches within a branch instead of remote servers. Distributed caches in the branch can either be on peer clients within the branch or be on dedicated caching servers.”

In other words, Branch Cache is P2P background caching of often accessed content (documents and Web pages) with the goal of reducing WAN traffic and improving user experience.  Right… that being said.  I needed/wanted to test this feature out within a completely self-contained lab environment before forcing this into an actual live deployment.

Not a big deal, considering we all know of and use this wacky little technology called virtualization.  So, I built my lab, and set about mirroring a simple main + branch office scenario using Hyper-V.  However, there was one small nagging problem.  How to easily mimic a crappy WAN connection using Hyper-V?  Granted, I could force Branch Cache to be on all the time for network files by forcing its latency threshold to 0ms.  But, that would defeat the entire purpose.  I wanted to see Branch Cache in action exactly how our clients would see it.  After all, you don’t go a really good Sushi restaurant and order a charbroiled hamburger just because you can.  That would be just wrong.

So… after searching around using Google, I quickly came to the conclusion that there were several common ways to accomplish my goal of mimicking a crappy WAN link:

  1. Use a virtualization product that allows this.
  2. Pay money for a solution or hardware solution.
  3. Use Linux.

Naturally, I choose free… I mean 3.  To help others that might be seeking a similar goal, here is what I did.

  1. I downloaded the latest version of Ubuntu Server (yes server).  I was going to use Suse, but they wanted me to register.  Enough people already have my email address, thank-you.
  2. I then created a new VM, yanked the network adapter, and added in two legacy network adapters (yes I had created my virtual networks beforehand).  One adapter was on my mail office segment, and the other was on my branch office segment.
  3. Next, I installed a basic Ubuntu server with nothing else enabled.  For giggles, also installed Gnome, and was going install and configure the Hyper-V IC v2.0 Beta.  But, that just seemed like an unnecessary hardship.
  4. Once my newly minted Linux box was up and running.  I then configured the network properties and enabled IP Forwarding (VIM rocks, I always really hated VI): (Edit the /etc/network/interfaces file for the network settings and Edit the /etc/sysctl.conf file to turn on net.ipv4.ip_forward)
  5. I then rebooted the Linux box, and once it was back online I verified that it was able to act as my router between my two previously mentioned network segments.
  6. The next step was to interject some WAN crappiness, and here is the command I used: sudo tc qdisc add dev eth1 root handle 1:0 netem delay 100ms

Basically, Linux is a rock star when it comes to providing a rich tool set for managing and manipulating the transmission of packets.  So, the command that I executed (tc) made use of Linux Traffic Control (a kernel thing) which allows me to easily interject 100ms latency on eth1.  Boff, Bonk, Pow, Plop, Kapow, swa-a-p, whamm, zzzzzwap, bam… instant WAN crappiness.

If you like this, check out some other posts from Tyson:

  • When a computer science degree matters, and when it doesn’t
  • Since when did cloud computing become/need a manifesto?
  • Why would one phish using a Certificate Authority (CA) as bait?
  • Would I trust you, if everyone else trusted you?
  • Here is a good question: Is scripting programming or just systems administration?
  • PowerShell boy and the case of the missing cmdlets!
  • Fun with PowerShell 2.0 Eventing!
  • Creating a custom 404 page to handle link redirection for ASP.NET web applications

Or if you want, you can also check out some of Tyson’s latest publications:

Lastly, visit the Microsoft Subnet for more news, blogs, and opinions from around the Internet.  Or, sign up for the bi-weekly Microsoft newsletter.  (Click on News/Microsoft News Alert)