This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

delay measurement and add tree

0

Hi there,

i'm trying to analyze some custom parts of a frame for benchmarking to check if frames are transported through a system and when transported i try to calculate the delay based on input and output frame timestamps. The Input and Output Frames are identified by a sequence number added to the testframe. With the LUA Script the sequence number decoding works. Now i want to calculate the Delay by comparing the sequence bumber of input/output. This is also (lookslike) working but i'm unable to add the delay to the ui tree. Looks like it is overwritten. Here's the code:

    local f = sptlog.fields 
    f.seq = ProtoField.uint32("sptlog.seq", "Sequence of Packet")
    f.sig = ProtoField.uint32("sptlog.sig", "Signature")
    f.tdiff = ProtoField.float("sptlog.tdiff", "Time Diff")
function sptlog.dissector(buffer, pinfo, tree)

        if buffer:len() > 50 then
            --We first have to find the offset
            SIG_OFF = 0
            diff =0
            for lc = 1,buffer:len()-3,1 do
                local part = tostring(buffer:range(lc,3))
                if part == "535443" then
                    SIG_OFF = lc
                    SIG_OFF = SIG_OFF + 3
                    lc = buffer:len()
                end
            end
            if SIG_OFF ~= 0 then
                subtree = tree:add(sptlog, buffer(),"STC DATA")
                subtree:add(f.sig, buffer:range(SIG_OFF-3,3))
                seq = buffer:range(SIG_OFF,2):uint()
                if not pinfo.visited then
                        if not stp_array[seq] then
                                local timestamp = NSTime(pinfo.abs_ts, select(2,math.modf(pinfo.abs_ts)) * 10^9)
                                stp_array[seq] = timestamp
                        else
                            local timestamp = NSTime(pinfo.abs_ts, select(2,math.modf(pinfo.abs_ts)) * 10^9)
                            diff = timestamp - stp_array[seq]
                        end
                end
                warn (pinfo.abs_ts)
                warn (diff)
                warn ("--------")
                subtree:add(f.seq, buffer:range(SIG_OFF,2)) 
                subtree:add(f.tdiff,diff):set_generated()

            end

        end</code></pre><p>The subtree:add(f.tdiff,diff):set_generated() is not working or gets overwritten. Looks like the script parses two packets in the testcapture five times..</p><p>Any idea? Thanks!</p><p>TIA</p><p>Thomas</p></div><div id="question-tags" class="tags-container tags"><span class="post-tag tag-link-proto_tree_add_item" rel="tag" title="see questions tagged &#39;proto_tree_add_item&#39;">proto_tree_add_item</span> <span class="post-tag tag-link-wireshark" rel="tag" title="see questions tagged &#39;wireshark&#39;">wireshark</span></div><div id="question-controls" class="post-controls"></div><div class="post-update-info-container"><div class="post-update-info post-update-info-user"><p>asked <strong>05 Nov '15, 09:31</strong></p><img src="https://secure.gravatar.com/avatar/b06e5eb073e87534777ed9e71b853879?s=32&amp;d=identicon&amp;r=g" class="gravatar" width="32" height="32" alt="tsillaber&#39;s gravatar image" /><p><span>tsillaber</span><br />

6112
accept rate: 0%