title: emulating live network with ns-2
body: <p>I am a complete beginner to NS2 (and even Linux).my task is to demonstrate a very basic emulation example just to show that it is possible to use ns2 to emulate.  I've been
  trying to get any simple emulation script to work for the past few weeks but
  have failed.  I'm sure it would take an expert just a few minutes to
  write a couple lines of code to do this.  Most explanations I have read to
  similar problems are even too advanced for my understanding either in terms of
  NS2 or Linux.  If someone could please help me on a student level that would be<br>
  greatly appreciated.  </p>
  
  <p>I am using a Linux machine and so far I have downloaded and installed the
  allinone ns-2.34.  I have also googled for some simple example emulation
  scripts.    </p>
  
  <p>For example, I found this one:</p>
  
  <p><code># Create simulator</code>
  <code>set ns [new Simulator]</code>
  <code>$ns use-scheduler RealTime</code></p>
  
  <p><code># Emulator address</code>
  <code>set me [exec hostname]</code></p>
  
  <p><code># Packet input</code>
  <code>set bpf0 [new Network/Pcap/Live]</code>
  <code>$bpf0 set promisc_ true</code>
  <code>set nd0 [$bpf0 open readonly fxp0]</code>
  <code>set filt "(not ip host $me)"</code>
  <code>$bpf0 filter $filt</code></p>
  
  <p><code># Packet output</code>
  <code>set ipnet [new Network/IP]</code>
  <code>$ipnet open writeonly</code></p>
  
  <p><code># Input agent</code>
  <code>set pfa [new Agent/Tap]</code>
  <code>$pfa network $bpf0</code></p>
  
  <p><code># Output agent</code>
  <code>set ipa [new Agent/Tap]</code>
  <code>$ipa network $ipnet</code></p>
  
  <p><code># ICMP ECHO agent</code>
  <code>set echoagent [new Agent/PingResponder]</code></p>
  
  <p><code>set n0 [$ns node]</code>
  <code>set n1 [$ns node]</code>
  <code>set n2 [$ns node]</code>
  <code>$ns simplex-link $n0 $n2 100Mb 1000ms DropTail</code>
  <code>$ns simplex-link $n2 $n1 100Mb 1000ms DropTail</code>
  <code>$ns attach-agent $n0 $pfa</code>
  <code>$ns attach-agent $n1 $ipa</code>
  <code>$ns attach-agent $n2 $echoagent</code>
  <code>$ns simplex-connect $pfa $echoagent</code>
  <code>$ns simplex-connect $ipa $echoagent</code></p>
  
  <p><code># Wait for ping to come in...</code>
  <code>$ns run</code></p>
  
  <p>When I try running this script I get a message that says:</p>
  
  <p>invalid command name "Network/Pcap/Live"
    while executing
  "Network/Pcap/Live create o_11 "
    invoked from within
  "catch "$className create $o $args" msg"
    (procedure "new" line 3)
    invoked within
  "new Network/Pcap/Live"
    invoked from within
  "set bpf0 [new Network/Pcap/Live]"
    (file "./vince/emu1.tcl" line 12)</p>
  
  <p>Can anyone help me with this problem please?  Since I am not yet an ns2
  expert, I don't know all too well how that code works.  I believe it is a ping
  responder.  All I need is a very simple emulation example to show that it
  works so any other suggestions or example scripts would be great!  </p>
  
  <p>Thanks</p>