BCA / B.Tech 8 min read

NS2 Commands

Working NS2 Commands in Hindi | Use of NS2 Commands in Hindi:


  • The use of NS2 commands plays an important role in networking research. Through these commands, users can easily simulate various aspects of a network. The flexibility and powerful command set of NS2 help researchers and students to understand the complexities of networking.
  • By using the commands correctly, it becomes possible to analyze and solve various networking issues.
  • NS2 (Network Simulator 2) is a major open-source network simulator that is widely used for networking research. In it, various aspects of a network are simulated by using different types of commands.
  • These commands are written in OTcl (Object-oriented Tcl) language.
Here we will discuss in detail the working, structure, and use of NS2 commands.

Working of NS2 Commands in Hindi | Working of NS2 Commands:

1. Introduction to NS2:

In NS2, users use commands to create, set up, and simulate various networking components. These commands are helpful in defining various network elements, such as nodes, agents, connections, and traffic generation.

2. Structure of commands:

The structure of commands in NS2 is generally as follows:

  • Command name: This is the action that we want to perform, such as new, create, connect, etc.
  • Parameters: These are variables that are passed with the command. For example, specified for nodes or agents.
Example:

set ns [new Simulator]
In this command, set is a TCL command that sets a variable ns to a new simulator object.

3. Main commands

a. Creation of a simulator

set ns [new Simulator]
This command creates a new simulator that will be used for all other actions.

b. Creation of nodes

set node1 [$ns node]
set node2 [$ns node]
This command creates new nodes node1 and node2. Each node has a unique identity and it performs the task of transmitting data in the network.

c. Adding a connection

$ns connect $node1 $node2
This command establishes a connection between node1 and node2. This connection is necessary for data transfer.

d. Traffic generation

set tcp [$ns create-traffic-generator TCP]
This command creates a TCP traffic generator that will be responsible for sending data in the network.

e. Setting time

$ns at 1.0 "$node1 send $node2 10MB"
This command states that after 1.0 second, 10MB of data will be sent from node1 to node2.

f. Running the simulation

$ns run
This command starts the simulation and executes all the set actions.

4. Tracing and reporting

NS2 provides the facility to trace various parameters (metrics) during the simulation, such as latency, throughput, and packet loss. Example:

$ns trace-all "tracefile.tr"
This command stores all trace data in tracefile.tr.

5. Use with NAM

The trace files generated by NS2 can be used in NAM (Network Animator). NAM is used for the graphical representation of the simulation.

nam tracefile.nam
This command loads the trace file in NAM so that the user can have a visual experience of the network activities.

In this Chapter

NS2 Commands
Auto-Configuration and Anycast
Modified EUI-64 | What is Modified EUI-64?
Architecture of Mobile Computing
Wireless LAN in Hindi | What is Wireless LAN?
Wireless User Devices
MAC Protocol | What is MAC Protocol?
IEEE 802.11 | What is IEEE 802.11
Mobile IP | What is Mobile IP
Wireless TCP/IP
Unicast & Multicast Communication
Bluetooth | What is Bluetooth?
NS2 & NAM | What are NS2 and NAM?
Purpose & installation of NS2 & NAM
Background of NS2 & NAM
Architecture of NS2 & NAM
Interface of OTcl & C++
Trace Files & Formats
Protocol Support of NS2
Simulation Object of NS2 & NAM
Basic Syntax of NS2 & NAM
Node Creation of NS2 & NAM
Running NS2 & NAM
Finish Procedure NS2 & NAM
Invoking external commands within NS2
Nodes & Agents of NS2 & NAM
Creating Links in Wired Network
Setting Link Parameters
Sending Traffics Through NS2 Links
Routing Protocol Support of NS2
Scenarios in Wired Networks
Additional Parameters
Setting node positions
God object & topography
Protocol Support
Scenarios in Wireless Networks
What is the Internet? Difference Between Intranet and Extranet
Types of Internet
OSI Model and its Layers
Computer Network (CN) All Important Questions and Answers in English (MDSU)
BCA | Computer Network | 2025 Paper | MDSU Exam Paper
Importance of the Layer Model in Computer Networks
Network Classification
Network Topology
Network Switching & Components
Ethernet
Token Ring
Basic Networking Concepts & Cabling
What is a Computer in English?
Bridges in Computer Networks
Routers in Computer Networks
Gateways in Computer Networks
Public & Private Networks
FDMA (Frequency Division Multiple Access)
BCA | CN(Computer Network) Paper | 2023 MDSU Exam Paper
What is World Wide Web (WWW)
TDMA, SDMA, CDMA
Personal Communication System | What is PCS
IPv4 | What is IPv4?
Subnetting IPv4 Address
Casting in IPv4
Private IPv4 Addressing
IPv4 Address Scheme
IPv6 Addressing Scheme
Types of IPv6 Addressing