BCA / B.Tech 8 min read

Invoking external commands within NS2 in Hindi

Invoking external commands within NS2 | NS2 के भीतर बाहरी आदेशों को लागू करना : 


  • NS2 में बाहरी कमांड्स का उपयोग सिमुलेशन को और अधिक शक्तिशाली और लचीला बनाता है। exec कमांड के माध्यम से, आप बाहरी स्क्रिप्ट्स और प्रक्रियाओं को सरलता से जोड़ सकते हैं, जिससे सिमुलेशन के दौरान डेटा प्रोसेसिंग और विश्लेषण की सुविधा मिलती है। 
  • हालांकि, इस प्रक्रिया को ध्यानपूर्वक उपयोग करने की आवश्यकता होती है ताकि सिमुलेशन के प्रदर्शन पर नकारात्मक प्रभाव न पड़े। NS2 और OTcl का संयोजन आपको एक समृद्ध और प्रभावी सिमुलेशन वातावरण प्रदान करता है, जो बाहरी कमांड्स को सफलतापूर्वक जोड़ने में मदद करता है।
  • NS2 (Network Simulator 2) एक शक्तिशाली उपकरण है जिसका उपयोग नेटवर्क सिमुलेशन के लिए किया जाता है। कभी-कभी, आपको NS2 के भीतर अन्य बाहरी कमांड्स (external commands) को निष्पादित करने की आवश्यकता हो सकती है। 
  • यह प्रक्रिया NS2 के भीतर C++ और OTcl (Object-oriented Tcl) स्क्रिप्टिंग का संयोजन करके की जा सकती है। यहाँ हम बाहरी कमांड्स को NS2 में कैसे लागू किया जा सकता है

 इसके विभिन्न पहलुओं पर चर्चा करेंगे।

NS2 में बाहरी कमांड्स को लागू करना

1. OTcl और C++ का परिचय

NS2 मुख्यतः दो भाषाओं का उपयोग करता है:

OTcl: यह एक स्क्रिप्टिंग भाषा है जिसका उपयोग NS2 में सिमुलेशन सेटअप के लिए किया जाता है।
C++: NS2 का मुख्य सिमुलेटर कोड C++ में लिखा गया है, जो प्रदर्शन और दक्षता के लिए महत्वपूर्ण है।

2. बाहरी कमांड्स का उपयोग

बाहरी कमांड्स को NS2 में निष्पादित करने के लिए, आपको सामान्यतः exec कमांड का उपयोग करना होता है। यह कमांड आपको किसी भी कमांड को टर्मिनल या शेल में निष्पादित करने की अनुमति देता है।

3. exec कमांड का उपयोग

OTcl में exec कमांड का उपयोग करके आप विभिन्न बाहरी स्क्रिप्ट्स या कमांड्स चला सकते हैं। इसका सिंटैक्स निम्नलिखित है:

set result [exec command]
यहाँ command वह कमांड है जिसे आप निष्पादित करना चाहते हैं। परिणाम result में संग्रहित होगा।

4. उदाहरण

चलिये, हम एक उदाहरण देखते हैं जिसमें हम एक बाहरी कमांड को NS2 में निष्पादित करते हैं।

# NS2 स्क्रिप्ट की शुरुआत
set ns [new Simulator]

# नोड्स का निर्माण
set node1 [$ns node]
set node2 [$ns node]

# कनेक्शन जोड़ना
$ns connect $node1 $node2

# डेटा भेजने की प्रक्रिया
$ns at 1.0 "$node1 send $node2 10MB"

# बाहरी कमांड को निष्पादित करना
set command_result [exec echo "Hello from NS2"]
puts $command_result

# सिमुलेशन को चलाना
$ns run
इस उदाहरण में:

हमने echo "Hello from NS2" कमांड को exec के माध्यम से चलाया।
puts $command_result का उपयोग करते हुए हम कमांड के परिणाम को प्रिंट करते हैं।

5. बाहरी स्क्रिप्ट्स का उपयोग

आप केवल एकल कमांड ही नहीं, बल्कि स्क्रिप्ट्स भी चला सकते हैं। यदि आपके पास एक शेल स्क्रिप्ट है जिसे आप चलाना चाहते हैं, तो आप इसे भी इसी तरह से कर सकते हैं:

