This article presents a step-by-step procedure for installing and running ns-3 network simulations using the free resources provided by Colab Cloud Platform.
Note: The Complete Notebook file of this procedure can be downloaded from [3] and can be imported into your Google Colab for easy installation of ns-3 on Colab.
The following are the major steps :
- Setting up Google Colab environment
- Setting up a Persistent Storage
- Downloading ns-3 on the Persistent Storage
- Installing ns-3 on the Persistent Storage
- Running an example ns-3 simulation.
Step 1: Setting up Google Colab environment
- Go to the Google Colab website: https://colab.research.google.com/.
- Sign in to your Google account.
- Click on the “New Notebook” button (and you may rename the Notebook as according to the version that you are installing (for example you may rename it as ‘ns-3.37’)
- Select the “Python 3” runtime.
- You can now start writing code in your notebook.
Step 2: Setting up a Persistent Storage
Now you have to Change to the folder content/gdrive/MyDrive where you will have read, write (and execute) access. For that, you have to run the following command from the Jupyter Notebook.
Step 3: Downloading ns-3 on the Persistent Storage
Now you may download ns-3 from [2] and keep it under the Google Drive folder. For that, you have to run the following command from the Notebook.
The following output shows that the compressed file has been downloaded within 5 seconds. (the download was very fast because, it is using the very fast internet download speed provided by Google)
It will store the compressed file inside the folder ‘/content/gdrive/MyDrive’. Now we may extract the compressed file by running the following command from the Jupyter Notebook.
Step 4: Installing ns-3 on the Persistent Storage
Configure ns-3 by running the following commands from the Jupyter Notebook.
The following screenshot shows the successful configuration operation and the list of configured modules.
Build ns-3 by running the following commands from the Jupyter Notebook.
The following output shows that the build operation has been completed within 1 hour.
The following screenshot confirms the successful build operation.
Step 5: Running an example ns-3 simulation.
Run the Example simulation ‘first.cc’ provided with ns-3 by running the following commands from the Jupyter Notebook.
The following output shows that the first time the compile operation took 1 minute.
The following is the output of while running the compiled simulation of fist.cc
Conclusion
This article shows the way to use free computing and storage resources of Google Colab for doing ns-3 simulations. Even though the overall compile time was not good, it is possible to use it for running a large simulation (that may take, for example, 10 hours of CPU time). It is possible to run a batch of simulations remotely using the free cloud resources.
In fact, there is no simple way to run Network Animations such as NetAnim through this facility and visualize the simulation output. However, it is possible to do quality analysis and produce graphs using the available tools of Jupyter Notebooks.