Question

I want to get the frame time (relative) of the first packet that is not communicating on sos and DIS ports and ip address is not the one mentioned in the if statement. But the packet should be utilizing port 24111. However, the code below is not working for this purpose. It works, until I add udp_port~=24111. After that it gives me no results, which means that it doesn't go inside that conditional statement. I have tried to write the condition in multiple ways, even separating it out into a new if statement but it doesn't work. What I am doing wrong here. Thanks for suggestions in advance. Here is the piece of code that I have at the moment

    local first_outpacket = 0
    local flag = 0
    function stats_first_packet()
        local udp_port
        local frame_time
        local ip_addr
        frame_time = time_relative_extractor()
        udp_port = udp_port_extractor()
        ip_addr = ip_addr_extractor()
        if ( udp_port ) then
            if (not (udp_port == 3000 or udp_port==3838 or flag==1 or ip_addr=="192.168.1.2" or udp_port~=24111)) then
                first_outpacket = frame_time
                print(frame_time)
                flag = 1
            else
                -- print("tcp_src_port already recorded")
            end
        else
            -- print("no tcp_src_port")
        end
    end
Was it helpful?

Solution

The problem apparently lies in the data type returned by the extractor() functions. In order to compare them with another value in the if statement they have to be converted into strings using tostring() function. For example:

if (not (tostring(udp_port) == "3000" or tostring(udp_port)=="3838" or flag==1))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top