BCA / B.Tech 11 min read

Architecture of NS2 & NAM in Hindi

RK

लेखक Ratan Kumawat · संस्थापक, NotesMedia

प्रकाशित:

त्वरित सारांश और मुख्य बिंदु

  • • विषय फोकस: Computer Network & Communication Notes in Hindi | कंप्यूटर नेटवर्किंग और कम्युनिकेशन नोट्स (BCA / B.Tech Syllabus)
  • • मुख्य विषय: Architecture of NS2 & NAM in Hindi - General Topics
  • • अवलोकन: Quick Answer: NS2 (Network Simulator 2) एक discrete event-driven network simulator है, जिसका architecture दोहरी भाषा (Dual-Language Design) पर बना है: क...
  • • मुख्य अवधारणाएं: NS2 NAM architecture, Simulator object nodes links agents Hindi, Applications trace files architecture,NS2 NAM architecture, Simulator object nodes links agents, Applications trace files architecture
Quick Answer: NS2 (Network Simulator 2) एक discrete event-driven network simulator है, जिसका architecture दोहरी भाषा (Dual-Language Design) पर बना है: कोर packet प्रोसेसिंग और protocol लॉजिक के लिए C++, और सिमुलेशन सेटअप और टोपोलॉजी कॉन्फ़िगरेशन के लिए OTcl (Object Tcl)। इन दोनों को TclCL इंटरफेस जोड़ता है। NAM (Network Animator) एक ग्राफिकल विज़ुअलाइज़ेशन tool है जो NS2 की .nam ट्रेस file को पढ़कर नोड्स, लिंक्स और packet फ्लो का 2D एनिमेशन दिखाता है।

NS2 और NAM का परिचय (Introduction)

कंप्यूटर networking अनुसंधान और लैब प्रयोगों में वास्तविक router, switch और cable लगाना अत्यधिक महंगा होता है। इसलिए शोधकर्ता और छात्र वर्चुअल network बनाकर protocols (जैसे TCP, UDP, AODV, DSDV) के प्रदर्शन का परीक्षण करने के लिए NS2 का उपयोग करते हैं।

NS2 का विस्तृत इतिहास और सिंटैक्स समझने के लिए आप NS2 in Hindi और basic syntax of NS2 in Hindi पढ़ सकते हैं। जब NS2 सिमुलेशन चलाता है, तो वह टेक्स्ट आधारित लॉग्स (Trace files) जनरेट करता है। इन लॉग्स को इंसान के लिए ग्राफिक्स और वीडियो एनिमेशन के रूप में देखना संभव बनाता है NAM।

Advertisement

NS2 का ड्यूल-लैंग्वेज architecture (Dual-Language Architecture)

NS2 की सबसे बड़ी विशेषता इसका दो अलग-अलग programming भाषाओं का संयोजन है। परीक्षा में अक्सर पूछा जाता है कि "NS2 में C++ और OTcl दोनों का उपयोग क्यों किया जाता है?":

Comparison Factor C++ (System / Implementation Level) OTcl (Object Tcl - Configuration Level)
Role in NS2 विस्तृत protocol एल्गोरिदम, packet मैनिपुलेशन, और टाइमिंग इवेंट्स का कार्यान्वयन। network टोपोलॉजी बनाना, नोड्स जोड़ना, ट्रैफिक स्टार्ट/स्टॉप का समय निर्धारित करना।
Execution Speed अत्यधिक तीव्र (Fast execution), क्योंकि यह मशीन code में compile होता है। धीमी (Interpreted language), लेकिन सिमुलेशन सेटअप के लिए पर्याप्त।
Re-compilation code में जरा सा बदलाव करने पर भी पूरे NS2 को दोबारा compile (make) करना पड़ता है। बिना किसी compileेशन के स्क्रिप्ट तुरंत रन हो जाती है (Zero compilation overhead)।
Target Users protocol डेवलपर्स और रिसर्चर्स जो नया network protocol डिजाइन कर रहे हैं। network सिमुलेशन छात्र और परीक्षार्थी जो विभिन्न परिदृश्यों का परीक्षण कर रहे हैं।
Linkage Tool TclCL: C++ क्लास और OTcl ऑब्जेक्ट्स के बीच वेरिएबल्स और मेथड्स को मैप करने वाला ब्रिज। interface of OTcl and C++ in Hindi पढ़ें।

NS2 architecture के प्रमुख कोर घटक (Core Components)

NS2 के आंतरिक structure में नीचे दिए गए मुख्य मॉड्यूल्स मिलकर काम करते हैं:

1. Event Scheduler (इवेंट शेड्यूलर)

NS2 एक Discrete Event Simulator है, अर्थात इसमें वास्तविक समय के बजाय वर्चुअल सिमुलेशन क्लॉक चलती है। शेड्यूलर मेमोरी में इवेंट्स (जैसे packet का सेंड होना, लिंक पर पहुंचना, या ड्रॉप होना) की एक प्राथमिकता कतार (Priority Queue) बनाए रखता है और उन्हें समय के अनुसार एक-एक करके प्रोसेस करता है। इसमें ListScheduler, HeapScheduler, और CalendarScheduler जैसे शेड्यूलर इंजन होते हैं।

