This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Hi, I'm writing a Lua program to process data that captured by tshark, and I'm in need for a filter to separate inbound traffic from outbound traffic in our network to process each group alone. Can some one help me in this, because I'm new in both: Lua and Wireshark. Thanks

asked 25 Jan '12, 22:39

Leena's gravatar image

Leena
51171821
accept rate: 0%

edited 26 Jan '12, 00:46


I'm assuming you're interested in IP traffic only.

You would create two taps (aka "Listeners") -- one filtered for incoming packets to your host and another for outgoing:

local HOST_IP = '1.2.3.4'

local tap_in = Listener.new(nil, 'ip.dst=='..HOST_IP)
local tap_out = Listener.new(nil, 'ip.src=='..HOST_IP)

-- handles packets going to $HOST_IP
function tap_in.packet(pinfo, buf)
    print('#'..pinfo.number, '<IN>', tostring(buf))
end

-- handles packets going out from $HOST_IP
function tap_out.packet(pinfo, buf)
    print('#'..pinfo.number, '<OUT>', tostring(buf))
end


Copy this file to a temporary directory (e.g., /tmp/test.lua), and run it from TShark as follows:

$ tshark -Xlua_script:/tmp/test.lua

You can also load this from Wireshark (as shown in a recent post).

permanent link

answered 02 Feb '12, 18:53

helloworld's gravatar image

helloworld
3.1k42041
accept rate: 28%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×832
×431

question asked: 25 Jan '12, 22:39

question was seen: 4,760 times

last updated: 02 Feb '12, 18:53

p​o​w​e​r​e​d by O​S​Q​A