BCA / B.Tech 12 min read

Simulation Object of NS2 & NAM in Hindi

RK

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

प्रकाशित:

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

  • • विषय फोकस: Computer Network & Communication Notes in Hindi | कंप्यूटर नेटवर्किंग और कम्युनिकेशन नोट्स (BCA / B.Tech Syllabus)
  • • मुख्य विषय: Simulation Object of NS2 & NAM in Hindi - General Topics
  • • अवलोकन: Quick Answer: NS2 mein Simulation Object (set ns [new Simulator]) simulation engine ka central coordinator hota hai jo network topology, event schedulin...
  • • मुख्य अवधारणाएं: NS2 simulation object, $ns scheduler events finish Hindi, Procedure random seed simulation,NS2 simulation object, $ns scheduler events finish, Procedure random seed simulation
Quick Answer: NS2 mein Simulation Object (set ns [new Simulator]) simulation engine ka central coordinator hota hai jo network topology, event scheduling, nodes, links aur protocol agents ko manage karta hai. NAM (Network Animator) NS2 ke dwara generate ki gayi .nam trace file ko read karke inhi simulation objects ko visual graphical elements (nodes, color-coded packets, queue drops) ke roop mein screen par animate karta hai. Dono tools milkar complex network behavior ko simulate aur visualize karte hain.

NS2 mein Simulator Object kya hota hai?

Network Simulator 2 (NS2) ek discrete-event simulator hai jisme network ke components ko object-oriented tareeqe se represent kiya jaata hai. Jab bhi hum koi OTcl script likhte hain, toh sabse pehli aur sabse zaroori command hoti hai:

set ns [new Simulator]

Yah command Simulator class ka ek primary object create karti hai jise ns variable mein assign kiya jaata hai. Yah Simulator Object poore simulation environment ka master controller hota hai. Iske bina na toh nodes banaye ja sakte hain, na links connect ho sakte hain, aur na hi events ko timeline par schedule kiya ja sakta hai.

NS2 aur NAM ke basic concepts aur setup ke liye aap hamare NS2 and NAM in Hindi aur Node Creation in NS2 and NAM notes padh sakte hain.

Advertisement

NS2 Simulation Objects ki Hierarchy aur Components

NS2 simulation architecture mein kai core simulation objects aapas mein interact karte hain:

1. Simulator Object (Master Engine)

Yah global simulation environment ko manage karta hai. Iske mukhya kaam hain: internal clock aur timeline maintain karna, discrete events ko sort aur execute karna, nodes create karna, aur trace log files open/close karna.

2. Node Objects (Hosts aur Routers)

Node network ka fundamental building block hai. Command set n0 [$ns node] se ek node object banta hai. Node ke andar routing agent, protocol stack aur port classifiers hote hain jo aane wale packets ko correct destination par forward karte hain.

3. Link Objects (Channels aur Queues)

Do nodes ko jodne ke liye link object banta hai (jaise duplex-link). Link object ke paas teen important properties hoti hain: Bandwidth (data transfer speed), Delay (propagation time), aur Queue Management (DropTail ya RED buffer algorithm).

4. Agent Objects (Protocol Endpoints)

Nodes ke beech transport layer communication establish karne ke liye agent objects use hote hain, jaise Agent/TCP, Agent/TCPSink, Agent/UDP, aur Agent/Null. Yah packet creation, sequence numbering aur error recovery handle karte hain.

5. Application / Traffic Objects

Agents ke upar data traffic generate karne ke liye application objects attach kiye jaate hain, jaise Application/FTP (file transfer) aur Application/Traffic/CBR (constant bit rate streaming).

NAM (Network Animator) mein Simulation Objects

NAM ek Tcl/Tk based graphical visualization software hai jo NS2 ke text-based simulation events ko visually animate karta hai. NAM ke mukhya visual objects neeche diye gaye hain:

  • Graphical Nodes: Screen par circles ya boxes ke roop mein dikhte hain. Script ke through inka color, shape (box, circle, hexagon) aur label define kiya ja sakta hai.
  • Visual Links: Nodes ke beech lines ke roop mein appear hote hain. Inki orientation (right, left, up, down) aur queue position screen par visually set ki jaati hai.
  • Packet Animation: Packets chhote colored blocks ke roop mein ek node se doosre node tak travel karte huye dikhte hain. Alag-alag flows ke packets ko pehchanne ke liye flow ID (fid_) se alag color assign kiya jaata hai.
  • Drop Visualization: Jab link buffer full ho jaata hai aur router packet drop karta hai, toh NAM screen par dropped packet ko link se neeche girte huye animate karta hai.

