Lab 1. Simulation Environment

© Szymon Szott 2018

In this lab you will run your first network simulations and understand the basics of the ns-3 network simulator.

Throughout this instruction the PDF version of the ns-3 tutorial is referenced because it contains numbered sections. However, you may want to use the HTML version if you wish.

Hello World

Read Section 2.3 (Waf) from the ns-3 tutorial. waf is a substitute for which common Linux utility?

Look at your home directory structure for directories related to ns-3. What is the path to the ns-3.x directory (where x is the current version number)? We will be working from here.

Read Section 3.5 (Running a Script) from the ns-3 tutorial. In order to run the hello-simulator.cc script without recompiling ns-3 with examples enabled do the following:

cp examples/tutorial/hello-simulator.cc scratch/
./waf --run scratch/hello-simulator

Look at the code of hello-simulator.cc. Change the printed text so that it contains a unique value and run the script again.

First Network Simulation

Read Section 4.2.9 from the ns-3 tutorial and run first.cc by executing the following general steps:

  1. Copy the first.cc script file from examples/tutorial to the scratch subdirectory.
  2. Use ./waf --run scratch/first to run (waf will compile if necessary)

What kind of communication occurred in the simulation?

Test which of the following commands successfully runs first.cc:

Understand what every line of code in first.cc does. Everything is explained in Section 4.2 of the ns-3 tutorial.

Modify the script so that a total of 3 messages are sent by the client, one every X seconds, where X is any number greater or equal to 4. Compile and run the script and see if the end result is what you expected.

Wireshark

Read Section 5.3.2 of the ns-3 tutorial to learn how to enable .pcap output in first.cc. The extra line has to be inserted before Simulator::Run(). After running the updated script, where are the .pcap files located? How many files are there? What is their naming scheme?

Open the files in Wireshark. Modify Wireshark's IP settings (Edit -> Preferences -> Protocols -> IPv4) by enabling the "Validate..." option. Wireshark will notice an error in one of the IP header fields. Which one? Why is there an error there?


Homework

Installing ns-3

Install the latest version of ns-3 on a Linux machine. Alternatively, you can clone the latest ns-3-dev repository and install from there:

sudo apt install mercurial
hg clone http://code.nsnam.org/ns-3-dev
cd ns-3-dev
./waf configure
./waf

The Linux machine can be a virtual machine on your Windows PC (using VirtualBox or VMWare Player). A modern, but lightweight distribution such as Xubuntu is recommended.

Follow the ns-3 tutorial for help with the installation process. The ns-3 website also provides some installation notes. If you have trouble with gcc versions or gccxml, I suggest using build.py and not bake.py. Verify your installation by running the hello-world script.

Important ns-3 Abstractions

Read Section 4.1 from the ns-3 tutorial to learn basic ns-3 concepts. This will help you understand the scripts in the next labs.

Draw a simple diagram of two PCs connected in a LAN. Each PC has one Ethernet interface. One PC is running a WWW server, the other has a WWW client (web browser). Label the diagram using the ns-3 abstractions described in Section 4.1.


Report card

Link to the Lab 1 report card