How To Install ARP.H Packages in Ns2

To import Arp.H Packages in Ns2 we have an exciting and exclusive article that is just popped out for you to notify the steps that are required for the installation 

ARP (Medium Access Control) is tasked with emulating the functions of the ARP layer, which governs access to the physical transmission medium within a network. This layer oversees the transmission and reception of data across a shared communication channel, addressing responsibilities such as collision detection, addressing, and implementing channel access protocols like CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance). The Arp.h file includes declarations for various functionalities of the ARP layer, detailing how nodes synchronize their access to the medium and guarantee efficient data transmission. The ARP layer is essential for managing communication in both wired and wireless networks, facilitating the ability of multiple nodes to utilize the same channel without causing interference.

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:

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

set tf [open out.tr w]

$ns trace-all $tf

proc send_data {src dst} {

    puts “Node $src is sending data to Node $dst – ARP resolution may occur”

}

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

$ns duplex-link $n1 $n2 1Mb 10ms DropTail

$ns duplex-link $n2 $n3 1Mb 10ms DropTail

$ns duplex-link $n3 $n4 1Mb 10ms DropTail

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0

set null0 [new Agent/Null]

$ns attach-agent $n4 $null0

$ns connect $udp0 $null0

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 500

$cbr0 set rate_ 1Mb

$cbr0 attach-agent $udp0

$ns at 0.5 “$cbr0 start”

$ns at 4.5 “$cbr0 stop”

send_data $n0 $n1

send_data $n1 $n2

send_data $n2 $n3

send_data $n3 $n4

send_data $n4 $n0

proc finish {} {

    global ns nf tf

    $ns flush-trace

    close $nf

    close $tf

    exec nam out.nam &

    exit 0

}

$ns at 5.0 “finish”

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

NS-2.35 Configuration && Building Process

Screenshot:

NS-2.35 Configuration && Building Process

Screenshot:

Here, NS-2.35 Building process completed successfully. 

3.Importing Arp.h:

Here we imported the Arp.h header file code indirectly accessed the Arp class used in the Tcl script ARP resolution will be triggered at each node if the destination MAC address is unknown. The send_data Function is used to log the packet transmission and initiate ARP, though the actual ARP resolution happens internally in this example program. Here we highlighted the code line that highlighted which is internally accessed Arp.h, we will show class file that used in this code via Arp folder.

Screenshot:

Importing Arp.h

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Screenshot:

Importing Arp.h

Here we will show the header file by opening Arp.h file to show the class or function imported from the Arp.h in the example code. ARP resolution will be triggered at each node if the destination MAC address is unknown. The send_data Function is used to log the packet transmission and initiate ARP, though the actual ARP resolution happens internally and command function (int     arpresolve(nsaddr_t dst, Packet *p, LL *ll); that interprets this Tcl command (send_data). When the Tcl script executes this line, when a packet is sent, ARP needs to map the destination IP address to a MAC address. This process is handled by the arpresolve() method during the simulation.

Screenshot:

Importing Arp.h

Screenshot:

5.Executing the Example Program for Arp Header:

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

Command:      “./ns Main.tcl”

Screenshot:

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

Screenshot:

Screenshot:

Screenshot:

Screenshot:

In the NS 2.35 Simulation Example Program, the Arp.h Header file is successfully imported. If you require additional implementation support for ARP.H PACKAGES, feel free to contact us! Our development team is ready to help you achieve optimal results. Additionally, you can access tailored research services at ns2projects.com.