SlideShare a Scribd company logo
NS­2 Tutorial



           Kameswari Chebrolu
Dept. of Computer Science and Engineering, 
               IIT Bombay
Motivation for Simulations
●
    Cheap ­­  does not require costly equipment
●
    Complex scenarios can be easily tested
●
    Results can be quickly obtained – more ideas can 
    be tested in a smaller timeframe
●
    The real thing isn't yet available
●
    Controlled experimental conditions
    –   Repeatability helps aid debugging
●
    Disadvantages: Real systems too complex to 
    model
Features of NS­2
●
    Protocols: TCP, UDP, HTTP, Routing algorithms, 
    MAC etc
●
    Traffic Models: CBR, VBR, Web etc
●
    Error Models: Uniform, bursty etc
●
    Misc: Radio propagation, Mobility models , Energy 
    Models
●
    Topology Generation tools
●
     Visualization tools (NAM), Tracing
NS Structure
●
    NS is an object oriented discrete­event simulator
    –   Simulator maintains list of events and executes one event after 
        another
    –   Single thread of control: no locking or race conditions
●
    Back end is C++ event scheduler
    –   Protocols mostly
    –   Fast to run, more control
●
    Front end is oTCL
    –   Creating scenarios, extensions to C++ protocols
    –   fast to write and change
TCL tutorial
                  set x 1
●
    Variables:    set y $x
●
    Arrays:     set a(0) 1

●
    Printing:   puts “$a(0) n”

●
    Arithmetic Expression:             set z = [expr $y + 5]

●
    Control Structures:  if {$z == 6} then { puts “Correct!”}
                                 for {set i =0} {$i < 5} {incr i }{
                                     puts “$i * $i equals [expr $i * $i]” 
                                 }

                             proc sum {a b} {
●
    Procedures:                 return [expr $a + $b]
                             }
NS programming Structure

●
    Create the event scheduler
●
    Turn on tracing
●
    Create network topology
●
    Create transport connections
●
    Generate traffic
●
    Insert errors
Creating Event Scheduler
●
    Create event scheduler: set ns [new simulator]
●
     Schedule an event: $ns at <time> <event>
    –   event is any legitimate ns/tcl function
             $ns at 5.0 “finish”      proc finish {} {
                                         global ns nf
●
    Start Scheduler                      close $nf
                                         exec nam out.nam &
                  $ns run
                                         exit 0
                                      }
Tracing
●
    All packet trace
      $ns trace­all [open out.tr w]
      <event> <time> <from> <to> <pkt> <size>

      ­­­­­­
      <flowid> <src> <dst> <seqno> <aseqno>

         + 0.51    0 1 cbr 500 ­­­­­­­ 0 0.0 1.0 0 2
         ­  0.51    0 1 cbr 500 ­­­­­­­ 0 0.0 1.0 0 2
         r  0.514  0 1 cbr 500 ­­­­­­­ 0 0.0 1.0 0 0
●
    Variable trace           set par [open output/param.tr w]
                             $tcp attach $par
                             $tcp trace cwnd_
                             $tcp trace maxseq_
                             $tcp trace rtt_
Tracing and Animation
●
    Network Animator


              set nf [open out.nam w]
              $ns namtrace­all $nf

               proc finish {} {
                  global ns nf
                  close $nf
                  exec nam out.nam &
                  exit 0
               }
Creating topology
●
    Two nodes connected by a link
●
    Creating nodes
          set n0 [$ns node]
          set n1 [$ns node]
●
    Creating link between nodes
    –   $ns <link_type> $n0 $n1 <bandwidth> <delay> 
        <queue­type>

$ns duplex­link $n0 $n1 1Mb 10ms DropTail
Sending data
●
    Create UDP agent
         set udp0 [new Agent/UDP]
         $ns attach­agent $n0 $udp0
●
    Create CBR traffic source for feeding into UDP agent
          set cbr0 [new Application/Traffic/CBR]
          $cbr0 set packetSize_ 500
          $cbr0 set interval_ 0.005
          $cbr0 attach­agent $udp0
●
    Create traffic sink
            set null0 [new Agent/Null]
            $ns attach­agent $n1 $null0
Sending data
●
    Connect two agents
         $ns connect $udp0 $null0

●
    Start and stop of data
          $ns at 0.5 “$cbr0 start”
          $ns at 4.5 “$cbr0 stop”
Creating TCP Connections
●
    Create TCP agent and attach it to the node
       set tcp0 [new Agent/TCP]
       $ns attach­agent $n0 $tcp0
