在ubuntu上安装NCTUns
How to install NCTUns in Debian/Ubuntu
Contenido[ocultar] |
Introduction
The NCTUns is a high-fidelity and extensible network simulator and emulator capable of simulating various protocols used in both wired and wireless IP networks. NCTUns uses directly the Linux TCP/IP protocol stack to generate high-fidelity simulation results.
This document describes how to install NCTUns (developed only for Fedora Linux 9) on a Debian Unstable (Sid) operating system. A similar process should work on Debian Stable (Lenny) and latests versions of Ubuntu.
Dependencies
Install the build and runtime dependencies:
$ apt-get install build-essential rpm tcl8.5 tcl8.5-dev xinetd rsh-server libncurses5-dev libqt3-mt
Download NCTUns
Download NCTUns and uncompress it:
$ wget http://nsl10.csie.nctu.edu.tw/download/NCTUns-allinone-linux-2.6.25.9-f9.20080919-3.tar.gz $ tar xzf NCTUns-allinone-linux-2.6.25.9-f9.20080919-3.tar.gz $ cd NCTUns-5.0
Modify NCTUns
We need to modify slightly NCTUns code to install it on a Debian/Ubuntu system:
- install.d/E00common (line 26).
# WHICH="/usr/bin/which --skip-function --skip-alias" WHICH="/usr/bin/which"
- install.d/E00common (line 139).
#if [[ `eval echo \\\$$1` =~ ^[Yy]([Ee][Ss])?$ ]]; then if grep -q "^[Yy]\([Ee][Ss]\)\?$" <<< "${!1}"; then
- install.d/S06check (line 31). Now, this is an ugly hack: the script uses rpm to query packages and check out if it is installed. Echoing any fake line makes the script think a package is installed (we don't want to install RPMs on a Debian system)
# test rpm package manager whether exists #RPM=rpm #export RPM=`$WHICH $RPM 2>/dev/null` fake_rpm() { echo "fake_rpm"; } export RPM=fake_rpm
- Create /etc/xinetd.d/rlogin
# default: on # description: rlogind is the server for the rlogin(1) program. The server \ # provides a remote login facility with authentication based on \ # privileged port numbers from trusted hosts. service login { socket_type = stream wait = no user = root log_on_success += USERID log_on_failure += USERID server = /usr/sbin/in.rlogind disable = no }
- Create /etc/xinetd.d/rsh
# default: on # description: The rshd server is the server for the rcmd(3) routine and, \ # consequently, for the rsh(1) program. The server provides \ # remote execution facilities with authentication based on \ # privileged port numbers from trusted hosts. service shell { socket_type = stream wait = no user = root log_on_success += USERID log_on_failure += USERID server = /usr/sbin/in.rshd disable = no }
Build NCTUns
Copy the existing install.conf-example to install.conf and enable all configuration variables except install_kernel (install_kernel=no). Then run the install script as root:
$ ./install.sh -c install.conf
Include the NCTUns environment variables adding these lines at the bottom of /home/nctuns/.bashrc:
export NCTUNSHOME=/usr/local/nctuns export NCTUNS_TOOLS=$NCTUNSHOME/tools export NCTUNS_BIN=$NCTUNSHOME/bin export PATH=${NCTUNS_BIN}:${PATH}
Run the NCTUns GUI
Login into the system with the nctuns user and run the GUI client:
$ nctunsclient
Run the NCTUns dispatcher/coordinator
NCTUns is a distributed system consisting in three parts: GUI, dispatcher and coordinators (which runs on every simulator server), which can be installed on different computers (manual). The GUI application has not any special requirement, but the dispatcher and coordinator require a modified kernel.
NCTUns sources include a precompiled modified kernel package (NCTUns-5.0/RPM/kernel-nctuns-2.6.25.9nctuns20080826-12.i386.rpm) for Fedora 9. Although we could convert to a Debian package with alien, its preferrable to build it from original Debian sources.
The kernel patches are located at src/kernel-patch/kernel-2.6.25.9nctuns20080826-patches.tar.bz2. Despite the name, this file does not contain patches but the whole content of the files that NCTUns needs to modify (or create). Since copying these files directly to the Debian kernel tree is unsafe, first of all we will create a real NCTUns patch.
If you are using Debian Unstable you may skip the next two steps by downloading this file and installing the included kernel package. The tarball contains also the NCTUns patch and the config-2.6.25 used to compile the kernel.
Create the NCTUns kernel patch
Download a pristine Linux kernel source and compare it against the NCTUns kernel files:
$ cd NCTUns-5.0/kernel-patch $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.9.tar.bz2 $ tar jxf linux-2.6.25.9.tar.bz2 $ mkdir linux-2.6.25.9-nctuns $ tar -C linux-2.6.25.9-nctuns -xjf kernel-2.6.25.9nctuns20080826-patches.tar.bz2 $ LC_ALL=C diff -urP linux-2.6.25.9 linux-2.6.25.9-nctuns | grep -v "^Only in" > nctuns-2.6.25.9.patch
Compile the Debian Kernel
Download a Debian kernel v2.6.25 (for example, here), apply the previously created NCTUns patch, compile the kernel and install the generated deb package.
$ cd /tmp $ wget http://puga.vdu.lt/debian/dists/lenny/main/binary-i386/l/linux-2.6.25/linux-source-2.6.25_2.6.25-3~1_all.deb $ dpkg -i linux-source-2.6.25_2.6.25-3~1_all.deb $ cd /usr/src $ tar jxf linux-source-2.6.25.tar.bz2 $ cd linux-source-2.6.25 $ patch -p1 < /path/to/patch/nctuns-2.6.25.9.patch $ cp config-2.6.25 .config $ make-kpkg --initrd --append-to-version=-nctuns kernel_image $ dpkg -i .. linux-image-2.6.25-nctuns_2.6.25-nctuns-10.00.Custom_i386.deb
Reboot the system and select the NCTUns kernel.
Test the daemons
Now that a NCTUns kernel is installed, both dispatcher and coordinator daemons should work (otherwise the message Sorry!! This kernel is not nctuns kernel. Please select nctuns kernel to boot. will be shown).
$ dispatcher ServerSocket listen to port:9810 ServerSocket listen to port:9800 (Active:0| fd:3) (Active:1| fd:4)
$ coordinator /usr/local/nctuns/bin/ ServerSocket listen to port:9830 FD:4 ServerSocket listen to port:9840 FD:5 ServerSocket listen to port:9880 FD:6 UnixDomainSocket Bind Path:/tmp/nctuns FD:7 [To Dispatcher...] register|127.0.0.1|9830|9840|IDLE [From Dispatcher...] OK