blob: b1ab5df7f2ea28cdc69210dd586f8525490e29e0 [file] [log] [blame]
Holger Hans Peter Freytherd37a5962010-06-08 13:18:58 +08001-- Simple LUA script to print the size of BSSGP messages over their type...
2
3do
4 local ip_bucket = {}
5
Holger Hans Peter Freyther3b12b7b2010-06-08 13:45:10 +08006 local pdu_types = {}
7 pdu_types[ 6] = "PAGING"
8 pdu_types[11] = "SUSPEND"
9 pdu_types[12] = "SUSPEND-ACK"
10 pdu_types[32] = "BVC-BLOCK"
11 pdu_types[33] = "BVC-BLOCK-ACK"
12 pdu_types[34] = "BVC-RESET"
13 pdu_types[35] = "BVC-RESET-ACK"
14 pdu_types[36] = "UNBLOCK"
15 pdu_types[37] = "UNBLOCK-ACK"
16 pdu_types[38] = "FLOW-CONTROL-BVC"
17 pdu_types[39] = "FLOW-CONTROL-BVC-ACK"
18 pdu_types[40] = "FLOW-CONTROL-MS"
19 pdu_types[41] = "FLOW-CONTROL-MS-ACK"
20 pdu_types[44] = "LLC-DISCARDED"
21
Holger Hans Peter Freytherd37a5962010-06-08 13:18:58 +080022 local function init_listener()
23 -- handle the port as NS over IP
24 local udp_port_table = DissectorTable.get("udp.port")
25 local gprs_ns_dis = Dissector.get("gprs_ns")
26 udp_port_table:add(23000,gprs_ns_dis)
27
28 -- bssgp filters
29 local bssgp_pdu_get = Field.new("bssgp.pdu_type")
30 local udp_length_get = Field.new("udp.length")
31
32 local tap = Listener.new("ip", "udp.port == 23000")
33 function tap.packet(pinfo,tvb,ip)
34 local pdu = bssgp_pdu_get()
35 local len = udp_length_get()
36
37 -- only handle bssgp, but we also want the IP frame
38 if not pdu then
39 return
40 end
41
42 pdu = tostring(pdu)
43 if tonumber(pdu) == 0 or tonumber(pdu) == 1 then
44 return
45 end
46
47 local ip_src = tostring(ip.ip_src)
48 local bssgp_histo = ip_bucket[ip_src]
49 if not bssgp_histo then
50 bssgp_histo = {}
51 ip_bucket[ip_src] = bssgp_histo
52 end
53
54 local key = pdu
55 local bucket = bssgp_histo[key]
56 if not bucket then
57 bucket = {}
58 bssgp_histo[key] = bucket
59 end
60
61 table.insert(bucket, tostring(len))
Holger Hans Peter Freyther3b12b7b2010-06-08 13:45:10 +080062 print("IP: " .. ip_src .. " PDU: " .. pdu_types[tonumber(pdu)] .. " Length: " .. tostring(len))
Holger Hans Peter Freytherd37a5962010-06-08 13:18:58 +080063 end
64
65 function tap.draw()
66 -- well... this will not be called...
67-- for ip,bssgp_histo in pairs(dumpers) do
68-- print("IP " .. ip)
69-- end
70 end
71
72 function tap.reset()
73 -- well... this will not be called...
74 end
75 end
76
77 init_listener()
78end