●
    Create a Null Agent and attach it to the node
       set null0 [new Agent/TCPSink]
       $ns attach­agent $n1 $null0
●
    Connect the agents
        $ns connect $tcp0 $null0
Traffic on top of TCP
●
    FTP
      set ftp [new Application/FTP]
      $ftp attach­agent $tcp0

●
    Telnet
       set telnet [new Application/Telnet]
       $telnet attach­agent $tcp0
Introducing Errors
●
    Creating Error Module
        set err [new ErrorModel]
        $err unit pkt_
        $err set rate_ 0.01
        $err ranvar [new RandomVariable/Uniform]
        $err drop­target [new Agent/Null]


●
    Inserting Error Module
         $ns lossmodel $err $n0 $n1
Examples
●
    UDP Script
●
    Tracing (wired,wireless,tcp)
●
    TCP without Loss
●
    TCP with Loss
NS Internals

                      n0                                                      n1

                    Port              Application/FTP                       Port 
                  Classifier      dst_=1.0                                Classifier       dst_=0.0
           Addr                Agent/TCP                           Addr                Agent/TCPSink
         Classifier        0                                     Classifier        0
                 0                                                       1
                                       Link n0­n1
entry_           1                                      entry_           0



                                       Link n1­n0
Summary
●
    Simulators help in easy verification of protocols 
    in less time, money
●
    NS offers support for simulating a variety of 
    protocol suites and scenarios
●
    Front end is oTCL, back end is C++
●
    NS is an on­going effort of research and 
    development
Reference Material
●
     http://www.isi.edu/nsnam/ns/
     ●
         Marc Greis' tutorial
     ●
         Jae Chung tutorial
     ●
         Ns manual

More Related Content

What's hot

Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
Kenneth Geisshirt
 
Ejercicios
EjerciciosEjercicios
Ejercicios
leonharo
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
Kenneth Geisshirt
 
Dex and Uniswap
Dex and UniswapDex and Uniswap
Dex and Uniswap
Gene Leybzon
 
Minion pool - a worker pool for nodejs
Minion pool - a worker pool for nodejsMinion pool - a worker pool for nodejs
Minion pool - a worker pool for nodejs
Marcelo Gornstein
 
To Infinity & Beyond: Protocols & sequences in Node - Part 2
To Infinity & Beyond: Protocols & sequences in Node - Part 2To Infinity & Beyond: Protocols & sequences in Node - Part 2
To Infinity & Beyond: Protocols & sequences in Node - Part 2
Bahul Neel Upadhyaya
 
Constructor Overloading in java
Constructor Overloading in javaConstructor Overloading in java
Constructor Overloading in java
One97 Communications Limited
 
C c++-meetup-1nov2017-autofdo
C c++-meetup-1nov2017-autofdoC c++-meetup-1nov2017-autofdo
C c++-meetup-1nov2017-autofdo
Kim Phillips
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
Codable routing
Codable routingCodable routing
Codable routing
Pushkar Kulkarni
 
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Hands on with smart contracts 2. Presentation for the Blockchain Applications...Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Gene Leybzon
 
timingExercise
timingExercisetimingExercise
timingExercise
Amrita Singh
 
201801 CSE240 Lecture 12
201801 CSE240 Lecture 12201801 CSE240 Lecture 12
201801 CSE240 Lecture 12
Javier Gonzalez-Sanchez
 
Richard Salter: Using the Titanium OpenGL Module
Richard Salter: Using the Titanium OpenGL ModuleRichard Salter: Using the Titanium OpenGL Module
Richard Salter: Using the Titanium OpenGL Module
Axway Appcelerator
 
Textile
TextileTextile
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ScyllaDB
 
Richard Fridrich: Třesení stromem v JavaScriptu
Richard Fridrich: Třesení stromem v JavaScriptuRichard Fridrich: Třesení stromem v JavaScriptu
Richard Fridrich: Třesení stromem v JavaScriptu
Develcz
 
Towards hasktorch 1.0
Towards hasktorch 1.0Towards hasktorch 1.0
Towards hasktorch 1.0
Junji Hashimoto
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
khasmanjalali
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
PROIDEA
 

What's hot (20)

Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
 
Ejercicios
EjerciciosEjercicios
Ejercicios
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
 
Dex and Uniswap
Dex and UniswapDex and Uniswap
Dex and Uniswap
 
Minion pool - a worker pool for nodejs
Minion pool - a worker pool for nodejsMinion pool - a worker pool for nodejs
Minion pool - a worker pool for nodejs
 