NS2 Simulation Objects Reference Table

Neeche diye gaye table mein NS2 ke sabhi core simulation objects, unka creation syntax aur primary role explain kiya gaya hai:

Simulation Object OTcl Creation Syntax Primary Role / Function
Simulator Instance set ns [new Simulator] Central clock, scheduler aur global event controller.
Node Instance set n0 [$ns node] Virtual host, client ya router ka representation.
Duplex Link $ns duplex-link $n0 $n1 10Mb 10ms DropTail Bidirectional communication line aur queue buffer.
TCP Agent set tcp [new Agent/TCP] Reliable, connection-oriented data sender endpoint.
TCPSink Agent set sink [new Agent/TCPSink] TCP packets ko receive aur acknowledge karne wala endpoint.
UDP Agent set udp [new Agent/UDP] Fast, connectionless data sender endpoint.
Null Agent set null [new Agent/Null] UDP packets ko consume/discard karne wala receiver endpoint.
CBR Traffic set cbr [new Application/Traffic/CBR] Fixed interval par regular packet bursts generate karta hai.

NS2 aur NAM ke beech Relationship aur Data Flow

NS2 simulation engine aur NAM visual tool ek coordinated workflow mein kaam karte hain:

  1. Script Configuration: User OTcl script mein NS2 network objects define karta hai aur NAM layout commands (jaise duplex-link-op) set karta hai.
  2. Trace Generation: Simulation execute hone par ($ns run), NS2 disk par out.nam file create karta hai jisme har event ka graphical coordinate aur timestamp log hota hai.
  3. Visual Playback: Simulation complete hone par NAM application out.nam file ko parse karti hai aur screen par play, pause, fast-forward control buttons ke sath interactive animation dikhati hai.

Comparison: NS2 Simulation Engine vs NAM Animator

Dono tools ke mukhya antar aur roles ko neeche table mein dekhein:

Comparison Parameter NS2 Simulation Engine NAM (Network Animator)
Core Purpose Mathematical modeling, protocol logic aur packet event scheduling. Visual animation aur graphical representation.
Underlying Technologies C++ (fast core) aur OTcl (scripting interface). Tcl/Tk GUI library.
Input OTcl user script (.tcl file). NS2 dwara generate ki gayi NAM trace file (.nam file).
Output Text trace files (.tr) aur NAM trace files (.nam). Interactive graphical window aur playback controls.
Metric Analysis Throughput, end-to-end delay, packet delivery ratio ka numerical calculation. Topology layout, queue congestion aur link failure ka visual inspection.
Advertisement

Complete Working Script: NS2 Simulation with NAM Objects

Neeche di gayi script mein NS2 simulation objects banaye gaye hain aur NAM ke visual attributes (color, label, orientation) customize kiye gaye hain:

# Step 1: Simulator Object banayein
set ns [new Simulator]

# Step 2: Flow colors configure karein (NAM visual ke liye)
$ns color 1 Blue
$ns color 2 Red

# Step 3: NAM trace file open karein
set namfile [open out.nam w]
$ns namtrace-all $namfile

# Step 4: Finish procedure define karein
proc finish {} {
    global ns namfile
    $ns flush-trace
    close $namfile
    exec nam out.nam &
    exit 0
}

# Step 5: Nodes banayein aur NAM layout set karein
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]

# Node shapes aur labels
$n0 color "blue"
$n0 shape "box"
$n1 color "red"
$n2 color "green"

# Step 6: Links aur NAM orientation define karein
$ns duplex-link $n0 $n1 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 20ms DropTail

$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient right-down
$ns duplex-link-op $n1 $n2 queuePos 0.5

# Step 7: TCP agent aur FTP attach karein
set tcp [new Agent/TCP]
$tcp set fid_ 1
$ns attach-agent $n0 $tcp

