Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Save the Lua script below to a file ending in .lua in the
Help->About Wireshark->Folders: Personal Lua Plugins folder.
Start Wireshark or if Wireshark is already running, do Analyze->Reload Lua Plugins. It creates a new field (my_ppi.rate) formatted like the field in the Packet Details.

-- my_ppi.lua
-- https://ask.wireshark.org/question/26798/data-rate-formatting-possible/
-- Grab and format fields as needed

-- Step 1 - document as you go. See header above and set_plugin_info().
local my_ppi_info =
{
    version = "1.0.0",
    author = "Chuck Craft",
    description = "Copy ppi.80211-common.rate with custom format",
}

set_plugin_info(my_ppi_info)

-- Step 2 - create a protocol to attach new fields to
local my_ppi_p = Proto.new("my_ppi","Custom formatted ppi fields")

-- Step 3 - add some field(s) to Step 2 protocol
local pf = { rate = ProtoField.string("my_ppi.rate", "ppi.80211-common.rate with units") }

my_ppi_p.fields = pf

-- Step 4 - grab existing field(s) that will have different output format
ppi_rate_f = Field.new("ppi.80211-common.rate")

-- Step 5 - create the postdissector function that will run on each frame/packet
function my_ppi_p.dissector(tvb,pinfo,root)
    local tree = nil

    finfo = ppi_rate_f()

    if not (finfo == nil) then
        if not tree then
            tree = root:add(my_ppi_p)
        end
    local field_data = string.format("%.1f Mbps", finfo() / 1000.0)
    tree:add(pf.rate, field_data)
    end
end

-- Step 6 - register the new protocol as a postdissector
register_postdissector(my_ppi_p)

Save the Lua script below to a file ending in .lua in the
Help->About Wireshark->Folders: Personal Lua Plugins folder.
Start Wireshark or if Wireshark is already running, do Analyze->Reload Lua Plugins. It creates a new field (my_ppi.rate) formatted like the field in the Packet Details.

-- my_ppi.lua
-- https://ask.wireshark.org/question/26798/data-rate-formatting-possible/
-- Grab and format fields as needed

-- Step 1 - document as you go. See header above and set_plugin_info().
local my_ppi_info =
{
    version = "1.0.0",
    author = "Chuck Craft",
    description = "Copy ppi.80211-common.rate with custom format",
}

set_plugin_info(my_ppi_info)

-- Step 2 - create a protocol to attach new fields to
local my_ppi_p = Proto.new("my_ppi","Custom formatted ppi fields")

-- Step 3 - add some field(s) to Step 2 protocol
local pf = { rate = ProtoField.string("my_ppi.rate", "ppi.80211-common.rate with units") }

my_ppi_p.fields = pf

-- Step 4 - grab existing field(s) that will have different output format
ppi_rate_f = Field.new("ppi.80211-common.rate")

-- Step 5 - create the postdissector function that will run on each frame/packet
function my_ppi_p.dissector(tvb,pinfo,root)
    local tree = nil

    finfo = ppi_rate_f()

    if not (finfo == nil) then
        if not tree then
            tree = root:add(my_ppi_p)
        end
     local field_data = string.format("%.1f Mbps", finfo() / 1000.0)
     tree:add(pf.rate, field_data)
    end
end

-- Step 6 - register the new protocol as a postdissector
register_postdissector(my_ppi_p)