How To Install CONF.H Packages in Ns2

To import Conf.h packages in NS2 tool an exciting and exclusive article that is just popped out for you to notify the steps that are required for the installation. We will help you with best reasech ideas realated to Conf.h packages in NS2 tool . The conf.h header file is essential for establishing the configuration settings and parameters utilized within the simulation environment. This file encompasses macros, constants, and global variables that facilitate the configuration of various elements of NS-2, including default simulation values, compilation flags, and environmental settings. Typically, the conf.h file contains default specifications for packet sizes, queue lengths, and bandwidth, as well as settings that allow for the activation or deactivation of specific features in the simulator, such as debugging options or particular protocols. Additionally, it includes definitions for protocol identifiers, as well as the maximum and minimum values for simulation parameters and other constants that are employed across various modules.

PRE-REQUISITES:

  1. Fresh installation of Ubuntu 16.04 LTS:

Screenshot:

Fresh installation of Ubuntu 16.04 LTS

2.NS-ALLINONE-2.35 Installation:

Screenshot:

NS-ALLINONE-2.35 Installation

3.NS-2.35 Installation: 

Screenshot:

NS-2.35 Installation

Here, Percentage (%)  symbol Denotes the successful installation of the NS 2.35 Simulator.

Screenshot:

NS-2.35 Installation

HEADER FILE VERIFICATION:

  1. Locate to the ns-2.35 folder:

Screenshot:

Locate to the ns-2.35 folder

2.Create the Main.tcl file in the scratch folder:

Next we need to create the Main.tcl file by using text editor in the ns-2.35 folder.

Screenshot:

Create the Main.tcl file in the scratch folder

Next we need to paste the below code to the Main.tcl file and save the file in the ns-2.35 folder.

Code:

set ns [new Simulator]

set nf [open out.nam w]

$ns namtrace-all $nf

proc finish {} {

    global ns nf

    $ns flush-trace

    close $nf

    exec nam out.nam &

    exit 0}

set topo [new Topography]

$topo load_flatgrid 100 100

set rng [new RNG]              

$rng seed 0                   

set num_nodes 10

set nodes [list]

for {set i 0} {$i < $num_nodes} {incr i} {

    set n [$ns node]

    lappend nodes $n

    set xpos [expr {int([$rng uniform 0 100])}]

    set ypos [expr {int([$rng uniform 0 100])}]

    $n set X_ $xpos

    $n set Y_ $ypos

    $n set Z_ 0

for {set i 0} {$i < [expr {$num_nodes – 1}]} {incr i} {

    $ns duplex-link [lindex $nodes $i] [lindex $nodes [expr {$i + 1}]] 1Mb 10ms DropTail}

set udp0 [new Agent/UDP]

$ns attach-agent [lindex $nodes 0] $udp0

set null0 [new Agent/Null]

$ns attach-agent [lindex $nodes 4] $null0

$ns connect $udp0 $null0

set cbr [new Application/Traffic/CBR]

$cbr set packetSize_ 512

$cbr set rate_ 1Mb

$cbr attach-agent $udp0

$ns at 0.1 “$cbr start”

$ns at 4.0 “$cbr stop”

$ns at 5.0 “finish”

$ns run

Screenshot:

Create the Main.tcl file in the scratch folder

3.Open the Terminal:

Next, we need to launch the terminal by right clicking the mouse in the ns-2.35 location.

Screenshot:

Open the Terminal

Screenshot:

Open the Terminal

4.NS-2.35 Configuration && Building Process:

Next, we need to configure and build the ns-2.35 folder to make the Created files need to work in ns-2.35 configuration.

Command:      “./make”

Screenshot:

Screenshot:

NS-2.35 Configuration && Building Process

Screenshot:

5.Importing Conf.h:

Here we imported the Conf.h header file code indirectly accessed the Conf header define ($ns namtrace-all $nf) enables NAM trace for the simulation. Internally, the conf.h file configures various NAM-related constants, such as packet types and node representations in this example program. Here we highlighted the code line that highlighted which is internally accessed Conf.h that we will show class file that used in this code via Nam folder.

Screenshot:

Importing Conf.h

Screenshot:

importing Conf.h

Here we will show the header file by opening Conf.h file to show the class or function imported from the Conf.h in the example code. It defines ($ns namtrace-all $nf) enables NAM trace for the simulation. Internally, the conf.h file configures various NAM-related constants, such as packet types and node representations.

Screenshot:

Importing Conf.h

6.Executing the Example Program for Packet Header:

Then we need to run the Example program for Packet Header to view output of the program.

Command:      “./ns Main.tcl”

Screenshot:

Executing the Example Program for Conf Header

Here we shown the output of the example program by using Conf.h.

Screenshot:

Executing the Example Program for Conf Header

 Screenshot:

Executing the Example Program for Conf Header

Screenshot:

Executing the Example Program for Conf Header

In the NS 2.35 Simulation Example Program, the Conf.h Header file is successfully imported.