A Preliminary Study of VM Installation and NS3

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

image-20201025001449348

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:

image-20201025094419183

Now you can double-click the file in the file to decompress it.

After decompression, copy the file to the home file.

image-20201025002610850

Use the cd command to enter ns-3.29 under ns-allione-3.29

image-20201025003014452

2.2 Enter debug mode

./waf configure --build-profile=debug --enable-examples --

image-20201025003622143

Successfully enter the debug mode.

2.3 Running example

./waf --run hello-simulator

Will produce the following result,

image-20201025010643047

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:

image-20201025010809906

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

image-20201025011950384

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

image-20201025014429311
The results are as follows:

image-20201025014429311

Look, the result is already Nice to meet you!

Guess you like

Origin blog.csdn.net/weixin_43843172/article/details/109269392