Ghost packet response frequency

Hello there!

I am research for ghost packet receiving problem now.

I found out that this PR https://github.com/brocaar/loraserver/pull/409 not actually resolving problem with ghost packets.
What I found out is sometimes response for packet received together with “ghost” packet is sent on “ghost” packet frequency instead of original packet frequency.

So I dig to code to find place where "freq" property from uplink json is used to determine response frequency.
And I found that “freq” is packed to UplinkTXInfo struct in chirpstack-gateway-bridge backend/semtechudp/packets/push_data.go#L159
But as I can see in gw.proto only one UplinkTXInfo is exists in opposite to multiple UplinkRXInfo.

Using frequency for response from first (or last) available packet may be a reason for this problem as I think.

Here []gw.UplinkFrame with unique UplinkTXInfo for each other is transformed to portobuf serialized message.

Here gw.UplinkFrame.TXInfo from pb message is used to fill models.RXPacket structure with only single TXInfo property.

Example uplink JSON from packet_forwarder
{
   "rxpk":[
      {
         "jver":1,
         "tmst":133903775,
         "time":"2020-06-03T12:23:44.438993Z",
         "tmms":1275222243439,
         "chan":4,
         "rfch":0,
         "freq":867.300000,
         "mid":4,
         "stat":1,
         "modu":"LORA",
         "datr":"SF12BW125",
         "codr":"4/5",
         "rssis":-96,
         "lsnr":-12.0,
         "foff":-1203,
         "rssi":-85,
         "size":21,
         "data":"QI2GVAABMFoCBM/KrjiZeNY7/fYY"
      },
      {
         "jver":1,
         "tmst":133903775,
         "time":"2020-06-03T12:23:44.438993Z",
         "tmms":1275222243439,
         "chan":1,
         "rfch":1,
         "freq":868.300000,
         "mid":0,
         "stat":1,
         "modu":"LORA",
         "datr":"SF12BW125",
         "codr":"4/5",
         "rssis":-23,
         "lsnr":11.5,
         "foff":-1203,
         "rssi":-22,
         "size":21,
         "data":"QI2GVAABMFoCBM/KrjiZeNY7/fYY"
      }
   ]
}

Also, I find that GW count in link_check MAC command response calculated incorrect here.

I’m not good enough in Golang to make patch.
Can anyone approve or decline my suggestions? @brocaar maybe?

Ghost packets receiving was already described in these forum topics:


Sorry for my English =)