aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-05-10 18:45:35 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-05-10 18:45:35 +0200
commit9cbdf1138fa8c5880179f20b03372998f80faa72 (patch)
tree874322cac8c8d8e4fe8b22692e96af2b3bc26f28
parentef466d4f06e41317bea2dee8f3514f6441c15949 (diff)
gprs: Add a lua script to collect buffers on the downlink.
This can be used to throw the data into GNUplot. It collects the time (from the start of the trace), the buffer data in kbyte and the number of buffered PDUs. It is assuming that no PDU is delivered toward the target.
-rw-r--r--openbsc/contrib/gprs/gprs-buffer-count.lua80
1 files changed, 80 insertions, 0 deletions
diff --git a/openbsc/contrib/gprs/gprs-buffer-count.lua b/openbsc/contrib/gprs/gprs-buffer-count.lua
new file mode 100644
index 000000000..ca8864ad1
--- /dev/null
+++ b/openbsc/contrib/gprs/gprs-buffer-count.lua
@@ -0,0 +1,80 @@
+-- I count the buffer space needed for LLC PDUs in the worse case and print it
+
+do
+ local function init_listener()
+ -- handle the port as NS over IP
+ local udp_port_table = DissectorTable.get("udp.port")
+ local gprs_ns_dis = Dissector.get("gprs_ns")
+ udp_port_table:add(23000,gprs_ns_dis)
+
+ -- bssgp filters
+ local bssgp_pdu_get = Field.new("bssgp.pdu_type")
+ local bssgp_delay_get = Field.new("bssgp.delay_val")
+ local llcgprs_get = Field.new("llcgprs")
+ local pdus = nil
+
+ print("START...")
+
+ local tap = Listener.new("ip", "udp.port == 23000 && bssgp.pdu_type == 0")
+ function tap.packet(pinfo,tvb,ip)
+ local pdu = bssgp_pdu_get()
+ local len = llcgprs_get().len
+ local delay = bssgp_delay_get()
+
+ -- only handle bssgp, but we also want the IP frame
+ if not pdu then
+ return
+ end
+
+ if tonumber(tostring(delay)) == 65535 then
+ pdus = { next = pdus,
+ len = len,
+ expires = -1 }
+ else
+ local off = tonumber(tostring(delay)) / 100.0
+ pdus = { next = pdus,
+ len = len,
+ expires = pinfo.rel_ts + off }
+ end
+ local now_time = tonumber(tostring(pinfo.rel_ts))
+ local now_size = 0
+ local l = pdus
+ local prev = nil
+ local count = 0
+ while l do
+ if now_time < l.expires or l.expires == -1 then
+ now_size = now_size + l.len
+ prev = l
+ l = l.next
+ count = count + 1
+ else
+ -- delete things
+ if prev == nil then
+ pdus = nil
+ l = nil
+ else
+ prev.next = l.next
+ l = l.next
+ end
+ end
+ end
+-- print("TOTAL: " .. now_time .. " PDU_SIZE: " .. now_size)
+ print(now_time .. " " .. now_size / 1024.0 .. " " .. count)
+-- print("NOW: " .. tostring(pinfo.rel_ts) .. " Delay: " .. tostring(delay) .. " Length: " .. tostring(len))
+ end
+
+ function tap.draw()
+ -- well... this will not be called...
+-- for ip,bssgp_histo in pairs(dumpers) do
+-- print("IP " .. ip)
+-- end
+ print("END")
+ end
+
+ function tap.reset()
+ -- well... this will not be called...
+ end
+ end
+
+ init_listener()
+end