Holger Hans Peter Freyther | e11b107 | 2010-06-08 13:18:58 +0800 | [diff] [blame^] | 1 | -- Simple LUA script to print the size of BSSGP messages over their type... |
| 2 | |
| 3 | do |
| 4 | local ip_bucket = {} |
| 5 | |
| 6 | local function init_listener() |
| 7 | -- handle the port as NS over IP |
| 8 | local udp_port_table = DissectorTable.get("udp.port") |
| 9 | local gprs_ns_dis = Dissector.get("gprs_ns") |
| 10 | udp_port_table:add(23000,gprs_ns_dis) |
| 11 | |
| 12 | -- bssgp filters |
| 13 | local bssgp_pdu_get = Field.new("bssgp.pdu_type") |
| 14 | local udp_length_get = Field.new("udp.length") |
| 15 | |
| 16 | local tap = Listener.new("ip", "udp.port == 23000") |
| 17 | function tap.packet(pinfo,tvb,ip) |
| 18 | local pdu = bssgp_pdu_get() |
| 19 | local len = udp_length_get() |
| 20 | |
| 21 | -- only handle bssgp, but we also want the IP frame |
| 22 | if not pdu then |
| 23 | return |
| 24 | end |
| 25 | |
| 26 | pdu = tostring(pdu) |
| 27 | if tonumber(pdu) == 0 or tonumber(pdu) == 1 then |
| 28 | return |
| 29 | end |
| 30 | |
| 31 | local ip_src = tostring(ip.ip_src) |
| 32 | local bssgp_histo = ip_bucket[ip_src] |
| 33 | if not bssgp_histo then |
| 34 | bssgp_histo = {} |
| 35 | ip_bucket[ip_src] = bssgp_histo |
| 36 | end |
| 37 | |
| 38 | local key = pdu |
| 39 | local bucket = bssgp_histo[key] |
| 40 | if not bucket then |
| 41 | bucket = {} |
| 42 | bssgp_histo[key] = bucket |
| 43 | end |
| 44 | |
| 45 | table.insert(bucket, tostring(len)) |
| 46 | print("IP: " .. ip_src .. " PDU: " .. pdu .. " Length: " .. tostring(len)) |
| 47 | end |
| 48 | |
| 49 | function tap.draw() |
| 50 | -- well... this will not be called... |
| 51 | -- for ip,bssgp_histo in pairs(dumpers) do |
| 52 | -- print("IP " .. ip) |
| 53 | -- end |
| 54 | end |
| 55 | |
| 56 | function tap.reset() |
| 57 | -- well... this will not be called... |
| 58 | end |
| 59 | end |
| 60 | |
| 61 | init_listener() |
| 62 | end |