Installing ns3.35 in Debian 10 chroot Jail Under Debian 11 Host OS or any Version of Linux Host

https://www.projectguideline.com/installing-ns3-35-in-debian-10-chroot-jail-under-debian-11-host-os-or-any-version-of-linux-host/

 

Article Written by: CharlesPandian

Problems that we face during installing ns-3 under Native and Virtual Hardware/OS:

The  most common issues that we may face under native hardware are:

  1. The Unix/Linux variant operating system(host OS) that is previously installed in the native hardware will not support or will not have the necessary version of GCC and other dependent packages that are needed to compile ns3.35 and NetAnim successfully.
  2. Further, if we try to install the necessary version of GCC and other dependent packages under the host operating system, then it may raise some package conflicts; so some of the software that is previously installed in the system may fail to work.

The  most common issues that we may face under type II hypervisors are:

  1. Generally, the virtual hardware (under VirtualBox or VMWare or Microsoft Virtual PC) will not have sufficient memory (RAM); so the software that are requiring high memory and disk i/o will run with poor performance in terms of speed under virtualization.
  2. Generally, the compile process of ns3.35 or any ns-3 version will consume a lot of CPU power and resources. So, the compile process will perform very poorly under normal type II  virtualization.
  3. Since some extra components of ns-3 such as NetSimulyzer (a 3D visualization tool for ns-3) will expect 3D graphic acceleration hardware by default, and such 3D graphics hardware may not be available or could not be configured under virtualization, (Even if we can successfully complete the compile process under VM) simply, such 3D hardware/software fails to start with some ‘3D graphics’ related errors.

 

Chroot based Virtualization

According to Wikipedia “A chroot on Unix operating systems is an operation that changes the apparent root directory for the current running process and its children. A program that is run in such a modified environment cannot name (and therefore normally cannot access) files outside the designated directory tree. The modified environment is called a chroot jail.”

Keep in mind that the OS environment virtualized in chroot jail will only use the kernel of the host operating system. Since every ‘self-contained’ kernel doesn’t depend on the standard C library or any other library,  installing any software under chroot will only depend on the libraries that we instal inside the chroot environment.  Technically, in a chroot environment, we can use an old Linux variant with a new kernel of the host(or even an elder kernel of the host).

So, using this amazing chroot facility, we can easily install any guest UNIX/Linux variant under a host operating system and install/compile any software without disturbing the packages and software that are installed on the host OS.

It is a classical and brilliant way of virtualization.

Advantages of installing ns-3 Under Chroot Jail Based Virtualization.

  1. It is possible to install any version of ns-3 on any version of Linux host, whether it is a new or old version(we only need to install the necessary Linux version in the chroot jail that is suitable for the version of ns3 that we are going to install)
  2. Installing dependency packages under chroot jail will not collapse the package integrity of the HOST OS. So our installation will not end as a nightmare or a crash the host Linux system in any way. 
  3. Unlike in other Type II hypervisors, under chroot, we will get native CPU speed during the ns-3 compile process.
  4. Unlike in other Type II hypervisors, under chroot, the compile process will have access to all the real physical CPUs and the whole installed RAM in the system.
  5. Unlike in other Type II hypervisors, under chroot, the compile process will have the native speed of accessing the system hard drives and other resources, so it will also boost the overall compile process.
  6. Most among all, if the path of “chroot jail’ is kept in a separate drive or volume, and if the HOST OS installed in the system will crash/fail in future for some other reason, and we need to reinstall it again, then the new installation will not at all affect anything that we did in chroot jail.  So that, after the reinstallation of the host OS, our ns-3 installation residing in chroot jail will be instantly available for our use.

Installation of Debian 10 Buster (64 bit) chroot Jail Environment under Debian 11

The Installation Requirements of chroot jail environment in Host

  1. Any low or high version of Unix/Linux desktop Host OS installation ( we need not worry about the version of GCC and other libraries installed in the Host OS)
  2. binutils and debootstrap package

Note: I used Debian 11 as the host OS. But, technically/theoretically, it is possible to use any lower version of Debian Host or even any other lower version of  Linux/Unix variant as HOST OS. 

Installation of chroot Jail

Step 1: Install the dependencies 

$ sudo apt install binutils  debootstrap

 

Step 2: Create a directory for holding the root file system (of the guest OS -Debian 10). Here I am creating a folder  “Debian10Buster” under a partition that is mounted under /mnt/Virtual.

$ cd /mnt/Virtual
$ mkdir Debian10Buster 

 

Step 3: Download the entire directory structure of 64 bit Debian 10 (Buster) Linux under the folder Debian10Buster using debootstrap command

$ sudo debootstrap –arch=amd64 buster ./Debian10Buster http://deb.debian.org/debian

The following  image shows the downloaded root directory structure of Debian 10 under the mounted file system of Host OS Debian 11

 

 

Step 4: Starting the ‘chroot jail’ terminal

