Hi Eloy,<div><br></div><div>Thanks a lot for your response. Once I've followed your instructions, everything is working as expected :) I am using nexp 0.18 by the way</div><div><br></div><div>Great tool by the way :) I have so many scenarios where I can use it for my everyday work</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Milos</div><div><br></div><div><br><br><div class="gmail_quote">On Mon, Aug 27, 2012 at 9:17 PM, Eloy Paris <span dir="ltr"><<a href="mailto:peloy@netexpect.org" target="_blank">peloy@netexpect.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[Milos, I am sorry for responding here in the list in addition to the private message that I just sent you but the answer might be of benefit to other users as well.]<div>
<div class="h5"><br>
<br>
On 08/27/2012 03:09 PM, Milos Kostic-Veljkovic wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I have installed netexpect on ubuntu 12 with apt-get, together with<br>
bunch of other packages. This is a fresh install<br>
<br>
Now when I try to run any of the examples, scripts always fail with an<br>
error.<br>
<br>
Example code:<br>
<br>
root@ubuntu1:/home/riverbed/<u></u>Documents# cat arp.nexp<br>
spawn_network -i eth3 host 22.0.0.21 and {arp[6:2]} == 1<br>
set mymac 00:11:22:33:44:55<br>
<br>
           expect_network {1} {<br>
               # Received an ARP request, send ARP reply<br>
<br>
puts $arp  <---- ADDED THIS ON PURPOSE TO TRY TO PRINT $ARP<br>
# puts $arp(sip)<br>
          send_network -o eth3 \<br>
                   ether(src = $mymac, dst = $arp(sha) )/ \<br>
                   arp-reply(tha = $arp(sha), tip = $arp(sip), \<br>
                             sha = $mymac, sip = 22.0.0.21)<br>
               nexp_continue<br>
           }<br>
<br>
<br>
And the error is always:<br>
<br>
root@ubuntu1:/home/riverbed/<u></u>Documents# nexp arp.nexp<br>
\x00\x01\x08\x00\x06\x04\x00\<u></u>x01\x00\x0c\x29\x77\x04\x27\<u></u>x16\x00\x00\x01\x00\x00\x00\<u></u>x00\x00\x00\x16\x00\x00\x15<br>
(this above is puts $arp output)<br>
<br>
error is bellow:<br>
<br>
can't read "arp(sha)": variable isn't array<br>
</blockquote>
<br></div></div>
$arp(sha) is what needed to be used before dissection tasks were moved to libwireshark, i.e. the Wireshark dissection engine.<br>
<br>
Now, an expect_network {} statement will produce the same variable names as the field names that Wireshark would produce (those used in Wireshark display filters). Therefore, the above send_network should be re-written to something like this:<br>

<br>
  send_network -o eth3 \<br>
      ether(src = $mymac, dst = ${arp.src.hw_mac})/ \<br>
      arp-reply(tha = ${arp.src.hw_mac}, tip = ${arp.src.proto_ipv4}, \<div class="im"><br>
                sha = $mymac, sip = 22.0.0.21)<br>
<br></div>
As a troubleshooting/debugging technique you can put the "show dissection vars" right after your expect_network command. Here's an interactive example:<br>
<br>
netexpect> spawn_network -i eth0 arp<br>
netexpect> expect_network 1<br>
netexpect> show dissection vars<br>
arp.hw.size arp.dst.hw_mac frame.time_epoch frame.protocols frame.time_relative eth.type vlan eth.dst.eth.lg vlan.cfi arp.src.hw_mac arp.proto.type frame.time_delta_displayed frame.ignored frame.len eth eth.src.eth.lg arp.hw.type arp.isgratuitous arp.proto.size arp.src.proto_ipv4 frame.marked eth.src.eth.addr frame.cap_len eth.dst.eth.ig frame arp.opcode _ arp.dst.proto_ipv4 eth.dst.eth.addr pdu eth.src.eth.ig vlan.etype frame.number vlan.trailer frame.time_delta vlan.priority arp frame.time eth.src <a href="http://vlan.id" target="_blank">vlan.id</a> eth.dst<br>

netexpect> puts "MAC = ${arp.src.hw_mac} type = ${arp.proto.type} IP = ${arp.dst.proto_ipv4}"<br>
MAC = 00:1d:45:95:66:50 type = 2048 IP = 10.80.35.41<br>
<br>
The "info vars" command also shows the variables that were created during dissection. For example:<br>
<br>
netexpect> info vars<br>
tcl_interactive tcl_version escape_printable frame.number arp.opcode <a href="http://vlan.id" target="_blank">vlan.id</a> auto_path errorInfo auto_execs vlan.priority vlan env eth.dst.eth.addr frame.cap_len arp.src.proto_ipv4 argc frame.marked vlan.etype frame.time_epoch argv0 iface frame.ignored arp.isgratuitous verbose multianswers eth.src.eth.addr eth.src auto_index tcl_pkgPath tclreadline_library frame.time_relative eth.src.eth.ig tcl_prompt1 arp.src.hw_mac arp.proto.size tcl_prompt2 _ timeout eth.dst.eth.ig argv tcl_rcFileName frame.time arp.dst.hw_mac listener_id arp errorCode arp.hw.size pdu vlan.trailer tcl_patchLevel tclreadline_version arp.proto.type tcl_platform tcl_library msg arp.dst.proto_ipv4 eth eth.dst frame tclreadline_patchLevel eth.src.eth.lg speaker_id frame.time_delta_displayed arp.hw.type tsformat frame.len vlan.cfi eth.type frame.time_delta eth.dst.eth.lg frame.protocols<br>

<br>
I have been trying to clean up the examples shipped in the examples/ directory of the netexpect tarball. A few examples probably need to be converted, though, and the examples in the wiki probably are very outdated and I need to clean them up.<br>

<br>
Cheers<br>
<br>
Eloy Paris.-<br>
<a href="http://netexpect.org" target="_blank">netexpect.org</a><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
     while executing<br>
"send_network -o eth3  ether(src = $mymac, dst = $arp(sha) )/<br>
  arp-reply(tha = $arp(sha), tip = $arp(sip),  sha = $mymac, sip =<br>
22.0.0.21)"<br>
     invoked from within<br>
"expect_network {1} {<br>
               # Received an ARP request, send ARP reply<br>
<br>
puts $arp<br>
# puts $arp(sip)<br>
          send_network -o eth3 \<br>
         ..."<br>
     (file "arp.nexp" line 4)<br>
<br>
<br>
Thanks for your tips if you could point me to the good direction how to<br>
fix this<br>
<br>
Milos<br>
<br>
<br></div>
______________________________<u></u>_________________<br>
Netexpect-users mailing list<br>
<a href="mailto:Netexpect-users@lists.alioth.debian.org" target="_blank">Netexpect-users@lists.alioth.<u></u>debian.org</a><br>
<a href="http://lists.alioth.debian.org/mailman/listinfo/netexpect-users" target="_blank">http://lists.alioth.debian.<u></u>org/mailman/listinfo/<u></u>netexpect-users</a><br>
<br>
</blockquote>
<br>
<br>
______________________________<u></u>_________________<br>
Netexpect-users mailing list<br>
<a href="mailto:Netexpect-users@lists.alioth.debian.org" target="_blank">Netexpect-users@lists.alioth.<u></u>debian.org</a><br>
<a href="http://lists.alioth.debian.org/mailman/listinfo/netexpect-users" target="_blank">http://lists.alioth.debian.<u></u>org/mailman/listinfo/<u></u>netexpect-users</a><br>
</blockquote></div><br><br clear="all"><div><br></div><br>
</div>