set sink [new Agent/TCPSink]
$ns attach-agent $n2 $sink
$ns connect $tcp $sink

set ftp [new Application/FTP]
$ftp attach-agent $tcp

# Step 8: Events schedule karein aur run karein
$ns at 0.5 "$ftp start"
$ns at 4.0 "$ftp stop"
$ns at 4.5 "finish"

$ns run

Common Mistakes to Avoid

  • $ns namtrace-all $namfile command ko nodes create karne se pehle call karna zaroori hai. Agar yah baad mein likhenge toh nodes NAM screen par nahi dikhenge.
  • NAM layout clean rakhne ke liye duplex-link-op orient specify karna na bhoolein; warna sabhi nodes ek doosre ke upar overlap ho jaate hain.
  • Queue visualization ke liye queuePos set karte samay value 0.5 ke aaspas rakhein taaki buffer box link ke upar theek se render ho sake.

Exam के लिए Important Questions

Short Questions (2-3 marks)

  1. NS2 mein set ns [new Simulator] command ka kya mahatva hai?
  2. NAM mein nodes ke shapes aur colors ko customize karne ke liye kaunsi commands use hoti hain?
  3. NS2 mein Agent Object aur Application Object ke beech kya sambandh hota hai?
  4. NAM animation mein queuePos attribute ka purpose kya hai?

Long Questions (5-10 marks)

  1. NS2 mein Simulation Objects ke concept aur hierarchy ko explain kijiye. Simulator, Node, Link aur Agent objects ek sath kaise kaam karte hain?
  2. NAM (Network Animator) kya hai? Yah NS2 ke sath kaise integrate hota hai aur trace files ke sahare graphical animation kaise generate karta hai?
  3. Ek complete OTcl script likhiye jisme teen nodes hon, custom shapes aur colors apply kiye gaye hon, aur NAM mein queue buffer animation dikhaya gaya ho.

Frequently Asked Questions (FAQs)

Kya NAM ke bina NS2 simulation run kiya ja sakta hai?

Haan, NAM sirf optional visualization ke liye hai. Agar aapko sirf data analysis (jaise packet delay ya loss percentage) karna hai, toh aap bina NAM ke sirf out.tr trace file generate karke AWK scripts ya Python se analyze kar sakte hain.

Simulation Object mein 'at' command ka kya roll hota hai?

$ns at <time> <event> command event scheduler ko batati hai ki specific simulation second par kaunsa function, traffic start, ya script call hona chahiye.

fid_ parameter ka use kyon kiya jaata hai?

fid_ (Flow ID) alag-alag traffic flows ko unique integer number deta hai. Is number ko $ns color <id> <color> ke sath map kiya jaata hai taaki NAM window mein alag-alag traffic flows alag colors (jaise Blue, Red) mein nazar aayein.

NAM trace file (.nam) aur normal trace file (.tr) mein kya antar hai?

.tr file pure text tabular metrics record karti hai research analysis ke liye, jabki .nam file visual drawing coordinates, node positions, packet shapes aur color changes record karti hai graphical animator ke liye.

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

Quick Answer: NS2 mein Simulation Object (set ns [new Simulator]) simulation engine ka central coordinator hota hai jo network topology, event scheduling, nodes, links aur protocol agents ko manage karta hai.
Computer Network & Communication Notes in Hindi | कंप्यूटर नेटवर्किंग और कम्युनिकेशन नोट्स के पाठ्यक्रम में Simulation Object of NS2 & NAM in Hindi एक महत्वपूर्ण अध्याय है। यह मुख्य सिद्धांतों, परीक्षा प्रश्नों और सूत्रों को समझने के लिए अत्यधिक आवश्यक है।
हाँ, NotesMedia पर आपको Simulation Object of NS2 & NAM in Hindi के महत्वपूर्ण प्रश्नोत्तर, हल किए गए उदाहरण और नोट्स बिल्कुल मुफ्त मिलेंगे। अधिक अभ्यास के लिए आप हमारा ऐप भी डाउनलोड कर सकते हैं।
Advertisement

In this Chapter

Simulation Object 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
Architecture of NS2 & NAM in Hindi
Interface of OTcl & C++ in Hindi
Trace Files & Formats in Hindi
Protocol Support of NS2 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