Creating a new model in NS3 Network Simulator

: Nowadays, network simulators are very useful to model a communications system. In this technical note we will focus in the creation of a new error model in NS-3 network simulator.This note describes the main steps to create or modify an Wi-Fi error model in this network simulator. In our case, we have created a new error model to included the approach of [1] to compute PER (Packet Error Rate) for vehicular environments.


Introduction
Usually in communications research projects, researchers look for the way to create or modify protocols, methods, process, among others in the chosen simulation tools .Nowadays, Wi-Fi is one of the most used technologies in the wireless communications environments.Currently, the Wi-Fi module of NS-3 includes three error models, which are used in different scenarios.For this reason, in this technical note we show a way to add a new model in the popular NS-3 network simulator.For our case, we show how to add a new error model in the Wi-Fi module [2].The new error model to be implemented was the proposed in [1].This approach has the advantage of being a easy computation of PER.
Although in this technical note we focus on an error model, it should be noted that to create any type of model the process is basically the same.Notice that, we will use NS-3 version 25 and the Ubuntu distribution 14.04.5 LTS.In the next sections, we explain the process in detail

Adding a New Model
It must be clear to create a new model in the NS-3 network simulator is that "a module is not the same that the model" [3] [4].The NS-3 models are simply abstract representations of real-world objects such as devices, channels, protocols, etc.On the other hand, an NS-3 module can include more than one model.For example, the Internet module contains models for TCP and UDP [5].In our case, as it is an error model, we will analyze the existing objects linked to the other error models, in order to create a similar dependency when adding our new model.

Configuration
To configure the new model, we recommend the following steps:

Storage
We should decide where in the Source Tree where the Model will be located.
All of the NS-3 model source code is in the directory src/.You will need to choose which subdirectory your model will resides in [6] .Therefore, it makes sense to put it into the src/ directory somewhere, particularly for ease of integrating with the build system.
In the case of the error model, so it makes sense to implement this in the src/Wi-Fi/ module where NS-3 error models are implemented [7].

Building
NS-3 network simulator uses the "waf" build system.So, you will have to integrate your new NS-3 model using Waf build system.This requires that you add your files to the wscript file located in each directory.
Wscript is very important, because if we do not add the new model here, the simulation will not be executed or if it does then it will be wrong.
Let's start by adding error-model.hand error-model.cc(the could be empty) to wscript in src/Wi-Fi.It is really just a matter of adding the .ccfile to the rest of the source files, and the .hfile to the list of the header files.The Fig. 4 show us how to edit the file.

Using the model
We can call the new error model by adding the following configuration.Fig. 5 show a configuration by default.

NewErrorModel
The objective of our NewErrorModel in NS-3 is to add an Analytical PER (Packet Error Rate) Model for 802.11p networks.
For that, we have modified the main operation of existing models.We have based on (1) proposed on [1].Eq. 1 shows the PER as function of SNR and packet length.Where c is a constant to sustain interpolation issues, its value is 10 dB.The values of: c i , d i (i = 1, ..., 4) are reported in Table I in [1].Eq. 1 was added to the source file NewErrorModel.cc.

Simulation results
For the simulations we use an wireless scenario for MANETs (Mobile Ad-hoc Networks) with different parameters according to Table 1.To test the variation we have compared the three following error models performance: YansErrorRateModel, NistErrorRateModel and NewErrorRateModel.Here, we show a comparison between three error models using two scenarios.In the first case we have tested the models under a MANET with 60 nodes using a Manhattan Grid mobility model.The Fig. 6 and Fig. 7, scenarios 1 and 2 respectively, show us the throughput obtained in the transmission.To the second case we are using a MANET with 30 nodes under a Random Way point mobility model.

Figure 1 .
Figure 1.Internet Module, with some with some of its models

1 .
Go to the module in which you want to create the new model, in our case we will work in Wi-Fi module. 2 .Create the header file (.h):In this file is necessary to create a new class for the new model considering the inheritance.And the linked objects.The Fig. 2 show us this new class.

Figure 2 .
Figure 2. New class NewErrorRateModel, inheritance of ErrorRateModel 3 .Create the source code .cc:In this file we should code all the processes in functions that we want the model to execute.

Figure 6 .
Figure 6.Comparison of error models

Figure 7 .
Figure 7.Comparison of error models