To Infinity & Beyond: Protocols & sequences in Node - Part 2
To Infinity & Beyond: Protocols & sequences in Node - Part 2To Infinity & Beyond: Protocols & sequences in Node - Part 2
To Infinity & Beyond: Protocols & sequences in Node - Part 2
 
Constructor Overloading in java
Constructor Overloading in javaConstructor Overloading in java
Constructor Overloading in java
 
C c++-meetup-1nov2017-autofdo
C c++-meetup-1nov2017-autofdoC c++-meetup-1nov2017-autofdo
C c++-meetup-1nov2017-autofdo
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
Codable routing
Codable routingCodable routing
Codable routing
 
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Hands on with smart contracts 2. Presentation for the Blockchain Applications...Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
 
timingExercise
timingExercisetimingExercise
timingExercise
 
201801 CSE240 Lecture 12
201801 CSE240 Lecture 12201801 CSE240 Lecture 12
201801 CSE240 Lecture 12
 
Richard Salter: Using the Titanium OpenGL Module
Richard Salter: Using the Titanium OpenGL ModuleRichard Salter: Using the Titanium OpenGL Module
Richard Salter: Using the Titanium OpenGL Module
 
Textile
TextileTextile
Textile
 
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
 
Richard Fridrich: Třesení stromem v JavaScriptu
Richard Fridrich: Třesení stromem v JavaScriptuRichard Fridrich: Třesení stromem v JavaScriptu
Richard Fridrich: Třesení stromem v JavaScriptu
 
Towards hasktorch 1.0
Towards hasktorch 1.0Towards hasktorch 1.0
Towards hasktorch 1.0
 
Oop lab report
Oop lab reportOop lab report
Oop lab report
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 

Viewers also liked

Tagz & talezz new ppt
Tagz & talezz new pptTagz & talezz new ppt
Tagz & talezz new ppt
aditi joshi
 
Investor presentation conference call fye 2013 final
Investor presentation conference call fye 2013 finalInvestor presentation conference call fye 2013 final
Investor presentation conference call fye 2013 final
MBAC_Fertilizer
 
Managerial economics
Managerial economicsManagerial economics
Managerial economics
gitikadeshmukh
 
PaperCut-MF Education Features
PaperCut-MF Education FeaturesPaperCut-MF Education Features
PaperCut-MF Education Features
Jon Farquharson
 
MBAC Investor Presentation Conference Call Q2 2014
MBAC Investor Presentation Conference Call Q2 2014MBAC Investor Presentation Conference Call Q2 2014
MBAC Investor Presentation Conference Call Q2 2014
MBAC_Fertilizer
 
Divorce
DivorceDivorce
Divorce
Sweetha Ammu
 
General workshop agenda
General workshop agendaGeneral workshop agenda
General workshop agenda
David Pool
 
Presentation omnicomm service (possibilities omnicomm online)
Presentation omnicomm service (possibilities omnicomm online)Presentation omnicomm service (possibilities omnicomm online)
Presentation omnicomm service (possibilities omnicomm online)
Дмитрий Журавлев
 
4 bit manchester_adder
4 bit manchester_adder4 bit manchester_adder
4 bit manchester_adder
tejaswinimedishetti
 
Jamaica
JamaicaJamaica
Jamaica
erxaviflow
 
Inventory types
Inventory typesInventory types
Inventory types
Anubha Dureja
 

Viewers also liked (12)

Tagz & talezz new ppt
Tagz & talezz new pptTagz & talezz new ppt
Tagz & talezz new ppt
 
Investor presentation conference call fye 2013 final
Investor presentation conference call fye 2013 finalInvestor presentation conference call fye 2013 final
Investor presentation conference call fye 2013 final
 
Managerial economics
Managerial economicsManagerial economics
Managerial economics
 
PaperCut-MF Education Features
PaperCut-MF Education FeaturesPaperCut-MF Education Features
PaperCut-MF Education Features
 
MBAC Investor Presentation Conference Call Q2 2014
MBAC Investor Presentation Conference Call Q2 2014MBAC Investor Presentation Conference Call Q2 2014
MBAC Investor Presentation Conference Call Q2 2014
 
Divorce
DivorceDivorce
Divorce
 
General workshop agenda
General workshop agendaGeneral workshop agenda
General workshop agenda
 
Presentation omnicomm service (possibilities omnicomm online)
Presentation omnicomm service (possibilities omnicomm online)Presentation omnicomm service (possibilities omnicomm online)
Presentation omnicomm service (possibilities omnicomm online)
 