# एक बाहरी शेल स्क्रिप्ट चलाना
set script_result [exec ./my_script.sh]
puts $script_result

6. कमांड आउटपुट को फ़ाइल में सहेजना

यदि आप आउटपुट को किसी फ़ाइल में सहेजना चाहते हैं, तो आप > का उपयोग कर सकते हैं:

set result [exec echo "Hello from NS2" > output.txt]
यह कमांड "Hello from NS2" को output.txt फ़ाइल में सहेज देगा।

7. बाहरी प्रक्रियाओं का प्रबंधन

यदि आप एक बाहरी प्रक्रिया को नियंत्रित करना चाहते हैं, जैसे कि उसे रोकना या फिर से शुरू करना, तो आपको ध्यान रखना होगा कि NS2 मुख्य रूप से सिमुलेशन के लिए डिज़ाइन किया गया है। 
लेकिन exec के माध्यम से आप अन्य प्रक्रियाओं को प्रबंधित कर सकते हैं, हालांकि यह अधिक जटिल हो सकता है।

In this Chapter

Invoking external commands within NS2 in Hindi
Auto Configuration Anycast in Hindi
Modified EUI-64 in Hindi | Modified EUI-64 क्या है?
Architecture of Mobile Computing in Hindi
Wireless LAN in Hindi | Wireless LAN क्या है?
Wireless User Devices in Hindi
MAC Protocol in Hindi | MAC प्रोटोकॉल क्या है?
IEEE 802.11 in Hindi | IEEE 802.11 क्या है
Mobile IP in Hindi | Mobile IP हिंदी में
Wireless TCP IP in Hindi
Unicast & Multicast Communication in Hindi
Bluetooth in Hindi | Bluetooth क्या है?
NS2 & NAM in Hindi | NS2 और NAM क्या है?
Purpose & installation of NS2 & NAM in Hindi
Background of NS2 & NAM in Hindi
Architecture of NS2 & NAM in Hindi
Interface of OTcl & C++ in Hindi
Trace Files & Formats in Hindi
Protocol Support of NS2 in Hindi
Simulation Object of NS2 & NAM in Hindi
Basic Syntax of NS2 & NAM in Hindi
Node Creation of NS2 & NAM in Hindi
Running NS2 & NAM in Hindi
Finish Procedure NS2 & NAM in Hindi
Nodes & Agents of NS2 & NAM in Hindi
NS2 Commands in Hindi
Creating Links in Wired Network in Hindi
Setting Link Parameters in Hindi
Sending Traffics Through NS2 Links in Hindi
Routing Protocol Support of NS2 in Hindi
Scenarios in Hindi
Additional Parameters in Hindi
Setting node positions in Hindi
God object & topography in Hindi
Protocol Support in Hindi
Scenarios in Wireless Network in Hindi
Internet क्या है? Intranet और Extranet के बीच अंतर
इंटरनेट के प्रकार | Types of Internet in Hindi
OSI Model in Hindi - OSI मॉडल क्या है और इसकी लेयर हिंदी में
Computer Network (CN) All Important Questions and Answers in Hindi (MDSU)
BCA | Computer Network | 2025 Paper | MDSU Exam Paper
Importance of Layer Model in Hindi
Network Classification in Hindi
Network Topology in Hindi
Network Switching & Component in Hindi
Ethernet in Hindi
Token Ring in Hindi
Basic working & Cabling in Hindi
What is Computer in Hindi | कंप्यूटर क्या है?
Bridges in Hindi
Router in Hindi
Gateway in Hindi
Public & Private Network in Hindi
FDMA in Hindi
BCA | CN(Computer Network) Paper | MDSU 2023 Exam Paper
What is WWW in Hindi and Introduction of WWW
CDMA,SDMA,TDMA in Hindi
Personal communication system in Hindi | PCS क्या है
IPv4 in Hindi | IPv4 क्या है?
Subnetting IPv4 address in Hindi
Casting in Hindi | कास्टिंग हिंदी में
Private IPv4 Addressing in Hindi
IPv4 Address Scheme in Hindi
IPv6 Addressing Scheme in Hindi
Types of IPv6 Addressing in Hindi