Thursday, December 20, 2012

Get iperf3 (new version) source code

There is a new version of iperf, iperf3 at code.google.com/p/iperf/. I am not sure if it is any better than iperf2 but it is cool to have a new source to play with. Anyways if you want to build this code on Ubuntu you may encounter a failure due to missing libraries.

Here is a quick review of my attempt to build this tool.

1. Download the latest beta code
user@localhost:~$ wget http://iperf.googlecode.com/files/iperf-3.0b4.tar.gz

2. Extract the code
user@localhost:~$ tar -xvzf iperf-3.0b4.tar.gz

3. With most source code you then have to run the configuration tool for the makefile to be properly built

user@localhost:~$ cd iperf-3.0b4/
user@localhost:~/iperf-3.0b4$ ./configure
This is the output that I got
./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for ranlib... ranlib
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... (cached) ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for ANSI C header files... (cached) yes
checking for uuid_create... no
checking for uuid_generate... no
checking for uuid_generate in -luuid... no
configure: error: libuuid is not available
What I noticed is that libuuid is not available. So how do we find where we can get libuuid? A google search lead me to this page:
www.debian-administration.org/article/334/Finding_which_package_contains_a_file
and the apt-file tool

4. So let us use apt-file and figure it out and then install the necessary library.
4a. If you don't have apt-file follow the guide available at the link above to install it and prepare, or just do the following
user@localhost:~/iperf-3.0b4$ sudo apt-get install apt-file && sudo apt-file update

4b. Search using apt-file for libuuid
user@localhost:~/iperf-3.0b4$ apt-file search libuuid
cruft: /usr/lib/cruft/filters-unex/libuuid1
drizzle: /usr/lib/drizzle7/libuuid_function_plugin.so
drizzle-dbg: /usr/lib/debug/usr/lib/drizzle7/libuuid_function_plugin.so
fp-units-base-2.4.4: /usr/lib/fpc/2.4.4/units/x86_64-linux/uuid/libplibuuid.a
fp-units-base-2.4.4: /usr/lib/fpc/2.4.4/units/x86_64-linux/uuid/libuuid.o
fp-units-base-2.4.4: /usr/lib/fpc/2.4.4/units/x86_64-linux/uuid/libuuid.ppu
fpc-source-2.4.4: /usr/share/fpcsrc/2.4.4/packages/uuid/src/libuuid.pp
libdata-uuid-libuuid-perl: /usr/share/doc/libdata-uuid-libuuid-perl/changelog.Debian.gz
libdata-uuid-libuuid-perl: /usr/share/doc/libdata-uuid-libuuid-perl/copyright
libuuid-perl: /usr/share/doc/libuuid-perl/changelog.Debian.gz
libuuid-perl: /usr/share/doc/libuuid-perl/copyright
libuuid-tiny-perl: /usr/share/doc/libuuid-tiny-perl/changelog.Debian.gz
libuuid-tiny-perl: /usr/share/doc/libuuid-tiny-perl/copyright
libuuid1: /lib/x86_64-linux-gnu/libuuid.so.1
libuuid1: /lib/x86_64-linux-gnu/libuuid.so.1.3.0
libuuid1: /usr/share/doc/libuuid1/changelog.Debian.gz
libuuid1: /usr/share/doc/libuuid1/copyright
libuuidm-ocaml-dev: /usr/share/doc/libuuidm-ocaml-dev/README
libuuidm-ocaml-dev: /usr/share/doc/libuuidm-ocaml-dev/changelog.Debian.gz
libuuidm-ocaml-dev: /usr/share/doc/libuuidm-ocaml-dev/copyright
libuuidm-ocaml-dev: /var/lib/ocaml/lintian/libuuidm-ocaml-dev.info
libuuidm-ocaml-dev: /var/lib/ocaml/md5sums/libuuidm-ocaml-dev.md5sums
libuuidtools-ruby: /usr/share/doc/libuuidtools-ruby/changelog.Debian.gz
libuuidtools-ruby: /usr/share/doc/libuuidtools-ruby/copyright
libuuidtools-ruby-doc: /usr/share/doc/libuuidtools-ruby-doc/changelog.Debian.gz
libuuidtools-ruby-doc: /usr/share/doc/libuuidtools-ruby-doc/copyright
libuuidtools-ruby1.8: /usr/share/doc/libuuidtools-ruby1.8/changelog.Debian.gz
libuuidtools-ruby1.8: /usr/share/doc/libuuidtools-ruby1.8/copyright
libuuidtools-ruby1.9.1: /usr/share/doc/libuuidtools-ruby1.9.1/changelog.Debian.gz
libuuidtools-ruby1.9.1: /usr/share/doc/libuuidtools-ruby1.9.1/copyright
mingw-w64-dev: /usr/i686-w64-mingw32/lib/libuuid.a
mingw-w64-dev: /usr/x86_64-w64-mingw32/lib/libuuid.a
mingw32-runtime: /usr/i586-mingw32msvc/lib/libuuid.a
pandora-build: /usr/share/aclocal/pandora_have_libuuid.m4
uuid-dev: /usr/lib/x86_64-linux-gnu/libuuid.a
uuid-dev: /usr/lib/x86_64-linux-gnu/libuuid.so
wine1.4-amd64: /usr/lib/x86_64-linux-gnu/wine/libuuid.a

