Ask Your Question

Filter udp packets using lua script

asked 2022-05-13 16:08:09 +0000

linuxbegginer gravatar image

So I have tshark and lua script which i am trying to run. I am running with the command:

sudo tshark -X lua_script:luascript.lua -c 100

Where my lua scrpit looks like this:

     packets = 0;
     file ="result.txt","a")
     local function init_listener()
          local tap =,"ip.addr ==")
          function tap.reset()
               packets = 0;
          function tap.packet()
               packets = packets + 1
          function tap.draw()
                print("Packets to/from",packets)

So when i ran tshark I get each packet ouputs to the command line like this one:

98 5.300306453 →    TCP 60 443 → 54114 [ACK] Seq=1 Ack=1031 Win=65535 Len=0

And everytime udp packet comes up i want to save it to output file(with all the information). So indeed tap.packet() captures Those packets but what i want is to write them to output file using lua script.

How do i do that?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2022-05-13 16:43:21 +0000

Chuckc gravatar image

sudo tshark .... look at giving your user the permissions it needs - Running Wireshark as You

tshark -q option will suppress the packet lines.

There are examples on the Wireshark wiki for dumping packets -
dumping to multiple files, Dump VoIP calls into separate files
Documentation for dumper in the WSDG.

edit flag offensive delete link more


Ty very much :)

linuxbegginer gravatar imagelinuxbegginer ( 2022-05-14 10:54:35 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-05-13 16:08:09 +0000

Seen: 181 times

Last updated: May 13 '22