2. Node Architecture (नोड का आंतरिक structure)

NS2 में एक नोड वास्तव में कई कंपोनेंट्स का समूह होती है। जब कोई packet नोड पर आता है, तो Address Classifier यह तय करता है कि packet इसी नोड के लिए है या इसे दूसरे लिंक पर फॉरवर्ड करना है। यदि packet इसी नोड के लिए है, तो Port Classifier उसे संबंधित एजेंट (जैसे TCP या UDP) को सौंप देता है। नोड्स की संरचना के लिए node creation in NS2 देखें।

3. Links और Queues (लिंक्स और कतारें)

दो नोड्स के बीच data ट्रांसफर के लिए duplex-link या simplex-link बनाया जाता है। प्रत्येक लिंक के साथ एक Queue (जैसे DropTail, RED, CBQ) जुड़ी होती है। जब network में कंजेशन होता है, तो कतार की क्षमता भरने पर packets ड्रॉप होते हैं।

4. Agents और Traffic Generators

एजेंट्स ट्रांसपोर्ट और राउटिंग लेयर्स का प्रतिनिधित्व करते हैं (जैसे Agent/TCP, Agent/UDP, Agent/TCPSink, Agent/Null)। इनके ऊपर एप्लिकेशन लेयर का ट्रैफिक जनरेट करने के लिए Application/Traffic/CBR (Constant Bit Rate) या Application/FTP जोड़ा जाता है।

NAM (Network Animator) architecture और विज़ुअलाइज़ेशन

NAM एक Tcl/Tk आधारित एनिमेशन software है, जो सिमुलेशन के परिणामों को 2D screen पर दिखाता है। इसके मुख्य घटक नीचे दिए गए हैं:

  • NAM Trace Parser: यह NS2 से जनरेट की गई .nam file को पढ़ता है। इस file में विशेष कमांड्स होती हैं जैसे नोड का निर्माण (n), लिंक का निर्माण (l), packet का ट्रांसफर (+, -, h, r, d)।
  • Animation Canvas: नोड्स को गोल वृत्तों, लिंक्स को सीधी रेखाओं, और packets को छोटे रंगीन चौकोर डिब्बों के रूप में screen पर गतिमान दिखाता है।
  • Playback Control Panel: इसमें Play, Pause, Rewind, Fast Forward, और Slider बार होते हैं, जिससे छात्र सिमुलेशन को किसी भी विशिष्ट समय (जैसे 2.5 सेकंड पर) रोककर packet फ्लो देख सकते हैं।
  • Packet Drop Indicator: जब बफर फुल हो जाता है और लिंक से packet गिरता है, तो NAM में वह packet लाइन से नीचे गिरता हुआ स्पष्ट दिखाई देता है।

NS2 Trace File (.tr) बनाम NAM File (.nam)

परीक्षा में ट्रेस file्स के अंतर पर 5-अंक का प्रश्न पूछा जाता है:

Comparison Factor Standard Trace File (.tr) NAM Trace File (.nam)
Purpose सांख्यिकीय data विश्लेषण, ग्राफ प्लॉटिंग (Xgraph, Gnuplot), थ्रूपुट और डिले calculation। network टोपोलॉजी और packet फ्लो का ग्राफिकल 2D वीडियो एनिमेशन देखना।
Output Viewer AWK scripts, Python, MATLAB, या साधारण Text Editor. केवल NAM (Network Animator) tool से।
Standard Event Codes + (Enqueue), - (Dequeue), r (Receive), d (Drop). n (Node config), l (Link config), +, -, h, r, d.
Visual Information रंग, नोड के आकार और screen लेआउट की कोई जानकारी नहीं होती। नोड का रंग, लेबल, आकार, लिंक एंगल और packet का रंग शामिल होता है।
Advertisement

Worked Example: Complete Executable NS2 Script with NAM

नीचे एक पूर्ण और प्रामाणिक Tcl सिमुलेशन स्क्रिप्ट दी गई है, जो 2 नोड्स बनाती है, UDP-CBR ट्रैफिक चलाती है, और सिमुलेशन समाप्त होने पर NAM को स्वचालित रूप से लॉन्च करती है:

# 1. Create a Simulator instance
set ns [new Simulator]

# 2. Define colors for packets in NAM
$ns color 1 Blue

# 3. Open trace files for writing
set tracefile [open out.tr w]
$ns trace-all $tracefile
set namfile [open out.nam w]
$ns namtrace-all $namfile

# 4. Finish procedure to close files and run NAM
proc finish {} {
    global ns tracefile namfile
    $ns flush-trace
    close $tracefile
    close $namfile
    exec nam out.nam &
    exit 0
}

# 5. Create two network nodes
set n0 [$ns node]
set n1 [$ns node]

# 6. Create a 1Mbps Duplex Link with DropTail Queue
$ns duplex-link $n0 $n1 1Mb 10ms DropTail

# 7. Setup UDP Agent on n0 and Null Agent on n1
set udp [new Agent/UDP]
$udp set class_ 1
$ns attach-agent $n0 $udp