I look at this list and choose uuid-dev

4c. Install the chosen package
user@localhost:~/iperf-3.0b4$ sudo apt-get install uuid-dev

5. Re-run ./configure to confirm success
If no other errors run make to build the tool.

6. user@localhost:~/iperf-3.0b4$ make
Now you can look in the src directory for iperf3 which is a compiled version you can use on the same architure of linux...enjoy the iperf tool

Here is a good site on how to use iperf basics linhost.info/2010/02/iperf-on-windows/. Note: it was written with iperf2 on Windows. Perhaps I will write a quick guide, later, regarding my primary use case for iperf, validating VPN performance.

Monday, December 10, 2012

Proper upstart script for the No-IP DNS Update Client

Updated script again, better error handling and readability. Only looked at it due to a little bit of rebuilding my HTPC which runs this tool.
#!/bin/bash
### BEGIN INIT INFO
# Provides:          noip2
# Required-Start:    networking
# Required-Stop:     networking
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts instance of noip2
# Description:       No-IP DUC (DNS Update Client) start stop service script
### END INIT INFO
#
# copy to /etc/init.d
# run "update-rc.d noip2 defaults" to install
# run "update-rc.d noip2 remove" to remove
#
# Version 1 by Craig Lorentzen
# Version 2 - Added LSB INIT INFO
# Version 3 - Improved error handling and readability
# Version 4 - Added status (to check if the service is running and with what PID

NAME=noip2
PATH=/usr/local/bin
DAEMON=$PATH/$NAME
PID=$(/bin/pidof -s $DAEMON)

do_start()
{
        echo "Starting $NAME."
        echo
        if [ $PID ]; then
                echo "   WARNING: $NAME is already running."
                echo
                PID=
        else
                $($DAEMON)
        fi
}

do_stop()
{
        echo "Stopping $NAME."
        echo
        if [ $PID ]; then
                kill $PID
                PID=
        else
                echo "   WARNING: $NAME is not running."
                echo
        fi
}

do_status()
{
        if [ $PID ]; then
                echo "$NAME is running as $PID"
        else
                echo "$NAME is not running"
                echo
        fi
}

case "$1" in
        start)
                do_start
        ;;
        stop)
                do_stop
        ;;
        restart)
                echo "Restarting $NAME."
                do_stop
                do_start
        ;;
        status)
                do_status
        ;;
        *)
                echo "     Usage: $NAME (start|stop|restart|status)"
                echo
                exit 1
        ;;
esac

exit 0

If you have a No-IP Dynamic DNS account, free at no-ip.com Then you likely want to use the DUC (Dynamic Update Client) to automate the process of keeping it up-to-date. No-IP provides a client for Windows, Mac, and Linux. I have an Linux host running 24x7 at my house, so I decided to try the Linux version.

http://www.no-ip.com/downloads.php?page=linux

This tool used to be in the Ubuntu repositories but has been removed, so No-IP provides the source to be compiled, however, they don't provide a good start script and do not use the upstart method to install the automatic starter. So I decided to create a proper script to follow the upstart method. I understand that this script is not following all LSB standards, however, it should do what people need after following the process that No-IP Provides to compile and install.