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

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

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 = ''

local tap_in =, 'ip.dst=='..HOST_IP)
local tap_out =, 'ip.src=='..HOST_IP)

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

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

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

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 25 Jan '12, 22:39

question was seen: 5,423 times

last updated: 02 Feb '12, 18:53

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