How to Install UDP.H Packages in Ns2
To import Udp.h packages in NS2 tool stay in touch with ns2projects.com, if you face any struggle after reading the ideas then we will be your trusted partner. Here, we will explain about the Udp Header executes the Client Datagram Convention (UDP), which gives a connectionless, best-effort conveyance benefit for arrange communication. Not at all like TCP, UDP does not ensure bundle conveyance, arrange, or mistake redress, making it appropriate for applications that prioritize speed over unwavering quality, such as video spilling or real-time gaming. The ‘udp.h’ record incorporates the statements for UDP specialist capacities, which handle sending and getting datagrams without building up a association between the sender and recipient. Here, we have an exciting and exclusive article that is just popped out for you to notify the steps that are required for the installation of Udp.h.
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 ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
set tracefile [open out.tr w]
$ns trace-all $tracefile
proc finish {} {
global ns nf tracefile
$ns flush-trace
close $tracefile
close $nf
exec nam out.nam &
exit 0}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]
$ns simplex-link $n0 $n1 1Mb 10ms DropTail
$ns simplex-link $n1 $n2 1Mb 10ms DropTail
$ns simplex-link $n2 $n3 1Mb 10ms DropTail
$ns simplex-link $n3 $n4 1Mb 10ms DropTail
$ns simplex-link $n4 $n5 1Mb 10ms DropTail
$ns simplex-link $n5 $n6 1Mb 10ms DropTail
$ns simplex-link $n6 $n7 1Mb 10ms DropTail
$ns simplex-link $n7 $n0 1Mb 10ms DropTail
$ns rtproto LS
set udp0 [new Agent/UDP] ;# Create UDP agents and attach them to nodes
$ns attach-agent $n0 $udp0
set udp1 [new Agent/UDP]
$ns attach-agent $n7 $udp1
set cbr0 [new Application/Traffic/CBR] ;# Create a UDP traffic generator and attach it to the UDP agent
$cbr0 set packetSize_ 1000
$cbr0 set rate_ 500Kb
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n7 $null0 ; # Connect the UDP agents
$ns connect $udp0 $null0
$ns at 1.0 “$cbr0 start”
$ns at 10.0 “$cbr0 stop”
$ns at 12.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:
Screenshot:
Screenshot:
Here, NS-2.35 Building process completed successfully.
5.Importing Udp.h:
Here we imported the Udp.h header file code indirectly accessed the Udp class used in the Tcl script (set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0), Agent/UDP in Tcl maps to the UdpAgent class in the header file. It creates a new instance of UdpAgent and attaches it to a node (n0), enabling it to participate in this example program. Here we highlighted the code line that highlighted which is internally accessed Udp.h that we will show class file that used in this code via Apps folder.
Screenshot:
Screenshot:
Here we will show the header file by opening Udp.h file to show the class or function imported from the Udp.h in the example code. Udp.h is used (set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0), UDP agents handle the UDP functionality on the respective nodes during the simulation.
Screenshot:
Screenshot:
6.Executing the Example Program for Udp Header:
Then we need to run the Example program for Udp Header to view output of the program.
Command: “./ns Main.tcl”
Screenshot:
Here we shown the output of the example program by using Udp.h.
Screenshot:
Screenshot:
Screenshot:
In the NS 2.35 Simulation Example Program, the Udp.h Header file is successfully imported.