Creating Random Traffic Pattern in NS 2.34

Creating Random Traffic Pattern in NS 2.34

In this tutorial, we will look at creating random traffic patterns in ns-2.34 for wireless communications.

I’m going to open the terminal and inside the terminal, I will change the directory to cd ns/ns all in one 2.34 and independent utilities, CMU, in this directory or path I will type ns cbrgen.tcl.

As you can see, it displays the usage of the command for creating traffic patterns, you need to have parameters such as type of traffic which will be CBR or TCL, number of nodes, seed to provide random output, the maximum number of connections, as well as rate.

In this case, we will assume, type of traffic as CBR, the number of nodes is 100, the seed is 1.0, the maximum number of connections is 20 and the rate is 4 packets per second.

Now I’m going to execute the cbrgen.tcl command by typing ns cbrgen.tcl, space -n that is number of nodes -seed 1.0, -mc 20 connections and -rate that is 4 packets per second.

As you can see the CBR command creates a traffic pattern which can be used in TCL file for simulation. This output needs to be saved in the file which can be called later in the TCL file.

The video below describes the entire process of creating a Random Traffic Pattern in NS2.34


Creating Random Traffic Pattern in NS 2.34
To save the output we use the redirection operator, use the same command with the same parameters and provide the file named after the redirection operator in this case I am providing traffic-test as the filename for the traffic pattern.

This file contains the randomly generated source and destination of our traffic pattern.