From 25ad2334684e0f0fea70385dbb9840814f6605db Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Sun, 3 Jan 2016 18:42:47 +0100 Subject: [PATCH 1/2] Ostinato VM with GUI --- appliances/ostinato.gns3a | 47 +++--- packer/tinycore-linux/README.rst | 15 ++ packer/tinycore-linux/ostinato-drone.json | 5 + packer/tinycore-linux/ostinato.json | 5 + .../tinycore-linux/scripts/ostinato-drone.sh | 132 ++++++++++++++++ packer/tinycore-linux/scripts/ostinato.sh | 149 ++++++++++++++++++ 6 files changed, 330 insertions(+), 23 deletions(-) create mode 100644 packer/tinycore-linux/ostinato-drone.json create mode 100644 packer/tinycore-linux/ostinato.json create mode 100644 packer/tinycore-linux/scripts/ostinato-drone.sh create mode 100644 packer/tinycore-linux/scripts/ostinato.sh diff --git a/appliances/ostinato.gns3a b/appliances/ostinato.gns3a index 6a4eeee..37b0f68 100644 --- a/appliances/ostinato.gns3a +++ b/appliances/ostinato.gns3a @@ -1,43 +1,44 @@ { - "name": "Ostinato Drone", + "name": "Ostinato", "category": "guest", "description": "Ostinato is an open-source, cross-platform network packet crafter/traffic generator and analyzer with a friendly GUI. Craft and send packets of several streams with different protocols at different rates.", - "vendor_name": "Ostinato", - "vendor_url": "http://ostinato.org/", - "documentation_url": "http://ostinato.org/docs.html", - "product_name": "Drone", - "product_url": "http://ostinato.org/", - "registry_version": 1, + "vendor_name": "Ostinato", + "vendor_url": "http://ostinato.org/", + "documentation_url": "http://ostinato.org/docs.html", + "product_name": "Ostinato", + "product_url": "http://ostinato.org/", + "registry_version": 1, "status": "experimental", - "maintainer": "Bernhard Ehler", + "maintainer": "Bernhard Ehlers", "maintainer_email": "be@bernhard-ehlers.de", - "usage": "The traffic generator listen on port 50001.\n Use the Ostinato GUI to control it. If you want to use two traffic geneator at the same time you need to modify the port in the VM Qemu options.\nThe drone VM and the Ostinato GUI must use the same version.", - + "usage": "Use interfaces starting with eth1 as traffic interfaces, eth0 is only for the (optional) management of the server/drone.", + "port_name_format": "eth{0}", + "qemu": { "adapter_type": "e1000", - "adapters": 1, - "ram": 128, + "adapters": 4, + "ram": 256, "arch": "i386", - "console_type": "telnet", - "options": "-net nic,vlan=999,model=e1000 -net user,vlan=999,hostfwd=tcp::50001-:7878" + "console_type": "vnc", + "options": "-vga std -usbdevice tablet" }, - "images": [ + "images": [ { - "filename": "ost-drone-0.7-v1.qcow2", - "version": "0.7", - "md5sum": "6c20f767f89782e66929e6cbb7143ab1", - "filesize": 18415616, - "download_url": "http://www.bernhard-ehlers.de/projects/ostinato4gns3/install-qemu.html", - "direct_download_url": "http://www.bernhard-ehlers.de/projects/ostinato4gns3/ost-drone-0.7-v1.qcow2" + "filename": "ostinato-0.7.1-2.qcow2", + "version": "0.7.1", + "md5sum": "c534aeb6e7d24b23e0458c36ad4784fc", + "filesize": 56295424, + "download_url": "http://www.bernhard-ehlers.de/projects/ostinato4gns3/index.html", + "direct_download_url": "http://www.bernhard-ehlers.de/projects/ostinato4gns3/ostinato-0.7.1-2.qcow2" } ], "versions": [ { - "name": "0.7", + "name": "0.7.1", "images": { - "hda_disk_image": "ost-drone-0.7-v1.qcow2" + "hda_disk_image": "ostinato-0.7.1-2.qcow2" } } ] diff --git a/packer/tinycore-linux/README.rst b/packer/tinycore-linux/README.rst index f91f536..4a750c5 100644 --- a/packer/tinycore-linux/README.rst +++ b/packer/tinycore-linux/README.rst @@ -38,6 +38,21 @@ A build of Core with Openvswitch preinstalled. packer build -var-file=openvswitch.json core64-linux.json +Ostinato +''''''''' + +A build of Core with Ostinato drone preinstalled. + +.. code:: bash + + packer build -var-file=ostinato.json core-linux.json + +A drone-only VM can be build with: + +.. code:: bash + + packer build -var-file=ostinato-drone.json core-linux.json + Tiny Core Linux installation **************************** diff --git a/packer/tinycore-linux/ostinato-drone.json b/packer/tinycore-linux/ostinato-drone.json new file mode 100644 index 0000000..5943778 --- /dev/null +++ b/packer/tinycore-linux/ostinato-drone.json @@ -0,0 +1,5 @@ +{ + "vm_name": "ostinato-drone.qcow2", + "setup_script": "ostinato-drone.sh", + "disk_size": "200" +} diff --git a/packer/tinycore-linux/ostinato.json b/packer/tinycore-linux/ostinato.json new file mode 100644 index 0000000..848112a --- /dev/null +++ b/packer/tinycore-linux/ostinato.json @@ -0,0 +1,5 @@ +{ + "vm_name": "ostinato.qcow2", + "setup_script": "ostinato.sh", + "disk_size": "200" +} diff --git a/packer/tinycore-linux/scripts/ostinato-drone.sh b/packer/tinycore-linux/scripts/ostinato-drone.sh new file mode 100644 index 0000000..750cc66 --- /dev/null +++ b/packer/tinycore-linux/scripts/ostinato-drone.sh @@ -0,0 +1,132 @@ +set -e +set -x + +# setup environment +. /etc/profile +. /etc/init.d/tc-functions +getMirror + +# load qt-4.x-base without the X dependecies +# alternatively a "tce-load -wi qt-4.x-base" loads it with all dependecies +wget -P /mnt/sda1/tce/optional $MIRROR/qt-4.x-base.tcz +wget -P /mnt/sda1/tce/optional $MIRROR/qt-4.x-base.tcz.md5.txt +touch /mnt/sda1/tce/optional/qt-4.x-base.tcz.dep +tce-load -i /mnt/sda1/tce/optional/qt-4.x-base.tcz + +# load the remaining dependencies for ostinato +tce-load -wi qt-4.x-base +tce-load -wi qt-4.x-script +tce-load -wi glib2 +tce-load -wi openssl +tce-load -wi libpcap + +# load also iperf +tce-load -wi iperf3 + +# change tcedir to ram disk +mv /etc/sysconfig/tcedir /etc/sysconfig/tcedir.hd +ln -s /tmp/tce /etc/sysconfig/tcedir + +# setup compile environment +tce-load -wi compiletc +tce-load -wi squashfs-tools +tce-load -wi curl +export CFLAGS="-march=i486 -mtune=i686 -O2" +export CXXFLAGS="-march=i486 -mtune=i686 -O2" +export LDFLAGS="-Wl,-O1" + +# compile protobuf +curl -L -O https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz +tar xfz protobuf-2.6.1.tar.gz +cd protobuf-2.6.1 +./configure --prefix=/usr/local +make +sudo make install +sudo rm /usr/local/lib/libprotobuf.so +cd .. +rm -rf protobuf* + +# compile ostinato +tce-load -wi qt-4.x-dev +tce-load -wi libpcap-dev +ver=`curl -sI https://bintray.com/pstavirs/ostinato/ostinato-src/_latestVersion | sed -n '/Location:/ {s%.*/ostinato-src/%%;s%/view.*%%;p;}'` +curl -k -L -O https://bintray.com/artifact/download/pstavirs/ostinato/ostinato-src-$ver.tar.gz +tar xfz ostinato-src-$ver.tar.gz +cd ostinato-$ver +# patch only useful for ostinato <= 0.7.1 +patch -p0 <<'EOF' +--- server/pcapport.cpp.orig 2015-02-24 08:38:33.000000000 +0000 ++++ server/pcapport.cpp 2015-02-25 09:58:38.943383048 +0000 +@@ -696,7 +696,8 @@ + + while (curTicks.QuadPart < tgtTicks.QuadPart) + QueryPerformanceCounter(&curTicks); +-#elif defined(Q_OS_LINUX) ++// #elif defined(Q_OS_LINUX) ++#elif 0 + struct timeval delay, target, now; + + //qDebug("usec delay = %ld", usec); +EOF +qmake -config release "QMAKE_CXXFLAGS+=$CXXFLAGS" +# ostinato >= 0.8 supports building of a component +# make server +# sudo INSTALL_ROOT=/tmp/ostinato make server-install_subtargets +make +sudo INSTALL_ROOT=/tmp/ostinato make install +sudo rm /tmp/ostinato/usr/local/bin/ostinato +sudo chown -R root:root /tmp/ostinato +sudo chmod +s /tmp/ostinato/usr/local/bin/drone +cd .. +mksquashfs /tmp/ostinato ostinato-drone.tcz +md5sum ostinato-drone.tcz > ostinato-drone.tcz.md5.txt +echo -e "qt-4.x-base.tcz\nqt-4.x-script.tcz\nlibpcap.tcz" > ostinato-drone.tcz.dep +mv ostinato-drone.tcz* /mnt/sda1/tce/optional/ +echo ostinato-drone.tcz >> /mnt/sda1/tce/onboot.lst +sudo rm -rf /tmp/ostinato +rm -rf ostinato* + +# ostinato configuration file +mkdir -p .config/Ostinato +cat > .config/Ostinato/drone.ini <<'EOF' +[General] +RateAccuracy=Low +[PortList] +Include=eth* +Exclude=eth0 +EOF + +# change tcedir back to hard disk +rm -f /etc/sysconfig/tcedir +mv /etc/sysconfig/tcedir.hd /etc/sysconfig/tcedir + +# disable automatic interface configuration with dhcp +sudo sed -i -e '/label .*core/,/append / s/\(append .*\)/\1 nodhcp/' /mnt/sda1/boot/extlinux/extlinux.conf + +# add startup script for ostinato +cat >> /opt/bootlocal.sh <<'EOF' + +# Boot parameter "nodhcp": network interfaces are not yet configured +if grep -q -w nodhcp /proc/cmdline; then + # This waits until all devices have registered + /sbin/udevadm settle --timeout=10 + + # configure eth0 with DHCP + /sbin/udhcpc -b -i eth0 -x hostname:$(/bin/hostname) -p /var/run/udhcpc.eth0.pid >/dev/null 2>&1 & + + # alternatively configure static interface address and route + #ifconfig eth0 x.x.x.x netmask 255.255.255.0 up + #route add default gw y.y.y.y + + # activate other eth devices + NETDEVICES="$(awk -F: '/eth[1-9][0-9]*:/{print $1}' /proc/net/dev 2>/dev/null)" + for DEVICE in $NETDEVICES; do + ifconfig $DEVICE mtu 9000 up + done +fi + +# start ostinato drone +HOME=/home/gns3 drone < /dev/null > /var/log/ostinato-drone.log 2>&1 & +EOF + +exit 0 diff --git a/packer/tinycore-linux/scripts/ostinato.sh b/packer/tinycore-linux/scripts/ostinato.sh new file mode 100644 index 0000000..5df31cc --- /dev/null +++ b/packer/tinycore-linux/scripts/ostinato.sh @@ -0,0 +1,149 @@ +set -e +set -x + +# setup environment +. /etc/profile + +# Install the GUI +tce-load -wi fltk-1.3 +tce-load -wi flwm +tce-load -wi Xorg-7.7 +tce-load -wi wbar +tce-load -wi Xprogs +tce-load -wi Xlibs +tce-load -wi aterm + +# set X resolution to 800x600 +cat > 99-resolution.conf <<'EOF' +Section "Screen" + Identifier "Screen0" + DefaultDepth 24 + SubSection "Display" + Modes "800x600" + EndSubSection +EndSection +EOF +sudo mv 99-resolution.conf /usr/local/share/X11/xorg.conf.d/ +echo usr/local/share/X11/xorg.conf.d >> /opt/.filetool.lst + +# load the dependencies for ostinato +tce-load -wi qt-4.x-base +tce-load -wi qt-4.x-script +tce-load -wi libpcap + +# load also iperf +tce-load -wi iperf3 + +# change tcedir to ram disk +mv /etc/sysconfig/tcedir /etc/sysconfig/tcedir.hd +ln -s /tmp/tce /etc/sysconfig/tcedir + +# setup compile environment +tce-load -wi compiletc +tce-load -wi squashfs-tools +tce-load -wi curl +export CFLAGS="-march=i486 -mtune=i686 -O2" +export CXXFLAGS="-march=i486 -mtune=i686 -O2" +export LDFLAGS="-Wl,-O1" + +# compile protobuf +curl -L -O https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz +tar xfz protobuf-2.6.1.tar.gz +cd protobuf-2.6.1 +./configure --prefix=/usr/local +make +sudo make install +sudo rm /usr/local/lib/libprotobuf.so +cd .. +rm -rf protobuf* + +# compile ostinato +tce-load -wi qt-4.x-dev +tce-load -wi libpcap-dev +ver=`curl -sI https://bintray.com/pstavirs/ostinato/ostinato-src/_latestVersion | sed -n '/Location:/ {s%.*/ostinato-src/%%;s%/view.*%%;p;}'` +curl -k -L -O https://bintray.com/artifact/download/pstavirs/ostinato/ostinato-src-$ver.tar.gz +tar xfz ostinato-src-$ver.tar.gz +cd ostinato-$ver +# patch only useful for ostinato <= 0.7.1 +patch -p0 <<'EOF' +--- server/pcapport.cpp.orig 2015-02-24 08:38:33.000000000 +0000 ++++ server/pcapport.cpp 2015-02-25 09:58:38.943383048 +0000 +@@ -696,7 +696,8 @@ + + while (curTicks.QuadPart < tgtTicks.QuadPart) + QueryPerformanceCounter(&curTicks); +-#elif defined(Q_OS_LINUX) ++// #elif defined(Q_OS_LINUX) ++#elif 0 + struct timeval delay, target, now; + + //qDebug("usec delay = %ld", usec); +EOF +qmake -config release "QMAKE_CXXFLAGS+=$CXXFLAGS" +make +sudo INSTALL_ROOT=/tmp/ostinato make install +sudo mkdir -p /tmp/ostinato/usr/local/share/applications +cat > ostinato.desktop <<'EOF' +[Desktop Entry] +Name=Ostinato +Exec=ostinato +Type=Application +OnlyShowIn=Old; +Categories=System; +EOF +sudo mv ostinato.desktop /tmp/ostinato/usr/local/share/applications/ +sudo chown -R root:root /tmp/ostinato +sudo chmod +s /tmp/ostinato/usr/local/bin/drone +cd .. +mksquashfs /tmp/ostinato ostinato.tcz +md5sum ostinato.tcz > ostinato.tcz.md5.txt +echo -e "qt-4.x-base.tcz\nqt-4.x-script.tcz\nlibpcap.tcz" > ostinato.tcz.dep +mv ostinato.tcz* /mnt/sda1/tce/optional/ +echo ostinato.tcz >> /mnt/sda1/tce/onboot.lst +sudo rm -rf /tmp/ostinato +rm -rf ostinato* + +# ostinato configuration file +mkdir -p .config/Ostinato +cat > .config/Ostinato/drone.ini <<'EOF' +[General] +RateAccuracy=Low +[PortList] +Include=eth* +Exclude=eth0 +EOF + +# change tcedir back to hard disk +rm -f /etc/sysconfig/tcedir +mv /etc/sysconfig/tcedir.hd /etc/sysconfig/tcedir + +# disable automatic interface configuration with dhcp +sudo sed -i -e '/label .*core/,/append / s/\(append .*\)/\1 nodhcp/' /mnt/sda1/boot/extlinux/extlinux.conf + +# add startup script for ostinato +cat >> /opt/bootlocal.sh <<'EOF' + +# Boot parameter "nodhcp": network interfaces are not yet configured +if grep -q -w nodhcp /proc/cmdline; then + # This waits until all devices have registered + /sbin/udevadm settle --timeout=10 + + # configure eth0 with DHCP + /sbin/udhcpc -b -i eth0 -x hostname:$(/bin/hostname) -p /var/run/udhcpc.eth0.pid >/dev/null 2>&1 & + + # alternatively configure static interface address and route + #ifconfig eth0 x.x.x.x netmask 255.255.255.0 up + #route add default gw y.y.y.y + + # activate other eth devices + NETDEVICES="$(awk -F: '/eth[1-9][0-9]*:/{print $1}' /proc/net/dev 2>/dev/null)" + for DEVICE in $NETDEVICES; do + ifconfig $DEVICE mtu 9000 up + done +fi + +# start ostinato drone +HOME=/home/gns3 drone < /dev/null > /var/log/ostinato-drone.log 2>&1 & +EOF + +exit 0 From 8ce5975c4d0241b8bb44079d0893837cbc938512 Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Mon, 4 Jan 2016 15:45:18 +0100 Subject: [PATCH 2/2] Ostinato update --- appliances/ostinato.gns3a | 2 +- packer/tinycore-linux/scripts/ostinato-drone.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/appliances/ostinato.gns3a b/appliances/ostinato.gns3a index 37b0f68..8beeaef 100644 --- a/appliances/ostinato.gns3a +++ b/appliances/ostinato.gns3a @@ -27,7 +27,7 @@ { "filename": "ostinato-0.7.1-2.qcow2", "version": "0.7.1", - "md5sum": "c534aeb6e7d24b23e0458c36ad4784fc", + "md5sum": "68895c56addf4a9ce0f2db9c9ed288d2", "filesize": 56295424, "download_url": "http://www.bernhard-ehlers.de/projects/ostinato4gns3/index.html", "direct_download_url": "http://www.bernhard-ehlers.de/projects/ostinato4gns3/ostinato-0.7.1-2.qcow2" diff --git a/packer/tinycore-linux/scripts/ostinato-drone.sh b/packer/tinycore-linux/scripts/ostinato-drone.sh index 750cc66..0903f0a 100644 --- a/packer/tinycore-linux/scripts/ostinato-drone.sh +++ b/packer/tinycore-linux/scripts/ostinato-drone.sh @@ -14,7 +14,6 @@ touch /mnt/sda1/tce/optional/qt-4.x-base.tcz.dep tce-load -i /mnt/sda1/tce/optional/qt-4.x-base.tcz # load the remaining dependencies for ostinato -tce-load -wi qt-4.x-base tce-load -wi qt-4.x-script tce-load -wi glib2 tce-load -wi openssl