How to Install MAC 802_11.h Packages in Ns2
to Import MAC-802_11. packages in ns2 we have shared the steps in detail.
The MAC 802.11.h file is responsible for implementing the MAC (Medium Access Control) layer protocol in accordance with the IEEE 802.11 standard, which is commonly utilized in wireless local area networks (WLANs). This protocol plays a crucial role in managing how devices access the shared wireless medium, overseeing packet transmissions, addressing collisions, and handling acknowledgments to facilitate efficient data transfer within a wireless network. The mac-802_11.h file includes declarations for key methods and functions that replicate the behavior of the MAC 802.11 protocol. This includes mechanisms to minimize collisions by having devices check the medium before sending data, as well as an optional handshake process to mitigate hidden terminal issues. Additionally, it ensures reliable packet delivery by requiring the receiver to send an acknowledgment upon successful receipt. When a device detects a busy channel or a collision, it will wait for a random period before attempting to transmit again.
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
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(ifqlen) 50
set val(nn) 10
set val(rp) DumbAgent
set val(x) 600
set val(y) 600
Mac/802_11 set dataRate_ 11Mb
set ns_ [new Simulator]
set tracefd [open infra.tr w]
$ns_ trace-all $tracefd
set namtrace [open infra.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
set chan_1_ [new $val(chan)]
$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) \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace OFF \
-macTrace ON \
-movementTrace ON \
-channel $chan_1_
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
set mac_($i) [$node_($i) getMac 0]
$mac_($i) set RTSThreshold_ 3000
$node_($i) set X_ [expr $i * 50.0]
$node_($i) set Y_ 50.0
$node_($i) set Z_ 0.0
}
set AP_ADDR1 [$mac_(0) id]
$mac_(0) ap $AP_ADDR1
set AP_ADDR2 [$mac_([expr $val(nn) – 1]) id]
$mac_([expr $val(nn) – 1]) ap $AP_ADDR2
$mac_(1) ScanType ACTIVE
for {set i 3} {$i < [expr $val(nn) – 1]} {incr i} {
$mac_($i) ScanType PASSIVE
}
$ns_ at 1.0 “$mac_(2) ScanType ACTIVE”
Application/Traffic/CBR set packetSize_ 1023
Application/Traffic/CBR set rate_ 256Kb
for {set i 1} {$i < [expr $val(nn) – 1]} {incr i} {
set udp1($i) [new Agent/UDP]
$ns_ attach-agent $node_($i) $udp1($i)
set cbr1($i) [new Application/Traffic/CBR]
$cbr1($i) attach-agent $udp1($i)
}
set base0 [new Agent/Null]
$ns_ attach-agent $node_(1) $base0
set base1 [new Agent/Null]
$ns_ attach-agent $node_(8) $base1
$ns_ connect $udp1(4) $base0
$ns_ connect $udp1(5) $base1
$ns_ at 2.0 “$cbr1(4) start”
$ns_ at 4.0 “$cbr1(5) start”
$ns_ at 10.0 “$node_(4) setdest 300.0 1.0 30.0”
$ns_ at 20.0 “stop”
$ns_ at 20.0 “puts \”NS EXITING…\” ; $ns_ halt”
proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
exec nam infra.nam &
exit 0
}
$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 Mac-802_11.h:
Here we imported the Mac-802_11.h header file code indirectly accessed the Mac-802_11 class used in the Tcl script (set val(mac) Mac/802_11) are used for simulating the MAC (Medium Access Control) layer protocol for the IEEE 802.11 standard in wireless networks. This configuration helps to create Wireless Medium to avoid Collision in the network in this example program. Here we highlighted the code line that highlighted which is internally accessed Mac-802_11.h, we will show class file that used in this code via Mac folder.
Screenshot:
Screenshot:
Here we will show the header file by opening Mac-802_11.h file to show the class or function imported from the Mac-802_11.h in the example code. This Tcl Script Line (set val(mac) Mac/802_11) are used for simulating the MAC (Medium Access Control) layer protocol for the IEEE 802.11 standard in wireless networks. This configuration helps to create Wireless Medium to avoid Collision for Multiple Nodes Communication in the network in this example program.
Screenshot:
Screenshot:
6.Executing the Example Program for Mac-802_11 Header:
Then we need to run the Example program for Mac-802_11 Header to view output of the program.
Command: “./ns Main.tcl”
Screenshot:
Here we shown the output of the example program by using Mac-802_11.h.
Screenshot:
Screenshot:
Screenshot:
In the NS 2.35 Simulation Example Program, the Mac-802_11.h Header file is successfully imported.
Facing difficulties after knowing the steps on how to run Mac-802_11.h_ packages in NS2 tool. Share with us all your needs ,let us handle your work we assure success. Our team assists you in obtaining the ideal MAC-802_11. PACKAGES project results customized to meet your requirements.Give us all of your project ideas if you’re having trouble coming up with a theme, and we’ll give you the best advice possible. Our development staff will help you get the greatest outcomes. We have all the resources and tools need to help you at the appropriate time.
Visit ns2projects.com to obtain personalized research services. contact us if you need any additional assistance with MAC-802_11. PACKAGES!