4 bit manchester_adder
4 bit manchester_adder4 bit manchester_adder
4 bit manchester_adder
 
Bpupki ppki
Bpupki ppkiBpupki ppki
Bpupki ppki
 
Jamaica
JamaicaJamaica
Jamaica
 
Inventory types
Inventory typesInventory types
Inventory types
 

Similar to Ns tutorial

NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
Wajath
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorial
code453
 
NS2-tutorial.pdf
NS2-tutorial.pdfNS2-tutorial.pdf
NS2-tutorial.pdf
srinivasa gowda
 
Ns 2 Network Simulator An Introduction
Ns 2 Network Simulator An IntroductionNs 2 Network Simulator An Introduction
Ns 2 Network Simulator An Introduction
Jaipur National University, Jaipur, Rajasthan, India
 
ns2-lecture.ppt
ns2-lecture.pptns2-lecture.ppt
ns2-lecture.ppt
AnniModgil
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
Dr. Edwin Hernandez
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
Ajit Nayak
 
18CSL51 - Network Lab Manual.pdf
18CSL51 - Network Lab Manual.pdf18CSL51 - Network Lab Manual.pdf
18CSL51 - Network Lab Manual.pdf
Selvaraj Seerangan
 
Tut hemant ns2
Tut hemant ns2Tut hemant ns2
Tut hemant ns2
crescent000
 
Working with NS2
Working with NS2Working with NS2
Working with NS2
chanchal214
 
Network Simulator Tutorial
Network Simulator TutorialNetwork Simulator Tutorial
Network Simulator Tutorial
cscarcas
 
~Ns2~
~Ns2~~Ns2~
NS2 (1).docx
NS2 (1).docxNS2 (1).docx
NS2 (1).docx
SanjayDharmaraj
 
Venkat ns2
Venkat ns2Venkat ns2
Venkat ns2
venkatnampally
 
Ns2
Ns2Ns2
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
ProfDrSharadSharma
 
Ns2
Ns2Ns2
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
AAKASH S
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
AAKASH S
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
AAKASH S
 

Similar to Ns tutorial (20)

NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorial
 
NS2-tutorial.pdf
NS2-tutorial.pdfNS2-tutorial.pdf
NS2-tutorial.pdf
 
Ns 2 Network Simulator An Introduction
Ns 2 Network Simulator An IntroductionNs 2 Network Simulator An Introduction
Ns 2 Network Simulator An Introduction
 
ns2-lecture.ppt
ns2-lecture.pptns2-lecture.ppt
ns2-lecture.ppt
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
 
18CSL51 - Network Lab Manual.pdf
18CSL51 - Network Lab Manual.pdf18CSL51 - Network Lab Manual.pdf
18CSL51 - Network Lab Manual.pdf
 
Tut hemant ns2
Tut hemant ns2Tut hemant ns2
Tut hemant ns2
 
Working with NS2
Working with NS2Working with NS2
Working with NS2
 
Network Simulator Tutorial
Network Simulator TutorialNetwork Simulator Tutorial
Network Simulator Tutorial
 
~Ns2~
~Ns2~~Ns2~
~Ns2~
 
NS2 (1).docx
NS2 (1).docxNS2 (1).docx
NS2 (1).docx
 
Venkat ns2
Venkat ns2Venkat ns2
Venkat ns2
 
Ns2
Ns2Ns2
Ns2
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
 
Ns2
Ns2Ns2
Ns2
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 

