How to Install PROPAGATION.H Packages in Ns2

To import the PROPAGATION.H packages in the Ns2 tool, follow the steps outlined below. We’ll provide you with customized solutions and intriguing research ideas that will capture the readers’ interest. 

The simulation of radio wave propagation in wireless networks is handled by Propagation.h. The Propagation module simulates the movement of signals from a transmitting node to a receiving node while accounting for environmental conditions, distance, and signal strength. As it determines whether a transmitted signal reaches its destination and how much it is affected by attenuation or interference, this class is critical to accurately simulating wireless communication. The Free-Space Model, which simulates signal propagation in an unhindered environment and determines signal strength based on the distance between the transmitter and receiver, is one of the propagation models used in NS-2 simulations that are declared in the propagation.h file. The Two-Ray Ground Model is better suited for longer distances since it takes into consideration both the direct and reflected paths of the signal.

PRE-REQUISITES:

  1. Fresh installation of Ubuntu 16.04 LTS:

Screenshot:

Fresh installation of Ubuntu 16.04 LTS

2.NS-2.35 Installation:

Screenshot:

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

Screenshot:

HEADER FILE VERIFICATION:

  1. Locate to the ns-2.35 folder:

Screenshot:

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 val(chan)       Channel/WirelessChannel 

set val(prop)       Propagation/TwoRayGround

set val(netif)      Phy/WirelessPhy

set val(mac)        Mac/802_11              

set val(ifq)        Queue/DropTail/PriQueue 

set val(ll)         LL                   

set val(ant)        Propagation/OmniPropagation    

set val(ifqlen)     50                      

set val(nn)         20                

set val(rp)         AODV                   

set val(x)          500                    

set val(y)          400                    

set val(stop)       150                   

set ns      [new Simulator]

set tracefd [open testAODV.tr w]

set namtrace [open testAODV.nam w]

$ns trace-all $tracefd

$ns namtrace-all-wireless $namtrace $val(x) $val(y)

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

# Node configuration for Propagation

$ns node-config -adhocRouting $val(rp) \

    -llType $val(ll) \

    -macType $val(mac) \

    -ifqType $val(ifq) \

    -ifqLen $val(ifqlen) \ 

    -antType $val(ant) \ 

    -propType $val(prop) \ 

    -phyType $val(netif) \ 

    -channelType $val(chan) \ 

    -topoInstance $topo \ 

    -agentTrace ON \ 

    -routerTrace OFF \ 

    -movementTrace ON \ 

    -energyModel “EnergyModel” \ 

    -initialEnergy 1000.0 \ 

    -rxPower 0.3 \ 

    -txPower 0.6 \ 

    -idlePower 0.1 

for {set i 0} {$i < $val(nn)} {incr i} { 

    set node_($i) [$ns node] 

    $node_($i) set X_ [expr 10+round(rand()*480)] 

    $node_($i) set Y_ [expr 10+round(rand()*380)] 

    $node_($i) set Z_ 0.0 

for {set i 0} {$i < $val(nn)} {incr i} { 

    $ns at [expr 15+round(rand()*60)] \ 

        “$node_($i) setdest [expr 10+round(rand()*480)] [expr 10+round(rand()*380)] [expr 2+round(rand()*15)]” 

$ns at 10.0 “$node_(0) setdest 250.0 250.0 3.0” 

$ns at 15.0 “$node_(1) setdest 45.0 285.0 5.0” 

$ns at 70.0 “$node_(2) setdest 480.0 300.0 5.0” 

$ns at 20.0 “$node_(3) setdest 200.0 200.0 5.0” 

$ns at 25.0 “$node_(4) setdest 50.0 50.0 10.0” 

$ns at 60.0 “$node_(5) setdest 150.0 70.0 2.0” 

$ns at 90.0 “$node_(6) setdest 380.0 150.0 8.0” 

$ns at 42.0 “$node_(7) setdest 200.0 100.0 15.0” 

$ns at 55.0 “$node_(8) setdest 50.0 275.0 5.0” 

$ns at 19.0 “$node_(9) setdest 250.0 250.0 7.0” 

set tcp [new Agent/TCP/Newreno] 

$tcp set class_ 2 

 

set sink [new Agent/TCPSink] 

$ns attach-agent $node_(2) $tcp 

$ns attach-agent $node_(9) $sink 

$ns connect $tcp $sink 

set ftp [new Application/FTP] 

$ftp attach-agent $tcp 

proc plotWindow {tcpSource file} { 

    global ns 

    set time 0.01 

    set now [$ns now] 

    set cwnd [$tcpSource set cwnd_] 

    puts $file “$now $cwnd” 

    $ns at [expr $now+$time] “plotWindow $tcpSource $file” 

proc stop {} { 

    global ns tracefd namtrace 

    $ns flush-trace 

    close $tracefd 

    close $namtrace 

    exec nam testAODV.nam & 

    exit 0 

$ns at 10.0 “$ftp start” 

$ns at $val(stop) “stop” 

$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:

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:

NS-2.35 Configuration && Building Process

Screenshot:

NS-2.35 Configuration && Building Process

 

Screenshot:

NS-2.35 Configuration && Building Process

Here, NS-2.35 Building process completed successfully.

5.Importing Propagation.h:

Here we imported the Propagation.h header file code indirectly accessed the Propagation class used in the Tcl script that we had highlighted lines are configured which determines whether signals are successfully transmitted, received, or lost due to factors like distance, noise, or obstacles in the wireless Network in this example program. Here we highlighted the code line that highlighted which is internally accessed Propagation.h, we will show class file that used in this code via Mobile folder.

Screenshot:

Importing Propagation.h

Screenshot:

Importing Propagation.h

Here we will show the header file by opening Propagation.h file to show the class or function imported from the Propagation.h in the example code. This Tcl Script Line are configured with TwoRayGround Propagation model which determines whether signals are successfully transmitted, received, or lost due to factors like distance, noise, or obstacles in the wireless Network with each node in this example program.

Screenshot:

Importing Propagation.h

Screenshot:

Importing Propagation.h

6.Executing the Example Program for Propagation Header:

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

Command:      “./ns Main.tcl”

Screenshot:

Executing the Example Program for Propagation Header

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

Screenshot:

Executing the Example Program for Propagation Header

Screenshot:

Fresh installation of Ubuntu 16.04 LTS

Screenshot:

Executing the Example Program for Propagation Header

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