I am taking a course called “Latency in Communication Systems” taught by Martin Karsten in University of Waterloo. We talked about different aspects of latency in communication systems, there were some lectures from industry (Sandvine, TD Securites, RIM, and SUN/Oracle) about what were the different problems they were facing during their system implementation. I had also presented two papers on profiling and router performance during the course. My course project is the reason I am writing this post, I have to install and evaluate SPDY. SPDY is a new application-layer protocol designed by Google to replace HTTP in order to make the web faster. It offers multiple requests per connection, server-initiated requests along with the client-initiated requests, header and data compression over SSL. In this post I am not going to talk about SPDY and it’s features, I will explain the process of SPDY client (chromium) and server installation as I need them later to evaluate this protocol.

Install Chromium

Edit: Follow the build instruction for linux here: http://code.google.com/p/chromium/wiki/LinuxBuildInstructions

I started to compile chromium on Ubuntu Karmic Koala 9.10. The obvious place to start is the chromium website, Although take a look at this, we need to enable data recording to cache some data for the in-memory server, I will explain this later. These are the required step to take :

  1. Install all the prerequisites

  2. Download the source tarball from here.

  3. Extract it to a location (It should not include any spaces). I extracted it to ~/chromium

  4. Install depot_tools

    1. svn co http://src.chromium.org/svn/trunk/tools/depot_tools

    2. Add depot_tools to your PATH: $ export PATH=`pwd`/depot_tools:"$PATH"

  5. Updating your checkout once by running gclient sync --force

    in the source code directory (~/chromium/src). It is important to include the ‘–force’ option as I was getting this message:

    make: *** No rule to make target `third_party/yasm/source/patched-yasm/ modules/arch/x86/gen_x86_insn.py', needed by `out/Debug/obj/gen/ third_party/yasm/x86insns.c'. Stop."

    over and over again since I forgot to include the –force option. It seems that this command generate platform-specific files

    • Important: ensure that you have GYP_GENERATORS=make in your environment before running gclient sync or gclient runhooks –force. This tells the Chromium build system to output Makefiles. Example: export GYP_GENERATORS=make gclient sync

    • Take this step only if you want to record data to be used by flip-server, if you just want to compile and run chromium skip this step and go to step 9. Modify the file chrome/common/chrome_constants.cc - change the line which reads kRecordModeEnabled = false

      to

      kRecordModeEnabled = true

    • Go to the source directory and write (if you are using a multiple-core machine use -jX, where X is the number of make processes to startup): make chrome

    • You can find the executable in src/out/Debug/chrome Now you should be able to run chrome with no problem.

    Install flip-server

    To install flip-server, take a look at this. Go to the Chromuim src directory, and here are the steps that I took to install flip server:

    1. If you don’t already have a test key.pem and certificate.pem, you can generate one like so:
openssl genrsa -out key.pem 1024
openssl req -new -key key.pem -out request.pem  #and answer the questions at the prompt with whatever
openssl x509 -req -days 30 -in request.pem -signkey key.pem -out cert.pem
2.  Get the patch from: <http://codereview.chromium.org/1566013>, Click the &#8216;download raw patch&#8217; link and save. Assuming you&#8217;re in the <tt>chromium/src</tt> directory, type: ``patch -p0 < filename_of_the_patch_you_just_downloaded``

