# Copyright (c) 2016, Neelakandan Manihatty Bojan
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
#
# * Neither the name of the project, the copyright holder nor the names of its
#  contributors may be used to endorse or promote products derived from
#   this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file documents the process required to evaluate the port-to-port latency 
experienced by packets through different switches.
Note that the process may change between platforms and OS.

Requirements:
=============

Hardware
--------

1. A host machine/server
2. NIC card
3. DAG capture card
4. Network switch
5. Network taps (Optical)
6. Fibers and transceivers

For the number of quantity, please refer to "Test setup and configuration" section. 

Software
--------

1. Setup the Qjump-camio-tools and ensure that it is in working order.

Follow the instruction below.
https://github.com/camsas/qjump-camio-tools

Make a note of the path for installation (needs to be exported in the main bash script).


2. Generating pcap files.

As an example, we have provided two pcap files (64 Byte and 1514 Byte).
Customized pcap files can also be generated with different tools.

http://www.codeproject.com/Tips/612847/Generate-a-quick-and-easy-custom-pcap-file-using-P

3. Install Tcpreplay 

sudo apt-get install tcpreplay

Tcpreplay is a tool to replay saved tcpdump files at arbitrary speeds

4. Disable Aavahi Daemon

Avahi daemon can interfere with the experiments by generating packets along the interfaces.
Temporarily disable them. 

https://ubuntuusertips.wordpress.com/2012/09/13/get-rid-of-avahi-service/


Test Setup and configuration
============================

1. loopback mode : This mode is used to characterize the latency of the experimental setup 
(without the switch).The latency includes contributions from fiber, transceivers, optical 
taps. An LC-LC connector can be used to loopback fibers. A detailed image of the test setup 
is shown in loopback_mode.png (in this folder).


2. Switch test mode : In this mode, we connect the switch to the host and measure the 
port-to-port latency observed by the packets. Test setup details can be found in switch_test.png.

3. Ensure that the cables connecting from the taps to the DAG capture card have shorter 
lengths (1-2 m). 

Running the tests:
=================


1. Copy the Makefile and run.sh into the /tmp directory.

cp Makefile /tmp
cp run.sh /tmp


2. Change to the /tmp directory and run 'make all'

cd /tmp/

3. Ensure that the path for the qjump tools and repo are exported to run.sh

4. Check if the nic interfaces on the host are active.

5. run 'make all'

6. The results for each of the pcaps can be found inside 'results' folder in the same directory.


Contact:
========

If you have any questions, please contact nm525@cam.ac.uk . 




