A Preliminary Study of VM Installation and NS3
One: vm virtual machine installation
I am here to use the vm virtual machine to install the Ubuntu operating system
Poke here
First install the virtual machine Amway link, you can try it,
Two: NS3 exploration
2.1 Modify the file and enter the ns-3.29 folder
After moving the ns installation package to the disk where the virtual machine is located, start the terminal terminal, and then enter the ls -l command to query the file and its permissions, you will find the figure
The ns file is marked in red, we need to use the command chmod to modify the ns compressed package command to make it readable, writable and executable for all users. Enter the following command and execute it.
chmod 777 ns-allinone-3.29.tar.bz2
Enter the ls -l command again as shown in the figure:
Now you can double-click the file in the file to decompress it.
After decompression, copy the file to the home file.
Use the cd command to enter ns-3.29 under ns-allione-3.29
2.2 Enter debug mode
./waf configure --build-profile=debug --enable-examples --
Successfully enter the debug mode.
2.3 Running example
./waf --run hello-simulator
Will produce the following result,
Compile and run successfully!
Three: After modifying with C++ program, it becomes hello world
Use the Vim editor under linux to modify the file, and compile and run again.
3.1 Find the file:
3.2 Open and modify:
sudo vim hello-simulator.cc
Error:
vim command not found
This is because the vim editor is not installed in the initial system
input the command
sudo apt-get install vim
When asked during the installation of Vim, enter y to confirm
After installation, enter again
sudo vim hello-simulator.cc
The result is as follows
Edit below, enter i to enter edit mode
Modify the code as follows:
#include "ns3/core-module.h"
#include <iostream>
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("HelloSimulator");
int
main (int argc, char *argv[])
{
std::cout<<" Nice to meet you" <<std::endl;
return 0;
}
Because no namespace is specified, std is added to the regular cout
Press and hold esc to restore the normal mode, then enter: wq to save
Of course, it can also be opened and saved in other editors in the file management.
After that, use the cd… command twice to return to the previous menu and run again
The results are as follows: