How To Install Antenna.H Packages in Ns2
To Import Antenna.H Packages In Ns2 read out the syeps shared below, if you are struggling with best project ideas and topics then we will help you with best outcomes.
The Antenna.h file is essential for modeling how signals are transmitted and received, detailing aspects like directionality, gain, and the propagation characteristics of wireless signals. This class is vital for assessing the communication efficiency between nodes, particularly in simulations of wireless and mobile networks. Within the antenna.h file, you’ll find the Antenna class declaration, which includes various methods and attributes that enable users to adjust different antenna-related features. NS-2 supports a variety of antennas, such as OmniAntenna, which emits signals evenly in all directions. It also defines how signal strength can increase in specific directions, enhancing communication over longer distances or under particular conditions. The angle or direction of signal transmission and reception is crucial, especially for directional antennas. Additionally, the physical height of the antenna can influence how signals propagate and are received.
The Antenna class works in conjunction with the WirelessPhy (physical layer) class to manage signal propagation and reception, helping to establish the effective range and communication quality between nodes, taking into account antenna properties and environmental factors like distance and obstacles. The simulation can be set up to utilize an omnidirectional antenna with designated height and gain. While the fundamental implementation of antenna behavior is handled in the C++ code within antenna.h, users can modify these antenna settings through TCL commands, tailoring parameters to fit the simulation’s requirements. The Antenna class is particularly significant in mobile and wireless simulations, as it directly affects the communication range and reliability between nodes.
PRE-REQUISITES:
- Fresh installation of Ubuntu 16.04 LTS:
Screenshot:
2.NS-2.35 Installation:
Screenshot:
Here, Percentage (%) symbol Denotes the successful installation of the NS 2.35 Simulator.
Screenshot:
HEADER FILE VERIFICATION:
- 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
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) Antenna/OmniAntenna
set val(ifqlen) 50
set val(nn) 15
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 Antenna
$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:
3.Open the Terminal:
Next, we need to launch the terminal by right clicking the mouse in the ns-2.35 location.
Screenshot:
Screenshot:
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:
Screenshot:
Here, NS-2.35 Building process completed successfully.
5.Importing Antenna.h:
Here we imported the Antenna.h header file code indirectly accessed the Antenna class used in the Tcl script that we had highlighted lines are configured to use an omnidirectional antenna through wireless Network communication for transmission and reception of signals in this example program. Here we highlighted the code line that highlighted which is internally accessed Antenna.h, we will show class file that used in this code via Mobile folder.
Screenshot:
Screenshot:
Here we will show the header file by opening Antenna.h file to show the class or function imported from the Antenna.h in the example code. This Tcl Script Line are used configured to use an omnidirectional antenna through wireless Network communication for transmission and reception of signals with each node in this example program.
Screenshot:
Screenshot:
6.Executing the Example Program for Antenna Header:
Then we need to run the Example program for Antenna Header to view output of the program.
Command: “./ns Main.tcl”
Screenshot:
Here we shown the output of the example program by using Antenna.h.
Screenshot:
Screenshot:
Screenshot:
In the NS 2.35 Simulation Example Program, the Antenna.h Header file is successfully imported.
If you have any project doubts related to Antenna.h_Importation, don’t hesitate to reach out to us! We’re here to assist you in achieving the best results. You can also get customized research services at ns2projects.com.