Network Simulator ns2 - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Network Simulator ns2

Description:

Network Simulator ns2 – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 22
Provided by: cs03
Category:
Tags: close | network | ns2 | pink | simulator | up

less

Transcript and Presenter's Notes

Title: Network Simulator ns2


1
Network Simulator ns2
  • An introduction

2
Computer based objects
  • Ns2 uses C objects
  • Objects possess
  • Attributes
  • - state variables
  • Function or procedures
  • - required to manipulate variables
  • User creates instances of objects
  • Features passed via inheritance

3
Components of ns2
  • To run ns2 enter
  • ns2 ns-simple.tcl
  • Network animator - nam
  • Output file out.nam (typical)
  • To run animator
  • nam out.nam

4
Setting up ns2 - 1
  • To create a simulator object
  • set ns new Simulator
  • Define colors for data flows
  • Used in nam - comment
  • Blue Red Green Orange
  • Grey Cyan Black Pink
  • ns color 1 Blue

5
Setting up ns2 - 2
  • Open the NAM trace fileset nf open out.nam
    wns namtrace-all nf
  • File variable nf
  • Open nf for writing
  • User defines name of output file - out.nam

6
Setting up ns2 - 3
  • Define a 'finish' procedure
  • proc finish global ns nf ns
    flush-trace Close the NAM trace file
    close nf Execute NAM on the trace
    file exec nam out.nam exit 0

7
Setting up ns2 - 4
  • Create four nodesset n0 ns nodeset n1 ns
    nodeset n2 ns nodeset n3 ns nodeset n4
    ns node

8
Setting up ns2 - 4
  • Create links between the nodes
  • ns duplex-link n0 n2 2Mb 10ms DropTail
  • ns duplex-link n1 n2 2Mb 10ms DropTail
  • ns duplex-link n2 n3 1.7Mb 20ms DropTail

9
Setting up ns2 5
  • Give node position (for NAM)
  • ns duplex-link-op n0 n2 orient right-down
  • ns duplex-link-op n1 n2 orient right-up
  • ns duplex-link-op n2 n3 orient right

10
Setting up ns2 6
  • Set Queue Size of link (n2-n3) to 20
  • ns queue-limit n2 n3 20
  • ns queue-limit n3 n6 20

11
Screenshot 1
12
Setting up ns2 7
  • Monitor the queue for link (n2-n3). (for NAM)
  • ns duplex-link-op n2 n3 queuePos 0.5

13
Setting up ns2 8
  • Setup a TCP connectionset tcp new
    Agent/TCPtcp set class_ 2ns attach-agent n0
    tcpset sink new Agent/TCPSink

14
Setting up ns2 9
  • ns attach-agent n3 sinkns connect tcp
    sinktcp set fid_ 1
  • Flow id fid sets colour

15
Setting up ns2 10
  • Setup a FTP over TCP connectionset ftp new
    Application/FTPftp attach-agent tcpftp set
    type_ FTP

16
Setting up ns2 11
  • Setup a UDP connectionset udp new
    Agent/UDPns attach-agent n1 udpset null
    new Agent/Null

17
Setting up ns2 12
  • ns attach-agent n3 nullns connect udp
    nulludp set fid_ 2

18
Setting up ns2 13
  • Constant bit rate CBR
  • Setup a CBR over UDP connectionset cbr new
    Application/Traffic/CBRcbr attach-agent
    udpcbr set type_ CBRcbr set packet_size_
    1000cbr set rate_ 1mbcbr set random_ false

19
Schedule events
  • Schedule events for the CBR and FTP agentsns
    at 0.1 "cbr start"ns at 2.0 "ftp start"ns
    at 3.0 "ftp stop"ns at 5.0 "cbr stop"

20
Run simulation
  • Define time to detach agents
  • Define time to call finish
  • Print some parameters
  • Run the simulationns run

21
Screenshot
Write a Comment
User Comments (0)
About PowerShow.com