3.  Find the commented-out-section in net.gyp (look for &#8216;flip\_in\_mem\_edsm\_server&#8221;) and uncomment it.
4.  You will need to install the openssl libraries. The exact packages depend on your linux distribution (but will be named something like ssl-dev or openssl-dev, or in ubuntu libssl-dev), so watch the error messages, if any. After you&#8217;ve done all that, you do: ``make out/Debug/flip_in_mem_edsm_server ``

5.  I had to change these lines to get rid of some compiling errors :
    *   While compiling I got :
/usr/include/linux/tcp.h:72: error: '__u32 __fswab32(__u32)' cannot
appear in a constant-expression
/usr/include/linux/tcp.h:72: error: a function call cannot appear in a
constant-expression
/usr/include/linux/tcp.h:73: error: '__u32 __fswab32(__u32)' cannot
appear in a constant-expression
/usr/include/linux/tcp.h:73: error: a function call cannot appear in a
constant-expression
        To fix it, in file <tt>src/net/tools/flip_server/flip_in_mem_edsm_server.cc</tt> change the line that reads:

        <pre class="brush: plain; light: true; title: ; notranslate" title="">#include &lt;linux/tcp.h&gt;</pre>

        to

        <pre class="brush: plain; light: true; title: ; notranslate" title="">#include &lt;netinet/tcp.h&gt;</pre>

    *   In the same file change : <pre class="brush: plain; light: true; title: ; notranslate" title="">state-&gt;ssl_method = SSLv23_method();</pre>

        to

        <pre class="brush: plain; light: true; title: ; notranslate" title="">state-&gt;ssl_method = const_cast&lt;SSL_METHOD *&gt; (SSLv23_method()); </pre>

    *   I was getting some errors related to <tt>printSslError </tt> function in <tt>flip_in_mem_edsm_server.cc</tt>, it seems that this function prints out the errors related to SSL encryption, since I did not need that I commented the contents of the function out.

## Install Chrome which is able to talk to localhost server

Now if you want a quick chrome installation that is able to talk to your installed server on localhost you need to copy the following script, save it in a file and run <tt>bash filename</tt>:
#!/bin/bash

if [ "$(dpkg --print-architecture)" == "amd64" ]; then
  echo -ne "\n\nYou have a 64 bit computer\n\n"
  linux_versions="linux64";
else
  echo -ne "\n\nYou have a 32 bit computer\n\n"
  linux_versions="linux";
fi

for linux_version in $linux_versions; do
  install_dir=$HOME/spdy-chrome-canary/$linux_version

  if mkdir -p $install_dir; then
    echo "Directory: \"$install_dir\" made or already existed"
  else
      echo "$install_dir exists, but is not a directory."
      echo "Please remove whatever is there so this script can proceed next time."
      exit 128
  fi

  pushd $install_dir

  install -d chrome-linux-old
  mv chrome-linux chrome-linux-old/chrome-linux-`date +"%F-%k-%M-%S-%N"`
  rm -rf chrome-linux chrome-linux-old chrome-linux.zip
  wget http://build.chromium.org/buildbot/continuous/$linux_version/LATEST/chrome-linux.zip
  unzip chrome-linux.zip
  rm -rf chrome-linux.zip

  popd

  filename_base=SPDY-Chrome-$linux_version
  cat &gt;&gt; $HOME/Desktop/$filename_base.desktop &lt;&lt;-EOF
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=$filename_base
Categories=Application;Network;WebBrowser;
Exec=$install_dir/chrome-linux/chrome --use-spdy --enable-logging --log-level=0 --user-data-dir=.$filename_base %U
Icon=/tmp/chrome-linux/product_logo_48.png
MimeType=text/html;text/xml;
Terminal=false
Type=Application
EOF

  filename_base=SPDY-Chrome-local-server-$linux_version
  cat &gt;&gt; $HOME/Desktop/$filename_base.desktop &lt;&lt;-EOF
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=$filename_base
Categories=Application;Network;WebBrowser;
Exec=$install_dir/chrome-linux/chrome --use-spdy --enable-logging --log-level=0 --user-data-dir=.$filename_base --host-resolver-rules='MAP * localhost' --testing-fixed-http-port=10040 --testing-fixed-https-port=10040 %U
Icon=/tmp/chrome-linux/product_logo_48.png
MimeType=text/html;text/xml;
Terminal=false
Type=Application
EOF

  filename_base=NO-SPDY-Chrome-local-server-$linux_version
  cat &gt;&gt; $HOME/Desktop/$filename_base.desktop &lt;&lt;-EOF
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=$filename_base
Categories=Application;Network;WebBrowser;
Exec=$install_dir/chrome-linux/chrome --enable-logging --log-level=0 --user-data-dir=.$filename_base --host-resolver-rules='MAP * localhost' --testing-fixed-http-port=16002 --testing-fixed-https-port=16002 %U
Icon=/tmp/chrome-linux/product_logo_48.png
MimeType=text/html;text/xml;
Terminal=false
Type=Application
EOF

done