# export display environment of host OS for running GUI application of chroot (guest) using the host OS’s windowing system.
$ export DISPLAY=:0.0
$ xhost +

 

# Enter into chroot jail
$ cd /mnt/Virtual
$ sudo chroot ./Debian10Buster

The above command opens the terminal of chroot jail Environment.

The following terminal output shows the root (/) of the chroot jail.

 

 

So the above terminal is a root (/) file system of the Debian 10 Buster which is under chroot jail.

From this terminal, we can not access the root file system of the Debian 11 host. So we can safely do all our installations and experiments under this chroot jail.

The following is the view from the host OS’s desktop. Here the left side file explorer shows the absolute path of the chrooted folder.  But the right-side terminal shows the same location under restricted chroot jail.

 

 

Installation of ns-3 Under Chroot Jail

 

Step 6: Install the necessary dependencies of ns3 

# refresh the database of available packages
$ apt-get update

 

#install the dependencies
$ apt install g++ python3 python3-dev pkg-config sqlite3 tbase5-dev qtchooser qt5-qmake qtbase5-dev-tools

#(see https://www.nsnam.org/wiki/Installation for more details)

Step 7: Download ns3.35 from https://www.nsnam.org/releases/ns-3-35/

# Download ns-allinone-3.35.tar.bz2under home directory
# cd /home
$ wget https://www.nsnam.org/releases/ns-allinone-3.35.tar.bz2

 

#extract the compressed file using your own method

In this tutorial, I will extract the directory structure of ns-3.35under the folder /home/ns-allinone-3.35 (under the virtual Debian 10 guest) 

The following output shows the absolute path of ns-allinone-3.35 installation from file explorer that was running under the host OS (Debian 11) 

 

 

Step 8: Compiling ns-3.35

 

#compiling ns-3.35

 

$ cd /home/ns-allinone-3.35/ns-3.35

#configure make file according to the environment
$./waf configure

# Sometimes we may need to configure some gcc options  and then configure the make as follows
#  CXXFLAGS=”-Wall -g -O0″ ./waf configure

#Compiling ns-3.35
$ ./waf
 

 

The following terminal shows the successful compile of ns-3.35 under chroot jail

 

Installation of NetAnim Under Chroot Jail

 

Step 1: 

 

#Creating Make file for compiling NetAnim

 

$ cd /home/ns-allinone-3.35/netanim-3.108

#configure make file using qmake
$ .qmake NetAnim.pro

 

The above command will create the Makefile for the compilation of NetAnim. The following screenshot shows the successful creation of Makefile.

 

 

 

#compiling NetAnim

 

$ make -j9

# the option -j9 is for compile using multiple CPU jobs

The following screenshot shows the successful compile of NetAnim.

The following screenshots of the guest OS (Debian 11) show the NetAnim GUI from the chrooted Debian 10.

 

 

Final Note :

We have to keep in mind that the NetAnim is actually running in Debian 10 (chrooted Guest OS) and only just showing its output on Debian 11’s (Host OS) windowing system. The important thing we have to understand here is, the application which is running under chroot jail environment will get the native or near-native performance of the Host OS and Host hardware. So, we are getting the native software and hardware performance under this unique virtualization technology. So that the ns-3 compile process also gets accelerated and get near-native software and hardware performance.

Important: If you face any issues or errors while running  NetAnim GUI under chroot, then you have to mount the /proc and /dev file systems of the host under the root / of chroot (mount -t proc /proc proc/) before entering into chroot jail.  We have to export the Host Display before entering into the chroot jail

The Main Advantage of Using Chroot:

Using this amazing, classical virtualization technology, one can install any number of software under chrooted environment.

For example, in the following screenshot, we see 11  different Deibian installations on separate chrooted directories. We can start any number of such chrooted Linux environments simultaneously on the same laptop. 

Further, it is possible to install more than one compatible version of ns-3s  or any software on a single chrooted environment. The following screenshot shows that there are different versions of ns-3s and other software that are installed on a chrooted 64bit version of Debian10 Buster Operating System.

Some Examples of “Chroot Jail” based Simulations

In the following articles, you may find some of the simulations that I did under chroot jail. Please note the excellent performance of these GUI based 3D simulations. In fact, these simulations are actually running under chroot jail but the GUI 3D outputs are rendered in the Host Disply’s windowing system. So that these simulations are getting the native 3D performance.  One will never get such a level of performance under any other kind of virtualization like “VirtualBox”.

 

For installing ns-3.37, one may follow the procedure explained in the following article :

Simulations using chrooted Debian 10 Buster AMD64 (Under Debian 11 Host)

Simulations using chrooted Debian 9 Stretch AMD64 (Under Debian 11 Host)

References:

  1. https://www.nsnam.org/wiki/Installation
  2. https://en.wikipedia.org/wiki/Chroot
posted @ 2023-09-30 09:35  张同光  阅读(18)  评论(0编辑  收藏  举报