Search code examples
luawiresharktshark

How to change a Lua Script designed for Wireshark so it works with Tshark?


I have this partial Lua Script which is working perfectly with Wireshark:

local function appl_rtt_dialog_menu()
    local win = TextWindow.new("Application Latency");
    local label = ""
    local tot = 0
    local i

    i = 0
    label = label .. "Server\t\tMin Application RTT\n"
    for k,v in pairsByValues(min_appl_RRT, rev) do
        label = label .. string.format("%-20s\t%.3f / %.3f msec\n", shortenString(k), v, max_appl_RRT[k])
        if(i == max_num_entries) then break else i = i + 1 end
    end

    win:set(label)
    win:add_button("Clear", function() win:clear() end)
end

I am trying to modify it for using in Tshark. since the script is written for GUI and Tshark has none, I change it in order to print to the console:

do
    local function appl_rtt()
        local label = ""
        local i
        i = 0
        label = label .. "Server\t\tMin Application RTT\n"
        for k,v in pairsByValues(min_appl_RRT, rev) do
            label = label .. string.format("%-20s\t%.3f / %.3f msec\n", shortenString(k), v, max_appl_RRT[k])
            print(label)
            if(i == max_num_entries) then break else i = i + 1 end
        end

    end
    appl_rtt()
end

but there is no output.

does anyone know how to change the script?


Solution

  • I have fixed it with Listener() and draw() functions.