0

I have a very large trace file and am trying to use Wireshark to determine which dest port has the most packets sent to it. Is there a way to get counts of packets sent to particular ports? Or to sort by number of packets sent a port?

user1190650
  • 3,207
  • 6
  • 27
  • 34

1 Answers1

0

You can write a simple wireshark listener in lua.

local tap 

local ports = {} 

local function packet(pinfo, tvb, userdata)
    -- store number of packets per each port
    local port = pinfo.dst_port
    ports[port] = (ports[port] or 0) + 1
end

local function draw(userdata)

    local maxi,maxv = 0,0
    -- print all gathered statictics and find max
    for i,v in pairs(ports) do
        print(i .. ":",  v)
        if maxv < v then
            maxi,maxv = i,v
        end
    end
    print ("Max:", maxi, maxv)
end

local function reset(userdata)
    ports = {}
end

local function show_ports()
    tap = Listener.new()
    tap.packet = packet
    tap.draw = draw 
    tap.reset = reset 
end

register_stat_cmd_arg('ports', show_ports)

Try it:

tshark -X lua_script:ports.lua -z ports -r in.pcap 
graphite
  • 2,920
  • 22
  • 40