Ns tutorial

  • 1. NS­2 Tutorial Kameswari Chebrolu Dept. of Computer Science and Engineering,  IIT Bombay
  • 2. Motivation for Simulations ● Cheap ­­  does not require costly equipment ● Complex scenarios can be easily tested ● Results can be quickly obtained – more ideas can  be tested in a smaller timeframe ● The real thing isn't yet available ● Controlled experimental conditions – Repeatability helps aid debugging ● Disadvantages: Real systems too complex to  model
  • 3. Features of NS­2 ● Protocols: TCP, UDP, HTTP, Routing algorithms,  MAC etc ● Traffic Models: CBR, VBR, Web etc ● Error Models: Uniform, bursty etc ● Misc: Radio propagation, Mobility models , Energy  Models ● Topology Generation tools ●  Visualization tools (NAM), Tracing
  • 4. NS Structure ● NS is an object oriented discrete­event simulator – Simulator maintains list of events and executes one event after  another – Single thread of control: no locking or race conditions ● Back end is C++ event scheduler – Protocols mostly – Fast to run, more control ● Front end is oTCL – Creating scenarios, extensions to C++ protocols – fast to write and change
  • 5. TCL tutorial set x 1 ● Variables: set y $x ● Arrays: set a(0) 1 ● Printing: puts “$a(0) n” ● Arithmetic Expression: set z = [expr $y + 5] ● Control Structures:  if {$z == 6} then { puts “Correct!”} for {set i =0} {$i < 5} {incr i }{ puts “$i * $i equals [expr $i * $i]”  } proc sum {a b} { ● Procedures:     return [expr $a + $b] }
  • 6. NS programming Structure ● Create the event scheduler ● Turn on tracing ● Create network topology ● Create transport connections ● Generate traffic ● Insert errors
  • 7. Creating Event Scheduler ● Create event scheduler: set ns [new simulator] ●  Schedule an event: $ns at <time> <event> – event is any legitimate ns/tcl function $ns at 5.0 “finish” proc finish {} { global ns nf ● Start Scheduler close $nf exec nam out.nam & $ns run exit 0 }
  • 8. Tracing ● All packet trace $ns trace­all [open out.tr w] <event> <time> <from> <to> <pkt> <size> ­­­­­­ <flowid> <src> <dst> <seqno> <aseqno> + 0.51    0 1 cbr 500 ­­­­­­­ 0 0.0 1.0 0 2 ­  0.51    0 1 cbr 500 ­­­­­­­ 0 0.0 1.0 0 2 r  0.514  0 1 cbr 500 ­­­­­­­ 0 0.0 1.0 0 0 ● Variable trace set par [open output/param.tr w] $tcp attach $par $tcp trace cwnd_ $tcp trace maxseq_ $tcp trace rtt_
  • 9. Tracing and Animation ● Network Animator set nf [open out.nam w] $ns namtrace­all $nf proc finish {} { global ns nf close $nf exec nam out.nam & exit 0 }
  • 10. Creating topology ● Two nodes connected by a link ● Creating nodes set n0 [$ns node] set n1 [$ns node] ● Creating link between nodes – $ns <link_type> $n0 $n1 <bandwidth> <delay>  <queue­type> $ns duplex­link $n0 $n1 1Mb 10ms DropTail
  • 11. Sending data ● Create UDP agent set udp0 [new Agent/UDP] $ns attach­agent $n0 $udp0 ● Create CBR traffic source for feeding into UDP agent set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach­agent $udp0 ● Create traffic sink set null0 [new Agent/Null] $ns attach­agent $n1 $null0
  • 12. Sending data ● Connect two agents $ns connect $udp0 $null0 ● Start and stop of data $ns at 0.5 “$cbr0 start” $ns at 4.5 “$cbr0 stop”
  • 13. Creating TCP Connections ● Create TCP agent and attach it to the node set tcp0 [new Agent/TCP] $ns attach­agent $n0 $tcp0 ● Create a Null Agent and attach it to the node set null0 [new Agent/TCPSink] $ns attach­agent $n1 $null0 ● Connect the agents $ns connect $tcp0 $null0
  • 14. Traffic on top of TCP ● FTP set ftp [new Application/FTP] $ftp attach­agent $tcp0 ● Telnet set telnet [new Application/Telnet] $telnet attach­agent $tcp0
  • 15. Introducing Errors ● Creating Error Module set err [new ErrorModel] $err unit pkt_ $err set rate_ 0.01 $err ranvar [new RandomVariable/Uniform] $err drop­target [new Agent/Null] ● Inserting Error Module $ns lossmodel $err $n0 $n1
  • 16. Examples ● UDP Script ● Tracing (wired,wireless,tcp) ● TCP without Loss ● TCP with Loss
  • 17. NS Internals n0 n1 Port  Application/FTP Port  Classifier dst_=1.0 Classifier dst_=0.0 Addr  Agent/TCP Addr  Agent/TCPSink Classifier 0 Classifier 0 0 1 Link n0­n1 entry_ 1 entry_ 0 Link n1­n0
  • 18. Summary ● Simulators help in easy verification of protocols  in less time, money ● NS offers support for simulating a variety of  protocol suites and scenarios ● Front end is oTCL, back end is C++ ● NS is an on­going effort of research and  development
  • 19. Reference Material ●  http://www.isi.edu/nsnam/ns/ ● Marc Greis' tutorial ● Jae Chung tutorial ● Ns manual