set null [new Agent/Null]
$ns attach-agent $n1 $null
$ns connect $udp $null

# 8. Setup CBR Traffic Generator
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 500
$cbr set interval_ 0.005
$cbr attach-agent $udp

# 9. Schedule Simulation Events
$ns at 0.5 "$cbr start"
$ns at 4.5 "$cbr stop"
$ns at 5.0 "finish"

# 10. Run the Simulation
$ns run

विद्यार्थी अक्सर क्या गलतियां करते हैं? (Common Student Mistakes)

  • C++ और OTcl के रोल में कन्फ्यूजन: छात्र सोचते हैं कि सिमुलेशन रन करने के लिए C++ code compile करना पड़ता है। यदि आप केवल टोपोलॉजी बदल रहे हैं, तो केवल .tcl file को ns script.tcl से रन करना होता है; C++ compileेशन केवल नया protocol बनाते समय चाहिए।
  • flush-trace भूल जाना: Finish फंक्शन में $ns flush-trace न लिखने पर बफर में रुका हुआ data .nam file में नहीं लिख पाता, जिससे NAM खाली या करप्टेड ओपन होता है।
  • NAM को अलग software समझना: NAM कोई स्वतंत्र सिमुलेटर नहीं है; यह केवल NS2 की आउटपुट ट्रेस file को रेंडर करने वाला एनीमेशन व्यूअर है।

Exam के लिए Important Questions

Short Questions (2 से 5 अंक)

  1. NS2 का पूरा नाम क्या है? यह किस प्रकार का सिमुलेटर है?
  2. NS2 में C++ और OTcl दोनों का एक साथ उपयोग क्यों किया जाता है?
  3. TclCL क्या है और NS2 architecture में इसकी क्या भूमिका है?
  4. NAM क्या है? यह सिमुलेशन में क्या काम करता है?
  5. NS2 की ट्रेस file में +, -, r, और d का क्या अर्थ है?

Long Questions (10 से 20 अंक)

  1. NS2 (Network Simulator 2) के ड्यूल-लैंग्वेज architecture की विस्तृत विवेचना कीजिए। C++ और OTcl के लिंकेज और TclObject मैपिंग को समझाइए।
  2. NS2 और NAM के बीच संबंध और data फ्लो को स्पष्ट कीजिए। Standard Trace File (.tr) और NAM Trace File (.nam) का तुलनात्मक विश्लेषण कीजिए।
  3. एक पूर्ण NS2 Tcl स्क्रिप्ट लिखिए जो 3 नोड्स के बीच TCP और FTP ट्रैफिक को सिमुलेट करती हो और NAM एनिमेशन जनरेट करती हो। स्क्रिप्ट के प्रत्येक चरण की व्याख्या कीजिए।

FAQs

Q1: क्या NS2 विंडोज़ ऑपरेटिंग system पर चल सकता है?

NS2 मूल रूप से Linux (Ubuntu/Debian) के लिए डिज़ाइन किया गया है। विंडोज़ में इसे Cygwin या WSL (Windows Subsystem for Linux) के माध्यम से चलाया जाता है।

Q2: NS2 और NS3 में क्या मुख्य अंतर है?

NS3, NS2 का उन्नत उत्तराधिकारी है। NS3 में OTcl को पूरी तरह हटा दिया गया है; उसमें कोर protocols C++ में लिखे जाते हैं और simulation script C++ या Python में लिखी जाती है।

Q3: क्या NAM में वायरलेस नोड्स की गति (Mobility) देखी जा सकती है?

हाँ, NS2 के वायरलेस सिमुलेशन (Mobile IP, Ad-hoc Wi-Fi) में नोड्स की X, Y स्थिति (2D) और ट्रांसमिशन रेंज का सर्किल NAM में स्पष्ट एनिमेट होता है।

अक्सर पूछे जाने वाले प्रश्न (FAQs)

Quick Answer: NS2 (Network Simulator 2) एक discrete event-driven network simulator है, जिसका architecture दोहरी भाषा (Dual-Language Design) पर बना है: कोर packet प्रोसेसिंग और protocol लॉजिक के लिए C++, और सिमुलेशन सेटअप और टोपोलॉजी कॉन्फ़िगरेशन के लिए OTcl (Object Tcl)।
Computer Network & Communication Notes in Hindi | कंप्यूटर नेटवर्किंग और कम्युनिकेशन नोट्स के पाठ्यक्रम में Architecture of NS2 & NAM in Hindi एक महत्वपूर्ण अध्याय है। यह मुख्य सिद्धांतों, परीक्षा प्रश्नों और सूत्रों को समझने के लिए अत्यधिक आवश्यक है।
हाँ, NotesMedia पर आपको Architecture of NS2 & NAM in Hindi के महत्वपूर्ण प्रश्नोत्तर, हल किए गए उदाहरण और नोट्स बिल्कुल मुफ्त मिलेंगे। अधिक अभ्यास के लिए आप हमारा ऐप भी डाउनलोड कर सकते हैं।
Advertisement

In this Chapter

Architecture of NS2 & NAM 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
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
Invoking external commands within NS2 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